EJB Control Tutorial
Tutorial Overview
The EJB Control is an extensible control, and you do not use it directly. To create an EJB control for an EJB, you would create a control extending the EJB Control. An extended EJB control can only represent one EJB, so you must create one for each EJB.
Extending the EJB control
- Create a Java interface extending the appropriate EJB Control interface. If the EJB is a session bean, you must extend org.apache.beehive.controls.system.ejb.SessionEJBControl, or if it is an entity bean, extend org.apache.beehive.controls.system.ejb.EntityEJBControl.
- Annotate the Java interface with @ControlExtension (org.apache.beehive.controls.api.bean.ControlExtension), so the Control Annotation Processor will know that the Java interface is a control extension.
- Have the Java interface also extend the EJB's home and business interfaces. The business interface may either by the EJB's local interface or the remote interface.
- Specifiy how the EJB control should lookup the EJB. To lookup the EJB by its JNDI name, set the EJB control's @EJBHome.jndiName annotation to the EJB's JNDI name. To lookup the EJB using an EJB link, set the EJB control's @EJBHome.ejbLink annotation to the name of the EJB link. (see Annotation).
- If the EJB control uses JNDI to look up an EJB, you may optionally specify the JNDI context environment properties using the @JNDIContextEnv annotation (see Annotation).
EJB Control Extension Example
package org.apache.beehive.controls.system.ejb.sample.control; import org.apache.beehive.controls.api.bean.ControlExtension; import org.apache.beehive.controls.system.ejb.SessionEJBControl; import org.apache.beehive.controls.system.ejb.EJBControl.EJBHome; import org.apache.beehive.controls.system.ejb.EJBControl.JNDIContextEnv; import org.apache.beehive.controls.system.ejb.sample.bean.HelloHome; import org.apache.beehive.controls.system.ejb.sample.bean.HelloRemote; @ControlExtension @EJBHome( jndiName="org.apache.beehive.controls.system.ejb.sample.HelloHome") @JNDIContextEnv( contextFactory="weblogic.jndi.WLInitialContextFactory", providerURL="t3://localhost:7001", principal="weblogic", credentials="weblogic") public interface HelloEJBControl extends SessionEJBControl, HelloHome, HelloRemote { }
This code is part of the EJB Control samples that is available in the samples directory of the Beehive source tree.