Sun Java System Application Server 

Samples Index

The External JNDI Resource Factory Sample Application

This sample application demonstrates:

The external JNDI resource factory used in this application is an LDAP-based object repository that enables you to store and retrieve objects on a designated LDAP server. This sample application also provides an application client component that illustrates how to access a resource factory.

Relative to install_dir/samples/jndi/apps/external/, the directory structure of this sample application is:

Building, Deploying, and Running the Application

The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:

Follow this general procedure:

  1. Build the Application. The build file, build.xml, is in the app_dir directory, specifically, install_dir/samples/jndi/apps/external.
  2. Deploy the Application The EAR file is install_dir/samples/jndi/apps/external/jndi-external.ear.
  3. Configure LDAP access for the application.
  4. Run the Application as described below.

Configuring LDAP Access

This application requires access to an LDAP server. Before running the application client, you must create a property file that contains a property specifying the LDAP server. Place the property file in a local directory accessible to the application client or in a accessible location accesible via HTTP URL.

To create the property file, copy and modify the file app_dir/src/conf/ExternalRepository.properties. The file contains three properties. Set the java.naming.provider.url>/code> property to indicate where your LDAP server is running. You may change the external.repository.name property to change the name of the external repository.

Running the Sample Application

To run the application, enter these commands:

cd  install_dir/samples/jndi/apps/external
asant run

This command invokes the application client for this sample application. The application client requires two to four arguments:

  • property.file.location specifies the location of the property file, either a local file path or a URL.
  • command.name can be either CREATE, STORE, or LOOKUP. CREATE binds the external resource factory in the LDAP server indicated in the property file. STORE and LOOKUP, store and retrieve objects from the external repository, respectively.
  • command.arg1 is used only with STORE or LOOKUP commands, and specifies the JNDI path to use.
  • command.arg2 is used only with the STORE command and specifies the object type.

The run target of the main build.xml file has four properties that you can set.

For example, to create the external repository in the remote LDAP server, use the following command:

asant
-Dproperty.file.location="URL_or_pathname_of_property_file"
-Dcommand.name="CREATE" run
To store an object in the external repository, use the following command:
asant
-Dproperty.file.location="URL_or_pathname_of_property_file"
-Dcommand.name="STORE"
-Dcommand.arg1="object_jndi_name"
-Dcommand.arg2="object_type" run
To look up an object in the external repository, use the following command:
asant -Dproperty.file.location="URL_or_pathname_of_property_file"
-Dcommand.name="LOOKUP"
-Dcommand.arg1="object_jndi_name" run

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.