Albert,

You can store the data in a singleton class that you access
from your stateless session beans.

class MyStatelessSessionBean extends ...
{
        public String getReadOnlyTableData1()
        {
                MySingleton singleton = MySingleton.getInstance();
                return singleton.getData1();
        }
        public int getReadOnlyTableData2()
        {
                MySingleton singleton = MySingleton.getInstance();
                return singleton.getData2();
        }
        .... etc.
}

class MySingleton
{
        //Singleton instance
        private static MySingleton singleton = null;

        //Read-only RDBMS data
        private String data1;
        private int data2;
        ... et cetera

        //Private constructor!
        private MySingleton()
        {
                //Read the read-only RDBMS data here
        }

        public synchronized static MySingleton getInstance()
        {
                if(singleton == null)
                {
                        singleton = new MySingleton();
                }                       
                return singleton;
        }
        
        public String getData1() {return data1;}
        public int getData2() {return data2;}
        ... et cetera
}


Later,
Sean

        
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Albert Brotzer
> Sent: Wednesday, April 12, 2000 1:25 PM
> To: [EMAIL PROTECTED]
> Subject: Caching data
> 
> 
> Hello everybody,
> 
> my application uses a databasetable with some readonly data. Almost every
> Bean in my application needs access to this data. I'd like avoid the
> overhead of reading the data from the database whenever some Bean 
> needs it.
> 
> I already tried to use a Stateless Session Bean as a cache for 
> data. In the
> ejbCreate() method of this bean I read in the data from the database and
> store it in instance variables of that bean. I thought, that the 
> ejbCreate()
> method for stateless session beans would only be called once. But 
> apparently
> it is called every time a client invokes the create() method of 
> my stateless
> session bean.
> 
> Am I doing something stupid? Does someone know a 
> solution/workaround for my
> problem?
> 
> Thanks a lot for your help!
> Best Regards,
> Albert
> 
> *******************************************************************
> DELICom DPD Deutscher Paket Dienst GmbH & Co. KG
> Wailandtstrasse 1, D-63741 Aschaffenburg
> Telefon: +49 / (0)6021 / 492-6039
> Fax: +49 / (0)6021 / 492-6502
> E-Mail: [EMAIL PROTECTED]
> Internet: http://www.dpd.de
> *******************************************************************
> 
> 
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to