org.apache.servicemix.common
Class AsyncBaseLifeCycle

java.lang.Object
  extended by org.apache.servicemix.common.AsyncBaseLifeCycle
All Implemented Interfaces:
javax.jbi.component.ComponentLifeCycle
Direct Known Subclasses:
BaseLifeCycle, DefaultComponent

public class AsyncBaseLifeCycle
extends java.lang.Object
implements javax.jbi.component.ComponentLifeCycle

Base class for life cycle management of components. This class may be used as is.

Since:
3.0
Version:
$Revision: 399873 $
Author:
Guillaume Nodet

Field Summary
protected  javax.jbi.messaging.DeliveryChannel channel
           
protected  ServiceMixComponent component
           
protected  org.apache.servicemix.executors.Executor consumerExecutor
           
protected  Container container
           
protected  javax.jbi.component.ComponentContext context
           
protected  java.lang.ThreadLocal<java.lang.String> correlationId
           
protected  java.lang.String currentState
           
protected  org.apache.servicemix.executors.ExecutorFactory executorFactory
           
static java.lang.String INITIALIZED
           
protected  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> knownExchanges
           
protected  org.slf4j.Logger logger
           
protected  javax.management.ObjectName mbeanName
           
protected  java.lang.Thread poller
           
protected  java.util.concurrent.atomic.AtomicBoolean polling
           
protected  org.apache.servicemix.executors.Executor providerExecutor
           
protected  java.util.concurrent.atomic.AtomicBoolean running
           
protected  javax.transaction.TransactionManager transactionManager
           
protected  boolean workManagerCreated
           
 
Constructor Summary
AsyncBaseLifeCycle()
           
AsyncBaseLifeCycle(ServiceMixComponent component)
           
 
Method Summary
protected  org.apache.servicemix.executors.ExecutorFactory createExecutorFactory()
           
protected  javax.management.ObjectName createExtensionMBeanName()
           
protected  void doInit()
           
protected  void doShutDown()
           
protected  void doStart()
           
protected  void doStop()
           
protected  boolean exceptionShouldRollbackTx(java.lang.Throwable t)
           
protected  org.apache.servicemix.executors.ExecutorFactory findExecutorFactory()
           
 Container getContainer()
           
 javax.jbi.component.ComponentContext getContext()
           
 java.lang.String getCurrentState()
           
 javax.xml.namespace.QName getEPRServiceName()
           
 org.apache.servicemix.executors.Executor getExecutor(javax.jbi.messaging.MessageExchange.Role role)
           
 org.apache.servicemix.executors.ExecutorFactory getExecutorFactory()
           
protected  java.lang.Object getExtensionMBean()
           
 javax.management.ObjectName getExtensionMBeanName()
           
protected  java.util.Set<java.lang.String> getKnownExchanges(Endpoint endpoint)
           
protected  Endpoint getResolvedEPR(javax.jbi.servicedesc.ServiceEndpoint ep)
          Handle an exchange sent to an EPR resolved by this component
 java.lang.Object getSmx3Container()
           
 void handleExchange(Endpoint endpoint, javax.jbi.messaging.MessageExchange exchange, boolean add)
           
 void init(javax.jbi.component.ComponentContext context)
           
 boolean isInitialized()
           
 boolean isShutDown()
           
 boolean isStarted()
           
 boolean isStopped()
           
 boolean isUnknown()
           
 void onMessageExchange(javax.jbi.messaging.MessageExchange exchange)
           
protected  void pollDeliveryChannel()
           
 void prepareExchange(javax.jbi.messaging.MessageExchange exchange, Endpoint endpoint)
           
 void prepareShutdown(Endpoint endpoint)
          Prepare an endpoint for shutdown by waiting until all its pending exchanges have been finished.
 void prepareShutdown(Endpoint endpoint, long timeout)
          Prepare an endpoint for shutdown by waiting until all its pending exchanges have been finished.
