EJB 3.0. Provide interfaces to clients
Suppose I am writing enterprise session bean(v开发者_运维知识库 3.0) for using it as remote bean.
I have written remote bussines interface, implemented interface's methods in a bean class(bean also uses another java objects to transfer data to client, that classes specified as serializable to be marshalled over the network) and now I want to provide that bean to clients. To use bean functionality client needs bussiness interface of that bean and also classes that are used to transfer data from bean to client.
To solve this problem I made a jar from that bean and provide it to clients. Clients then have to add this jar library to client's project and after that find the bean implementation using lookup
method from Context
class.
But when I make a jar it puts all bean classes to jar archive, so client can decompile jar's bytecode and to see the real implementation of my interface. It's not very good practice.
So how can I provide all the necessary interfaces to clients without providing the real implementation?
Put the client interface into a different package or project, and when you build the client jar, only include the class files for that client interface.
精彩评论