Thursday, December 6, 2012

How to switch EJB client to local or remote interface without changing code

purpose of this post is to show the design of EJB client that is allowed to switch to @Local or @Remote easily without changing codes.

1. Create a java interface with all the method signatures. eg. IFooService
2. Create an empty java interface that extends IFooService and annotate it as @Local. eg. ILocalFooService.
3. Create an empty java interface that extends IFooService and annotate it as @Remote. eg. IRemoteFooService
4. Create the implementation class that implements both ILocalFooService and IRemoteFooService, eg. FooService.

1. compile IFooService as base-service.jar
2. compile ILocalSercie as local-service.jar
3. compile IRemoteService as remote-service.jar
4. compile FooService as service-implementation.jar

when running in a remote environment, include only base-service.jar and remote-service.jar in the client environment.
when running in a local environment, include only base-service.jar and local-service.jar in the client environment.
service-implementation.jar always in the service provider environment. 


  1. To ensure Search engine marketing Links possibly the safest link building companies in the marketplace.Recommended Site Continue and mail out us details discuss when you find yourself uncertain relating to a specific thing and how to use it properly reading the product site and often requested inquiries.

  2. This article has some vast and valuable information about this subject.

  3. It’s my first time to visit this site & I’m really surprised to see such impressive stuff out there.
    UI/UX design agency

  4. Thanks friends, for providing such enlightening data.
    his response

  5. The superb highly informative blog I’m about to share this with all my contacts.
    Lead conversion system squared

  6. Hey buddies, such a marvelous blog you have made I’m surprised to read such informative stuf
    mobile app design services

  7. Keep the ball rolling you have done the great job here.
    top UX designer

  8. An unbelievable blog. This blog will indisputably be definitely recommended to my friends as well.
    UI UX design company

  9. Pretty! It was really a wonderful blog. Thanks for the provided information.
    user experience consultants



Related Posts Plugin for WordPress, Blogger...