1
/***************************************
3
* JBoss: The OpenSource J2EE WebOS *
5
* Distributable under LGPL license. *
6
* See terms of license at gnu.org. *
8
***************************************/
9
package org.jboss.test.remoting.performance.spring.http.web;
11
import org.jboss.remoting.callback.Callback;
12
import org.jboss.remoting.callback.HandleCallbackException;
13
import org.jboss.remoting.callback.InvokerCallbackHandler;
14
import org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer;
15
import org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer;
16
import org.springframework.beans.factory.BeanFactory;
17
import org.springframework.beans.factory.xml.XmlBeanFactory;
18
import org.springframework.core.io.ClassPathResource;
19
import org.springframework.core.io.Resource;
20
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
23
* @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
25
public class SpringHttpHandler implements InvokerCallbackHandler
27
private SpringHttpCallbackServer springHttpCallbackServer;
28
private String sessionId;
30
public SpringHttpHandler(String sessionId)
32
this.sessionId = sessionId;
37
// Resource res = new ClassPathResource("SpringHttpCallbackServerService.xml", SpringHttpHandler.class);
38
// BeanFactory factory = new XmlBeanFactory(res);
39
// springHttpCallbackServer = (SpringHttpCallbackServer)factory.getBean("springHttpCallbackServerService");
42
Instead of creating callback server proxies by injection, the following xml declaration is
43
replaced by programmatic creation. Each callback server is registered under a name
44
ending in the sessionId.
46
<bean id="springHttpCallbackServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
47
<property name="serviceUrl" value="rmi://localhost:1299/SpringHttpCallbackServerService"/>
48
<property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer"/>
52
RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
53
factory.setServiceUrl("rmi://localhost:1299/SpringHttpCallbackServerService:" + sessionId);
54
factory.setServiceInterface(org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer.class);
57
factory.afterPropertiesSet();
61
System.out.println("unable to create callback proxy");
62
System.out.println(e);
64
springHttpCallbackServer = (SpringHttpCallbackServer)factory.getObject();
67
public SpringHttpCallbackServer getSpringHttpCallbackServer()
69
return springHttpCallbackServer;
72
public void setSpringHttpCallbackServer(SpringHttpCallbackServer springHttpCallbackServer)
74
this.springHttpCallbackServer = springHttpCallbackServer;
77
public void handleCallback(Callback callback) throws HandleCallbackException
79
System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback);
83
springHttpCallbackServer.finishedProcessing(callback);
88
throw new HandleCallbackException(e.getMessage());