Because there are quite a few interfaces and classes that need to be developed to write an EJB, how does inheritance take place in EJBs?
A1:
Inheritance in EJBs is tricky to understand because of the many classes and interfaces involved. A simple rule of thumb to be aware of is to make sure that inheritance does not change the return types of the methods in the classes or interfaces. One example is of a child EJB inheriting the remote (or local) interface and home interfaces (remote or local) of an existing EJB. In this case, the child EJB has to ensure that the return type of the create() method is invoked on the bean's home interface object.
Entity beans are a bit more restrictive in that to override an entity bean, the create() method must not return a primary key class that is different from the parent EJB's primary key class data type.
Q2:
How does clustering affect EJBs deployed in a cluster in the WebLogic Server?
A2:
Clustering affects the EJBs in a significant way. Because EJBs are activated and passivated by the EJB container, the state of the EJB has to be replicated across all the EJB containers in all the servers in the cluster. WebLogic Server provides specially modified versions of the EJBHome and EJBObject container-generated objects to support clustering. In this scenario, the EJBHome stub class generated by the EJB container during deployment is replaced by a special-purpose stub class that keeps track of the EJBObjects in the cluster because the EJBObject is the primary component that performs client request delegation.