Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mule.providers
Class AbstractConnector  view AbstractConnector download AbstractConnector.java

java.lang.Object
  extended byorg.mule.providers.AbstractConnector
All Implemented Interfaces:
org.mule.util.ExceptionListener, org.mule.umo.provider.UMOConnector

public abstract class AbstractConnector
extends java.lang.Object
implements org.mule.umo.provider.UMOConnector, org.mule.util.ExceptionListener

AbstractConnector provides base functionality for all connectors provided with Mule. Connectors are the mechanism used to connect to external systems and protocols in order to send and receive data.

The AbstractConnector provides getter and setter methods for connector properties, name, transport name and protocol. It also provides methods to stop and start connecotors and sets up a dispatcher threadpool which allows deriving connectors the possibility to dispatch work to separate threads. This functionality is controlled with the transport.connector.doThreading property.

Version:
$Revision: 1.11 $

Field Summary
protected  boolean alive
          Determines in the connector is alive and well
private  org.mule.util.NamedThreadPool dispatchers
          The dispatcher threadpool
static java.lang.String DO_THREADING_PROPERTY
          The property name that specifies if a dispatch threadpool should be created
protected  boolean doThreading
          Determines whether a dispatch threadpool should be created
protected  org.mule.umo.UMOExceptionStrategy exceptionStrategy
          The exception strategy used by this connector
protected static org.apache.commons.logging.Log log
          logger used by this class
protected  java.lang.String name
          The name that identifies the connector
protected  java.util.HashMap properties
          Holds any configuration properties for the connector
protected  java.lang.String protocol
          The proptocol name the connector uses to communicate with the external system
protected  boolean started
          Specifies if the connector started
protected  java.lang.String transportName
          Holds the transport name of the connector i.e.
 
Constructor Summary
AbstractConnector()
           
 
Method Summary
abstract  void create()
          A template method to perform any additional creating work by the deriving class
 void create(java.util.HashMap properties)
          Creates the underlying connection for this connector
protected  void dispatch(java.lang.Thread thread)
          Dispatches a thread in the connector threadpool
 org.mule.umo.UMOExceptionStrategy getExceptionStrategy()
           
 java.lang.String getName()
           
 java.util.HashMap getProperties()
           
protected  java.lang.Object getProperty(java.lang.Object key)
           
protected  java.lang.Object getProperty(java.lang.Object key, java.lang.Object defaultValue)
           
abstract  java.lang.String getProtocol()
           
 java.lang.Object getSession()
           
 java.lang.String getTransportName()
           
 void handleException(java.lang.Object message, java.lang.Throwable exception)
           
 boolean isAlive()
           
 boolean isDoThreading()
           
 boolean isStarted()
           
 void onException(java.lang.Throwable throwable)
           
 void setDoThreading(boolean b)
           
 void setExceptionStrategy(org.mule.umo.UMOExceptionStrategy strategy)
           
 void setName(java.lang.String newName)
           
 void setProperties(java.util.HashMap newProps)
           
protected  void setProperty(java.lang.Object key, java.lang.Object value)
           
 void setProtocol(java.lang.String protocol)
           
 void setTransportName(java.lang.String name)
           
 void shutdown()
          Shutdowns the connector
protected abstract  void shutdownConnector()
          Template method to perform any work when destroying the connectoe
 void start()
          Starts the connector
protected abstract  void startConnector()
          Template method to perform any work when starting the connectoe
 void stop()
          Stops the connector
protected abstract  void stopConnector()
          Template method to perform any work when stopping the connectoe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOConnector
dispatch, getMessageAdapter, registerListener, removeListener, send
 

Field Detail

DO_THREADING_PROPERTY

public static final java.lang.String DO_THREADING_PROPERTY
The property name that specifies if a dispatch threadpool should be created

See Also:
Constant Field Values

doThreading

protected boolean doThreading
Determines whether a dispatch threadpool should be created


dispatchers

private org.mule.util.NamedThreadPool dispatchers
The dispatcher threadpool


started

protected boolean started
Specifies if the connector started


log

protected static transient org.apache.commons.logging.Log log
logger used by this class


name

protected java.lang.String name
The name that identifies the connector


protocol

protected java.lang.String protocol
The proptocol name the connector uses to communicate with the external system


transportName

protected java.lang.String transportName
Holds the transport name of the connector i.e. the transport name maybe email but the protocol might be POP3


