2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.test.remoting.transport.socket.timeout.keepalive;
25
import javax.management.MBeanServer;
26
import org.jboss.remoting.InvocationRequest;
27
import org.jboss.remoting.InvokerLocator;
28
import org.jboss.remoting.ServerInvocationHandler;
29
import org.jboss.remoting.ServerInvoker;
30
import org.jboss.remoting.callback.InvokerCallbackHandler;
31
import org.jboss.remoting.transport.Connector;
34
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
36
public class TimeoutServerTest
38
//private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=500&clientMaxPoolSize=100&maxPoolSize=500";
39
//private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3";
40
private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3&serializationtype=jboss";
41
private Connector connector = null;
43
private static int counter = 0;
45
public void setUp() throws Exception
47
connector = new Connector();
48
InvokerLocator locator = new InvokerLocator(locatorURI);
49
connector.setInvokerLocator(locator.getLocatorURI());
51
connector.addInvocationHandler("test", new TimeoutHandler());
55
protected void tearDown() throws Exception
64
public static void main(String[] args)
66
// org.apache.log4j.BasicConfigurator.configure();
67
// org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket.ServerThread").setLevel(XLevel.TRACE);
68
// org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket.SocketServerInvoker").setLevel(XLevel.TRACE);
70
TimeoutServerTest server = new TimeoutServerTest();
81
private class TimeoutHandler implements ServerInvocationHandler
85
* set the mbean server that the handler can reference
89
public void setMBeanServer(MBeanServer server)
91
//TODO: -TME Implement
95
* set the invoker that owns this handler
99
public void setInvoker(ServerInvoker invoker)
101
//TODO: -TME Implement
105
* called to handle a specific invocation. Please take care to make sure
106
* implementations are thread safe and can, and often will, receive concurrent
107
* calls on this method.
113
public Object invoke(InvocationRequest invocation) throws Throwable
115
Object obj = invocation.getParameter();
116
if(obj instanceof String && "timeout".equals(obj))
118
Thread.currentThread().sleep(30000);
120
return new Integer(++counter); //TODO: -TME Implement
124
* Adds a callback handler that will listen for callbacks from
125
* the server invoker handler.
127
* @param callbackHandler
129
public void addListener(InvokerCallbackHandler callbackHandler)
131
//TODO: -TME Implement
135
* Removes the callback handler that was listening for callbacks
136
* from the server invoker handler.
138
* @param callbackHandler
140
public void removeListener(InvokerCallbackHandler callbackHandler)
142
//TODO: -TME Implement
b'\\ No newline at end of file'