Re: stateless session bean OR ordinary java class ?
Pedro Salazar <[email protected]>
| Newsgroups | gmane.comp.java.sun.ejb.general |
|---|---|
| Organization | Portugal Telecom Inova????o, S.A. |
| Message-ID | <[email protected]> |
On Wed, 2003-11-26 at 18:28, Juan Pablo Lorandi wrote:
> > >
> > > Sure:
> > >
> > > 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?
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".