2010/01/11 - Apache Beehive has been retired.

For more information, please explore the Attic.

Apache > Beehive
 

EJB Control 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. If the EJB control uses JNDI to look up an EJB, you may optionally specify the JNDI context environment properties using the @JNDIContextEnv annotation.

EJB Control Extension Examples

Session Bean EJB Control Example

This code is part of the EJB Control samples that is available in the samples directory of the Beehive source tree. This sample demonstrates an EJB control for a session bean.

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="manager",
        credentials="manager")
public interface HelloEJBControl
    extends SessionEJBControl, HelloHome, HelloRemote {
}
            

Entity Bean EJB Control Example

This sample demonstrates an EJB control for a entity bean.

package org.apache.beehive.controls.system.ejb.sample.control;

import org.apache.beehive.controls.api.bean.ControlExtension;
import org.apache.beehive.controls.system.ejb.EntityEJBControl;
import org.apache.beehive.controls.system.ejb.EJBControl.EJBHome;
import com.mycompany.MyEntityBeanHome;
import com.mycompany.MyEntityBeanRemote;

@ControlExtension
@EJBHome(jndiName="com.mycompany.MyEntityBeanHome")
public interface MyEJBControl
    extends EntityEJBControl, MyEntityBeanHome, MyEntityBeanRemote {
}