Using an EJB3 Control

You can add an EJB control to any of the following:

Add the Client JAR to Your Application

Before you add an EJB control, you must first add the EJB client JAR to your application's EAR. Copy the client JAR to the following location:

    EarProject/EarContent/APP-INF/lib/  

Note that an EJB3 application can automatically generate a client jar by adding the following element to the ejb-jar.xml deployment descriptor:

    <ejb-client-jar>MyEJB_ClientJar.jar</ejb-client-jar>

To Insert a New EJB Control

To add a control to your client, use the following declaration:

    @Control
    private MyCtrl myEJB3Control;

Accessing the Methods of an EJB3

After you have created an EJB3 Control, you can invoke a target EJB3 method via the EJB3 control. Specifically, the EJB3 control exposes all and only the EJB3 methods defined in the EJB3 interfaces that the control extends. You can invoke these methods simply by invoking the method with the same signature on your EJB3 control.

    myEJB3Control.someMethod();

The EJB3 control automatically manages locating and referencing the EJB3 instance, and directs method invocations to the correct instance of the target EJB.



Still need help? Post a question on the Workshop newsgroup.