A client application performs business logic
and makes use of the framework provided by an underlying client.
Developing the code for a client application depends on the objects
and functions you want to exploit, and the programming model that
you want to use.
Before you begin
Install the software development resources needed to develop
client applications for use with WebSphere® Application Server. During code development,
you do not need access to the WebSphere Application Server. However, to assemble
some types of client applications you need to install files for the
client that provides the framework for the client application. Instead
of installing WebSphere Application Server you
can install the Application Client feature, which provides the same
resources and clients to aid development of client applications.
About this task
To use a client application to access a remote object on
an application server, develop your client application code as described
in the following steps and the related topics. These topics only describe
the client-specific considerations; they do not describe general client
programming models, which you should already be familiar with. Samples
for different types of client applications are provided with the Application
Client.
Procedure
- Choose the type of client that you want to use as a framework
for your client application. Decision factors for choosing
a client include whether you want to run a client application on Java
EE or J2SE; whether you want ease of use with a small installation
footprint or full-function with medium-large footprint; and whether
you need licence to copy or redistribute the client. For more information
about choosing the type of client, see Choosing a type of client.
- Develop the client application code. The following
substeps are a high-level general procedure. Information specific
to a type of client is given in the related tasks.
- Create an instance of the object that you want to access
on the remote server. You can use full Java Naming
and Directory Interface (JNDI) support to get a suitable reference
to administered objects from the server's JNDI namespace. Alternatively,
you can get suitable references to objects programmatically without
using JNDI.
Using
the javax.naming.InitialContext class, the client
application program uses the lookup operation to
access the Java Naming and Directory
Interface (JNDI) namespace. The InitialContext class
provides the lookup method to locate resources.
You
can compare the use of JNDI and programmatic techniques by looking
at the samples provided for the Java EE client and Java thin client
in an Application Client installation (for example, in
C:\wac70\samples\src\):
- Java EE client use of JNDI for BasicCalculatorHome: TechnologySamplesJ2EEClient\BasicCalculator\com\ibm\websphere\samples\technologysamples\basiccalcclient\BasicCalculatorClientJ2EE.java
- Java thin client programmatic retrieval of BasicCalculatorHome: TechnologySamplesThinClient\BasicCalculator\com\ibm\websphere\samples\technologysamples\basiccalcthinclient\BasicCalculatorClientThin.java
- Create a connection to the server. If the
server runs with security enabled, you can configure secure connections.
- Work with the objects to perform your business requirements. For example, send and receive JMS messages, update database
entries, handle error conditions, and close resources used.
- Compile or assemble the client application. This
creates the JAR or EAR file that you can deploy to make the client
application available for use.
To compile your client application,
include the JAR files needed in the CLASSPATH setting for the javac command;
for example, any extra JAR files for the client application's own
classes, JAR files for IBM® Thin
clients used, and JAR files for JDBC provider classes.
Attention: IBM-provided clients are not packaged with JDBC provider
classes. For example, the WebSphere Application Server Version 7.0 Java
Thin application client is not packaged with Apache Derby 10.2 classes.
If your client application needs to use a database class (such as
through the JNDI lookup of a datasource), you must obtain the class
files from the database provider and make them available when compiling
and running the client application.
What to do next
After you develop a client application, deploy it into the
environment you want it to run.