protected  void processExchange(javax.jbi.messaging.MessageExchange exchange)
           
protected  void processExchangeInTx(javax.jbi.messaging.MessageExchange exchange, javax.transaction.Transaction tx)
           
protected  void setComponent(ServiceMixComponent component)
           
protected  void setCurrentState(java.lang.String currentState)
           
 void setExecutor(javax.jbi.messaging.MessageExchange.Role role, org.apache.servicemix.executors.Executor executor)
          The executor to use for various tasks that need to be performed by the component.
 void setExecutorFactory(org.apache.servicemix.executors.ExecutorFactory executorFactory)
          The executor factory to use to create the executor.
 void shutDown()
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIALIZED

public static final java.lang.String INITIALIZED
See Also:
Constant Field Values

logger

protected transient org.slf4j.Logger logger

component

protected ServiceMixComponent component

context

protected javax.jbi.component.ComponentContext context

mbeanName

protected javax.management.ObjectName mbeanName

executorFactory

protected org.apache.servicemix.executors.ExecutorFactory executorFactory

consumerExecutor

protected org.apache.servicemix.executors.Executor consumerExecutor

providerExecutor

protected org.apache.servicemix.executors.Executor providerExecutor

running

protected java.util.concurrent.atomic.AtomicBoolean running

channel

protected javax.jbi.messaging.DeliveryChannel channel

poller

protected java.lang.Thread poller

polling

protected java.util.concurrent.atomic.AtomicBoolean polling

transactionManager

protected javax.transaction.TransactionManager transactionManager

workManagerCreated

protected boolean workManagerCreated

correlationId

protected java.lang.ThreadLocal<java.lang.String> correlationId

currentState

protected java.lang.String currentState

container

protected Container container

knownExchanges

protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> knownExchanges
Constructor Detail

AsyncBaseLifeCycle

public AsyncBaseLifeCycle()

AsyncBaseLifeCycle

public AsyncBaseLifeCycle(ServiceMixComponent component)
Method Detail

getContainer

public Container getContainer()

setComponent

protected void setComponent(ServiceMixComponent component)

getExtensionMBeanName

public javax.management.ObjectName getExtensionMBeanName()
Specified by:
getExtensionMBeanName in interface javax.jbi.component.ComponentLifeCycle

getExtensionMBean

protected java.lang.Object getExtensionMBean()
                                      throws java.lang.Exception
Throws:
java.lang.Exception

createExtensionMBeanName

protected javax.management.ObjectName createExtensionMBeanName()
                                                        throws java.lang.Exception
Throws:
java.lang.Exception

getEPRServiceName

public javax.xml.namespace.QName getEPRServiceName()

getCurrentState

public java.lang.String getCurrentState()

setCurrentState

protected void setCurrentState(java.lang.String currentState)

isStarted

public boolean isStarted()

isStopped

public boolean isStopped()
Returns:
true if the object is stopped

isShutDown

public boolean isShutDown()
Returns:
true if the object is shutDown

isInitialized

public boolean isInitialized()
Returns:
true if the object is shutDown

isUnknown

public boolean isUnknown()
Returns:
true if the object is shutDown

init

public void init(javax.jbi.component.ComponentContext context)
          throws javax.jbi.JBIException
Specified by:
init in interface javax.jbi.component.ComponentLifeCycle
Throws:
javax.jbi.JBIException

doInit

protected void doInit()
               throws java.lang.Exception
Throws:
java.lang.Exception

shutDown

public void shutDown()
              throws javax.jbi.JBIException
Specified by:
shutDown in interface javax.jbi.component.ComponentLifeCycle
Throws:
javax.jbi.JBIException

doShutDown

protected void doShutDown()
                   throws java.lang.Exception
Throws:
java.lang.Exception

start

public void start()
           throws javax.jbi.JBIException
Specified by:
start in interface javax.jbi.component.ComponentLifeCycle
Throws:
javax.jbi.JBIException

