Home and component interfaces specify the services provided by a bean. I wonder whether polymorphism can be applied to enterprise bean. Instead of writing only one bean class for a given home and component interfaces, I write two bean classes(CardBean1 and CardBean2), each of which provides different functionalities. In one <session> in the deploymen descriptor, I fill <ejb-class> with CardBean1, and in another <session> I fill <ejb-class> with CardBean2.
The clien accesses the bean services via component interface. Since both beans have the same component interface, the client (a developer) does not know which bean provides the services.
In this case, you will have to provide two JNDI names when deploying the beans - ejb/Card1 and ejb/Card2 - because you have two session tags in the DD.
Clients looking up ejb/Card1 will be able to consume the services of CardBean1 and those looking up ejb/Card2 will be able to consume the services of CardBean2. So the clients do know which bean they are talking to.
It is quite true if the client looks up home interface from the initial context. But what if the client does not lookup home from the initial context and obtain component interface from the home interface. The interface is passed to the client as an argument. Since both beans have the same interface, the client won't know which one is which. After the client invokes getEJBHome() method from this component interface, the Home interface is returned. The Home interface is the same for both bean!