Chapter 10: Creating Application Clients  Configuring application client properties

Chapter 10: 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 an EAServer 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>

StepsCreating an application client in EAServer 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 8, “Creating Enterprise JavaBeans Clients.”

  4. Configure the application client properties. See “Configuring application client properties”.





Copyright © 2005. Sybase Inc. All rights reserved. Configuring application client properties