org.mule.umo.provider
Interface UMOConnector

All Superinterfaces:
Disposable, Initialisable
All Known Implementing Classes:
AbstractConnector

public interface UMOConnector
extends Disposable, Initialisable

UMOConnector is the mechanism used to connect to external systems and protocols in order to send and receive data.


Field Summary
static int INT_VALUE_NOT_SET
           
 
Method Summary
 void dispatch(UMOImmutableEndpoint endpoint, UMOEvent event)
          Dispatches an event from the endpoint to the external system
 UMOMessageDispatcherFactory getDispatcherFactory()
          The dispatcher factory is used to create a message dispatcher of the current request
 ExceptionListener getExceptionListener()
           
 UMOMessageAdapter getMessageAdapter(Object message)
          Gets a UMOMessageAdapter from the connector for the given message (data)
 String getName()
           
 OutputStream getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message)
          Will get the output stream for this type of transport.
 String getProtocol()
           
 ScheduledExecutorService getScheduler()
          Returns a Scheduler service for execution of periodic tasks.
 UMOStreamMessageAdapter getStreamMessageAdapter(InputStream in, OutputStream out)
          Gets a UMOStreamMessageAdapter from the connector for the given message.
 void handleException(Exception exception)
           
 boolean isDisposed()
           
 boolean isDisposing()
           
 boolean isRemoteSyncEnabled()
           
 boolean isStarted()
           
 UMOMessage receive(UMOEndpointURI endpointUri, long timeout)
          Deprecated. Use receive(UMOImmutableEndpoint endpoint, long timeout)
 UMOMessage receive(UMOImmutableEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
 UMOMessageReceiver registerListener(UMOComponent component, UMOEndpoint endpoint)
          This creates a UMOMessageReceiver associated with this endpoint and registers it with the connector.
 UMOMessage send(UMOImmutableEndpoint endpoint, UMOEvent event)
          Sends an event from the endpoint to the external system
 void setDispatcherFactory(UMOMessageDispatcherFactory factory)
          The dispatcher factory is used to create a message dispatcher of the current request
 void setExceptionListener(ExceptionListener listener)
           
 void setName(String newName)
           
 void startConnector()
           
 void stopConnector()
           
 boolean supportsProtocol(String protocol)
           
 void unregisterListener(UMOComponent component, UMOEndpoint endpoint)
           
 
Methods inherited from interface org.mule.umo.lifecycle.Disposable
dispose
 
Methods inherited from interface org.mule.umo.lifecycle.Initialisable
initialise
 

Field Detail

INT_VALUE_NOT_SET

public static final int INT_VALUE_NOT_SET
See Also:
Constant Field Values
Method Detail

registerListener

public UMOMessageReceiver registerListener(UMOComponent component,
                                           UMOEndpoint endpoint)
                                    throws Exception
This creates a UMOMessageReceiver associated with this endpoint and registers it with the connector.

Parameters:
component - the listening component
endpoint - the endpoint contains the listener endpointUri on which to listen on.
Returns:
message receiver
Throws:
Exception - if the UMOMessageReceiver cannot be created or the Receiver cannot be registered

unregisterListener

public void unregisterListener(UMOComponent component,
                               UMOEndpoint endpoint)
                        throws Exception
Parameters:
component - the listening component
endpoint - the associated endpointDescriptor with the listener
Throws:
Exception - if the listener cannot be unregistered. If a listener is not associated with the given endpoint this will not throw an exception

isStarted

public boolean isStarted()
Returns:
true if the endpoint is started

isDisposed

public boolean isDisposed()
Returns:
false if the connector is alive and well or true if the connector is being destroyed

isDisposing

public boolean isDisposing()
Returns:
false if the connector is alive and well or true if the connector has been told to dispose

getMessageAdapter

public UMOMessageAdapter getMessageAdapter(Object message)
                                    throws MessagingException
Gets a UMOMessageAdapter from the connector for the given message (data)

Parameters:
message - the data with which to initialise the UMOMessageAdapter
Returns:
the UMOMessageAdapter for the endpoint
Throws:
MessagingException - if the message parameter is not supported
See Also:
UMOMessageAdapter

getStreamMessageAdapter

public UMOStreamMessageAdapter getStreamMessageAdapter(InputStream in,
                                                       OutputStream out)
                                                throws MessagingException
Gets a UMOStreamMessageAdapter from the connector for the given message. This Adapter will correctly handle data streaming for this type of connector

Parameters:
in - the input stream to read the data from
out - the outputStream to write data to. This can be null.
Returns:
the UMOStreamMessageAdapter for the endpoint
Throws:
MessagingException - if the message parameter is not supported
See Also:
UMOStreamMessageAdapter

getName

public String getName()
Returns:
the name associated with the connector

setName

public void setName(String newName)
Parameters:
newName - the name to associate with the connector

getProtocol

public String getProtocol()
Returns:
the primary protocol name for endpoints of this connector

supportsProtocol

public boolean supportsProtocol(String protocol)
Parameters:
protocol - protocol name
Returns:
true if the protocol is supported by this connector.

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Parameters:
listener - the exception strategy to use with this endpoint
See Also:
ExceptionListener

getExceptionListener

public ExceptionListener getExceptionListener()
Returns:
the Exception stategy used by the endpoint
See Also:
ExceptionListener

handleException

public void handleException(Exception exception)
Parameters:
exception - the exception that was caught

getScheduler

public ScheduledExecutorService getScheduler()
Returns a Scheduler service for execution of periodic tasks.

Returns:
scheduler

setDispatcherFactory

public void setDispatcherFactory(UMOMessageDispatcherFactory factory)
The dispatcher factory is used to create a message dispatcher of the current request

Parameters:
factory - the factory to use when a dispatcher request is madr

getDispatcherFactory

public UMOMessageDispatcherFactory getDispatcherFactory()
The dispatcher factory is used to create a message dispatcher of the current request

Returns:
the factory to use when a dispatcher request is madr

startConnector

public void startConnector()
                    throws UMOException
Throws:
UMOException

stopConnector

public void stopConnector()
                   throws UMOException
Throws:
UMOException

isRemoteSyncEnabled

public boolean isRemoteSyncEnabled()

dispatch

public void dispatch(UMOImmutableEndpoint endpoint,
                     UMOEvent event)
              throws DispatchException
Dispatches an event from the endpoint to the external system

Parameters:
event - The event to dispatch
endpoint - endpoint to dispatch from
Throws:
DispatchException - if the event fails to be dispatched

receive

public UMOMessage receive(UMOEndpointURI endpointUri,
                          long timeout)
                   throws Exception
Deprecated. Use receive(UMOImmutableEndpoint endpoint, long timeout)

Make a specific request to the underlying transport

Parameters:
endpointUri - the endpoint URI to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

receive

public UMOMessage receive(UMOImmutableEndpoint endpoint,
                          long timeout)
                   throws Exception
Make a specific request to the underlying transport

Parameters:
endpoint - the endpoint to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

send

public UMOMessage send(UMOImmutableEndpoint endpoint,
                       UMOEvent event)
                throws DispatchException
Sends an event from the endpoint to the external system

Parameters:
event - The event to send
endpoint - endpoint to send from
Returns:
event the response form the external system wrapped in a UMOEvent
Throws:
DispatchException - if the event fails to be dispatched

getOutputStream

public OutputStream getOutputStream(UMOImmutableEndpoint endpoint,
                                    UMOMessage message)
                             throws UMOException
Will get the output stream for this type of transport. Typically this will be called only when Streaming is being used on an outbound endpoint. If Streaming is not supported by this transport an UnsupportedOperationException is thrown. Note that the stream MUST release resources on close. For help doing so, see CallbackOutputStream.

Parameters:
endpoint - the endpoint that releates to this Dispatcher
message - the current message being processed
Returns:
the output stream to use for this request
Throws:
UMOException - in case of any error


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