[jboss-cvs] JBoss Messaging SVN: r3357 - branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 22 03:47:18 EST 2007
Author: jmesnil
Date: 2007-11-22 03:47:18 -0500 (Thu, 22 Nov 2007)
New Revision: 3357
Modified:
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-544: Replace client-server transport with NIO based transport
* in disconnect(), disposed properly MINA resources to pass ClientExitTest
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java 2007-11-21 17:40:28 UTC (rev 3356)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Client.java 2007-11-22 08:47:18 UTC (rev 3357)
@@ -51,30 +51,33 @@
// By default, a blocking request will timeout after 5 seconds
private int blockingRequestTimeout = 5;
private TimeUnit blockingRequestTimeUnit = SECONDS;
+ private NioSocketConnector connector;
+ private ScheduledExecutorService blockingScheduler;
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
-
+
public Client()
{
}
-
+
// Public --------------------------------------------------------
- public void connect(String host, int port, TransportType transport) throws Exception
+ public void connect(String host, int port, TransportType transport)
+ throws Exception
{
connect(host, port, transport, false);
}
- public void connect(String host, int port, TransportType transport, boolean useSSL)
- throws Exception
+ public void connect(String host, int port, TransportType transport,
+ boolean useSSL) throws Exception
{
assert host != null;
assert port > 0;
assert transport != null;
- NioSocketConnector connector = new NioSocketConnector();
+ connector = new NioSocketConnector();
connector.setConnectTimeout(CONNECTION_TIMEOUT);
@@ -119,8 +122,16 @@
public boolean disconnect() throws Exception
{
- assert session != null;
+ if (session == null)
+ {
+ // no session => not connected
+ // do nothing
+ return false;
+ }
+ assert connector != null;
+ assert blockingScheduler != null;
+
if (sslFilter != null)
{
sslFilter.stopSsl(session).awaitUninterruptibly();
@@ -129,7 +140,12 @@
Thread.sleep(500);
}
CloseFuture closeFuture = session.close().awaitUninterruptibly();
- return closeFuture.isClosed();
+ boolean closed = closeFuture.isClosed();
+
+ connector.dispose();
+ blockingScheduler.shutdown();
+
+ return closed;
}
public void sendOneWay(AbstractPacket packet)
@@ -196,9 +212,9 @@
private void addBlockingRequestResponseFilter(
DefaultIoFilterChainBuilder chain)
{
- ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+ blockingScheduler = Executors.newScheduledThreadPool(1);
RequestResponseFilter filter = new RequestResponseFilter(
- new PacketInspector(), scheduler);
+ new PacketInspector(), blockingScheduler);
chain.addLast("reqres", filter);
}
More information about the jboss-cvs-commits
mailing list