Here is a potential solution:

Have each bean call directly to access a connection cache, using a String
variable for the JNDI name for that cache.  Then, write a stateless session
bean that returns the JNDI name of the cache you need to access, based on
the role of the user.  Call the stateless session bean, and then use the
name it provides to lookup the correct connection cache.

This will allow you to map the caches differently for each bean, but will
encapsulate the logic of choosing the JNDI name in a single place.


Jonathan Baker
Internet Applications Division
Sybase, Inc.



Daniel Caune wrote:
>
> I need some expert advices about EJB optimization.
>
> I need my different EJBs get the connection object to a database from an
> unique "location" without giving any parameter (data source name, account
> user name, account password). There must be a alias between a J2EE and a
> database account.
>
> The "location" gets the caller role, retrieves the database account
> corresponding to this role, gets a data source corresponding to a data
> source name (defined in this location, or a resource of this location),
> creates a connection from this data source, and returns this connection
> objet to the caller.
>
> What is the best way to implement this "location" ?
>
> (1) a stateless session bean : data source and aliases between J2EE role and
> database account are defined in the bean's deployment file. The problem is
> the communication performance between two beans. If two beans run in the
> same J2EE, does the communication necessary uses RMI ? So what about
> performance ?
>
> (2) a class defined in each bean that needs a connection to database. Thus
> connection properties (data source, account user name, account password)
> must be defined in each bean deployment file. The problem would data
> redundancy, so perhaps not so easy to maintain.
>
> (3) ... (your advice ! ;-) )
>
> Thank you !
>
> Daniel
>
> ===========================================================================
> 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".

Reply via email to