Hi,
I'm having my clients connect a server side factory that hands back refs to remoted objects that also live in the server...
Lets say I am trying to return an object that implements the IFoo interface ( and the server side object that implements it is Foo )...
So, the server side config file has something like:
----------------------------------------------
<bean id="myFooObject" class="Foo" />
<bean id="myRemotedFoo" class="org.springframework.remoting.rmi.RmiService Exporter">
<property name="service"><ref local="myFooObject"/></property>
<property name="serviceInterface">
<value>IFoo</value>
</property>
<property name="serviceName"><value>someServiceName</value></property>
<property name="registryPort"><value>1099</value></property>
</bean>
---------------------------------
Now I want my "factory" object to hand back a ref to my remoted foo...
This does not work ( class cast exception when trying to cast to interface type), but this is how I would assume you would do it:
------------------------------
class MyFactory
{
...
public IServerServiceFactory getLocalServiceFactory() {
// context is a FileSystemXmlApplicationContext
Object o = context.getBean("myRemotedFoo");
System.out.println(o);
//note that o is an instance of
//org.springframework.remoting.rmi.RmiServiceExporte r
IFoo sf = (IServerServiceFactory)o;
}
}
-----------------------
Do I need to lookup the object in RMI on the serverside ( as if I were a client ), ( e.g. use a RmiProxyFactoryBean ) ? So then I'd have client and server config for objects living in the same server?
Thanks in advance!!


Reply With Quote
