[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/http/web ...
Tom Elrod
tom.elrod at jboss.com
Mon Aug 14 18:06:34 EDT 2006
User: telrod
Date: 06/08/14 18:06:34
Added: src/tests/org/jboss/test/remoting/performance/spring/http/web
SpringHttpCallbackServerService.xml
SpringHttpHandler.java SpringHttpServer.java
SpringHttpServerImpl.java
Log:
JBREM-578 - add performance benchmark test for spring http transport.
Revision Changes Path
1.1 date: 2006/08/14 22:06:34; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpCallbackServerService.xml
Index: SpringHttpCallbackServerService.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean class="org.jboss.test.remoting.performance.spring.http.web.SpringHttpHandler">
<property name="springHttpCallbackServerService" ref="springHttpCallbackServerService"/>
</bean>
<bean id="springHttpCallbackServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://localhost:1299/SpringHttpCallbackServerService"/>
<property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer"/>
</bean>
</beans>
1.1 date: 2006/08/14 22:06:34; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpHandler.java
Index: SpringHttpHandler.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.test.remoting.performance.spring.http.web;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
/**
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
*/
public class SpringHttpHandler implements InvokerCallbackHandler
{
private SpringHttpCallbackServer springHttpCallbackServer;
public void start()
{
Resource res = new ClassPathResource("SpringHttpCallbackServerService.xml", SpringHttpHandler.class);
BeanFactory factory = new XmlBeanFactory(res);
springHttpCallbackServer = (SpringHttpCallbackServer)factory.getBean("springHttpCallbackServerService");
}
public SpringHttpCallbackServer getSpringHttpCallbackServer()
{
return springHttpCallbackServer;
}
public void setSpringHttpCallbackServer(SpringHttpCallbackServer springHttpCallbackServer)
{
this.springHttpCallbackServer = springHttpCallbackServer;
}
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback);
try
{
springHttpCallbackServer.finishedProcessing(callback);
}
catch(Exception e)
{
e.printStackTrace();
throw new HandleCallbackException(e.getMessage());
}
}
}
1.1 date: 2006/08/14 22:06:34; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpServer.java
Index: SpringHttpServer.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.test.remoting.performance.spring.http.web;
/**
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
*/
public interface SpringHttpServer
{
public Object makeCall(Object obj, Object param);
public Object sendNumberOfCalls(Object obj, Object param);
}
1.1 date: 2006/08/14 22:06:34; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpServerImpl.java
Index: SpringHttpServerImpl.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.test.remoting.performance.spring.http.web;
import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
import org.jboss.test.remoting.performance.synchronous.CallTracker;
import org.jboss.test.remoting.performance.synchronous.Payload;
import java.util.Map;
/**
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
*/
public class SpringHttpServerImpl implements SpringHttpServer
{
private Map callTrackers = new ConcurrentHashMap();
public Object sendNumberOfCalls(Object obj, Object param)
{
System.out.println("sent number of calls " + obj + " " + param);
String sessionId = (String) obj;
Integer totalCountInteger = (Integer) param;
int totalCount = totalCountInteger.intValue();
System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId);
CallTracker tracker = (CallTracker) callTrackers.get(sessionId);
if (tracker != null)
{
tracker.createTotalCount(totalCount);
}
else
{
SpringHttpHandler callbackHandler = new SpringHttpHandler();
callbackHandler.start();
tracker = new CallTracker(sessionId, callbackHandler);
callTrackers.put(sessionId, tracker);
tracker.createTotalCount(totalCount);
}
return totalCountInteger;
}
public Object makeCall(Object obj, Object param)
{
Payload payload = (Payload) param;
int clientInvokeCallCount = payload.getCallNumber();
String sessionId = (String) obj;
CallTracker tracker = (CallTracker) callTrackers.get(sessionId);
if (tracker != null)
{
tracker.verifyClientInvokeCount(clientInvokeCallCount);
}
else
{
System.err.println("No call tracker exists for session id " + sessionId);
throw new RuntimeException("No call tracker exists for session id " + sessionId);
}
return new Integer(clientInvokeCallCount);
}
}
More information about the jboss-cvs-commits
mailing list