Perhaps the company is obtainable from the security identity. Presumably
the login authenticates the user as belonging to a company. It is a
small step from there to associate the user principal with a company
role, if that is not already done. You can then obtain the database by
iterating over companies and checking the context role:

if (ctxt.isCallerInRole(company.getRoleName()))
    ds = company.getDatasourceName();

Fred Loney
Spirited Software, Inc.
www.spiritedsw.com

----- Original Message -----
From: "Wagner Nobres [Develop]" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 14, 2001 5:10 AM
Subject: EJB Entity Dinamic Connection Cache


> In the project i work, each company has your own database, but the
> login system is the same to all. When a company logs in the system,
> the system looks for the database for the company in a specific
> table in a database x. After all, everything the company do in the
> system, will be done in you own database.
>
> The problem is the following:
>
> I use 1 entity for each table to all companies. i don�t know how to
> say to an entity bean to use a specific a data source for each company
> that login in the system. Today, a do the following:
>
> myentity.findByContactType(contactTypeId, dataBase)
>
>
> public ejbFindByContactType {String contactTypeId, String dataBase) {
>        .
>        .
>        .
>        javax.sql.DataSource test =
>
(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/base"+dataBase+"pri
v");
>        .
>        .
>        .
> }
>
> It�s terrible, no?
>
>
> I�d like to receive suggestions of how can i do that without having to
> get the dataBase number by a parameter in a find or create method...
>
>
> Thanks for all,
>
>
>
> ============================
> Wagner Nobres
> Develop Informatica Limited
> Porto Alegre, Brazil
> ============================
>
> Email: [EMAIL PROTECTED]
> +55 (51) 3219-2555
> +55 (51) 9121-9799
>
>
========================================================================
===
> 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