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 DeploymentException failure(String task, String info, Throwable e) { return ManagementSupport.failure(task, component.getComponentName(), info, e); }
protected void doStart() throws Exception { synchronized (running) { endpoint.getServiceUnit().getComponent().getExecutor(MessageExchange.Role.CONSUMER).execute(new Runnable() { public void run() { StandardConsumerProcessor.this.poll(); } }); running.wait(); } }
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 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); }
|| !ep.getServiceUnit().getComponent().getRegistry().isRegistered(ep.getServiceUnit()))) { logger.info("something wrong during register endpoint {}", ep.getKey()); e.getServiceUnit().getComponent().getRegistry().unregisterServiceUnit(e.getServiceUnit()); boolean initialized = true; for (Endpoint e : endpoints) { if (e.getServiceUnit().getComponent().getComponentContext() == null) { initialized = false; break;
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); } } } }
protected ServiceEndpoint createExternalEndpoint() { return new ExternalEndpoint(getServiceUnit().getComponent().getEPRElementName(), getLocationURI(), getService(), getEndpoint(), getInterfaceName()); }
public void prepareExchange(MessageExchange exchange) throws MessagingException { getServiceUnit().getComponent().prepareExchange(exchange, this); }
parents.add(getParentClassLoader(applicationContext)); for (String library : sls) { ClassLoader cl = this.component.getContainer().getSharedLibraryClassLoader(library); if (cl == null) { throw new IllegalStateException("No such shared library: " + library); ClassLoader cl = this.component.getContainer().getComponentClassLoader(component); if (cl == null) { throw new IllegalStateException("No such component: " + component);
protected ServiceEndpoint createExternalEndpoint() { return new ExternalEndpoint(getServiceUnit().getComponent().getEPRElementName(), getLocationURI(), getService(), getEndpoint(), getInterfaceName()); }
protected void prepareExchange(MessageExchange exchange) throws MessagingException { Endpoint ep = getEndpoint(); ep.getServiceUnit().getComponent().prepareExchange(exchange, ep); }
public EndpointComponentContext(Endpoint endpoint) { this.endpoint = endpoint; this.context = endpoint.getServiceUnit().getComponent().getComponentContext(); }
public Map<String, String> getServiceUnits() { if (endpointRegistrations == null) { throw new IllegalStateException("Service assembly has not been deployed"); } Map<String, String> sus = new HashMap<String, String>(); for (Endpoint ep : getEndpoints()) { if (ep.getServiceUnit() == null) { // This should not happen, as we only register the SA after all endpoints have been deployed throw new IllegalStateException("Endpoint has not been initialized. Check that the component is installed."); } sus.put(ep.getServiceUnit().getName(), ep.getServiceUnit().getComponent().getComponentName()); } return sus; }
public void onMessage(final Message message) { logger.debug("Received jms message {}", message); endpoint.getServiceUnit().getComponent().getExecutor(MessageExchange.Role.CONSUMER).execute(new Runnable() { public void run() { try { logger.debug("Handling jms message {}", message); Context context = createContext(); MessageExchange exchange = toNMS(message, context); // TODO: copy protocol messages //inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(message)); pendingMessages.put(exchange.getExchangeId(), context); channel.send(exchange); } catch (Throwable e) { logger.error("Error while handling jms message", e); } } }); }
public void onMessage(final Message message) { try { logger.debug("Received jms message {}", message); Context context = createContext(); MessageExchange exchange = toNMS(message, context); if (!(exchange instanceof InOnly)) { throw new UnsupportedOperationException("JCA consumer endpoints can only use InOnly MEP"); } exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, transactionManager.getTransaction()); pendingMessages.put(exchange.getExchangeId(), context); if (endpoint.isSynchronous()) { channel.sendSync(exchange); process(exchange); } else { endpoint.getServiceUnit().getComponent().prepareExchange(exchange, endpoint); channel.send(exchange); } } catch (Throwable e) { logger.error("Error while handling jms message", e); } }
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(); }
/** * Validate the endpoint at either deployment time for statically * defined endpoints or at runtime for dynamic endpoints * * @throws DeploymentException */ public void validate() throws DeploymentException { try { registerService(); } catch (Exception e) { throw ManagementSupport.failure( "deploy", getServiceUnit().getComponent().getComponentName(), null, e); } }
public void onMessage(final Message message) { logger.debug("Received jms message {}", message); endpoint.getServiceUnit().getComponent().getExecutor(MessageExchange.Role.PROVIDER).execute(new Runnable() { public void run() { InOut exchange = null;
public EndpointDeliveryChannel(Endpoint endpoint) throws MessagingException { this.endpoint = endpoint; this.channel = endpoint.getServiceUnit().getComponent().getComponentContext().getDeliveryChannel(); }