properties

protected java.util.HashMap properties
Holds any configuration properties for the connector


exceptionStrategy

protected org.mule.umo.UMOExceptionStrategy exceptionStrategy
The exception strategy used by this connector


alive

protected boolean alive
Determines in the connector is alive and well

Constructor Detail

AbstractConnector

public AbstractConnector()
Method Detail

getName

public java.lang.String getName()
Specified by:
getName in interface org.mule.umo.provider.UMOConnector

getProperties

public java.util.HashMap getProperties()
Specified by:
getProperties in interface org.mule.umo.provider.UMOConnector

setName

public void setName(java.lang.String newName)
Specified by:
setName in interface org.mule.umo.provider.UMOConnector

setProperties

public void setProperties(java.util.HashMap newProps)
Specified by:
setProperties in interface org.mule.umo.provider.UMOConnector

create

public void create(java.util.HashMap properties)
            throws java.lang.Exception
Description copied from interface: org.mule.umo.provider.UMOConnector
Creates the underlying connection for this connector

Specified by:
create in interface org.mule.umo.provider.UMOConnector

create

public abstract void create()
                     throws java.lang.Exception
A template method to perform any additional creating work by the deriving class


getProtocol

public abstract java.lang.String getProtocol()
Specified by:
getProtocol in interface org.mule.umo.provider.UMOConnector

getTransportName

public java.lang.String getTransportName()
Specified by:
getTransportName in interface org.mule.umo.provider.UMOConnector

setProtocol

public void setProtocol(java.lang.String protocol)
Specified by:
setProtocol in interface org.mule.umo.provider.UMOConnector

setTransportName

public void setTransportName(java.lang.String name)
Specified by:
setTransportName in interface org.mule.umo.provider.UMOConnector

setProperty

protected void setProperty(java.lang.Object key,
                           java.lang.Object value)

getProperty

protected java.lang.Object getProperty(java.lang.Object key,
                                       java.lang.Object defaultValue)

getProperty

protected java.lang.Object getProperty(java.lang.Object key)

start

public void start()
           throws java.lang.Exception
Description copied from interface: org.mule.umo.provider.UMOConnector
Starts the connector

Specified by:
start in interface org.mule.umo.provider.UMOConnector

isStarted

public boolean isStarted()
Specified by:
isStarted in interface org.mule.umo.provider.UMOConnector

stop

public void stop()
          throws java.lang.Exception
Description copied from interface: org.mule.umo.provider.UMOConnector
Stops the connector

Specified by:
stop in interface org.mule.umo.provider.UMOConnector

shutdown

public void shutdown()
              throws java.lang.Exception
Description copied from interface: org.mule.umo.provider.UMOConnector
Shutdowns the connector

Specified by:
shutdown in interface org.mule.umo.provider.UMOConnector

isAlive

public boolean isAlive()
Specified by:
isAlive in interface org.mule.umo.provider.UMOConnector

getSession

public java.lang.Object getSession()
Specified by:
getSession in interface org.mule.umo.provider.UMOConnector

handleException

public void handleException(java.lang.Object message,
                            java.lang.Throwable exception)
Specified by:
handleException in interface org.mule.umo.provider.UMOConnector

onException

public void onException(java.lang.Throwable throwable)
Specified by:
onException in interface org.mule.util.ExceptionListener

getExceptionStrategy

public org.mule.umo.UMOExceptionStrategy getExceptionStrategy()
Specified by:
getExceptionStrategy in interface org.mule.umo.provider.UMOConnector

setExceptionStrategy

public void setExceptionStrategy(org.mule.umo.UMOExceptionStrategy strategy)
Specified by:
setExceptionStrategy in interface org.mule.umo.provider.UMOConnector

startConnector

protected abstract void startConnector()
                                throws java.lang.Exception
Template method to perform any work when starting the connectoe


stopConnector

protected abstract void stopConnector()
                               throws java.lang.Exception
Template method to perform any work when stopping the connectoe


shutdownConnector

protected abstract void shutdownConnector()
                                   throws java.lang.Exception
Template method to perform any work when destroying the connectoe


isDoThreading

public boolean isDoThreading()

setDoThreading

public void setDoThreading(boolean b)

dispatch

protected void dispatch(java.lang.Thread thread)
Dispatches a thread in the connector threadpool