PDA

View Full Version : Run HttpInvoker without config file



bodtx
May 10th, 2012, 08:42 AM
Hello all, I'm trying to run an application to bench a call to HttpInvoker.
I'd like to run spring without config file to minimize the startup time. It should as fast as an EJB call.

So here is my test:

HttpInvokerProxyFactoryBean ht = new HttpInvokerProxyFactoryBean();
ht.setServiceUrl("http://192.168.X.X:8080/XXX/Services/XXX");
ht.setServiceInterface(MyClass.class);
HttpInvokerClientConfiguration htC = new HttpInvokerClientConfiguration()
{

public String getServiceUrl()
{
return "http://192.168.X.X:8080/XXX/Services/XXX";
}

public String getCodebaseUrl()
{
return null;
}
};

RemoteInvocation remo = new RemoteInvocation();
RemoteInvocationResult reqR = ht.getHttpInvokerRequestExecutor().executeRequest( htC, remo);

final IMyClass myClass = (IMyClass)reqR.getValue();

myClass is null so I think this object RemoteInvocation should be defined precisely but I don't know how.
Any idea about how I can do this?

Thank you

bodtx
May 11th, 2012, 02:19 AM
Well ok I've found the solution, I've had to call on more method to change the state of the factory bean : "afterPropertiesSet();";
So here is the code:


HttpInvokerProxyFactoryBean ht = new HttpInvokerProxyFactoryBean();
ht.setServiceUrl("http://192.168.X.X:8080/XXX/Services/XXX");
ht.setServiceInterface(MyClass.class);
ht.afterPropertiesSet();
final IMyClass myClass = (IMyClass)ht.getObject();
... do some stuff with my class


some usefull links:
http://stackoverflow.com/questions/10185051/spring-httpinvoker-how-to-replace-serviceurl-at-runtime

http://www.eclipse.org/forums/index.php/m/739454/

http://static.springsource.org/spring/docs/1.1.x/api/org/springframework/remoting/httpinvoker/HttpInvokerProxyFactoryBean.html