[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/lease/servlet ...
Tom Elrod
tom.elrod at jboss.com
Thu Jan 18 02:37:28 EST 2007
User: telrod
Date: 07/01/18 02:37:28
Added: src/tests/org/jboss/test/remoting/lease/servlet Tag:
remoting_2_x ServletLeaseTestClient.java
ServletHandler.java
remoting-servlet-server-invoker-service.xml
readme.txt
Log:
JBREM-671 - fixed so leasing will work again when using servlet invoker.
Revision Changes Path
No revision
No revision
1.1.2.1 +44 -0 JBossRemoting/src/tests/org/jboss/test/remoting/lease/servlet/Attic/ServletLeaseTestClient.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServletLeaseTestClient.java
===================================================================
RCS file: ServletLeaseTestClient.java
diff -N ServletLeaseTestClient.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ServletLeaseTestClient.java 18 Jan 2007 07:37:28 -0000 1.1.2.1
@@ -0,0 +1,44 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, 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.lease.servlet;
+
+import org.jboss.test.remoting.lease.LeaseTestClient;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
+ */
+public class ServletLeaseTestClient extends LeaseTestClient
+{
+ // Default locator values
+ private static String transport = "servlet";
+ private static String host = "localhost";
+ private static int port = 8080;
+
+ private String locatorURI = transport + "://" + host + ":" + port + "/servlet-invoker/ServerInvokerServlet/?" + InvokerLocator.CLIENT_LEASE + "=" + "true";
+
+ protected String getLocatorUri()
+ {
+ return locatorURI;
+ }
+
+}
\ No newline at end of file
1.1.2.1 +114 -0 JBossRemoting/src/tests/org/jboss/test/remoting/lease/servlet/Attic/ServletHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServletHandler.java
===================================================================
RCS file: ServletHandler.java
diff -N ServletHandler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ServletHandler.java 18 Jan 2007 07:37:28 -0000 1.1.2.1
@@ -0,0 +1,114 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, 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.lease.servlet;
+
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.ConnectorMBean;
+import org.jboss.remoting.security.ServerSocketFactoryMBean;
+import org.jboss.remoting.security.ServerSocketFactoryWrapper;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.MalformedObjectNameException;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
+ */
+public class ServletHandler implements ServerInvocationHandler, ConnectionListener
+{
+
+ public ServletHandler()
+ {
+ try
+ {
+ ObjectName connectorObjName = new ObjectName("jboss.remoting:service=Connector,transport=Servlet");
+ MBeanServer mbeanServer = getMBeanServer();
+ System.out.println("Found jboss mbean server.");
+ if(mbeanServer != null)
+ {
+ ConnectorMBean servletConnector = (ConnectorMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, connectorObjName, ConnectorMBean.class, false);
+ servletConnector.addConnectionListener(this);
+ }
+ }
+ catch (MalformedObjectNameException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ protected MBeanServer getMBeanServer()
+ {
+ // the intention of having this as a separate protected method is for subclasses to override
+ // it in case this servlet is not running in JBossAS and thus needs to find an non-JBoss
+ // MBeanServer. This design won't work however since when this servlet is loaded, it will
+ // still need to load in this JBoss specific MBeanServerLocator. But, this servlet also
+ // requires JBoss logging too so its not like this is the only place that breaks if not running
+ // in JBossAS. To complete this design, we must make this parent servlet an abstract class,
+ // which this method abstract. Then we need to create a JBoss-specific subclass with this
+ // method's code in its getMBeanServer().
+ for (Iterator i = MBeanServerFactory.findMBeanServer(null).iterator(); i.hasNext();)
+ {
+ MBeanServer server = (MBeanServer) i.next();
+ if (server.getDefaultDomain().equals("jboss"))
+ {
+ return server;
+ }
+ }
+ return null;
+ }
+
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ return "foobar";
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ System.out.println("Connection exception: " + throwable.getMessage() + " for Client " + client);
+ }
+}
\ No newline at end of file
1.1.2.1 +26 -0 JBossRemoting/src/tests/org/jboss/test/remoting/lease/servlet/Attic/remoting-servlet-server-invoker-service.xml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: remoting-servlet-server-invoker-service.xml
===================================================================
RCS file: remoting-servlet-server-invoker-service.xml
diff -N remoting-servlet-server-invoker-service.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ remoting-servlet-server-invoker-service.xml 18 Jan 2007 07:37:28 -0000 1.1.2.1
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:service=Connector,transport=Servlet"
+ display-name="Servlet transport Connector">
+
+ <!--<attribute name="InvokerLocator">-->
+ <!--servlet://localhost:8080/servlet-invoker/ServerInvokerServlet-->
+ <!--</attribute>-->
+
+ <attribute name="Configuration">
+ <config>
+ <invoker transport="servlet">
+ <attribute name="clientLeasePeriod">3000</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.lease.servlet.ServletHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
1.1.2.1 +23 -0 JBossRemoting/src/tests/org/jboss/test/remoting/lease/servlet/Attic/readme.txt
(In the diff below, changes in quantity of whitespace are not shown.)
Index: readme.txt
===================================================================
RCS file: readme.txt
diff -N readme.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ readme.txt 18 Jan 2007 07:37:28 -0000 1.1.2.1
@@ -0,0 +1,23 @@
+The servlet lease test require a web container. Currently, this test has to be run
+manually. Here are the instructions for running
+the test manually.
+
+servlet
+
+1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory.
+2. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory.
+3. Copy remoting-servlet-invoker-service.xml to deploy directory.
+4. Copy jboss-remoting-tests.jar to server lib directory
+5. Start web container (JBossAS).
+6. Run ServletLeaseTestClient.
+
+Even with this, will still have to look at the JBoss server.log (or just console output), where should see something like:
+
+INFO [STDOUT] Connection exception: null for Client org.jboss.remoting.Client at 274608
+
+every time the client lease expires on the server side.
+
+
+
+
+
More information about the jboss-cvs-commits
mailing list