1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.test.remoting.performance.spring.rmi;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
/**
* @author <a href="mailto:tom@jboss.org">Tom Elrod</a>
*/
public class SpringRMIHandler implements InvokerCallbackHandler
{
private SpringRMICallbackServer springRMICallbackServer;
private String sessionId;
public SpringRMIHandler(String sessionId)
{
this.sessionId = sessionId;
}
public void start()
{
// Resource res = new ClassPathResource("SpringRMICallbackServerService.xml", SpringRMIHandler.class);
// BeanFactory factory = new XmlBeanFactory(res);
// springRMICallbackServer = (SpringRMICallbackServer)factory.getBean("springRMICallbackServerService:" );
/*
Instead of creating callback server proxies by injection, the following xml declaration is
replaced by programmatic creation. Each callback server is registered under a name
ending in the sessionId.
<bean id="springRMICallbackServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://localhost:1299/SpringRMICallbackServerService"/>
<property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer"/>
</bean>
*/
RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
factory.setServiceUrl("rmi://localhost:1299/SpringRMICallbackServerService:" + sessionId);
factory.setServiceInterface(org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer.class);
try
{
factory.afterPropertiesSet();
}
catch (Exception e)
{
System.out.println("unable to create callback proxy");
System.out.println(e);
}
springRMICallbackServer = (SpringRMICallbackServer)factory.getObject();
}
public SpringRMICallbackServer getSpringRMICallbackServer()
{
return springRMICallbackServer;
}
public void setSpringRMICallbackServer(SpringRMICallbackServer springRMICallbackServer)
{
this.springRMICallbackServer = springRMICallbackServer;
}
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback);
try
{
springRMICallbackServer.finishedProcessing(callback);
}
catch(Exception e)
{
e.printStackTrace();
throw new HandleCallbackException(e.getMessage());
}
}
}
|