protected void doInit() throws Exception { // Register extension mbean MBeanServer server = this.context.getMBeanServer(); Object mbean = getExtensionMBean(); if (server != null && mbean != null) { MBeanServerHelper.register(server, createExtensionMBeanName(), mbean); } // Obtain or create the work manager // When using the WorkManager from ServiceMix, // some class loader problems can appear when // trying to uninstall the components. // Some threads owned by the work manager have a // security context referencing the component class loader // so that every loaded classes are locked // this.workManager = findWorkManager(); if (this.executorFactory == null) { this.executorFactory = findExecutorFactory(); } if (this.executorFactory == null) { this.executorFactory = createExecutorFactory(); } this.consumerExecutor = this.executorFactory.createExecutor("component." + getContext().getComponentName() + ".consumer"); this.providerExecutor = this.executorFactory.createExecutor("component." + getContext().getComponentName() + ".provider"); }
public void shutDown() throws JBIException { try { logger.debug("Shutting down component"); Thread.currentThread().setContextClassLoader(component.getClass().getClassLoader()); doShutDown(); setCurrentState(LifeCycleMBean.SHUTDOWN); this.context = null; logger.debug("Component shut down"); } catch (JBIException e) { throw e; } catch (Exception e) { throw new JBIException("Error calling shutdown", e); } }
public void start() throws JBIException { try { logger.debug("Starting component"); Thread.currentThread().setContextClassLoader(component.getClass().getClassLoader()); if (this.running.compareAndSet(false, true)) { doStart(); setCurrentState(LifeCycleMBean.STARTED); } logger.debug("Component started"); } catch (JBIException e) { throw e; } catch (Exception e) { throw new JBIException("Error calling start", e); } }
public void stop() throws JBIException { try { logger.debug("Stopping component"); Thread.currentThread().setContextClassLoader(component.getClass().getClassLoader()); if (this.running.compareAndSet(true, false)) { doStop(); setCurrentState(LifeCycleMBean.STOPPED); } logger.debug("Component stopped"); } catch (JBIException e) { throw e; } catch (Exception e) { throw new JBIException("Error calling stop", e); } }
Endpoint ep = this.component.getRegistry().getEndpoint(key); if (ep == null) { if (endpoint.getServiceName().equals(getEPRServiceName())) { ep = getResolvedEPR(exchange.getEndpoint()); ep.activate(); ep.start(); doProcess(ep, exchange); } finally { throw new IllegalStateException("Endpoint not found for: " + exchange.getExchangeId()); doProcess(ep, exchange);
protected void processExchangeWithoutTx(MessageExchange exchange) { ExchangeStatus oldStatus = exchange.getStatus(); try { processExchange(exchange); } catch (Throwable t) { logger.error("Error processing exchange {}", exchange, t); try { // If we are transacted and this is a runtime exception // try to mark transaction as rollback if (transactionManager != null && transactionManager.getStatus() == Status.STATUS_ACTIVE && exceptionShouldRollbackTx(t)) { transactionManager.setRollbackOnly(); if (!container.handleTransactions()) { transactionManager.suspend(); } } if (oldStatus == ExchangeStatus.ACTIVE) { exchange.setError(t instanceof Exception ? (Exception) t : new Exception(t)); channel.send(exchange); } } catch (Exception inner) { logger.error("Error setting exchange status to ERROR", inner); } } }
public void init(ComponentContext context) throws JBIException { try { logger.debug("Initializing component"); Thread.currentThread().setContextClassLoader(component.getClass().getClassLoader()); this.context = context; this.channel = context.getDeliveryChannel(); try { this.transactionManager = (TransactionManager) context.getTransactionManager(); } catch (Throwable e) { // Ignore, this is just a safeguard against non compliant // JBI implementation which throws an exception instead of // return null } container = Container.detect(context); doInit(); setCurrentState(INITIALIZED); logger.debug("Component initialized"); } catch (JBIException e) { throw e; } catch (Exception e) { throw new JBIException("Error calling init", e); } }
@Override protected void doShutDown() throws Exception { serviceUnit.shutDown(); super.doShutDown(); }
@Override protected void doStop() throws Exception { serviceUnit.stop(); super.doStop(); }
@Override protected void doStart() throws Exception { super.doStart(); serviceUnit.start(); }
@Override protected void doInit() throws Exception { super.doInit(); List endpoints = getConfiguredEndpoints(); if (endpoints != null && !endpoints.isEmpty()) { Iterator iter = endpoints.iterator(); while (iter.hasNext()) { Endpoint endpoint = (Endpoint) iter.next(); if (endpoint == null) { logger.warn("Ignoring null endpoint in list: {}", endpoints); continue; } addEndpoint(endpoint); } } serviceUnit.init(); }
if (exceptionShouldRollbackTx(t)) { transactionManager.setRollbackOnly();
transactionManager.resume(tx); processExchange(exchange); } catch (Throwable t) { logger.error("Error processing exchange {}", exchange, t); if (exceptionShouldRollbackTx(t)) { transactionManager.setRollbackOnly();