2 Replies Latest reply on Nov 27, 2006 12:08 PM by peterj

    Common Beans???

    pander

      Hi,

      Not sure if this is the correct place to post this but hopefully someone on here will know the answer or be able to offer some good advice.

      In my WebApp I am using the DatabaseServerLoginModule to login my users and also perform some custom processing during the login process.... for example, if the login is validated a database query is made to grab the users' account details and setup that data within the users' session. It is during this login custom processing that I also query the database to grab some data from some lookup tables.... for example, I have tables which hold data on ISO Country codes and Descriptions, Salutations, Timezones, Languages etc. The data from these lookup tables is used to populate form fields such as drop-down boxes on the front end JSP's.

      At present, and I'm sure this must be the wrong way to do this, each user that logs in gets this information setup within their own session. The question I am hoping someone can answer is whether or not there is a way to setup "Common Beans" for your WebApp when the JBOSS starts up? All of the lookup tables I am using are totally generic and do not rely on a users ID or any other user specific data to build the lookup query...they should really only be called/queried once, perhaps when the server starts up or the WebApp is deployed, and be available to be used by any user.

      Any help would be greatly appreciated.

      Kind Regards,
      Paul.

        • 1. Re: Common Beans???
          kaobe

          Hi,

          you could use the Scheduler MBean to schedule a little module that gets this data and puts it in the JBoss Cache. Information on how to do this is offered in the JBoss documentation. From your System code you could then lookup the cache and get the information you need. If you don't like using the scheduler, you could even do it the first time the information is needed and populate the cache with your information. Following calls would just have to lookup the cache and get the information.

          Peter

          • 2. Re: Common Beans???
            peterj

            First, please do not post the same question on multiple forums.

            You could store the beans in the servlet context. For example, within doPost, you could have:

            ServletContext ctx = this.getServletContext();
            ctx.setAttribute("globalbean", bean);

            and you can use getAttribute on the context to get it later.