Announcement Announcement Module
Collapse
No announcement yet.
Dynamic settings for ProxyFactoryBean-created objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic settings for ProxyFactoryBean-created objects

    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

  • #2
    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.
    Quick question before I try to answer your more detailed questions. Why are you having to write code to do this? Shouldn't your application server be provided this transparently, through its cluster management?

    Comment


    • #3
      Quick question before I try to answer your more detailed questions. Why are you having to write code to do this? Shouldn't your application server be provided this transparently, through its cluster management?
      Thanks for answering and trying to understand... The system is (for the moment) distributed, but not clustered. Most of our data belongs to some production site. We have a central server offering a transparent view of all the data, and n local servers deployed on the production sites and managing their data. Upon modification on a local server, the new data is sent to the central server for synchronisation. Local data cannot be modified from the central server.

      A client receives the system topology when it connects to the central server. In order to update any local data, he must access the matching local site, hence my need for dynamic JNDI configuration.

      Hope it's clear enough,
      Baptiste

      Comment


      • #4
        I think you can extend SimpleRemoteSlsbInvokerInterceptor, overriding the getSessionBeanInstance() method to do your round-robin/whatever.

        So long as your interceptor is threadsafe, which it should naturally be, you can then use one singleton ProxyFactoryBean with this interceptor--no target or TargetSource is required.

        Rgds
        Rod

        Comment

        Working...
        X