12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Document Type Definitions (DTDs)<br />

myStringEnv<br />

java.lang.String<br />

MyStringEnvEntryValue<br />

<br />

<br />

ejb/Sort<br />

Session<br />

SortHome<br />

Sort<br />

sort<br />

<br />

<br />

<br />

reference to a jdbc datasource mentioned down in the DD section<br />

<br />

jdbc/CheckingDataSource<br />

javax.sql.DataSource<br />

Container<br />

<br />

Example of a vendor-specific file:<br />

<br />

<br />

<br />

<br />

ejb/Sort<br />

sort<br />

<br />

<br />

jdbc/CheckingDataSource<br />

datasources/OracleDataSource<br />

<br />

<br />

For more information about environment entries, ejb-refs, or resource-refs, see the<br />

relevant sections of Sun Microsystem's EJB 2.0 specifications at www.java.sun.com/<br />

j2ee.<br />

Sample code<br />

This example shows the usage of the logical local JNDI naming context. It shows how<br />

a client uses the deployment descriptors specified in the preceding section.<br />

// get a JNDI context using the Naming service and create a remote object<br />

javax.naming.Context context = new javax.naming.InitialContext();<br />

Object ref = context.lookup("java:comp/env/ejb/Sort");<br />

SortHome home = (SortHome) javax.rmi.PortableRemoteObject.narrow(ref,<br />

SortHome.class);<br />

Sort sort = home.create();<br />

// get the value of an environment entry using JNDI<br />

Object envValue = context.lookup("java:comp/env/myStringEnv");<br />

System.out.println("Value of env entry = "+ (java.lang.String) envValue );<br />

// locate a UserTransaction object<br />

javax.transaction.UserTransaction userTransaction =<br />

(javax.transaction.UserTransaction) context.lookup("java:comp/<br />

100 BES Developer’s Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!