• Post Reply Bookmark Topic Watch Topic
  • New Topic

How Do I Make An EJB Reusable  RSS feed

Brett Breal
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an assignment to take a large system and break it into reusable components. Although there are many potential solutions, I am heading down the path of using EJBs since our system uses many web apps under Glassfish. I studied/passed the SCBCD to get a deeper understanding of EJB technology/capability, but I am just starting to use them in practice.

My question stems from the need to make an EJB reusable by different web apps. The approach I am taking is to create different EAR files, and put the web apps and (local) ejbs into each. Here is where I would like to have a single EJB that can be used by different web apps; however, each EJB requires a different configuration.

The problem is that each EJB needs to access a different database. I have written an EJB that can access/manipulate the data as needed. The problem is the database source (specified in the <jta-data-source> element of the persistence.xml file) needs to be different for each EAR configuration. I am looking for a solution that allows me to change the data source (JNDI name) at the EAR level. Thus, each EAR would have its web apps and the same EJB, but each EJB would be configured to access a different data source. I am using Eclipse for development.

Is there a way to accomplish this task? Maybe my approach is not correct (?).

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!