Rajendra,

I'm not sure I understand your problem very well. In the first paragraph you
mention needing to deploy beans for different sites using different databases.
Where's the dynamic behavior needed in this case. In the second paragraph you
are talking about dynamically changing the database connection with each bean
invocation. I don't know what a "set fn" is so I cannot comment on your current
solution.

I know of no portable way of setting the bean's properties at runtime. There are
other approaches that might work. For instance, in a singleton (see extensive
list discussion on singletons) you can store a map of bean instances and their
dynamic properties. For portability, you may want to use a class bound to a name
in the JNDI directory which can easily be accessed by any bean.

--Victor


Rajendra Mishra wrote:

> Victor,
>
>     It probaby would not be a good idea to deploy multiple beans with a
> different jndi name and then having logic in a session bean/servlet to call
> the appropriate bean. What happens if we have 10 sites (using different
> databases) and there are 10 beans in the system. The beans would have to be
> deployed 100 times.
>
>     I was thinking more in the line of this : Before getting any bean, set a
> property which that bean would refer to. What we are doing currently is we
> are passing the properties to each and every finder/create methods. Also
> before calling the set/get, we first set the connection properties with a
> set fn. In ejbLoad, we make sure that if we do not have a valid property
> object setup, then do not initialize the bean. This is working fine but I
> was thinking that if we could have some kind of properties associated with a
> bean which we can set/change at run-time, then it would be cleaner.  Can
> somebody tell me if this is possible?
>
> thanks.
> Raaj.
>
> ----- Original Message -----
> From: Victor Langelo <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, June 30, 2000 9:50 AM
> Subject: Re: Changng db connection on the fly
>
> > Rajendra,
> >
> > Most EJB servers support multiple connection pools. Each pool would supply
> > connections to a particular database. The connection info for each
> database is
> > part of the pool definition. You're beans would only need to know from
> which
> > pool to request a connection. The pool identifier can be saved in a bean
> > property. You can pass the pool identifier in the create method of a
> session
> > bean. For entity beans, the most portable solution would be to deploy the
> same
> > bean code multiple times with a deployment property identifying the pool.
> Then
> > the business logic would use the appropriate home depending on the
> database
> > desired.
> >
> > --Victor Langelo
> >
> >

===========================================================================
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".

Reply via email to