Discussions

EJB design: design quest:control the creation of object used in servlet

  1. I have been out of touch with coding for a while. i would like to know the best design to the following problem

    I have a class that implements soap client. It is basically used for executing sql statements or store procedures.

    I want to use this class in the struts servlet.

    Can you please suggest best way to use this class.


    Thanks
    d_luthra

    Threaded Messages (4)

  2. Let me get this right, u have a soap client that makes DB connection directly? or cud u explain it in a more clear way?
  3. go Struts![ Go to top ]

    im assuming u want to use an instance of this business object in ur Struts Actions.

    well u have two options.
    1) manually create a servlet or plugin that gets loaded on container startup and stores an instance of your business object class in ServletContext. then in ur Struts Actions you just
    getServletContext().getAttribute("soapClientObject") and use it accordingly.

    2) use Spring. Spring's WebApplicationContext is basically a lightweight JNDI. it does most of the work for you of creating an instance of your object and putting it in a WebApplicationContext (which you in turn retrieve from ServletContext).

    if you only have one object you need to access/share between Struts Actions, the first approach may be better. but if you plan on scaling in the future at all id definitely start using Spring's IoC features.
  4. thank You[ Go to top ]

    It is a good idea. Can you please give me more information about Spring? How to download it? Never heard of it before.


    Does it create multiple instances to scale better.
  5. Spring Framework[ Go to top ]

    Search google for "spring framework" :)

    (actually quite a bit of Spring documentation is right here on TSS)