Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 FactoryPattern

 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody.

I am using EJB3 and want to use multiple db-layer or using 1 layer but want to design in a way so that if I want to replace the current layer with any other layer I dont have to make changes in code .
1 is JPA and
2 is Hibernate
Can I implement 1 EJB Remote in different Implementation is ok, or any suggestion or good design to do this.

Any help is really appreciated.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Factory with simple facade will do for you.

Factory Class --> Instantiate and return you Facade class super interface.

FacadeInterface --> super interface.

Facade1 ---> implements a super interface and used to access(in your case) Hibernate.

Facade2 ---> implements a same interface as facade1 and used to access(in your case) JPA.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic