Announcement Announcement Module
Collapse
No announcement yet.
SimpleRemoteStatelessSessionProxyFactoryBean without IOC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleRemoteStatelessSessionProxyFactoryBean without IOC

    Can I used the proxy and RuntimeException benefits provided by the Spring EJB framework without using IOC? I am migrating a shop from pure J2EE to use some of the robust features of the architecture (nothing against IOC...just one step at a time). I love the Spring JDBC framework and have successfully used it without IOC and now I want to do something with a BusinessDelegate pattern and dynamic proxies to disconnect the dependencies from retrieving remote SLSB within a Struts Action. So I saw that SimpleRemoteStatelessSessionProxyFactoryBean has quite a few of these capabilities. Do I need to create my own implementation of this class for every EJB I use? And that version of the proxy bean will manage my EJB, the RuntimeExceptions, and caching the home, as well as other things.

    Thanks,

    -jay

  • #2
    Though I didn't try it myself I see no reason why you should not be able to use SimpleRemoteStatelessSessionProxyFactoryBean programatically.

    In any case you do not need to create own implementations. Just instantiate and parameterize it appropriately. You will need one instance per EJB interface.

    Regards,
    Andreas

    Comment


    • #3
      I tried doing something simple at first like the following and thought I could call the getObject from the proxy. But I get a NullPointerException.

      Code:
      public class BlueBookServiceProxyFactory extends
              SimpleRemoteStatelessSessionProxyFactoryBean {
      
          /**
           * 
           */
          public BlueBookServiceProxyFactory() {
              super();
              this.setJndiName(BlueBookServiceSessionHome.JNDI_NAME);
              this.setHomeInterface(BlueBookServiceSessionHome.class);
              this.setBusinessInterface(BlueBookServiceSession.class);
              this.setRefreshHomeOnConnectFailure(true);
              this.setCacheHome(true);
          }
      
      }
      
              BlueBookServiceProxyFactory proxyFactory = new BlueBookServiceProxyFactory();
              BlueBookServiceSession service = (BlueBookServiceSession)proxyFactory.getObject();
      Any thoughts?

      Comment


      • #4
        I miss two things:
        1. You should also assign a JndiTemplate to specify the server
        2. After configuration you should manually invoke afterPropertiesSet().

        Regards,
        Andreas

        Comment


        • #5
          Look at the implementation of SimpleRemoteStatelessSessionProxyFactoryBean. It essentially creates a proxy programmatically. You can use the ProxyFactory programmatic API to do the same thing, using the same remote interceptor.

          But it certainly IS possible to use Spring FactoryBeans without the IoC container, at least those that don't implement IoC interfaces such as BeanFactoryAware.

          Comment


          • #6
            Thanks Rod!

            I was able to successfully utilize the SimpleRemoteStatelessSessionProxyFactoryBean and LocalStatelessSessionProxyFactoryBean without IOC and love the abstraction that it creates.

            I was also successfully able to implement the Jdbc module without using IOC, which I was really really excited about. Everytime I tried to code my own Jdbc/Dao abstraction...I always wound up with a very limited functionality subset of what Spring provides...so it was great to get Spring working.

            Now the goal is to convince the architects about the benefits of IOC, since they can currently see the benefits of using just EJB and JDBC modules.

            Thanks!

            Comment

            Working...
            X