Is is possible for an EJB to have multiple remote interfaces? Would it be possible for your bean to have a getInterface method that takes as an argument the name of an interface and then returns the Remote interface that client has requested?
you got an intresting ques.
you can do that , but each interface you write and want expose need to be a separate bean,
you can n number of ejb's deployed with different jndi names
And you can give access to your main bean which lookup for
respective bean and returns the remote interface.
client requests for ejb2---> mainEJB --- look's for ejb2 and returns remote of ejb2.
and u can have ejb1,ejb2,ejb3 with diff interfaces.
you can use a combination of the Factory-Method and Facade Patterns to accomplish this... I'am assuming you want to share the same instance of an EJB... (hence a stateful SB or EB).
Another aproach is to code different remoteInterfaces and deploy different copies of the bean under different names per remote interface you'd like to expose for example lets say you have myBeanImpl as the bean implementation and myBeanHome as the home interface you need to expose 2 diff remote interfaces lets say myBean1 and myBean2 so you deploy
myBean1-myBeanHome-myBeanImpl as bean1 and
myBean2-myBeanHome-myBeanImpl as bean2
in this case u'll have diff instances of the bean.. i donot understand why you'd wanna do this... if you want to prevent some users from executing a set of methods you could do so using the deployment descriptor....
But I'd recommend using a facade pattern