protected Container getContainer() { try { ComponentContext ctx = getServiceUnit().getComponent().getComponentContext(); Field field = ctx.getClass().getDeclaredField("container"); field.setAccessible(true); return (Container) field.get(ctx); } catch (Exception e) { logger.debug("Unable to retrieve JBIContainer: {}", e.getMessage()); return null; } }
protected Map getParentBeansMap() { Map beans = new HashMap(); beans.put("context", new EndpointComponentContext(component.getComponentContext())); beans.put("component", component); Object smx3 = component.getSmx3Container(); if (smx3 != null) { beans.put("container", smx3); } return beans; }
public EndpointComponentContext(Endpoint endpoint) { this.endpoint = endpoint; this.context = endpoint.getServiceUnit().getComponent().getComponentContext(); }
public void deactivate() throws Exception { if (activated == null) { throw new IllegalStateException("Endpoint not activated: " + this); } ServiceEndpoint ep = activated; activated = null; ComponentContext ctx = getServiceUnit().getComponent().getComponentContext(); ctx.deactivateEndpoint(ep); super.deactivate(); }
public EndpointDeliveryChannel(Endpoint endpoint) throws MessagingException { this.endpoint = endpoint; this.channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel(); }
public void init() throws Exception { channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel(); }
public void activate() throws Exception { super.activate(); ComponentContext ctx = getServiceUnit().getComponent().getComponentContext(); activated = ctx.activateEndpoint(service, endpoint); }
public synchronized void deactivate() throws Exception { ServiceMixComponent component = getServiceUnit().getComponent(); ComponentContext ctx = component.getComponentContext(); if (activated != null) { ServiceEndpoint se = activated; activated = null; ctx.deregisterExternalEndpoint(se); } super.deactivate(); }
protected InitialContext getInitialContext() throws NamingException { Properties props = new Properties(); if (endpoint.getInitialContextFactory() != null && endpoint.getJndiProviderURL() != null) { props.put(InitialContext.INITIAL_CONTEXT_FACTORY, endpoint.getInitialContextFactory()); props.put(InitialContext.PROVIDER_URL, endpoint.getJndiProviderURL()); return new InitialContext(props); } else if (endpoint.getConfiguration().getJndiInitialContextFactory() != null && endpoint.getConfiguration().getJndiProviderUrl() != null) { props.put(InitialContext.INITIAL_CONTEXT_FACTORY, endpoint.getConfiguration().getJndiInitialContextFactory()); props.put(InitialContext.PROVIDER_URL, endpoint.getConfiguration().getJndiProviderUrl()); return new InitialContext(props); } else { return endpoint.getServiceUnit().getComponent().getComponentContext().getNamingContext(); } }
public void start() throws Exception { InitialContext ctx = getInitialContext(); connectionFactory = getConnectionFactory(ctx); channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel(); destination = endpoint.getDestination(); if (destination == null) { if (endpoint.getJndiDestinationName() != null) { destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName()); } else if (endpoint.getJmsProviderDestinationName() == null) { throw new IllegalStateException("No destination provided"); } } }
boolean initialized = true; for (Endpoint e : endpoints) { if (e.getServiceUnit().getComponent().getComponentContext() == null) { initialized = false; break;
protected void commonDoStartTasks(InitialContext ctx) throws Exception { channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); destination = endpoint.getDestination(); if (destination == null) { if (endpoint.getJndiDestinationName() != null) { destination = (Destination) ctx.lookup(endpoint.getJndiDestinationName()); } else if (endpoint.getJmsProviderDestinationName() != null) { if (STYLE_QUEUE.equals(endpoint.getDestinationStyle())) { destination = session.createQueue(endpoint.getJmsProviderDestinationName()); } else { destination = session.createTopic(endpoint.getJmsProviderDestinationName()); } } else { throw new IllegalStateException("No destination provided"); } } if (endpoint.getJndiReplyToName() != null) { replyToDestination = (Destination) ctx.lookup(endpoint.getJndiReplyToName()); } else if (endpoint.getJmsProviderReplyToName() != null) { if (destination instanceof Queue) { replyToDestination = session.createQueue(endpoint.getJmsProviderReplyToName()); } else { replyToDestination = session.createTopic(endpoint.getJmsProviderReplyToName()); } } }
/** * Used by POJOs acting as a consumer * @param uri * @param message * @return */ public Future<NormalizedMessage> send(String uri, NormalizedMessage message) { try { InOut me = getExchangeFactory().createInOutExchange(); URIResolver.configureExchange(me, getServiceUnit().getComponent().getComponentContext(), uri); MessageUtil.transferTo(message, me, "in"); final Holder h = new Holder(); getOrCreateCurrentRequest(me).addExchange(me); exchanges.put(me.getExchangeId(), h); BeanEndpoint.this.send(me); return h; } catch (Exception e) { throw new RuntimeException(e); } }
if (endpoint.isRollbackOnError()) { TransactionManager tm = (TransactionManager) endpoint.getServiceUnit().getComponent().getComponentContext().getTransactionManager(); tm.setRollbackOnly(); return;
public synchronized void activate() throws Exception { super.activate(); ServiceMixComponent component = getServiceUnit().getComponent(); ComponentContext ctx = component.getComponentContext(); activated = new ExternalEndpoint(component.getEPRElementName(), getLocationURI(), getService(), getEndpoint(), getInterfaceName()); ctx.registerExternalEndpoint(activated); }
private void resumeTx(MessageExchange exchange) throws MessagingException { if (!getEndpoint().getServiceUnit().getComponent().getContainer().handleTransactions()) { Transaction tx = (Transaction) exchange.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME); if (tx != null) { TransactionManager txmgr = (TransactionManager) endpoint.getServiceUnit().getComponent().getComponentContext().getTransactionManager(); try { txmgr.resume(tx); } catch (InvalidTransactionException e) { throw new MessagingException(e); } catch (SystemException e) { throw new MessagingException(e); } } } }
ComponentContext componentContext = this.serviceUnit.getComponent().getComponentContext();
targetEndpoint = getServiceUnit().getComponent().getComponentContext().getEndpoint(getTargetService(), getTargetEndpoint()); ServiceEndpoint[] endpoints = getServiceUnit().getComponent().getComponentContext().getEndpointsForService(getTargetService()); if (endpoints != null && endpoints.length > 0) { targetEndpoint = endpoints[0]; ServiceEndpoint[] endpoints = getServiceUnit().getComponent().getComponentContext().getEndpoints(getTargetInterface()); if (endpoints != null && endpoints.length > 0) { targetEndpoint = endpoints[0]; description = this.getServiceUnit().getComponent().getComponentContext().getEndpointDescriptor(targetEndpoint); definition = getBus().getExtension(WSDLManager.class).getDefinition((Element)description.getFirstChild()); List address = definition.getService(getTargetService()).getPort(getTargetEndpoint()).getExtensibilityElements();