[jboss-cvs] JBoss Messaging SVN: r3553 - trunk/src/main/org/jboss/messaging/core/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 9 07:54:05 EST 2008
Author: jmesnil
Date: 2008-01-09 07:54:05 -0500 (Wed, 09 Jan 2008)
New Revision: 3553
Modified:
trunk/src/main/org/jboss/messaging/core/remoting/Client.java
Log:
* extracted Client interface and moved implementation to o.j.messaging.core.remoting.impl
Modified: trunk/src/main/org/jboss/messaging/core/remoting/Client.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/Client.java 2008-01-09 12:51:42 UTC (rev 3552)
+++ trunk/src/main/org/jboss/messaging/core/remoting/Client.java 2008-01-09 12:54:05 UTC (rev 3553)
@@ -6,164 +6,42 @@
*/
package org.jboss.messaging.core.remoting;
-import static java.util.concurrent.TimeUnit.SECONDS;
-
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import javax.jms.IllegalStateException;
import javax.jms.JMSException;
import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
-import org.jboss.jms.exception.MessagingNetworkFailureException;
-import org.jboss.logging.Logger;
import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
*
* @version <tt>$Revision$</tt>
+ *
*/
-public class Client
+public interface Client
{
- // Constants -----------------------------------------------------
- private final Logger log = Logger.getLogger(Client.class);
+ void connect() throws Exception;
- // Attributes ----------------------------------------------------
+ boolean disconnect() throws Exception;
- private ServerLocator serverLocator;
+ boolean isConnected();
- private final NIOConnector connector;
+ String getURI();
- private NIOSession session;
+ String getSessionID();
- // By default, a blocking request will timeout after 5 seconds
- private int blockingRequestTimeout = 5;
- private TimeUnit blockingRequestTimeUnit = SECONDS;
-
- // Static --------------------------------------------------------
+ void sendOneWay(AbstractPacket packet) throws JMSException;
- // Constructors --------------------------------------------------
+ AbstractPacket sendBlocking(AbstractPacket packet) throws IOException,
+ JMSException;
- public Client(NIOConnector connector, ServerLocator locator)
- {
- assert connector != null;
- assert locator != null;
-
- this.connector = connector;
- this.serverLocator = locator;
- }
+ void setBlockingRequestTimeout(int timeout, TimeUnit unit);
- // Public --------------------------------------------------------
+ void addConnectionListener(
+ final ConsolidatedRemotingConnectionListener listener);
- public void connect() throws Exception
- {
- this.session = connector.connect();
- }
-
- public boolean disconnect() throws Exception
- {
- if (session == null)
- {
- return false;
- }
- session = null;
- return true;
- }
-
- public String getSessionID()
- {
- if (session == null || !session.isConnected())
- {
- return null;
- }
- return Long.toString(session.getID());
- }
-
- public void sendOneWay(AbstractPacket packet) throws JMSException
- {
- assert packet != null;
- checkConnected();
-
- session.write(packet);
- }
-
- public AbstractPacket sendBlocking(AbstractPacket packet)
- throws IOException, JMSException
- {
- assert packet != null;
- checkConnected();
-
- try
- {
- AbstractPacket response = (AbstractPacket) session.writeAndBlock(packet,
- blockingRequestTimeout, blockingRequestTimeUnit);
- return response;
- } catch (Throwable t)
- {
- IOException ioe = new IOException();
- ioe.initCause(t);
- throw ioe;
- }
- }
-
- public void setBlockingRequestTimeout(int timeout, TimeUnit unit)
- {
- this.blockingRequestTimeout = timeout;
- this.blockingRequestTimeUnit = unit;
- }
-
- public void addConnectionListener(
- final ConsolidatedRemotingConnectionListener listener)
- {
- connector.addConnectionListener(listener);
- }
-
- public void removeConnectionListener(
- ConsolidatedRemotingConnectionListener listener)
- {
- connector.removeConnectionListener(listener);
- }
-
- public boolean isConnected()
- {
- if (session == null)
- return false;
- else
- return session.isConnected();
- }
-
- public String getURI()
- {
- return connector.getServerURI();
- }
-
- @Override
- public String toString()
- {
- return "Client[session=" + session + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private void checkConnected() throws JMSException
- {
- if (session == null)
- {
- throw new IllegalStateException("Client " + this
- + " is not connected.");
- }
- if (!session.isConnected())
- {
- throw new MessagingNetworkFailureException("Client " + this
- + " is not connected.");
- }
- }
-
- // Inner classes -------------------------------------------------
-}
+ void removeConnectionListener(ConsolidatedRemotingConnectionListener listener);
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list