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. 


2 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

LinkWithin

Related Posts Plugin for WordPress, Blogger...