Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.transport
Class AbstractConnectable<O>

    java.lang.Object
      org.mule.transport.AbstractConnectable<O>

All Implemented Interfaces:
  Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable, Connectable

Direct Known Subclasses:
  AbstractMessageDispatcher, AbstractMessageReceiver, AbstractMessageRequester

    public abstract class AbstractConnectable<O>

extends Object
implements Connectable, LifecycleStateEnabled

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(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
`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()`
`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

### muleMessageFactory

    protected MuleMessageFactory muleMessageFactory

### connected

    protected final WaitableBoolean connected

### connecting

    protected final WaitableBoolean connecting

### startOnConnect

    protected volatile 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.

### lifecycleManager

    protected ConnectableLifecycleManager<O> lifecycleManager

Constructor Detail

### AbstractConnectable

    public AbstractConnectable(ImmutableEndpoint endpoint)

Method Detail

### createLifecycleManager

    protected abstract ConnectableLifecycleManager<O> createLifecycleManager()

### getLifecycleState

    public LifecycleState getLifecycleState()

  Specified by:
    `getLifecycleState` in interface `LifecycleStateEnabled`

### disposeAndLogException

    protected void disposeAndLogException()

### 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

### initializeRetryPolicy

    protected void initializeRetryPolicy()

### initializeMessageFactory

    protected void initializeMessageFactory()
                                     throws InitialisationException

  Subclasses can override this method to create a custom `MuleMessageFactory` instead of re-using the instance from the connector.

  Throws:
    `InitialisationException`

### 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:
  - `RetryContext.setOk()` when no problems found (or no validation required).
  - `RetryContext.setFailed(Throwable)` with a root cause for a connection failure.
  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`

### isConnecting

    public final boolean isConnecting()

### isDoThreading

    protected boolean isDoThreading()

### getConnectionDescription

    public String getConnectionDescription()

  Returns a string identifying the underlying resource

  Specified by:
    `getConnectionDescription` in interface `Connectable`

### start

    public final void start()
                     throws MuleException

  This method will start the connectable, calling `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`.

  Specified by:
    `start` in interface `Startable`
  Throws:
    `MuleException`

### connectAndThenStart

    protected void connectAndThenStart()
                                throws LifecycleException

  This method will call `connect()` after setting `startOnConnect` in true. This will make the `connect()` method call `start()` after finishing establishing connection.

  Throws:
    `LifecycleException`

### callDoStartWhenItIsConnected

    protected void callDoStartWhenItIsConnected()
                                         throws InterruptedException,
                                                MuleException

  This method will block until `connected` is true and then will call `doStart()`.

  Throws:
    `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.

### stop

    public final void stop()
                    throws MuleException

  Specified by:
    `stop` in interface `Stoppable`
  Throws:
    `MuleException`

### 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()
                                           throws MuleException

  Throws:
    `MuleException`

### isStarted

    public boolean isStarted()

### createMuleMessageFactory

    protected MuleMessageFactory createMuleMessageFactory()
                                                   throws CreateException

  This method uses the connector's `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.

  Throws:
    `CreateException`

### createMuleMessage

    public MuleMessage createMuleMessage(Object transportMessage,
                                         MuleMessage previousMessage,
                                         String encoding)
                                  throws MuleException

  Uses this object's `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`.

  Throws:
    `MuleException`

### createMuleMessage

    public MuleMessage createMuleMessage(Object transportMessage,
                                         String encoding)
                                  throws MuleException

  Uses this object's `MuleMessageFactory` to create a new `MuleMessage` instance. This is the designated way to build `MuleMessage`s from the transport specific message.

  Throws:
    `MuleException`

### createMuleMessage

    public MuleMessage createMuleMessage(Object transportMessage)
                                  throws MuleException

  Uses this object's `MuleMessageFactory` to create a new `MuleMessage` instance. Uses the default encoding.

  Throws:
    `MuleException`
  See Also:
    `MuleConfiguration.getDefaultEncoding()`

### createNullMuleMessage

    protected MuleMessage createNullMuleMessage()
                                         throws MuleException

  Uses this object's `MuleMessageFactory` to create a new `MuleMessage` instance. Rather than passing in a transport message instance, `NullPayload` is used instead. Uses the default encoding.

  Throws:
    `MuleException`

### isDoStartMustFollowDoConnect

    protected boolean isDoStartMustFollowDoConnect()

  Returns:
    true if doStart() must come strictly after the completion of doConnect()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.