org.mule.transport
Class AbstractConnectable

java.lang.Object
  extended by org.mule.transport.AbstractConnectable
All Implemented Interfaces:
ExceptionListener, Disposable, Initialisable, Startable, Stoppable, Connectable
Direct Known Subclasses:
AbstractMessageDispatcher, AbstractMessageReceiver, AbstractMessageRequester

public abstract class AbstractConnectable
extends Object
implements Connectable, ExceptionListener

Provide a default dispatch (client) support for handling threads lifecycle and validation.


Field Summary
protected  WaitableBoolean connected
           
protected  AbstractConnector connector
           
protected  edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed
           
protected  ImmutableEndpoint endpoint
           
protected  Log logger
           
protected  RetryPolicyTemplate retryTemplate
           
protected  WaitableBoolean started
           
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.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Constructor Summary
AbstractConnectable(ImmutableEndpoint endpoint)
           
 
Method Summary
 void activate()
           
 void connect()
          Make the connection to the underlying transport.
 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()
           
 void exceptionThrown(Exception e)
           
protected  String getConnectEventId(ImmutableEndpoint endpoint)
           
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 Connector getConnector()
           
 ImmutableEndpoint getEndpoint()
           
protected abstract  WorkManager getWorkManager()
           
 void handleException(Exception exception)
           
 void initialise()
          Method used to perform any initialisation work.
 boolean isConnected()
          Determines if this object is connected or not
protected  boolean isDoThreading()
           
 boolean isStarted()
           
 void passivate()
           
 void setEndpoint(ImmutableEndpoint endpoint)
           
 void start()
           
 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

logger

protected transient Log logger

endpoint

protected ImmutableEndpoint endpoint

connector

protected final AbstractConnector connector

retryTemplate

protected RetryPolicyTemplate retryTemplate

connected

protected final WaitableBoolean connected

started

protected final WaitableBoolean started

disposed

protected final edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean disposed

startOnConnect

protected boolean startOnConnect
Indicates whether the receiver/dispatcher/requester should start upon connecting. This is necessary to support asynchronous retry policies, otherwise the start() method would block until connection is successful.

Constructor Detail

AbstractConnectable

public AbstractConnectable(ImmutableEndpoint endpoint)
Method Detail

disposeAndLogException

protected void disposeAndLogException()

exceptionThrown

public void exceptionThrown(Exception e)
Specified by:
exceptionThrown in interface ExceptionListener

handleException

public void handleException(Exception exception)

validate

public boolean validate()

activate

public void activate()

passivate

public void passivate()

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an 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.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

dispose

public void dispose()
Template method to destroy any resources held by the Message Dispatcher

Specified by:
dispose in interface Disposable

getConnector

public Connector getConnector()

getEndpoint

public ImmutableEndpoint getEndpoint()

connect

public final void connect()
                   throws Exception
Description copied from interface: Connectable
Make the connection to the underlying transport. The fact that this object is connected or not should have no influence on the lifecycle, especially the start / stop state if applicable.

Specified by:
connect in interface Connectable
Throws:
Exception

validateConnection

public RetryContext validateConnection(RetryContext retryContext)
Description copied from interface: Connectable
Test whether the connector is able to connect to its resource(s). This will allow a retry policy to go into effect in the case of failure. Implementations must call either: Callers should then check for RetryContext.isOk(). The failure, if any, will be provided via the RetryContext.getLastFailure().

Specified by:
validateConnection in interface Connectable
Returns:
same retry context with status info set and any failures populated

disconnect

public final void disconnect()
                      throws Exception
Description copied from interface: Connectable
Disconnect the from the underlying transport

Specified by:
disconnect in interface Connectable
Throws:
Exception

getConnectEventId

protected String getConnectEventId(ImmutableEndpoint endpoint)

isConnected

public final boolean isConnected()
Description copied from interface: Connectable
Determines if this object is connected or not

Specified by:
isConnected in interface Connectable
Returns:

isDoThreading

protected boolean isDoThreading()

getConnectionDescription

public String getConnectionDescription()
Returns a string identifying the underlying resource

Specified by:
getConnectionDescription in interface Connectable
Returns:

start

public final void start()
                 throws MuleException
Specified by:
start in interface Startable
Throws:
MuleException

stop

public final void stop()
Specified by:
stop in interface Stoppable

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

doDispose

protected void doDispose()

doConnect

protected void doConnect()
                  throws Exception
Throws:
Exception

doDisconnect

protected void doDisconnect()
                     throws Exception
Throws:
Exception

doStart

protected void doStart()
                throws MuleException
Throws:
MuleException

doStop

protected void doStop()
               throws MuleException
Throws:
MuleException

toString

public String toString()
Overrides:
toString in class Object

setEndpoint

public void setEndpoint(ImmutableEndpoint endpoint)

getWorkManager

protected abstract WorkManager getWorkManager()

isStarted

public boolean isStarted()


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.