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.

Steps:
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.

Packaging:
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. 


7 comments:

  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.

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

    ReplyDelete
  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

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

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

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...