Chapter 11 Creating Application Clients
An application client uses JNDI to look up and gain access to EJB components, resources, and environment properties defined in an XML deployment descriptor.
An application client connects to a Jaguar server component using a JNDI environment naming context. Here is a simple implementation of an application client:
InitialContext initCntxt = new InitialContext();
Object acctRef = initCntxt.lookup("java:comp/env/ejb/acctBean");
acctBeanHome home = (acctBeanHome)
PortableRemoteObject.narrow(acctRef,
acctBeanHome.class);
Account acct = home.findByPrimaryKey(new
AcctPK(1));
String name = acct.getName();
System.out.println(name);
The application client JAR file includes a deployment descriptor that defines the JNDI environment naming context entries. This example defines the EJB reference for an acctBean:
<application-client>
<display-name>MyClient</display-name>
<ejb-ref>
<ejb-ref-name>ejb/AcctBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.sybase.acct.acctBeanHome</home>
<remote>com.sybase.acct.Account</remote>
</ejb-ref>
</application-clinet>
To create an application client in Jaguar Manager:
Copyright © 2000 Sybase, Inc. All rights reserved. |