Hi,
I originally posted in the EJB forum, but it's kind of a general issue, so I end up here. I work with Spring on the client side of an EJB project: my clients use SimpleRemoteStatelessSessionProxyFactoryBean to access remote SLSBs. In the case of an unique appserver, it works perfectly.
However, the system is distributed: the same SLSBs are deployed on several appservers, which also act as JNDI servers. My clients receive the system topology (= hostnames of the servers) at startup. Later on, they have to be able to call SLSBs on ANY server. It comes down to managing different JNDI settings (java.naming.provider.url) for my Spring SLSB proxies. I don't think BeanFactoryPostProcessor is enough, because I do have several JNDI servers discovered at runtime, not one.
The simplest solution would be to define the proxies as prototypes and maintain a map {server hostname, Spring proxy bean}. If a bean doesn't exist in the map, I just have to instanciate it (using BeanFactory.getBean(...)) with the correct JNDI settings for the hostname and return it to the client.
I doubt using SimpleRemoteStatelessSessionProxyFactoryBean directly would work, since it returns only singletons. Maybe I could add the required level of indirection by creating a custom ProxyFactoryBean. It would return prototypes, maintain the same map as before and create a SLSB proxy à la SimpleRemoteStatelessSessionProxyFactoryBean if necessary.
Is this the right approach? Are there other solutions? I'm hitting the limits of my Spring knowledge in this particular case, so I wait for you to enlighten me. Thanks in advance.
Baptiste


Reply With Quote