> > > > > > private static DataSource ds = null; > > > private static InitialContext ic = null; > > > > > > private void init() { > > > if (ic == null) > > > initHomes(); > > > } > > > private static synchronized void initHomes() { > > > if (ic == null) { > > > ic = new InitialContext(); > > > ds = (DataSource) ic.lookup("someDataSource); > > > } > > > } > > > > > > > Sorry but I didn't understood your example, unless you'd > > referred to ordinary classes, right? In stateless EJB there > > is no such thing as > > init() method for initialization. Or am I wrong? > > Sorry, my mistake. This is for a stateless session bean. You'd have to > include a call to init() in every business method invocation: > > public void methodA() { > init(); > //rest of code goes here. > }
Just one more thing, the "synchronized" keyword doesn't raise problems in the EJBs or since it's in a "static" method there is no problem? Actually, you should not use either static or synchronized in your ejb unless you´re using a final static field. According to the specifications this is to eliminate problems if your ejb container runs on more than 1 JVM (thanks to IBM I guess). So if you´re certain about what you´re doing (just 1 jvm for most servers) there should not be much of a problem using either static or synchronized. Sven regards, Pedro Salazar. -- PS [EMAIL PROTECTED] PGP:0E129E31D803BC61 =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". 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 "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".