From jboss-remoting-commits at lists.jboss.org Thu Jul 31 20:15:50 2008
Content-Type: multipart/mixed; boundary="===============2713474965496609735=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4445 -
remoting2/branches/2.x/docs/guide/en.
Date: Thu, 31 Jul 2008 20:15:50 -0400
Message-ID:
--===============2713474965496609735==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 20:15:50 -0400 (Thu, 31 Jul 2008)
New Revision: 4445
Modified:
remoting2/branches/2.x/docs/guide/en/chap5.xml
Log:
JBREM-1015: Described new Remoting.SOCKET_FACTORY_CLASS_NAME parameter; als=
o, some other uncommitted changes.
Modified: remoting2/branches/2.x/docs/guide/en/chap5.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/docs/guide/en/chap5.xml 2008-07-31 23:32:40 UTC =
(rev 4444)
+++ remoting2/branches/2.x/docs/guide/en/chap5.xml 2008-08-01 00:15:50 UTC =
(rev 4445)
@@ -920,25 +920,40 @@
A number of transport independent features are introduced in Re=
moting
version 2.4.
=
-
- Multihome servers
+
+ Binding to 0.0.0.0
=
- Before version 2.4, a Remoting server could bind either to a=
specific IP address, e.g., =
-
+ Before version 2.4, a Remoting server could bind to only one
+ specific IP address. In particular, the address 0.0.0.0 was transl=
ated
+ to the host returned by java.net.InetAddress.getLocalHost()<=
/code>
+ (or its equivalent IP address). As of version 2.4 [and later relea=
ses in
+ the 2.2 series], a server started with the address 0.0.0.0 binds to
+ all available interfaces.
=
- socket://192.168.0.2:6500
+ Note. If 0.0.0.0 appears =
in the
+ InvokerLocator, it needs to be translated t=
o an
+ address that is usable on the client side. If the system property
+ InvokerLocator.BIND_BY_HOST (actual value
+ "remoting.bind_by_host") is set to "true", the
+ InvokerLocator host will be transformed to =
the
+ value returned by
+ InetAddress.getLocalHost().getHostName().
+ Otherwise, it will be transformed to the value returned by
+ InetAddress.getLocalHost().getHostAddress().
=
- or to all IP addresses on a given host,=
e.g.,
+
+ =
+
+ Multihome servers
=
- socket://0.0.0.0:6500
+ As of release 2.4, besides binding to all
+ available interfaces, it is also possible to configure a server to
+ bind to a subset of the interfaces available on a given host. Supp=
ose,
+ for example, that a host machine has NICs configured with addresses
+ 10.32.4.2, 192.168.4.2, and 192.168.8.2, and suppose that 192.168.=
8.2 is
+ on a LAN from which access is meant to be denied. It is now possib=
le to
+ create a single server that binds to 10.32.4.2 and 192.168.4.2.
=
- As of release 2.4, it is possible to a configure a server to=
bind to a
- subset of the interfaces available on a given host. Suppose, for e=
xample,
- that a host machine has NICs configured with addresses 10.32.4.2,
- 192.168.4.2, and 192.168.8.2, and suppose that 192.168.8.2 is on a=
LAN from
- which access is meant to be denied. It is now possible to create a=
single
- server that binds to 10.32.4.2 and 192.168.4.2.
- =
It would be convenient to be able to create an In=
vokerLocator
that looks something like:
=
@@ -1103,9 +1118,8 @@
}
=
- =
- Support for IPv6 IP addresses
+ Support for IPv6 addresses
=
org.jboss.remoting.InvokerLocator wi=
ll now
accept IPv6 IP addresses. For example,
@@ -1225,12 +1239,11 @@
=
- How the server bind address and port is ultimately
- determined
+ How the server bind address and port is determined
=
If the serverBindAddress property is set, the server invoker w=
ill
- bind to that address. Otherwise, it will, with two exceptions, use =
the
- address in the InvokerLocator (if there is one). The first exceptio=
n is the
+ bind to that address. Otherwise, it will, with one exception, use t=
he
+ address in the InvokerLocator (if there is one). The exception is t=
he
case in which the clientConnectAddress property is set, which indica=
tes
that the adddess in the InvokerLocator is not the real address of the
server's host. In that case, and in the case that there is no addre=
ss
@@ -1246,8 +1259,8 @@
use host from InvokerLocator
else
use local host address
-
- There is one other exception. If the InvokerLocator address is
+ =
=
+
=
If the serverBindPort property is set, it will be used. If this
value is 0 or a negative number, then the next available port will be
@@ -1511,8 +1526,9 @@
continueAfterTimeout - in=
dicates
what a server thread should do after experiencing a
java.net.SocketTimeoutException. If set to
- "true", the server thread will continue to wait for an invocation;
- otherwise, it will return itself to the thread pool.
+ "true", or if JBossSerialization is being used, the server thread =
will
+ continue to wait for an invocation; otherwise, it will return itse=
lf to
+ the thread pool.
=
Configurations affecting the Socket invoker
client
@@ -2295,6 +2311,13 @@
sockets. The default value is 10.
=
+ MAX_CONTROL_CONNECTION_RESTARTS
+ (actual value is "maxControlConnectionRestarts"): The client sid=
e uses
+ this value to limit the number of times it will request a new co=
ntrol
+ connection after a ping timeout. The default value is 10.
+
+ =
+ SECONDARY_BIND_PORT (actual v=
alue is
"secondaryBindPort"): The server side uses this parameter to det=
ermine
the bind port for the secondary
@@ -3971,7 +3994,7 @@
Put the class name of a SocketFactory
in a configuration map, using key
- Remoting.SOCKET_FACTORY_NAME, and pass the
+ Remoting.SOCKET_FACTORY_CLASS_NAME, and p=
ass the
map to one of the Connector constructor=
s.
The SocketFactory class must have a def=
ault
constructor.
@@ -4170,7 +4193,7 @@
Put the class name of a SocketFactory
in a configuration map, using key
- Remoting.SOCKET_FACTORY_NAME, and pass the
+ Remoting.SOCKET_FACTORY_CLASS_NAME, and p=
ass the
map to one of the Client constructors. =
The
SocketFactory class must have a default
constructor, which will be used to create a
@@ -5211,8 +5234,8 @@
=
- Each transport that supports per invocation timeouts handles them a
- little differently. More details are given below.
+ Each transport handles per invocation timeouts a little differentl=
y.
+ More details are given below.
=
@@ -5854,8 +5877,8 @@
Client to indicate the socket factory to be used. Value must be instan=
ce
of javax.net.SocketFactory.
=
- SOCKET_FACTORY_NAME (actual v=
alue
- is 'socketFactory') - key for the configuration map passed to a Client=
to
+ SOCKET_FACTORY_CLASS_NAME (ac=
tual value
+ is 'socketFactoryClassName') - key for the configuration map passed to=
a Client to
indicate the classname of the socket factory to be used. Value should =
be
fully qualified classname of class that is an instance of
javax.net.SocketFactory and has a void constructor. This property will=
not
@@ -6439,16 +6462,19 @@
org.jboss.remoting.transport.socket.ServerThread
=
- evictabilityTimeout - indic=
ates the
- number of milliseconds during which a server thread waiting for the =
next
- invocation will not be preemptible.
- =
- continueAfterTimeout - indi=
cates
- what a server thread should do after experiencing a
- java.net.SocketTimeoutException. If set to "tr=
ue",
- the server thread will continue to wait for an invocation; otherwise,=
it
- will return itself to the thread pool.
+ EVICTABILITY_TIMEOUT (actua=
l value
+ "evictabilityTimeout") - indicates the number of milliseconds during=
which
+ a server thread waiting for the next invocation will not be
+ preemptible.
=
+ CONTINUE_AFTER_TIMEOUT (act=
ual
+ value "continueAfterTimeout") - indicates what a server thread shoul=
d do
+ after experiencing a
+ java.net.SocketTimeoutException. If set to "t=
rue",
+ or if JBossSerialization is being used, the server thread will conti=
nue to
+ wait for an invocation; otherwise, it will return itself to the thre=
ad
+ pool.
+ =
=
=
=
--===============2713474965496609735==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 20:17:46 2008
Content-Type: multipart/mixed; boundary="===============7853736121180363910=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4446 -
remoting2/branches/2.x/docs/guide/en.
Date: Thu, 31 Jul 2008 20:17:46 -0400
Message-ID:
--===============7853736121180363910==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 20:17:46 -0400 (Thu, 31 Jul 2008)
New Revision: 4446
Modified:
remoting2/branches/2.x/docs/guide/en/chap9.xml
Log:
Syntactic correction.
Modified: remoting2/branches/2.x/docs/guide/en/chap9.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/docs/guide/en/chap9.xml 2008-08-01 00:15:50 UTC =
(rev 4445)
+++ remoting2/branches/2.x/docs/guide/en/chap9.xml 2008-08-01 00:17:46 UTC =
(rev 4446)
@@ -159,7 +159,7 @@
when done using it. Otherwise, the client will continue to make its pi=
ng
call on the server to keep its lease current.
=
- The client can also provide extra metadata the will be communica=
ted to
+ The client can also provide extra metadata that will be communic=
ated to
the connection listener in case of failure by supplying a metadata Map=
to
the Client constructor. This map will be included in the Client instan=
ce
passed to the connection listener (via the handleConnectionException()
--===============7853736121180363910==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 20:46:05 2008
Content-Type: multipart/mixed; boundary="===============3700576490858077535=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4447 -
remoting2/branches/2.x/docs/guide/en.
Date: Thu, 31 Jul 2008 20:46:05 -0400
Message-ID:
--===============3700576490858077535==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 20:46:05 -0400 (Thu, 31 Jul 2008)
New Revision: 4447
Modified:
remoting2/branches/2.x/docs/guide/en/chap9.xml
Log:
JBREM-1012: Described injection of ConnectionListener.
Modified: remoting2/branches/2.x/docs/guide/en/chap9.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/docs/guide/en/chap9.xml 2008-08-01 00:17:46 UTC =
(rev 4446)
+++ remoting2/branches/2.x/docs/guide/en/chap9.xml 2008-08-01 00:46:05 UTC =
(rev 4447)
@@ -90,16 +90,15 @@
The second
criterion is that an implementation of the
org.jboss.remoting.ConnectionListener interface is added =
as a
- connection listener to the Connector, via the method
+ connection listener to the Connector, either via the method
=
public void addConnectionListener(ConnectionListener l=
istener)
=
- Once both criteria are met, the remoting server will turn on cl=
ient
- leasing.
- =
- Note that there is no way to register a
- ConnectionListener via xml based configuration =
for
- the Connector.
+ or though the use of the
+ ServerInvoker.CONNECTION_LISTENER parameter (actual value
+ "connectionListener") in the Connector's
+ configuration map or XML configuration file. Once both criteria are me=
t, the
+ remoting server will turn on client leasing.
=
The ConnectionListener will be notified of both client failures =
and
client disconnects via the handleConnectionException() method. If the =
client
--===============3700576490858077535==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 20:46:58 2008
Content-Type: multipart/mixed; boundary="===============6955024377538333813=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4448 -
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease.
Date: Thu, 31 Jul 2008 20:46:58 -0400
Message-ID:
--===============6955024377538333813==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 20:46:58 -0400 (Thu, 31 Jul 2008)
New Revision: 4448
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/InjectedC=
onnectionListenerTestCase.java
Log:
JBREM-1012: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/Injec=
tedConnectionListenerTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/Injected=
ConnectionListenerTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/lease/Injected=
ConnectionListenerTestCase.java 2008-08-01 00:46:58 UTC (rev 4448)
@@ -0,0 +1,223 @@
+package org.jboss.test.remoting.lease;
+
+import java.io.ByteArrayInputStream;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.w3c.dom.Document;
+
+
+/**
+ * =
+ * Unit test for JBREM-1012.
+ * =
+ * @author Ron Sigal
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Jul 18, 2008
+ *
+ */
+public class InjectedConnectionListenerTestCase extends TestCase
+{
+ private static Logger log =3D Logger.getLogger(InjectedConnectionListen=
erTestCase.class);
+ =
+ private static boolean firstTime =3D true;
+ =
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+ =
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime =3D false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern =3D "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout =3D new PatternLayout(pattern);
+ ConsoleAppender consoleAppender =3D new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender); =
+ }
+ =
+ TestConnectionListener.gotException =3D false;
+ }
+
+ =
+ public void tearDown()
+ {
+ }
+ =
+ =
+ public void testInjectionWithClassName() throws Throwable
+ {
+ log.info("entering " + getName());
+ =
+ // Start server.
+ MBeanServer mbeanServer =3D MBeanServerFactory.createMBeanServer();
+ setupServer(TestConnectionListener.class.getName(), mbeanServer);
+ =
+ // Create client.
+ InvokerLocator clientLocator =3D new InvokerLocator(locatorURI);
+ HashMap clientConfig =3D new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client =3D new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+ =
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+ =
+ // Verify ConnectionListener is notified.
+ log.info("client disconnecting");
+ client.disconnect();
+ log.info("client disconnected");
+ assertTrue(TestConnectionListener.gotException);
+ =
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+ =
+ =
+ =
+ public void testInjectionWithMBean() throws Throwable
+ {
+ log.info("entering " + getName());
+ =
+ // Start server.
+ String connectionListenerName =3D "jboss:type=3Dconnectionlistener";
+ ObjectName objName =3D new ObjectName(connectionListenerName);
+ MBeanServer mbeanServer =3D MBeanServerFactory.createMBeanServer();
+ TestConnectionListener listener =3D new TestConnectionListener();
+ mbeanServer.registerMBean(listener, objName);
+ setupServer(connectionListenerName, mbeanServer);
+ =
+ // Create client.
+ InvokerLocator clientLocator =3D new InvokerLocator(locatorURI);
+ HashMap clientConfig =3D new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.ENABLE_LEASE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client =3D new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+ =
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+ =
+ // Verify ConnectionListener is notified.
+ log.info("client disconnecting");
+ client.disconnect();
+ log.info("client disconnected");
+ assertTrue(TestConnectionListener.gotException);
+ =
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+ =
+ =
+ protected String getTransport()
+ {
+ return "socket";
+ }
+ =
+ =
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+ =
+
+ protected void setupServer(String listener, MBeanServer mbeanServer) th=
rows Exception
+ {
+ HashMap config =3D new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ Connector connector =3D new Connector(config);
+ mbeanServer.registerMBean(connector, new ObjectName("test:type=3Dcon=
nector"));
+ =
+ host =3D InetAddress.getLocalHost().getHostAddress();
+ port =3D PortUtil.findFreePort(host);
+ StringBuffer buf =3D new StringBuffer();
+ buf.append("\n");
+ buf.append("");
+ buf.append(" ");
+ buf.append(" " + host +=
"");
+ buf.append(" " + port + "<=
/attribute>");
+ buf.append(" " + listener + "");
+ buf.append(" 5000");
+ buf.append(" ");
+ buf.append("");
+ ByteArrayInputStream bais =3D new ByteArrayInputStream(buf.toString(=
).getBytes());
+ Document xml =3D DocumentBuilderFactory.newInstance().newDocumentBui=
lder().parse(bais);
+ connector.setConfiguration(xml.getDocumentElement());
+ connector.create();
+ connector.addInvocationHandler("test", new TestInvocationHandler());
+ connector.start();
+ locatorURI =3D connector.getInvokerLocator();
+ log.info("Started remoting server with locator uri of: " + locatorUR=
I);
+ }
+ =
+ =
+ protected void shutdownServer() throws Exception
+ {
+ if (connector !=3D null)
+ connector.stop();
+ }
+ =
+ =
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Thro=
wable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+ =
+ =
+ public interface TestConnectionListenerMBean extends ConnectionListener
+ { =
+ }
+ =
+ public static class TestConnectionListener implements TestConnectionLis=
tenerMBean
+ {
+ public static boolean gotException;
+ =
+ public void handleConnectionException(Throwable throwable, Client cl=
ient)
+ {
+ gotException =3D true;
+ log.info("TestConnectionListener got exception");
+ }
+ }
+}
\ No newline at end of file
--===============6955024377538333813==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 20:48:01 2008
Content-Type: multipart/mixed; boundary="===============0391185892559442625=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4449 -
remoting2/branches/2.x/src/main/org/jboss/remoting.
Date: Thu, 31 Jul 2008 20:48:01 -0400
Message-ID:
--===============0391185892559442625==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 20:48:00 -0400 (Thu, 31 Jul 2008)
New Revision: 4449
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1012: Enable injection of ConnectionListener.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.=
java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2=
008-08-01 00:46:58 UTC (rev 4448)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2=
008-08-01 00:48:00 UTC (rev 4449)
@@ -218,6 +218,8 @@
public static final String ECHO =3D "$ECHO$";
=
public static final String INVOKER_SESSION_ID =3D "invokerSessionId";
+ =
+ public static final String CONNECTION_LISTENER =3D "connectionListener";
=
=
// Static -------------------------------------------------------------=
--------------------------
@@ -349,7 +351,64 @@
throw new IllegalArgumentException("Can not add null ConnectionLi=
stener.");
}
}
+ =
+ public void setConnectionListener(Object listener)
+ {
+ if (listener =3D=3D null)
+ {
+ log.error("ConnectionListener is null");
+ return;
+ }
+ =
+ if (listener instanceof ConnectionListener)
+ {
+ addConnectionListener((ConnectionListener) listener);
+ return;
+ }
=
+ if (!(listener instanceof String))
+ {
+ log.error("Object supplied as ConnectionListener is neither Strin=
g nor ConnectionListener");
+ return;
+ }
+
+ ConnectionListener connectionListener =3D null;
+ try
+ {
+ MBeanServer server =3D getMBeanServer();
+ ObjectName objName =3D new ObjectName((String) listener);
+ Class c =3D ConnectionListener.class;
+ Object o =3D MBeanServerInvocationHandler.newProxyInstance(server=
, objName, c, false);
+ connectionListener =3D (ConnectionListener) o;
+ }
+ catch (MalformedObjectNameException e)
+ {
+ log.debug("Object supplied as ConnectionListener is not an object=
name.");
+ }
+
+ if (connectionListener =3D=3D null)
+ {
+ try
+ {
+ Class listenerClass =3D ClassLoaderUtility.loadClass((String) =
listener, ServerInvoker.class);
+ connectionListener =3D (ConnectionListener) listenerClass.newI=
nstance();
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to instantiate " + listener + ": " + e.getMe=
ssage());
+ return;
+ }
+ }
+
+ if (connectionListener =3D=3D null)
+ {
+ log.error("Unable to create ConnectionListener from " + listener);
+ return;
+ }
+ =
+ addConnectionListener(connectionListener);
+ }
+
public void removeConnectionListener(ConnectionListener listener)
{
if(connectionNotifier !=3D null)
@@ -1086,6 +1145,13 @@
}
}
=
+ // Inject ConnectionListener
+ String connectionListener =3D (String)config.get(CONNECTION_LISTENER=
);
+ if (connectionListener !=3D null)
+ {
+ setConnectionListener(connectionListener);
+ }
+ =
String registerCallbackListenersString =3D (String)config.get(REGIST=
ER_CALLBACK_LISTENER);
if(registerCallbackListenersString !=3D null)
{
--===============0391185892559442625==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 21:41:51 2008
Content-Type: multipart/mixed; boundary="===============4720651012729223052=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4450 -
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
Date: Thu, 31 Jul 2008 21:41:51 -0400
Message-ID:
--===============4720651012729223052==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: david.lloyd(a)jboss.com
Date: 2008-07-31 21:41:51 -0400 (Thu, 31 Jul 2008)
New Revision: 4450
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI=
.java
Log:
New and improved Remoting service URI utility methods
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Ser=
viceURI.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 00:48:00 UTC (rev 4449)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 01:41:51 UTC (rev 4450)
@@ -2,8 +2,6 @@
=
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
=
/**
* A parser for JBoss Remoting URI types.
@@ -11,77 +9,123 @@
public final class ServiceURI {
public static final String SCHEME =3D "jrs";
=
- private static final String FIRST_CHAR =3D "[$_a-zA-Z]";
- private static final String SUBSEQUENT_CHAR =3D "[-+$_a-zA-Z0-9]*";
- private static final String ID =3D FIRST_CHAR + SUBSEQUENT_CHAR;
- private static final String SEPARATOR =3D "[./]";
+ private ServiceURI() {
+ }
=
- private static final Pattern VALID_PATTERN =3D Pattern.compile("^(?:" =
+ ID + "(?:" + SEPARATOR + ID + ")*)*$");
-
- private final URI uri;
- private final String serviceType;
- private final String groupName;
- private final String endpointName;
-
- public ServiceURI(final String str) throws URISyntaxException {
- this(new URI(str));
+ /**
+ * Determine if this URI is for a Remoting service.
+ *
+ * @param uri the URI
+ * @return {@code true} if the given URI is a Remoting service URI
+ */
+ public static boolean isRemotingServiceUri(final URI uri) {
+ return SCHEME.equals(uri.getScheme());
}
=
- public ServiceURI(final URI uri) {
- this.uri =3D uri;
- if (! uri.getScheme().equals(SCHEME)) {
- throw new IllegalArgumentException("Invalid URI scheme for ser=
vice");
+ /**
+ * Get the service type from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the service type
+ * @throws IllegalArgumentException if the given URI is not for a remo=
ting service
+ */
+ public static String getServiceType(final URI uri) throws IllegalArgum=
entException {
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a remoting service URI=
");
}
final String ssp =3D uri.getSchemeSpecificPart();
- final int stcp =3D ssp.indexOf(':');
- if (stcp =3D=3D -1) {
+ final int firstColon =3D ssp.indexOf(':');
+ final String serviceType;
+ if (firstColon =3D=3D -1) {
serviceType =3D ssp;
- groupName =3D "";
- endpointName =3D "";
} else {
- serviceType =3D ssp.substring(0, stcp).trim();
- final int gncp =3D ssp.indexOf(':', stcp + 1);
- if (gncp =3D=3D -1) {
- groupName =3D ssp.substring(stcp + 1).trim();
- endpointName =3D "";
- } else {
- groupName =3D ssp.substring(stcp + 1, gncp).trim();
- // ignore everything after the last :
- final int encp =3D ssp.indexOf(':', gncp + 1);
- if (encp =3D=3D -1) {
- endpointName =3D ssp.substring(gncp + 1).trim();
- } else {
- endpointName =3D ssp.substring(gncp + 1, encp).trim();
- }
- }
+ serviceType =3D ssp.substring(0, firstColon);
}
- final Matcher matcher =3D VALID_PATTERN.matcher(serviceType);
- if (! matcher.matches()) {
- throw new IllegalArgumentException("Syntax error in service ty=
pe URI part");
+ return serviceType;
+ }
+
+ /**
+ * Get the group name from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the group name
+ * @throws IllegalArgumentException if the given URI is not for a remo=
ting service
+ */
+ public static String getGroupName(final URI uri) throws IllegalArgumen=
tException {
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a remoting service URI=
");
}
- matcher.reset(groupName);
- if (! matcher.matches()) {
- throw new IllegalArgumentException("Syntax error in group name=
URI part");
+ final String ssp =3D uri.getSchemeSpecificPart();
+ final int firstColon =3D ssp.indexOf(':');
+ final String groupName;
+ if (firstColon =3D=3D -1) {
+ return "";
}
- matcher.reset(endpointName);
- if (! matcher.matches()) {
- throw new IllegalArgumentException("Syntax error in endpoint n=
ame URI part");
+ final int secondColon =3D ssp.indexOf(':', firstColon + 1);
+ if (secondColon =3D=3D -1) {
+ groupName =3D ssp.substring(firstColon + 1);
+ } else {
+ groupName =3D ssp.substring(firstColon + 1, secondColon);
}
+ return groupName;
}
=
- public URI getUri() {
- return uri;
+ /**
+ * Get the endpoint name from a Remoting service URI.
+ *
+ * @param uri the URI
+ * @return the endpoint name
+ * @throws IllegalArgumentException if the given URI is not for a remo=
ting service
+ */
+ public static String getEndpointName(final URI uri) throws IllegalArgu=
mentException {
+ if (! isRemotingServiceUri(uri)) {
+ throw new IllegalArgumentException("Not a remoting service URI=
");
+ }
+ final String ssp =3D uri.getSchemeSpecificPart();
+ final int firstColon =3D ssp.indexOf(':');
+ final String endpointName;
+ if (firstColon =3D=3D -1) {
+ return "";
+ }
+ final int secondColon =3D ssp.indexOf(':', firstColon + 1);
+ if (secondColon =3D=3D -1) {
+ return "";
+ }
+ // ::: is not officially supported, but this leaves room for exten=
sions
+ final int thirdColon =3D ssp.indexOf(':', secondColon + 1);
+ if (thirdColon =3D=3D -1) {
+ endpointName =3D ssp.substring(secondColon + 1);
+ } else {
+ endpointName =3D ssp.substring(secondColon + 1, thirdColon);
+ }
+ return endpointName;
}
=
- public String getServiceType() {
- return serviceType;
+ /**
+ * Create a Remoting service URI.
+ *
+ * @param serviceType the service type, if any
+ * @param groupName the group name, if any
+ * @param endpointName the endpoint name, if any
+ * @return the URI
+ */
+ public static URI create(String serviceType, String groupName, String =
endpointName) {
+ try {
+ StringBuilder builder =3D new StringBuilder(serviceType.length=
() + groupName.length() + endpointName.length() + 2);
+ if (serviceType !=3D null && serviceType.length() > 0) {
+ builder.append(serviceType);
+ }
+ if (groupName !=3D null && groupName.length() > 0) {
+ builder.append(':').append(groupName);
+ if (endpointName !=3D null && endpointName.length() > 0) {
+ builder.append(':').append(groupName);
+ }
+ } else if (endpointName !=3D null && endpointName.length() > 0=
) {
+ builder.append(':').append(':').append(groupName);
+ }
+ return new URI(SCHEME, builder.toString(), null);
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException("URI syntax exception should n=
ot be possible here", e);
+ }
}
-
- public String getGroupName() {
- return groupName;
- }
-
- public String getEndpointName() {
- return endpointName;
- }
}
--===============4720651012729223052==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 21:48:05 2008
Content-Type: multipart/mixed; boundary="===============8953151696398955927=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4451 -
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
Date: Thu, 31 Jul 2008 21:48:05 -0400
Message-ID:
--===============8953151696398955927==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: david.lloyd(a)jboss.com
Date: 2008-07-31 21:48:05 -0400 (Thu, 31 Jul 2008)
New Revision: 4451
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI=
.java
Log:
New and improved Remoting service URI utility methods - fixed
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Ser=
viceURI.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 01:41:51 UTC (rev 4450)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 01:48:05 UTC (rev 4451)
@@ -115,14 +115,14 @@
if (serviceType !=3D null && serviceType.length() > 0) {
builder.append(serviceType);
}
+ builder.append(':');
if (groupName !=3D null && groupName.length() > 0) {
- builder.append(':').append(groupName);
- if (endpointName !=3D null && endpointName.length() > 0) {
- builder.append(':').append(groupName);
- }
- } else if (endpointName !=3D null && endpointName.length() > 0=
) {
- builder.append(':').append(':').append(groupName);
+ builder.append(groupName);
}
+ builder.append(':');
+ if (endpointName !=3D null && endpointName.length() > 0) {
+ builder.append(endpointName);
+ }
return new URI(SCHEME, builder.toString(), null);
} catch (URISyntaxException e) {
throw new IllegalStateException("URI syntax exception should n=
ot be possible here", e);
--===============8953151696398955927==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 21:49:45 2008
Content-Type: multipart/mixed; boundary="===============4952055453958751256=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4452 -
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
Date: Thu, 31 Jul 2008 21:49:45 -0400
Message-ID:
--===============4952055453958751256==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: david.lloyd(a)jboss.com
Date: 2008-07-31 21:49:45 -0400 (Thu, 31 Jul 2008)
New Revision: 4452
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI=
.java
Log:
Slightly stricter checking
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Ser=
viceURI.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 01:48:05 UTC (rev 4451)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceUR=
I.java 2008-08-01 01:49:45 UTC (rev 4452)
@@ -13,13 +13,13 @@
}
=
/**
- * Determine if this URI is for a Remoting service.
+ * Determine if this URI is a valid Remoting service URI.
*
* @param uri the URI
- * @return {@code true} if the given URI is a Remoting service URI
+ * @return {@code true} if the given URI is a valid Remoting service U=
RI
*/
public static boolean isRemotingServiceUri(final URI uri) {
- return SCHEME.equals(uri.getScheme());
+ return SCHEME.equals(uri.getScheme()) && uri.isOpaque();
}
=
/**
@@ -31,7 +31,7 @@
*/
public static String getServiceType(final URI uri) throws IllegalArgum=
entException {
if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a remoting service URI=
");
+ throw new IllegalArgumentException("Not a valid remoting servi=
ce URI");
}
final String ssp =3D uri.getSchemeSpecificPart();
final int firstColon =3D ssp.indexOf(':');
@@ -53,7 +53,7 @@
*/
public static String getGroupName(final URI uri) throws IllegalArgumen=
tException {
if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a remoting service URI=
");
+ throw new IllegalArgumentException("Not a valid remoting servi=
ce URI");
}
final String ssp =3D uri.getSchemeSpecificPart();
final int firstColon =3D ssp.indexOf(':');
@@ -79,7 +79,7 @@
*/
public static String getEndpointName(final URI uri) throws IllegalArgu=
mentException {
if (! isRemotingServiceUri(uri)) {
- throw new IllegalArgumentException("Not a remoting service URI=
");
+ throw new IllegalArgumentException("Not a valid remoting servi=
ce URI");
}
final String ssp =3D uri.getSchemeSpecificPart();
final int firstColon =3D ssp.indexOf(':');
--===============4952055453958751256==--
From jboss-remoting-commits at lists.jboss.org Thu Jul 31 23:07:52 2008
Content-Type: multipart/mixed; boundary="===============8911693385594492768=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4453 -
remoting2/branches/2.x/src/main/org/jboss/remoting.
Date: Thu, 31 Jul 2008 23:07:52 -0400
Message-ID:
--===============8911693385594492768==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-07-31 23:07:52 -0400 (Thu, 31 Jul 2008)
New Revision: 4453
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInvo=
ker.java
Log:
JBREM-1019: Syntax change to conform to jdk 1.4.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteCli=
entInvoker.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInv=
oker.java 2008-08-01 01:49:45 UTC (rev 4452)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/MicroRemoteClientInv=
oker.java 2008-08-01 03:07:52 UTC (rev 4453)
@@ -128,7 +128,7 @@
if (flag !=3D null)
{
String sflag =3D flag.toString();
- parentFirst =3D Boolean.valueOf(sflag);
+ parentFirst =3D Boolean.valueOf(sflag).booleanValue();
}
if (unmarshaller instanceof UpdateableClassloaderUnMarshaller)
{
--===============8911693385594492768==--
From jboss-remoting-commits at lists.jboss.org Fri Aug 1 01:50:13 2008
Content-Type: multipart/mixed; boundary="===============6202407085603883248=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4454 -
remoting2/branches/2.x/src/main/org/jboss/remoting/loading.
Date: Fri, 01 Aug 2008 01:50:13 -0400
Message-ID:
--===============6202407085603883248==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-01 01:50:12 -0400 (Fri, 01 Aug 2008)
New Revision: 4454
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteClas=
sLoader.java
Log:
JBREM-1000: Added two log.debug() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassB=
yteClassLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteCla=
ssLoader.java 2008-08-01 03:07:52 UTC (rev 4453)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/loading/ClassByteCla=
ssLoader.java 2008-08-01 05:50:12 UTC (rev 4454)
@@ -389,7 +389,9 @@
{
loaderClient.connect();
}
+ log.debug("attempting to load from network: " + className);
Object obj =3D loaderClient.invoke(marshallerMethodName, metad=
ata);
+ log.debug("loaded from network: " + obj);
=
if(obj !=3D null)
{
--===============6202407085603883248==--
From jboss-remoting-commits at lists.jboss.org Fri Aug 1 01:52:08 2008
Content-Type: multipart/mixed; boundary="===============8254292419756903588=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4455 -
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal.
Date: Fri, 01 Aug 2008 01:52:08 -0400
Message-ID:
--===============8254292419756903588==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-01 01:52:08 -0400 (Fri, 01 Aug 2008)
New Revision: 4455
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallerLoa=
derHandler.java
Log:
JBREM-1000: Can look in HeirarchicalLoaderRepository3s for scoped classes.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/Marsha=
llerLoaderHandler.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallerLo=
aderHandler.java 2008-08-01 05:50:12 UTC (rev 4454)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallerLo=
aderHandler.java 2008-08-01 05:52:08 UTC (rev 4455)
@@ -22,9 +22,19 @@
=
package org.jboss.remoting.marshal;
=
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
import org.jboss.logging.Logger;
+import org.jboss.mx.loading.LoaderRepository;
+import org.jboss.mx.loading.RepositoryClassLoader;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.ServerInvocationHandler;
@@ -43,10 +53,15 @@
{
private ServerInvoker invoker =3D null;
private MBeanServer server =3D null;
+ private List repositories;
=
protected final static Logger log =3D Logger.getLogger(MarshallerLoader=
Handler.class);
=
-
+ public MarshallerLoaderHandler(List repositories)
+ {
+ this.repositories =3D repositories;
+ }
+ =
/**
* set the mbean server that the handler can reference
*
@@ -102,9 +117,11 @@
else if(LOAD_CLASS_METHOD.equals(param))
{
String className =3D (String) metadMap.get(CLASSNAME);
+ log.debug("MarshallerLoaderHandler: loading class: " + className);
if(className !=3D null)
{
ret =3D loadClassBytes(className, invoker.getClassLoader());
+ log.debug("MarshallerLoaderHandler: returning class: " + class=
Name + ": " + ret);
}
else
{
@@ -155,6 +172,39 @@
if(className !=3D null)
{
byte[] classDefinition =3D ClassUtil.getClassBytes(className, cla=
ssLoader);
+ =
+ if (classDefinition =3D=3D null && repositories !=3D null)
+ {
+ Iterator it =3D repositories.iterator();
+ while (it.hasNext())
+ {
+ ObjectName name =3D (ObjectName) it.next();
+ log.debug("searching repository " + name);
+ =
+ try
+ {
+ Object o =3D server.getAttribute(name, "Instance");
+ LoaderRepository repository =3D (LoaderRepository) o;
+ Class c =3D repository.getCachedClass(className);
+ if (c =3D=3D null)
+ {
+ continue;
+ }
+ log.debug("found class in repository " + name);
+ RepositoryClassLoader cl =3D (RepositoryClassLoader) c.g=
etClassLoader();
+ classDefinition =3D loadByteCode(cl, className);
+ }
+ catch (Exception e)
+ {
+ log.debug("unable to get class from " + name + ": " + e.=
getMessage(), e);
+ }
+ }
+ }
+ =
+ if (classDefinition =3D=3D null)
+ {
+ log.debug("unable to load class " + className);
+ }
classBytes =3D new ClassBytes(className, classDefinition);
}
return classBytes;
@@ -179,4 +229,62 @@
{
//NO OP as don't won't allow listeners
}
+ =
+ /**
+ * Adapted from org.jboss.mx.loading.RepositoryClassLoader.
+ * =
+ * @param cl
+ * @param classname
+ * @return
+ * @throws ClassNotFoundException
+ * @throws IOException
+ */
+ protected byte[] loadByteCode(ClassLoader cl, String classname)
+ throws ClassNotFoundException, IOException
+ {
+ byte[] bytecode =3D null;
+ URL classURL =3D getClassURL(cl, classname);
+
+ // Load the class bytecode
+ InputStream is =3D null;
+ try
+ {
+ is =3D classURL.openStream();
+ ByteArrayOutputStream baos =3D new ByteArrayOutputStream();
+ byte[] tmp =3D new byte[1024];
+ int read =3D 0;
+ while( (read =3D is.read(tmp)) > 0 )
+ {
+ baos.write(tmp, 0, read);
+ }
+ bytecode =3D baos.toByteArray();
+ }
+ finally
+ {
+ if( is !=3D null )
+ is.close();
+ }
+
+ return bytecode;
+ }
+ =
+ /**
+ * Adapted from org.jboss.mx.loading.RepositoryClassLoader.
+ * =
+ * @param cl
+ * @param classname
+ * @return
+ * @throws ClassNotFoundException
+ */
+ private URL getClassURL(ClassLoader cl, String classname) throws ClassN=
otFoundException
+ {
+ String classRsrcName =3D classname.replace('.', '/') + ".class";
+ URL classURL =3D cl.getResource(classRsrcName);
+ if( classURL =3D=3D null )
+ {
+ String msg =3D "Failed to find: "+classname+" as resource: "+clas=
sRsrcName;
+ throw new ClassNotFoundException(msg);
+ }
+ return classURL;
+ }
}
--===============8254292419756903588==--
From jboss-remoting-commits at lists.jboss.org Fri Aug 1 01:52:53 2008
Content-Type: multipart/mixed; boundary="===============0089139596917883235=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4456 -
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal.
Date: Fri, 01 Aug 2008 01:52:53 -0400
Message-ID:
--===============0089139596917883235==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-01 01:52:52 -0400 (Fri, 01 Aug 2008)
New Revision: 4456
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoade=
rFactory.java
Log:
JBREM-1000: arshallerLoaderHandler gets repositories set and MBeanServer.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/Marsha=
llLoaderFactory.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoad=
erFactory.java 2008-08-01 05:52:08 UTC (rev 4455)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/MarshallLoad=
erFactory.java 2008-08-01 05:52:52 UTC (rev 4456)
@@ -23,7 +23,11 @@
package org.jboss.remoting.marshal;
=
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+
+import javax.management.MBeanServer;
+
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.Connector;
@@ -43,9 +47,11 @@
* listen on. Will return null if can not create the connector.
*
* @param locator
+ * @param repositories
+ * @param mbeanServer
* @return
*/
- public static Connector createMarshallLoader(InvokerLocator locator)
+ public static Connector createMarshallLoader(InvokerLocator locator, Li=
st repositories, MBeanServer mbeanServer)
{
Connector marshallerConnector =3D null;
try
@@ -54,8 +60,11 @@
marshallerConnector.setInvokerLocator(locator.getLocatorURI());
marshallerConnector.start();
=
- MarshallerLoaderHandler loader =3D new MarshallerLoaderHandler();
+ MarshallerLoaderHandler loader =3D new MarshallerLoaderHandler(re=
positories);
marshallerConnector.addInvocationHandler("loader", loader);
+ =
+ // Set after Connector.addInvocationHandler(), which also sets MB=
eanServer.
+ loader.setMBeanServer(mbeanServer);
}
catch(Exception e)
{
--===============0089139596917883235==--
From jboss-remoting-commits at lists.jboss.org Fri Aug 1 01:53:42 2008
Content-Type: multipart/mixed; boundary="===============4163758651540337470=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4457 -
remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
Date: Fri, 01 Aug 2008 01:53:42 -0400
Message-ID:
--===============4163758651540337470==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-01 01:53:42 -0400 (Fri, 01 Aug 2008)
New Revision: 4457
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.j=
ava
Log:
JBREM-1000: Added ability to read element from xml config fi=
le.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Conn=
ector.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.=
java 2008-08-01 05:52:52 UTC (rev 4456)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/Connector.=
java 2008-08-01 05:53:42 UTC (rev 4457)
@@ -508,7 +508,8 @@
// if loaderLocator is null, then probably not defined to have loade=
r service (i.e. no loader port specified)
if (loaderLocator !=3D null)
{
- marshallerLoader =3D MarshallLoaderFactory.createMarshallLoader(l=
oaderLocator);
+ List repositories =3D getLoaderRepositories();
+ marshallerLoader =3D MarshallLoaderFactory.createMarshallLoader(l=
oaderLocator, repositories, server);
}
return marshallerLoader;
}
@@ -972,6 +973,41 @@
}
}
=
+ private List getLoaderRepositories()
+ {
+ if (xml =3D=3D null)
+ {
+ return null;
+ }
+
+ NodeList repositoryNodes =3D xml.getElementsByTagName("repository");
+ if (repositoryNodes.getLength() =3D=3D 0)
+ {
+ return null;
+ }
+ =
+ List repositories =3D new ArrayList();
+ for (int i =3D 0; i < repositoryNodes.getLength(); i++)
+ {
+ Node node =3D repositoryNodes.item(i);
+ String repositoryName =3D node.getFirstChild().getNodeValue();
+
+ try
+ {
+ ObjectName objName =3D new ObjectName(repositoryName);
+ repositories.add(objName);
+ log.info("repository: " + repositoryName);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ log.debug("repository name is not an object name: " + reposito=
ryName);
+ continue;
+ }
+ }
+ =
+ return repositories;
+ }
+ =
private ServerInvocationHandler createHandlerProxy(ObjectName objName)
{
ServerInvocationHandler handler;
--===============4163758651540337470==--
From jboss-remoting-commits at lists.jboss.org Fri Aug 1 01:55:00 2008
Content-Type: multipart/mixed; boundary="===============5187520803085695094=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4458 -
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.
Date: Fri, 01 Aug 2008 01:55:00 -0400
Message-ID:
--===============5187520803085695094==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-01 01:55:00 -0400 (Fri, 01 Aug 2008)
New Revision: 4458
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPCl=
ientInvoker.java
Log:
JBREM-990: (1) useHttpURLConnection() tries to add responseMessage and resp=
onseCode to CannotConnectException(); (2) readResponse() checks for EOF on =
inputStream and throws EOFException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http=
/HTTPClientInvoker.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPC=
lientInvoker.java 2008-08-01 05:53:42 UTC (rev 4457)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPC=
lientInvoker.java 2008-08-01 05:55:00 UTC (rev 4458)
@@ -51,6 +51,7 @@
import org.jboss.util.threadpool.Task;
import org.jboss.util.threadpool.ThreadPool;
=
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -379,8 +380,21 @@
}
catch (Exception e)
{
- log.debug("Error invoking http client invoker.", e);
- throw new CannotConnectException("Can not connect http client inv=
oker.", e);
+ String message =3D "Can not connect http client invoker.";
+ if (e.getMessage() !=3D null)
+ message +=3D " " + e.getMessage() + ".";
+ =
+ try
+ {
+ String responseMessage =3D conn.getResponseMessage();
+ int code =3D conn.getResponseCode();
+ message +=3D " Response: " + responseMessage + "/" + code + ".=
";
+ }
+ catch (IOException e1)
+ {
+ log.debug("Unable to retrieve response message", e1);
+ }
+ throw new CannotConnectException(message, e);
}
=
// now check for error response and throw exception unless configure=
d to not do so
@@ -501,9 +515,9 @@
}
=
private Object readResponse(Map metadata, Map headers, UnMarshaller unm=
arshaller, InputStream is)
- throws IOException, ClassNotFoundException
+ throws ClassNotFoundException, IOException
{
- Object result;
+ Object result =3D null;
String encoding =3D null;
Object ceObj =3D headers.get("Content-Encoding");
if (ceObj !=3D null)
@@ -529,10 +543,25 @@
map.put(HTTPUnMarshaller.PRESERVE_LINES, o);
}
=
- if (unmarshaller instanceof VersionedUnMarshaller)
- result =3D ((VersionedUnMarshaller)unmarshaller).read(is, map, ge=
tVersion());
- else
- result =3D unmarshaller.read(is, map);
+ try
+ {
+ if (unmarshaller instanceof VersionedUnMarshaller)
+ result =3D ((VersionedUnMarshaller)unmarshaller).read(is, map,=
getVersion());
+ else
+ result =3D unmarshaller.read(is, map);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw e;
+ }
+ catch (IOException e)
+ {
+ if (-1 =3D=3D is.read())
+ {
+ throw new EOFException();
+ }
+ throw e;
+ }
=
return result;
}
--===============5187520803085695094==--
From jboss-remoting-commits at lists.jboss.org Sat Aug 2 00:00:54 2008
Content-Type: multipart/mixed; boundary="===============5789277809573891714=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4459 -
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
Date: Sat, 02 Aug 2008 00:00:54 -0400
Message-ID:
--===============5789277809573891714==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-02 00:00:54 -0400 (Sat, 02 Aug 2008)
New Revision: 4459
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/Clie=
ntSocketWrapper.java
Log:
JBREM-996, JBREM-997: In createStreams() took timeout reset out of finally =
clause.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sock=
et/ClientSocketWrapper.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/Cli=
entSocketWrapper.java 2008-08-01 05:55:00 UTC (rev 4458)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/Cli=
entSocketWrapper.java 2008-08-02 04:00:54 UTC (rev 4459)
@@ -158,16 +158,10 @@
}
}
=
- try
- {
- out =3D createOutputStream(serializationType, socket, marshaller);
- in =3D createInputStream(serializationType, socket, unmarshaller);
- }
- finally
- {
- setTimeout(savedTimeout);
- log.debug("reset timeout: " + savedTimeout);
- }
+ out =3D createOutputStream(serializationType, socket, marshaller);
+ in =3D createInputStream(serializationType, socket, unmarshaller);
+ setTimeout(savedTimeout);
+ log.debug("reset timeout: " + savedTimeout);
}
=
protected InputStream createInputStream(String serializationType, Socke=
t socket, UnMarshaller unmarshaller)
--===============5789277809573891714==--
From jboss-remoting-commits at lists.jboss.org Sat Aug 2 01:41:55 2008
Content-Type: multipart/mixed; boundary="===============2082594637092793573=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4460 -
remoting2/branches/2.x/src/etc.
Date: Sat, 02 Aug 2008 01:41:55 -0400
Message-ID:
--===============2082594637092793573==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-02 01:41:54 -0400 (Sat, 02 Aug 2008)
New Revision: 4460
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.core
Log:
JBREM-1019: Added read permission for system property "org.jboss.remoting.c=
lassloadingParentFirstDelegation", which is read in MicroRemoteClientInvoke=
r.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.core
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-08-02=
04:00:54 UTC (rev 4459)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.core 2008-08-02=
05:41:54 UTC (rev 4460)
@@ -182,6 +182,9 @@
//////////////////////////////////////////////////////////////////////////=
///////////////////
// System properties accessed by Remoting
=
+ // Used by org.jboss.remoting.MicroRemoteClientInvoker
+ permission java.util.PropertyPermission "org.jboss.remoting.classloadi=
ngParentFirstDelegation", "read";
+ =
// Used by org.jboss.remoting.callback.CallbackStore,
// org.jboss.remoting.callback.ServerInvokerCallbackHandler
permission java.util.PropertyPermission "file.separator", "read";
--===============2082594637092793573==--
From jboss-remoting-commits at lists.jboss.org Sun Aug 3 22:52:36 2008
Content-Type: multipart/mixed; boundary="===============3633997472774717403=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4461 -
remoting2/branches/2.x/src/etc.
Date: Sun, 03 Aug 2008 22:52:36 -0400
Message-ID:
--===============3633997472774717403==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-03 22:52:36 -0400 (Sun, 03 Aug 2008)
New Revision: 4461
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.tests
Log:
JBREM-1012: Added permissions for org.jboss.test.remoting.lease.InjectedCon=
nectionListenerTestCase.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.tests
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/etc/remoting.security.policy.tests 2008-08-0=
2 05:41:54 UTC (rev 4460)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.tests 2008-08-0=
4 02:52:36 UTC (rev 4461)
@@ -33,7 +33,10 @@
=
// Permission for org.jboss.remoting.callback.CallbackStore
permission java.io.FilePermission "${build.home}${/}output${/}tests${/=
}classes${/}-", "read, write, delete";
- =
+ =
+ // Permission for org.jboss.remoting.ConnectionNotifier =
+ permission javax.management.MBeanPermission "org.jboss.test.remoting.l=
ease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnec=
tionException[jboss:type=3Dconnectionlistener]", "invoke";
+ =
// org.jboss.test.remoting.detection.metadata.MetadataTestCase
permission javax.management.MBeanPermission "org.jboss.test.remoting.d=
etection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=3DNe=
tworkRegistry]", "isInstanceOf";
=
@@ -142,6 +145,8 @@
permission javax.management.MBeanPermission "org.jboss.test.remoting.d=
etection.jndi.JNDIDetectorTest2$TestNetworkRegistry#-[remoting:type=3DNetwo=
rkRegistry]", "registerMBean";
permission javax.management.MBeanPermission "org.jboss.test.remoting.d=
etection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=3DNe=
tworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf=
, addNotificationListener";
permission javax.management.MBeanPermission "org.jboss.test.remoting.h=
andler.mbean.MBeanHandler#-[test:type=3Dhandler]", "registerMBean";
+ permission javax.management.MBeanPermission "org.jboss.test.remoting.l=
ease.InjectedConnectionListenerTestCase$TestConnectionListener#-[jboss:type=
=3Dconnectionlistener]", "registerMBean";
+ permission javax.management.MBeanPermission "org.jboss.test.remoting.l=
ease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnec=
tionException[jboss:type=3Dconnectionlistener]", "invoke";
permission javax.management.MBeanPermission "org.jboss.test.remoting.s=
ecurity.TestCallbackErrorHandler#*[test:type=3DTestCallbackErrorHandler]", =
"registerMBean, getAttribute";
permission javax.management.MBeanPermission "org.jboss.test.remoting.s=
ecurity.TestCallbackStore#*[test:type=3DCallbackstore]", "registerMBean, ge=
tAttribute, invoke";
permission javax.management.MBeanPermission "org.jboss.test.remoting.s=
ecurity.TestNetworkRegistry#*[test:type=3DTestNetworkRegistry]", "registerM=
Bean, unregisterMBean, getAttribute";
--===============3633997472774717403==--
From jboss-remoting-commits at lists.jboss.org Mon Aug 4 00:21:47 2008
Content-Type: multipart/mixed; boundary="===============5929616384699080025=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4462 - in
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader:
parentfirst and 1 other directory.
Date: Mon, 04 Aug 2008 00:21:46 -0400
Message-ID:
--===============5929616384699080025==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2008-08-04 00:21:46 -0400 (Mon, 04 Aug 2008)
New Revision: 4462
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/par=
entfirst/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/par=
entfirst/ParentFirstClassloaderTestCase.java
Log:
JBREM-1019: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader=
/parentfirst/ParentFirstClassloaderTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/pa=
rentfirst/ParentFirstClassloaderTestCase.java (rev =
0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/pa=
rentfirst/ParentFirstClassloaderTestCase.java 2008-08-04 04:21:46 UTC (rev =
4462)
@@ -0,0 +1,286 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.classloader.parentfirst;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1019.
+ * =
+ * @author Ron Sigal
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Aug 3, 2008
+ *
+ */
+public class ParentFirstClassloaderTestCase extends TestCase
+{
+ private static Logger log =3D Logger.getLogger(ParentFirstClassloaderTe=
stCase.class);
+ =
+ private static boolean firstTime =3D true;
+ =
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+ =
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime =3D false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern =3D "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout =3D new PatternLayout(pattern);
+ ConsoleAppender consoleAppender =3D new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender); =
+ }
+ }
+
+ =
+ public void tearDown()
+ {
+ }
+ =
+
+ /**
+ * Verify that by default the context classloader is not called first.
+ */
+ public void testDefaultConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+ =
+ // Start server.
+ setupServer();
+ =
+ // Create client.
+ InvokerLocator clientLocator =3D new InvokerLocator(locatorURI);
+ HashMap clientConfig =3D new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client =3D new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+ =
+ TestClassLoader tcl =3D new TestClassLoader();
+ Thread.currentThread().setContextClassLoader(tcl);
+ =
+ // Test connection.
+ client.invoke("abc");
+ log.info("connection is good");
+ =
+ // Verify that TestClassLoader has not been queried.
+ assertFalse(tcl.visited);
+ log.info("context classloader has not been queried");
+ =
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+ =
+ =
+ /**
+ * Verify that by the context classloader is called first if =
+ * org.jboss.remoting.Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION is =
set to "true"
+ * in the config map.
+ */
+ public void testByConfigMap() throws Throwable
+ {
+ log.info("entering " + getName());
+ =
+ // Start server.
+ setupServer();
+ =
+ // Create client.
+ InvokerLocator clientLocator =3D new InvokerLocator(locatorURI);
+ HashMap clientConfig =3D new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION, "fal=
se");
+ addExtraClientConfig(clientConfig);
+ Client client =3D new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+ =
+ TestClassLoader tcl =3D new TestClassLoader();
+ setContextClassLoader(tcl);
+ =
+ // Test connection.
+ client.invoke("abc");
+ log.info("connection is good");
+ =
+ // Verify that TestClassLoader has been queried.
+ assertTrue(tcl.visited);
+ log.info("context classloader has been queried");
+ =
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+ =
+ =
+ /**
+ * Verify that by the context classloader is called first if the system=
property
+ * org.jboss.remoting.Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PRO=
P is set to "true"
+ * in the config map.
+ */
+ public void testBySystemProperty() throws Throwable
+ {
+ log.info("entering " + getName());
+ =
+ // Start server.
+ setupServer();
+ =
+ // Create client.
+ InvokerLocator clientLocator =3D new InvokerLocator(locatorURI);
+ HashMap clientConfig =3D new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client =3D new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+ =
+ System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PRO=
P, "false");
+ TestClassLoader tcl =3D new TestClassLoader();
+ setContextClassLoader(tcl);
+ =
+ // Test connection.
+ client.invoke("abc");
+ log.info("connection is good");
+ =
+ // Verify that TestClassLoader has been queried.
+ assertTrue(tcl.visited);
+ log.info("context classloader has been queried");
+ =
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+ =
+ protected String getTransport()
+ {
+ return "socket";
+ }
+ =
+ =
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+ =
+
+ protected void setupServer() throws Exception
+ {
+ host =3D InetAddress.getLocalHost().getHostAddress();
+ port =3D PortUtil.findFreePort(host);
+ locatorURI =3D getTransport() + "://" + host + ":" + port; =
+ serverLocator =3D new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorU=
RI);
+ HashMap config =3D new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector =3D new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler =3D new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+ =
+ =
+ protected void shutdownServer() throws Exception
+ {
+ if (connector !=3D null)
+ connector.stop();
+ }
+ =
+ =
+ protected void setContextClassLoader(final ClassLoader classLoader)
+ {
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ =
+ =
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Thro=
wable
+ {
+ return new TestClass();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+ =
+ static class TestClassLoader extends ClassLoader
+ {
+ boolean visited;
+ =
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ visited =3D true;
+ log.info("TestClassLoader.loadClass(): " + name);
+ throw new ClassNotFoundException(name);
+ }
+ }
+ =
+ =
+ static class TestClass implements Serializable
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID =3D 1L;
+ }
+}
\ No newline at end of file
--===============5929616384699080025==--
From jboss-remoting-commits at lists.jboss.org Mon Aug 4 22:59:59 2008
Content-Type: multipart/mixed; boundary="===============8621564708833983135=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r4463 - in
remoting3/trunk: api/src/main/java/org/jboss/cx/remoting/spi and 7 other
directories.
Date: Mon, 04 Aug 2008 22:59:58 -0400
Message-ID:
--===============8621564708833983135==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: david.lloyd(a)jboss.com
Date: 2008-08-04 22:59:58 -0400 (Mon, 04 Aug 2008)
New Revision: 4463
Added:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/HandleableClosea=
ble.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/RemoteServiceReg=
istration.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceListener.=
java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/SimpleCloseable.=
java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractHand=
leableCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractSimp=
leCloseable.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/FutureClie=
ntSource.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ServiceReg=
istration.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Closeable.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractClos=
eable.java
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Client.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientContext.ja=
va
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientSource.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceContext.j=
ava
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAuto=
Closeable.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Handl=
e.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Reque=
stHandler.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Reque=
stHandlerSource.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/Endp=
ointWrapper.java
remoting3/trunk/api/src/test/java/org/jboss/cx/remoting/spi/CloseableTes=
tCase.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/AbstractCo=
ntextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/ClientSour=
ceImpl.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/EndpointIm=
pl.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/proto=
col/basic/AbstractConnection.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/proto=
col/basic/Connection.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/cx/remoting/proto=
col/basic/MessageType.java
remoting3/trunk/protocol/basic/src/test/java/org/jboss/cx/remoting/proto=
col/basic/ConnectionTestCase.java
remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.=
java
Log:
API changes for service registration, location
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Client.ja=
va
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Client.java 200=
8-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Client.java 200=
8-08-05 02:59:58 UTC (rev 4463)
@@ -10,7 +10,7 @@
* @param the request type
* @param the reply type
*/
-public interface Client extends Closeable> {
+public interface Client extends HandleableCloseable> {
/**
* Send a request and block until a reply is received.
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientCon=
text.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientContext.j=
ava 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientContext.j=
ava 2008-08-05 02:59:58 UTC (rev 4463)
@@ -5,7 +5,7 @@
/**
* The server context for a single remote client instance.
*/
-public interface ClientContext extends Closeable {
+public interface ClientContext extends HandleableCloseable {
/**
* Get the attributes for this end of the channel as a map.
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientSou=
rce.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientSource.ja=
va 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ClientSource.ja=
va 2008-08-05 02:59:58 UTC (rev 4463)
@@ -8,7 +8,7 @@
* @param the request type
* @param the reply type
*/
-public interface ClientSource extends Closeable> {
+public interface ClientSource extends HandleableCloseable> {
/**
* Close the context source. New contexts may no longer be created af=
ter this
* method is called. Subsequent calls to this method have no addition=
al effect.
Deleted: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Closeable.=
java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Closeable.java =
2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Closeable.java =
2008-08-05 02:59:58 UTC (rev 4463)
@@ -1,26 +0,0 @@
-package org.jboss.cx.remoting;
-
-import java.io.IOException;
-
-/**
- * A Remoting resource that can be closed.
- *
- * @param the type that is passed to the close handler
- */
-public interface Closeable extends java.io.Closeable {
-
- /**
- * Close, waiting for any outstanding processing to finish.
- *
- * @throws IOException if the close failed
- */
- void close() throws IOException;
-
- /**
- * Add a handler that will be called upon close. The handler may be c=
alled before or after the close acutally
- * takes place.
- *
- * @param handler the close handler
- */
- void addCloseHandler(CloseHandler super T> handler);
-}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.=
java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2=
008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2=
008-08-05 02:59:58 UTC (rev 4463)
@@ -1,10 +1,12 @@
package org.jboss.cx.remoting;
=
import java.util.concurrent.ConcurrentMap;
+import java.net.URI;
import java.io.IOException;
import org.jboss.cx.remoting.spi.remote.RequestHandler;
import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
+import org.jboss.xnio.IoFuture;
=
/**
* A potential participant in a JBoss Remoting communications relationship.
@@ -51,10 +53,12 @@
* @param the request type
* @param the reply type
* @param requestListener the request listener
+ * @param serviceType the type of service to advertise
+ * @param groupName the name of the group of this type to be part of
* @return a handle for the client source
* @throws IOException if an error occurs
*/
- Handle createRequestHandlerSource(Request=
Listener requestListener) throws IOException;
+ Handle createRequestHandlerSource(Request=
Listener requestListener, String serviceType, String groupName) throw=
s IOException;
=
/**
* Create a client that uses the given request handler to handle its r=
equests.
@@ -77,4 +81,42 @@
* @throws IOException if an error occurs
*/
ClientSource createClientSource(RequestHandlerSource hand=
lerSource) throws IOException;
+
+ /**
+ * Attempt to locate a service. The return value then be queried for =
the service's {@code ClientSource}.
+ *
+ * @param the request type
+ * @param the reply type
+ * @param serviceUri the URI of the service
+ * @return the future service
+ * @throws IllegalArgumentException if the given URI is not a valid Re=
moting service URI
+ */
+ IoFuture> locateService(URI serviceUri) thro=
ws IllegalArgumentException;
+
+ /**
+ * Register a remotely available service.
+ * The remote endpoint may not have the same name as this endpoint. T=
he group name and service type must be
+ * non-{@code null} and non-empty. The metric must be greater than ze=
ro.
+ *
+ * @param serviceType the service type string
+ * @param groupName the group name
+ * @param endpointName the name of the remote endpoint
+ * @param handlerSource the remote handler source
+ * @param metric the preference metric, lower is more preferred
+ * @return a handle corresponding to the registration
+ * @throws IllegalArgumentException if one of the given arguments was =
not valid
+ * @throws IOException if an error occurs with the registration
+ */
+ SimpleCloseable registerRemoteService(String serviceType, String group=
Name, String endpointName, RequestHandlerSource handlerSource, int metric) =
throws IllegalArgumentException, IOException;
+
+ /**
+ * Add a listener for observing when local and remote services are add=
ed. The caller may specify whether the listener
+ * should be notified of the complete list of currently registered ser=
vices (set {@code onlyNew} to {@code false})
+ * or only services registered after the time of calling this method (=
set {@code onlyNew} to {@code true}).
+ *
+ * @param serviceListener the listener
+ * @param onlyNew {@code true} if only new registrations should be sen=
t to the listener
+ * @return a handle which may be used to unregister the listener
+ */
+ SimpleCloseable addServiceListener(ServiceListener serviceListener, bo=
olean onlyNew);
}
Copied: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/HandleableC=
loseable.java (from rev 4437, remoting3/trunk/api/src/main/java/org/jboss/c=
x/remoting/Closeable.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/HandleableClose=
able.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/HandleableClose=
able.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,27 @@
+package org.jboss.cx.remoting;
+
+import java.io.IOException;
+import java.io.Closeable;
+
+/**
+ * A Remoting resource that can be closed.
+ *
+ * @param the type that is passed to the close handler
+ */
+public interface HandleableCloseable extends Closeable {
+
+ /**
+ * Close, waiting for any outstanding processing to finish.
+ *
+ * @throws IOException if the close failed
+ */
+ void close() throws IOException;
+
+ /**
+ * Add a handler that will be called upon close. The handler may be c=
alled before or after the close acutally
+ * takes place.
+ *
+ * @param handler the close handler
+ */
+ void addCloseHandler(CloseHandler super T> handler);
+}
Added: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/RemoteServic=
eRegistration.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/RemoteServiceRe=
gistration.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/RemoteServiceRe=
gistration.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting;
+
+/**
+ *
+ */
+public interface RemoteServiceRegistration extends HandleableCloseable {
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceCo=
ntext.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceContext.=
java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceContext.=
java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -6,7 +6,7 @@
* The server-side context of a service. Used to hold state relating to a=
service (known as a {@code ContextSource} on
* the client side).
*/
-public interface ServiceContext extends Closeable {
+public interface ServiceContext extends HandleableCloseable {
=
/**
* Get an attribute map which can be used to cache arbitrary state on =
the server side.
Added: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceListe=
ner.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceListener=
.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceListener=
.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting;
+
+import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
+
+/**
+ * A listener for watching service registrations on an endpoint.
+ */
+public interface ServiceListener {
+
+ /**
+ * Receive notification that a local service was added. To receive a =
notification when it is closed, register a
+ * close handler on the provided {@code requestHandlerSource} paramete=
r.
+ *
+ * @param listenerHandle the handle to this listener
+ * @param serviceType the service type string
+ * @param groupName the group name string
+ * @param requestHandlerSource the request handler source
+ */
+ void localServiceCreated(SimpleCloseable listenerHandle, String servic=
eType, String groupName, RequestHandlerSource requestHandlerSource);
+
+ /**
+ * Receive notification that a remote service was registered. To rece=
ive a notification when it is unregistered, register a
+ * close handler on the provided {@code handle} parameter.
+ *
+ * @param listenerHandle the handle to this listener
+ * @param endpointName the remote endpoint name
+ * @param serviceType the service type string
+ * @param groupName the group name string
+ * @param metric the metric value
+ * @param requestHandlerSource the request handler source
+ * @param handle the handle to the registration
+ */
+ void remoteServiceRegistered(SimpleCloseable listenerHandle, String en=
dpointName, String serviceType, String groupName, int metric, RequestHandle=
rSource requestHandlerSource, SimpleCloseable handle);
+}
Added: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/SimpleClosea=
ble.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/SimpleCloseable=
.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/SimpleCloseable=
.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting;
+
+/**
+ * A simple close-only handle.
+ */
+public interface SimpleCloseable extends HandleableCloseable {
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/Abstr=
actAutoCloseable.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAut=
oCloseable.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractAut=
oCloseable.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -33,7 +33,7 @@
* A closeable implementation that supports reference counting. Since the=
initial reference count is zero, implementors
* must be careful to ensure that the first operation invoked is a call to=
{@link #getHandle()}.
*/
-public abstract class AbstractAutoCloseable extends AbstractCloseable {
+public abstract class AbstractAutoCloseable extends AbstractHandleableC=
loseable {
=
private final AtomicInteger refcount =3D new AtomicInteger(0);
private final Executor executor;
@@ -100,7 +100,7 @@
return new HandleImpl();
}
=
- private final class HandleImpl extends AbstractCloseable> im=
plements Handle {
+ private final class HandleImpl extends AbstractHandleableCloseable> implements Handle {
private HandleImpl() throws IOException {
super(AbstractAutoCloseable.this.executor);
inc();
Deleted: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/Abstra=
ctCloseable.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractClo=
seable.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractClo=
seable.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -1,178 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cx.remoting.spi;
-
-import org.jboss.cx.remoting.Closeable;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.CloseHandler;
-import org.jboss.cx.remoting.spi.SpiUtils;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.log.Logger;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.io.IOException;
-
-/**
- * A basic implementation of a closeable resource. Use as a convenient ba=
se class for your closeable resources.
- * Ensures that the {@code close()} method is idempotent; implements the r=
egistry of close handlers.
- */
-public abstract class AbstractCloseable implements Closeable {
-
- private static final Logger log =3D Logger.getLogger(AbstractCloseable=
.class);
-
- protected final Executor executor;
- private final Object closeLock =3D new Object();
- private final AtomicBoolean closed =3D new AtomicBoolean();
- private Set> closeHandlers;
-
- private static final boolean LEAK_DEBUGGING;
- private final StackTraceElement[] backtrace;
-
- static {
- boolean b =3D false;
- try {
- b =3D Boolean.parseBoolean(AccessController.doPrivileged(new P=
rivilegedAction() {
- public String run() {
- return System.getProperty("jboss.remoting.leakdebuggin=
g", "false");
- }
- }));
- } catch (SecurityException se) {
- b =3D false;
- }
- LEAK_DEBUGGING =3D b;
- }
-
- /**
- * Basic constructor.
- *
- * @param executor the executor used to execute the close notification=
handlers
- */
- protected AbstractCloseable(final Executor executor) {
- if (executor =3D=3D null) {
- throw new NullPointerException("executor is null");
- }
- this.executor =3D executor;
- backtrace =3D LEAK_DEBUGGING ? new Throwable().getStackTrace() : n=
ull;
- }
-
- /**
- * Read the status of this resource. This is just a snapshot in time;=
there is no guarantee that the resource
- * will remain open for any amount of time, even if this method return=
s {@code true}.
- *
- * @return {@code true} if the resource is still open
- */
- protected boolean isOpen() {
- return ! closed.get();
- }
-
- /**
- * Called exactly once when the {@code close()} method is invoked; the=
actual close operation should take place here.
- *
- * @throws RemotingException if the close failed
- */
- protected void closeAction() throws IOException {}
-
- /**
- * {@inheritDoc}
- */
- public final void close() throws IOException {
- if (! closed.getAndSet(true)) {
- log.trace("Closed %s", this);
- synchronized (closeLock) {
- if (closeHandlers !=3D null) {
- for (final CloseHandler super T> handler : closeHand=
lers) {
- try {
- executor.execute(new Runnable() {
- @SuppressWarnings({ "unchecked" })
- public void run() {
- SpiUtils.safeHandleClose(handler, (T) =
AbstractCloseable.this);
- }
- });
- } catch (RejectedExecutionException ree) {
- log.warn("Unable to execute close handler (exe=
cution rejected) for %s (%s)", this, ree.getMessage());
- }
- }
- closeHandlers =3D null;
- }
- }
- closeAction();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void addCloseHandler(final CloseHandler super T> handler) {
- synchronized (closeLock) {
- if (closeHandlers =3D=3D null) {
- closeHandlers =3D new HashSet>();
- }
- closeHandlers.add(handler);
- }
- }
-
- /**
- * Get the executor to use for handler invocation.
- *
- * @return the executor
- */
- protected Executor getExecutor() {
- return executor;
- }
-
- /**
- * Finalize this closeable instance. If the instance hasn't been clos=
ed, it is closed and a warning is logged.
- */
- protected void finalize() throws Throwable {
- try {
- super.finalize();
- } finally {
- if (isOpen()) {
- if (LEAK_DEBUGGING) {
- final Throwable t =3D new LeakThrowable();
- t.setStackTrace(backtrace);
- log.warn(t, "Leaked a %s instance: %s", getClass().get=
Name(), this);
- } else {
- log.warn("Leaked a %s instance: %s", getClass().getNam=
e(), this);
- }
- IoUtils.safeClose(this);
- }
- }
- }
-
- @SuppressWarnings({ "serial" })
- private static final class LeakThrowable extends Throwable {
-
- public LeakThrowable() {
- }
-
- public String toString() {
- return "a leaked reference";
- }
- }
-}
Copied: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/Abstrac=
tHandleableCloseable.java (from rev 4439, remoting3/trunk/api/src/main/java=
/org/jboss/cx/remoting/spi/AbstractCloseable.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractHan=
dleableCloseable.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractHan=
dleableCloseable.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.spi;
+
+import org.jboss.cx.remoting.HandleableCloseable;
+import org.jboss.cx.remoting.RemotingException;
+import org.jboss.cx.remoting.CloseHandler;
+import org.jboss.cx.remoting.spi.SpiUtils;
+import org.jboss.xnio.IoUtils;
+import org.jboss.xnio.log.Logger;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.io.IOException;
+
+/**
+ * A basic implementation of a closeable resource. Use as a convenient ba=
se class for your closeable resources.
+ * Ensures that the {@code close()} method is idempotent; implements the r=
egistry of close handlers.
+ */
+public abstract class AbstractHandleableCloseable implements Handleable=
Closeable {
+
+ private static final Logger log =3D Logger.getLogger(AbstractHandleabl=
eCloseable.class);
+
+ protected final Executor executor;
+ private final Object closeLock =3D new Object();
+ private final AtomicBoolean closed =3D new AtomicBoolean();
+ private Set> closeHandlers;
+
+ private static final boolean LEAK_DEBUGGING;
+ private final StackTraceElement[] backtrace;
+
+ static {
+ boolean b =3D false;
+ try {
+ b =3D Boolean.parseBoolean(AccessController.doPrivileged(new P=
rivilegedAction() {
+ public String run() {
+ return System.getProperty("jboss.remoting.leakdebuggin=
g", "false");
+ }
+ }));
+ } catch (SecurityException se) {
+ b =3D false;
+ }
+ LEAK_DEBUGGING =3D b;
+ }
+
+ /**
+ * Basic constructor.
+ *
+ * @param executor the executor used to execute the close notification=
handlers
+ */
+ protected AbstractHandleableCloseable(final Executor executor) {
+ if (executor =3D=3D null) {
+ throw new NullPointerException("executor is null");
+ }
+ this.executor =3D executor;
+ backtrace =3D LEAK_DEBUGGING ? new Throwable().getStackTrace() : n=
ull;
+ }
+
+ /**
+ * Read the status of this resource. This is just a snapshot in time;=
there is no guarantee that the resource
+ * will remain open for any amount of time, even if this method return=
s {@code true}.
+ *
+ * @return {@code true} if the resource is still open
+ */
+ protected boolean isOpen() {
+ return ! closed.get();
+ }
+
+ /**
+ * Called exactly once when the {@code close()} method is invoked; the=
actual close operation should take place here.
+ *
+ * @throws RemotingException if the close failed
+ */
+ protected void closeAction() throws IOException {}
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void close() throws IOException {
+ if (! closed.getAndSet(true)) {
+ log.trace("Closed %s", this);
+ synchronized (closeLock) {
+ if (closeHandlers !=3D null) {
+ for (final CloseHandler super T> handler : closeHand=
lers) {
+ try {
+ executor.execute(new Runnable() {
+ @SuppressWarnings({ "unchecked" })
+ public void run() {
+ SpiUtils.safeHandleClose(handler, (T) =
AbstractHandleableCloseable.this);
+ }
+ });
+ } catch (RejectedExecutionException ree) {
+ log.warn("Unable to execute close handler (exe=
cution rejected) for %s (%s)", this, ree.getMessage());
+ }
+ }
+ closeHandlers =3D null;
+ }
+ }
+ closeAction();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCloseHandler(final CloseHandler super T> handler) {
+ synchronized (closeLock) {
+ if (closeHandlers =3D=3D null) {
+ closeHandlers =3D new HashSet>();
+ }
+ closeHandlers.add(handler);
+ }
+ }
+
+ /**
+ * Get the executor to use for handler invocation.
+ *
+ * @return the executor
+ */
+ protected Executor getExecutor() {
+ return executor;
+ }
+
+ /**
+ * Finalize this closeable instance. If the instance hasn't been clos=
ed, it is closed and a warning is logged.
+ */
+ protected void finalize() throws Throwable {
+ try {
+ super.finalize();
+ } finally {
+ if (isOpen()) {
+ if (LEAK_DEBUGGING) {
+ final Throwable t =3D new LeakThrowable();
+ t.setStackTrace(backtrace);
+ log.warn(t, "Leaked a %s instance: %s", getClass().get=
Name(), this);
+ } else {
+ log.warn("Leaked a %s instance: %s", getClass().getNam=
e(), this);
+ }
+ IoUtils.safeClose(this);
+ }
+ }
+ }
+
+ @SuppressWarnings({ "serial" })
+ private static final class LeakThrowable extends Throwable {
+
+ public LeakThrowable() {
+ }
+
+ public String toString() {
+ return "a leaked reference";
+ }
+ }
+}
Added: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/Abstract=
SimpleCloseable.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractSim=
pleCloseable.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/AbstractSim=
pleCloseable.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cx.remoting.spi;
+
+import org.jboss.cx.remoting.SimpleCloseable;
+import java.util.concurrent.Executor;
+
+/**
+ * An abstract simple closeable implementation.
+ */
+public abstract class AbstractSimpleCloseable extends AbstractHandleableCl=
oseable implements SimpleCloseable {
+
+ /**
+ * Basic constructor.
+ *
+ * @param executor the executor used to execute the close notification=
handlers
+ */
+ protected AbstractSimpleCloseable(final Executor executor) {
+ super(executor);
+ }
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remot=
e/Handle.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Hand=
le.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Hand=
le.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -22,14 +22,14 @@
=
package org.jboss.cx.remoting.spi.remote;
=
-import org.jboss.cx.remoting.Closeable;
+import org.jboss.cx.remoting.HandleableCloseable;
import org.jboss.cx.remoting.CloseHandler;
import java.io.IOException;
=
/**
* A handle to a local resource.
*/
-public interface Handle extends Closeable> {
+public interface Handle extends HandleableCloseable> {
=
/**
* Get the resource.
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remot=
e/RequestHandler.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Requ=
estHandler.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Requ=
estHandler.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -22,7 +22,7 @@
=
package org.jboss.cx.remoting.spi.remote;
=
-import org.jboss.cx.remoting.Closeable;
+import org.jboss.cx.remoting.HandleableCloseable;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.CloseHandler;
import java.io.IOException;
@@ -31,7 +31,7 @@
* A request handler, which can be passed to remote endpoints. Remote sys=
tems can then use the handler
* to make invocations, or they may forward a handler on to other remote s=
ystems.
*/
-public interface RequestHandler extends Closeable {
+public interface RequestHandler extends HandleableCloseable {
=
/**
* Receive a one-way request from a remote system. This method is int=
ended to be called by protocol handlers. No
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remot=
e/RequestHandlerSource.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Requ=
estHandlerSource.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/remote/Requ=
estHandlerSource.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -22,7 +22,7 @@
=
package org.jboss.cx.remoting.spi.remote;
=
-import org.jboss.cx.remoting.Closeable;
+import org.jboss.cx.remoting.HandleableCloseable;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.CloseHandler;
import java.io.IOException;
@@ -33,7 +33,7 @@
* has the advantage that a round trip to the remote side is not necessary=
; the local side can spawn a request handler
* and simply notify the remote side of the change.
*/
-public interface RequestHandlerSource extends Closeable {
+public interface RequestHandlerSource extends HandleableCloseable {
=
/**
* Create a request handler for the service corresponding to this requ=
est handler source.
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapp=
er/EndpointWrapper.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/End=
pointWrapper.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/End=
pointWrapper.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -2,13 +2,17 @@
=
import java.util.concurrent.ConcurrentMap;
import java.io.IOException;
+import java.net.URI;
import org.jboss.cx.remoting.Endpoint;
import org.jboss.cx.remoting.RequestListener;
import org.jboss.cx.remoting.Client;
import org.jboss.cx.remoting.ClientSource;
+import org.jboss.cx.remoting.SimpleCloseable;
+import org.jboss.cx.remoting.ServiceListener;
import org.jboss.cx.remoting.spi.remote.RequestHandler;
import org.jboss.cx.remoting.spi.remote.RequestHandlerSource;
import org.jboss.cx.remoting.spi.remote.Handle;
+import org.jboss.xnio.IoFuture;
=
/**
* A simple delegating wrapper for endpoints.
@@ -49,8 +53,8 @@
/**
* {@inheritDoc} This implementation calls the same method on the del=
egate object.
*/
- public Handle createRequestHandlerSource(=
final RequestListener requestListener) throws IOException {
- return delegate.createRequestHandlerSource(requestListener);
+ public Handle createRequestHandlerSource(=
final RequestListener requestListener, final String serviceType, fina=
l String groupName) throws IOException {
+ return delegate.createRequestHandlerSource(requestListener, servic=
eType, groupName);
}
=
/**
@@ -66,4 +70,25 @@
public ClientSource createClientSource(final RequestHandl=
erSource handlerSource) throws IOException {
return delegate.createClientSource(handlerSource);
}
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the del=
egate object.
+ */
+ public IoFuture> locateService(final URI ser=
viceUri) throws IllegalArgumentException {
+ return delegate.locateService(serviceUri);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the del=
egate object.
+ */
+ public SimpleCloseable registerRemoteService(final String serviceType,=
final String groupName, final String endpointName, final RequestHandlerSou=
rce handlerSource, final int metric) throws IllegalArgumentException, IOExc=
eption {
+ return delegate.registerRemoteService(serviceType, groupName, endp=
ointName, handlerSource, metric);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the del=
egate object.
+ */
+ public SimpleCloseable addServiceListener(final ServiceListener servic=
eListener, final boolean onlyNew) {
+ return delegate.addServiceListener(serviceListener, true);
+ }
}
Modified: remoting3/trunk/api/src/test/java/org/jboss/cx/remoting/spi/Close=
ableTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/api/src/test/java/org/jboss/cx/remoting/spi/CloseableTe=
stCase.java 2008-08-04 04:21:46 UTC (rev 4462)
+++ remoting3/trunk/api/src/test/java/org/jboss/cx/remoting/spi/CloseableTe=
stCase.java 2008-08-05 02:59:58 UTC (rev 4463)
@@ -46,7 +46,7 @@
try {
final AtomicBoolean closed =3D new AtomicBoolean();
final CountDownLatch latch =3D new CountDownLatch(1);
- final AbstractCloseable