Chapter 11 Creating Application Clients


Creating an application client

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>

Steps To create an application client in Jaguar Manager:

  1. Expand the top-level Applications folder, then expand the icon that represents your application, and highlight Clients.

  2. Choose File | New Application Client and enter a name for the application client.

  3. If necessary, create the EJB client. See Chapter 9, "Creating Enterprise JavaBean Clients"

  4. Configure the application client properties. See "Configuring application client properties".


 


Copyright © 2000 Sybase, Inc. All rights reserved.