|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.transport.AbstractConnectable<O>
public abstract class AbstractConnectable<O>
Provide a default dispatch (client) support for handling threads lifecycle and validation.
Field Summary | |
---|---|
protected WaitableBoolean |
connected
|
protected WaitableBoolean |
connecting
|
protected AbstractConnector |
connector
|
protected ImmutableEndpoint |
endpoint
|
protected ConnectableLifecycleManager<O> |
lifecycleManager
|
protected Log |
logger
|
protected MuleMessageFactory |
muleMessageFactory
|
protected RetryPolicyTemplate |
retryTemplate
|
protected boolean |
startOnConnect
Indicates whether the receiver/dispatcher/requester should start upon connecting. |
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 | |
---|---|
AbstractConnectable(ImmutableEndpoint endpoint)
|
Method Summary | |
---|---|
void |
activate()
|
protected void |
callDoStartWhenItIsConnected()
This method will block until connected is true and then will call
doStart() . |
void |
connect()
Make the connection to the underlying transport. |
protected void |
connectAndThenStart()
This method will call connect() after setting startOnConnect
in true. |
protected abstract ConnectableLifecycleManager<O> |
createLifecycleManager()
|
MuleMessage |
createMuleMessage(java.lang.Object transportMessage)
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
MuleMessage |
createMuleMessage(java.lang.Object transportMessage,
MuleMessage previousMessage,
java.lang.String encoding)
Uses this object's MuleMessageFactory to create a new MuleMessage instance. |
MuleMessage |
createMuleMessage(java.lang.Object transportMessage,
java.lang.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 java.lang.String |
getConnectEventId(ImmutableEndpoint endpoint)
|
java.lang.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 |
boolean |
isConnecting()
|
protected boolean |
isDoStartMustFollowDoConnect()
|
protected boolean |
isDoThreading()
|
boolean |
isStarted()
|
void |
passivate()
|
void |
setEndpoint(ImmutableEndpoint endpoint)
|
void |
start()
This method will start the connectable, calling connect() if it is
needed. |
void |
stop()
|
java.lang.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 final WaitableBoolean connected
protected final WaitableBoolean connecting
protected volatile boolean startOnConnect
protected ConnectableLifecycleManager<O> lifecycleManager
Constructor Detail |
---|
public AbstractConnectable(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 java.lang.Exception
Connectable
connect
in interface Connectable
java.lang.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 java.lang.Exception
Connectable
disconnect
in interface Connectable
java.lang.Exception
protected java.lang.String getConnectEventId(ImmutableEndpoint endpoint)
public final boolean isConnected()
Connectable
isConnected
in interface Connectable
public final boolean isConnecting()
protected boolean isDoThreading()
public java.lang.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
protected void connectAndThenStart() throws LifecycleException
connect()
after setting startOnConnect
in true. This will make the connect()
method call start()
after finishing establishing connection.
LifecycleException
protected void callDoStartWhenItIsConnected() throws java.lang.InterruptedException, MuleException
connected
is true and then will call
doStart()
.
java.lang.InterruptedException
- if the thread is interrupted while waiting for
connected
to be true.
MuleException
- this is just a propagation of any MuleException
that doStart()
may throw.public final void stop() throws MuleException
stop
in interface Stoppable
MuleException
protected void doInitialise() throws InitialisationException
InitialisationException
protected void doDispose()
protected void doConnect() throws java.lang.Exception
java.lang.Exception
protected void doDisconnect() throws java.lang.Exception
java.lang.Exception
protected void doStart() throws MuleException
MuleException
protected void doStop() throws MuleException
MuleException
public java.lang.String toString()
toString
in class java.lang.Object
public void setEndpoint(ImmutableEndpoint endpoint)
protected abstract WorkManager getWorkManager() throws MuleException
MuleException
public boolean isStarted()
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(java.lang.Object transportMessage, MuleMessage previousMessage, java.lang.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(java.lang.Object transportMessage, java.lang.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(java.lang.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
protected boolean isDoStartMustFollowDoConnect()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |