KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > umo > provider > UMOConnector


1 /*
2  * $Id: UMOConnector.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.umo.provider;
12
13 import org.mule.umo.MessagingException;
14 import org.mule.umo.UMOComponent;
15 import org.mule.umo.UMOException;
16 import org.mule.umo.endpoint.UMOEndpoint;
17 import org.mule.umo.endpoint.UMOImmutableEndpoint;
18 import org.mule.umo.lifecycle.Disposable;
19 import org.mule.umo.lifecycle.Initialisable;
20
21 import java.beans.ExceptionListener JavaDoc;
22 import java.io.InputStream JavaDoc;
23 import java.io.OutputStream JavaDoc;
24
25 /**
26  * <code>UMOConnector</code> is the mechanism used to connect to external systems
27  * and protocols in order to send and receive data.
28  *
29  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
30  * @version $Revision: 3798 $
31  */

32 public interface UMOConnector extends Disposable, Initialisable
33 {
34     public static final int INT_VALUE_NOT_SET = -1;
35
36     /**
37      * This creates a <code>UMOMessageReceiver</code> associated with this endpoint
38      * and registers it with the connector
39      *
40      * @param component the listening component
41      * @param endpoint the endpoint contains the listener endpointUri on which to
42      * listen on.
43      * @throws Exception if the UMOMessageReceiver cannot be created or the Receiver
44      * cannot be registered
45      */

46     UMOMessageReceiver registerListener(UMOComponent component, UMOEndpoint endpoint) throws Exception JavaDoc;
47
48     /**
49      * @param component the listening component
50      * @param endpoint the associated endpointDescriptor with the listener
51      * @throws Exception if the listener cannot be unregistered. If a listener is not
52      * associated with the given endpoint this will not throw an
53      * exception
54      */

55     void unregisterListener(UMOComponent component, UMOEndpoint endpoint) throws Exception JavaDoc;
56
57     /**
58      * @return true if the endpoint is started
59      */

60     boolean isStarted();
61
62     /**
63      * @return false if the connector is alive and well or true if the connector is
64      * being destroyed
65      */

66     boolean isDisposed();
67
68     /**
69      * @return false if the connector is alive and well or true if the connector has
70      * been told to dispose
71      */

72     boolean isDisposing();
73
74     /**
75      * Gets a <code>UMOMessageAdapter</code> from the connector for the given
76      * message (data)
77      *
78      * @param message the data with which to initialise the
79      * <code>UMOMessageAdapter</code>
80      * @return the <code>UMOMessageAdapter</code> for the endpoint
81      * @throws MessagingException if the message parameter is not supported
82      * @see UMOMessageAdapter
83      */

84     UMOMessageAdapter getMessageAdapter(Object JavaDoc message) throws MessagingException;
85
86     /**
87      * Gets a <code>UMOStreamMessageAdapter</code> from the connector for the given
88      * message. This Adapter will correctly handle data streaming for this type of
89      * connector
90      *
91      * @param in the input stream to read the data from
92      * @param out the outputStream to write data to. This can be null.
93      * @return the <code>UMOStreamMessageAdapter</code> for the endpoint
94      * @throws MessagingException if the message parameter is not supported
95      * @see UMOStreamMessageAdapter
96      */

97     UMOStreamMessageAdapter getStreamMessageAdapter(InputStream JavaDoc in, OutputStream JavaDoc out)
98         throws MessagingException;
99
100     /**
101      * @return the name associated with the endpoint
102      */

103     String JavaDoc getName();
104
105     /**
106      * @param newName the name to associate with the endpoint
107      */

108     void setName(String JavaDoc newName);
109
110     /**
111      * @return the protocol name for the endpoint
112      */

113     String JavaDoc getProtocol();
114
115     /**
116      * @return true if the protocol is supported by this connector.
117      */

118     boolean supportsProtocol(String JavaDoc protocol);
119
120     /**
121      * The connector can pool dispatchers based on their endpointUri or can ingnore
122      * the endpointUri altogether and use a ThreadLocal or always create new.
123      *
124      * @param endpoint the endpoint that can be used to key cached dispatchers
125      * @return the component associated with the endpointUri If there is no component
126      * for the current thread one will be created
127      * @throws UMOException if creation of a component fails
128      */

129     UMOMessageDispatcher getDispatcher(UMOImmutableEndpoint endpoint) throws UMOException;
130
131     /**
132      * @param listener the exception strategy to use with this endpoint
133      * @see ExceptionListener
134      */

135     void setExceptionListener(ExceptionListener JavaDoc listener);
136
137     /**
138      * @return the Exception stategy used by the endpoint
139      * @see ExceptionListener
140      */

141     ExceptionListener JavaDoc getExceptionListener();
142
143     /**
144      * @param exception the exception that was caught
145      */

146     void handleException(Exception JavaDoc exception);
147
148     /**
149      * The dispatcher factory is used to create a message dispatcher of the current
150      * request
151      *
152      * @param factory the factory to use when a dispatcher request is madr
153      */

154     void setDispatcherFactory(UMOMessageDispatcherFactory factory);
155
156     /**
157      * The dispatcher factory is used to create a message dispatcher of the current
158      * request
159      *
160      * @return the factory to use when a dispatcher request is madr
161      */

162     UMOMessageDispatcherFactory getDispatcherFactory();
163
164     public void startConnector() throws UMOException;
165
166     public void stopConnector() throws UMOException;
167
168     public boolean isRemoteSyncEnabled();
169 }
170
Popular Tags