At what point will you know what the remote interface should be?
If you must wait until runtime, you could try something like the following:
Code:
public <R extends Object> R getRemoteObject(Class<R> remoteInterface) {
HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
httpInvokerProxyFactoryBean.setServiceInterface(remoteInterface);
httpInvokerProxyFactoryBean.setServiceUrl("http://localhost:8080/myapp/remoteService");
httpInvokerProxyFactoryBean.afterPropertiesSet();
return (R) httpInvokerProxyFactoryBean.getObject();
}