Maps a JNDI reference used by a bean to the referenced bean's remote interfaces.
Class tag on the EJB that references the other EJB through its remote interfaces.
@ejbgen:ejb-ref
[home="RemoteHomeInterFace"]
[id="TagID"]
[jndi-name="JNDIName"]
[link="EJBName"]
[remote="RemoteInterface"]
[name="ReferenceName"]
[type="Entity/Session"]
home
Optional. Specifies the remote home interface of the referenced EJB.
id
Optional. Specifies the ID of the tag. For more information, see EJBGen Tag Inheritance.
jndi-name
Optional. Specifies the remote JNDI name of the referenced EJB.
link
Optional. Specifies the (descriptive) name of the referenced bean, that is the name given in the ejb-name property located in the General Settings section of the Property Editor.
remote
Optional. Specifies the remote (business) interface of the referenced EJB.
name
Optional. The name of used to reference another bean.
type
Optional. Specifies the EJB type of the referenced bean. Valid values are Entity and Session.
To use this tag, specify its attributes in one of the following ways:
Specify link to map the reference.
Specify name, jndi-name, home, remote, and type.
If the two beans are co-located in the same EJB container, consider using a local reference to allow the beans to interact without the overhead of a distributed object protocol, thereby improving performance. For more information on a local reference, see @ejbgen:ejb-local-ref Annotation.
In this example, a Band EJB references a Recording EJB. Here is the partial code for the Band EJB, with the reference definition and use shown in bold:
* @ejbgen:ejb-ref type="Entity" remote="RecordingRemote" home="RecordingRemoteHome" jndi-name="ejb.RecordingRemoteHome" * name="ejb/recordLink" * ... */ abstract public class BandBean extends GenericEntityBean implements EntityBean { ... private RecordingRemoteHome recordingRemoteHome; public void setEntityContext(EntityContext c) { ctx = c; try { javax.naming.Context ic = new InitialContext(); recordingRemoteHome = (RecordingRemoteHome)ic.lookup("java:/comp/env/ejb/recordLink"); } catch(Exception e) { System.out.println("Unable to obtain RecordingHome: " + e.getMessage()); } } ... }
The Band bean defines the reference to the Recording bean by specifying the Recording bean's type, remote home interface, remote business interface, and remote JNDI name, and it names the local reference ejb/recordLink. It uses this reference name to locate and reference the Recording bean via the InitialContext's lookup method. To learn more about JNDI naming, see the tutorial Getting Started: Enterprise JavaBeans.
The name of the Recording bean is given in the definition of that bean:
/** * @ejbgen:entity prim-key-class="bands.RecordingBeanPK" * ejb-name = "Recording" * data-source-name="cgSampleDataSource" * table-name="recording_Sample" * abstract-schema-name = "Recording" * * @ejbgen:jndi-name remote="ejb.RecordingRemoteHome" * * @ejbgen:file-generation ... * remote-home-name = "RecordingRemoteHome" * remote-class-name = "RecordingRemote" * ... */ abstract public class RecordingBean extends GenericEntityBean implements EntityBean { ... }
To see an example of a reference tag that specifies link only, see @ejbgen:ejb-local-ref Annotation.
@ejbgen:ejb-local-ref Annotation
@ejbgen:file-generation Annotation