doStart

protected void doStart()
                throws java.lang.Exception
Throws:
java.lang.Exception

pollDeliveryChannel

protected void pollDeliveryChannel()

stop

public void stop()
          throws javax.jbi.JBIException
Specified by:
stop in interface javax.jbi.component.ComponentLifeCycle
Throws:
javax.jbi.JBIException

doStop

protected void doStop()
               throws java.lang.Exception
Throws:
java.lang.Exception

getContext

public javax.jbi.component.ComponentContext getContext()
Returns:
Returns the context.

getExecutor

public org.apache.servicemix.executors.Executor getExecutor(javax.jbi.messaging.MessageExchange.Role role)

setExecutor

public void setExecutor(javax.jbi.messaging.MessageExchange.Role role,
                        org.apache.servicemix.executors.Executor executor)
The executor to use for various tasks that need to be performed by the component. If none is provided, one will be created from the executorFactory.

Parameters:
executor -
See Also:
setExecutorFactory(ExecutorFactory)

getExecutorFactory

public org.apache.servicemix.executors.ExecutorFactory getExecutorFactory()

setExecutorFactory

public void setExecutorFactory(org.apache.servicemix.executors.ExecutorFactory executorFactory)
The executor factory to use to create the executor. If none is provided, one will be retrieved from the JBI container when the component is deployed into ServiceMix 3.x, or a default implementation will be used.

Parameters:
executorFactory -
See Also:
#setExecutor(Role, Executor)

createExecutorFactory

protected org.apache.servicemix.executors.ExecutorFactory createExecutorFactory()

getSmx3Container

public java.lang.Object getSmx3Container()

findExecutorFactory

protected org.apache.servicemix.executors.ExecutorFactory findExecutorFactory()

processExchangeInTx

protected void processExchangeInTx(javax.jbi.messaging.MessageExchange exchange,
                                   javax.transaction.Transaction tx)

exceptionShouldRollbackTx

protected boolean exceptionShouldRollbackTx(java.lang.Throwable t)

onMessageExchange

public void onMessageExchange(javax.jbi.messaging.MessageExchange exchange)

processExchange

protected void processExchange(javax.jbi.messaging.MessageExchange exchange)
                        throws java.lang.Exception
Throws:
java.lang.Exception

prepareExchange

public void prepareExchange(javax.jbi.messaging.MessageExchange exchange,
                            Endpoint endpoint)
                     throws javax.jbi.messaging.MessagingException
Throws:
javax.jbi.messaging.MessagingException

prepareShutdown

public void prepareShutdown(Endpoint endpoint)
                     throws java.lang.InterruptedException
Prepare an endpoint for shutdown by waiting until all its pending exchanges have been finished.

Parameters:
endpoint - the endpoint that is about to be shut down
Throws:
java.lang.InterruptedException

prepareShutdown

public void prepareShutdown(Endpoint endpoint,
                            long timeout)
                     throws java.lang.InterruptedException
Prepare an endpoint for shutdown by waiting until all its pending exchanges have been finished. This method will wait no longer than the timeout specified (in milliseconds)

Parameters:
endpoint - the endpoint that is about to be shut down
timeout - the maximum amount of time (in milliseconds) to wait
Throws:
java.lang.InterruptedException

getKnownExchanges

protected java.util.Set<java.lang.String> getKnownExchanges(Endpoint endpoint)

handleExchange

public void handleExchange(Endpoint endpoint,
                           javax.jbi.messaging.MessageExchange exchange,
                           boolean add)

getResolvedEPR

protected Endpoint getResolvedEPR(javax.jbi.servicedesc.ServiceEndpoint ep)
                           throws java.lang.Exception
Handle an exchange sent to an EPR resolved by this component

Parameters:
ep - the service endpoint
Returns:
an endpoint to use for handling the exchange
Throws:
java.lang.Exception


Copyright © 2005-2012 FuseSource. All Rights Reserved.