How to create a bean reference in the deployment descriptor and look it up at runtime.
See the part on developing Enterprise JavaBeans in the Programmer's Guide
To use the JAR Designer to add a resource reference to the deployment descriptor, you add the reference entry and specify its properties as shown here:
The property definitions are as follows:
Specifying container indicates that the container will sign on to the resource manager in order to obtain the resource factory. SilverStream uses the same username/password bindings as those used to add the database to the server. You must specify container for CMP beans.
At deployment, you can map the resource reference to a SilverStream database connection pool. If you deploy using the JAR Designer, you specify the binding to one of the databases that is currently available to the server, using the Property Inspector as shown here:
If you deploy the EJB JAR using the SilverCmd DeployEJB, you need to specify this mapping in the command's XML input file. The following snippet shows how you the node that can accomplish this:
<obj_resourceReferenceList> <obj_resourceReference> <name>resourceRefName</name> <dataSource>dbName</dataSource> </obj_resourceReference> </obj_resourceReferenceList>
You can find a referenced resource name in the java:comp/env directory as shown here:
DataSource ds; InitialContext m_initialContext = new InitialContext(); Context contextEnv = (Context) m_initialContext.lookup("java:comp/env/"); ds = (DataSource) contextEnv.lookup("jdbc/MyDataSource");
The EJB specification states that the resource factory reference is scoped to the bean whose entry in the deployment descriptor contains the reference to the resource factory, thus, the resource factory cannot be accessed from other beans at runtime. Other beans can also define resource references using the same names without causing a a name conflict.