|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.transport.AbstractTransportMessageHandler<O>
public abstract class AbstractTransportMessageHandler<O>
Provide a default dispatch (client) support for handling threads lifecycle and validation.
Field Summary | |
---|---|
protected AtomicBoolean |
connected
|
protected AbstractConnector |
connector
|
protected ImmutableEndpoint |
endpoint
|
protected ConnectableLifecycleManager<O> |
lifecycleManager
|
protected Log |
logger
|
protected MuleMessageFactory |
muleMessageFactory
|
protected RetryPolicyTemplate |
retryTemplate
|
Fields inherited from interface org.mule.api.lifecycle.Initialisable |
---|
PHASE_NAME |
Fields inherited from interface org.mule.api.lifecycle.Startable |
---|
PHASE_NAME |
Fields inherited from interface org.mule.api.lifecycle.Stoppable |
---|
PHASE_NAME |
Fields inherited from interface org.mule.api.lifecycle.Disposable |
---|
PHASE_NAME |
Constructor Summary | |
---|---|
AbstractTransportMessageHandler(ImmutableEndpoint endpoint)
|
Method Summary | |
---|---|
void |
activate()
|
void |
connect()
Make the connection to the underlying transport. |
protected abstract ConnectableLifecycleManager<O> |
createLifecycleManager()
|
MuleMessage |
createMuleMessage(Object transportMessage)
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
MuleMessage |
createMuleMessage(Object transportMessage,
MuleMessage previousMessage,
String encoding)
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
MuleMessage |
createMuleMessage(Object transportMessage,
String encoding)
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
protected MuleMessageFactory |
createMuleMessageFactory()
This method uses the connector's createMuleMessageFactory method to create
a new MuleMessageFactory . |
protected MuleMessage |
createNullMuleMessage()
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
void |
disconnect()
Disconnect the from the underlying transport |
void |
dispose()
Template method to destroy any resources held by the Message Dispatcher |
protected void |
disposeAndLogException()
|
protected void |
doConnect()
|
protected void |
doDisconnect()
|
protected void |
doDispose()
|
protected void |
doInitialise()
|
protected void |
doStart()
|
protected void |
doStop()
|
protected String |
getConnectEventId(ImmutableEndpoint endpoint)
|
String |
getConnectionDescription()
Returns a string identifying the underlying resource |
Connector |
getConnector()
|
ImmutableEndpoint |
getEndpoint()
|
LifecycleState |
getLifecycleState()
|
protected abstract WorkManager |
getWorkManager()
|
void |
initialise()
Method used to perform any initialisation work. |
protected void |
initializeMessageFactory()
Subclasses can override this method to create a custom MuleMessageFactory instead
of re-using the instance from the connector. |
protected void |
initializeRetryPolicy()
|
boolean |
isConnected()
Determines if this object is connected or not |
protected boolean |
isDoThreading()
|
boolean |
isStarted()
|
boolean |
isStarting()
|
boolean |
isStopping()
|
void |
passivate()
|
void |
setEndpoint(ImmutableEndpoint endpoint)
|
void |
start()
This method will start the connectable, calling connect() if it is
needed. |
void |
stop()
|
String |
toString()
|
boolean |
validate()
|
RetryContext |
validateConnection(RetryContext retryContext)
Test whether the connector is able to connect to its resource(s). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient Log logger
protected ImmutableEndpoint endpoint
protected final AbstractConnector connector
protected RetryPolicyTemplate retryTemplate
protected MuleMessageFactory muleMessageFactory
protected ConnectableLifecycleManager<O> lifecycleManager
protected final AtomicBoolean connected
Constructor Detail |
---|
public AbstractTransportMessageHandler(ImmutableEndpoint endpoint)
Method Detail |
---|
protected abstract ConnectableLifecycleManager<O> createLifecycleManager()
public LifecycleState getLifecycleState()
getLifecycleState
in interface LifecycleStateEnabled
protected void disposeAndLogException()
public boolean validate()
public void activate()
public void passivate()
public void initialise() throws InitialisationException
Initialisable
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.
initialise
in interface Initialisable
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdown
RecoverableException
- if an error occurs that can be recovered fromprotected void initializeRetryPolicy()
protected void initializeMessageFactory() throws InitialisationException
MuleMessageFactory
instead
of re-using the instance from the connector.
InitialisationException
public void dispose()
dispose
in interface Disposable
public Connector getConnector()
public ImmutableEndpoint getEndpoint()
public final void connect() throws Exception
Connectable
connect
in interface Connectable
Exception
public RetryContext validateConnection(RetryContext retryContext)
Connectable
RetryContext.setOk()
when no problems found (or no validation required).
RetryContext.setFailed(Throwable)
with a root cause for a connection failure.
RetryContext.isOk()
. The failure, if any, will be
provided via the RetryContext.getLastFailure()
.
validateConnection
in interface Connectable
public final void disconnect() throws Exception
Connectable
disconnect
in interface Connectable
Exception
protected String getConnectEventId(ImmutableEndpoint endpoint)
public final boolean isConnected()
Connectable
isConnected
in interface Connectable
protected boolean isDoThreading()
public String getConnectionDescription()
getConnectionDescription
in interface Connectable
public final void start() throws MuleException
connect()
if it is
needed.
This method is synchronous or not depending on how the retryTemplate
behaves.
This method ensures that doStart()
will be called at most one time
and will return without error if the component is already started.
start
in interface Startable
MuleException
public final void stop() throws MuleException
stop
in interface Stoppable
MuleException
protected void doInitialise() throws InitialisationException
InitialisationException
protected void doDispose()
protected void doConnect() throws Exception
Exception
protected void doDisconnect() throws Exception
Exception
protected void doStart() throws MuleException
MuleException
protected void doStop() throws MuleException
MuleException
public String toString()
toString
in class Object
public void setEndpoint(ImmutableEndpoint endpoint)
protected abstract WorkManager getWorkManager() throws MuleException
MuleException
public boolean isStarted()
public boolean isStarting()
public boolean isStopping()
protected MuleMessageFactory createMuleMessageFactory() throws CreateException
createMuleMessageFactory
method to create
a new MuleMessageFactory
. Subclasses may need to override this method in order to
perform additional initialization on the message factory before it's actually used.
CreateException
public MuleMessage createMuleMessage(Object transportMessage, MuleMessage previousMessage, String encoding) throws MuleException
MuleMessageFactory
to create a new MuleMessage
instance.
The payload of the new message will be taken from transportMessage
, all
message properties will be copied from previousMessage
.
MuleException
public MuleMessage createMuleMessage(Object transportMessage, String encoding) throws MuleException
MuleMessageFactory
to create a new MuleMessage
instance.
This is the designated way to build MuleMessage
s from the transport specific message.
MuleException
public MuleMessage createMuleMessage(Object transportMessage) throws MuleException
MuleMessageFactory
to create a new MuleMessage
instance.
Uses the default encoding.
MuleException
MuleConfiguration.getDefaultEncoding()
protected MuleMessage createNullMuleMessage() throws MuleException
MuleMessageFactory
to create a new MuleMessage
instance.
Rather than passing in a transport message instance, NullPayload
is used instead.
Uses the default encoding.
MuleException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |