Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Genuine EJB Doubts

Status
Not open for further replies.

lecmns

Programmer
Sep 11, 2001
19
0
0
IN
Guys,

one doubt..

in a Container managed Entity Bean, can we switch the datasource runtime?
looks impossible but is there a way out?
or can we do this atleast in a Bean managed Entity Bean?

are there any merits / demerits for this kind of approach ?

I have a table 'A' in three mahcines '1', '2' and '3'..
ie., 3 datasources configured for each machine ie., '1', '2' and '3'
but all have the exact copy of table 'A' with the same name too
So, in reality, I really don't require seperate entity beans to represent
any of this data as the representation is the same
so, the requirement..

Is the JNDI server one per the application server or per EJB Container?
doubt is because, we are thinking of registering same JNDI name for same
bean using different datasources in different container instances.. !!
any suggestions?

I am pretty much confused with all these..
help me out, guys..
thankx in advance..

mns

lecMns
B'lore
 
You are misusing the term Runtime here. You are really talking about deployment time not dynamically changing the datasource on the fly.

First, yes you can deploy a single EJB Implementation multiple time in an EJB Container. Each one could reference a different datasource. Each one will need separate deployment descriptors and need to be separately jared.

Second, no you cannot use the same JNDI name. This name is unique and can only be bound to one resource (in this case EJB) in an Application Server wide fashion. The Application Server provides the JNDI service not the EJB Container. May I ask how you are running multiple Containers within a single Server Instance? I don't know of any Application Servers that support this type of explicit control. Even if you can do this, what is it gaining you except for additional maintenance headaches?

The short answer is, you will need to separately deploy each EJB with different JNDI names even though the implementation classes will remain the same.
 
a better question is why r u doing this? is this for load balancing? you mentioned that all 3 db has the same table with the same data... r u trying to load balance db using ejb's. i am not sure if this is the right approach...
 
hey..

thankx to wushutwist and DixieFlatline for quick replies..

But I am talking about switching the data source at runtime and not at the deployment time. I know that by default every Entity Bean Deployment relates to one datasource which is then onwards kinda fixed. But I wanted to know if that can be changed based on some parameter that comes from some business logic.

about the JNDI Server with Container, that was just a doubt from ma side. Thankx for clearing that. So, it's not the container instance but the application server instance that can be made. In short, within each instance of application server there will be on container each, right? yes, it is definitely a prob if maintenance comes nito picture. But then this was sounding like a solution for our client's need. I am not saying that this is a neat way to do it.

Ys, we are trying to d othis with load balancing also in mind. But that's not the only reason.

The situation is such that our client 'A' has three other clients 'b', 'c' and 'd'. As far as client 'A' is concerned, data can be in one place. But it's the data of 'b', 'c' and 'd'. Now, 'b', 'c' and 'd' wants to have their data in their own premises for security reasons. So, you know, the same schema but different data per these subclients, but the application is with 'A' and he gonan control the flow and maintani it. I know it sounds kinda complicated. I was just trying to get solutions for this.

Any suggestions.. please let me know.. as it'll definitely matter in our design of the whole architecture..

Thankx once again for the reply and suggestions and clarifications..



lecMns
B'lore
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top