Application Configuration - JBI

Application Configuration for JBI components

This how-to shows how to use the configuration capabilities of the platform to modify connection parameters of JBI components without requiring applications to be redeployed. The technique is applicable to JavaCAPS, GlassfishESB, and OpenESB.

The scenario is based on the Application Configuration Lab How-To which implements a simple routing to read an input file and persist the data in a Database table.

The screencast consist of the following parts:

  1. Creating a simple routing using a File BC and a Database BC
  2. Configure the input filename using an Application Variable
  3. Configure the output database connection using an Application Configuration Object .

You can see some background information about Application Configuration capabilities in this narrated presentation.

Setup

The how-to assumes that you have already created two Databases - test and prod - and the associated Application Server JDBC resources. Part 5 of the GlassfishESB Introduction Tutorial shows how to create a database and setup the appropriate JDBC resources in Glassfish. This example uses JavaDB for the database, whereas how-to for the Repository technology used a MySQL database.

To create the database tables you can use a modified version of the same script. However to change from MySQL to JavaDB you will need to change the datatype LONG to BIGINT.

CREATE TABLE EMP(
EMPNO INT NOT NULL PRIMARY KEY,
ENAME VARCHAR(30),
JOB VARCHAR(30),
MGR INT,
HIREDATE DATE,
SAL BIGINT,
COMM BIGINT,
DEPTNO INT);

You can then create the required AppServer JDBC resources and connection pools from the cmd-line

Here's the commands to create the resources for the Prod database. 

> asadmin.bat create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource --restype javax.sql.DataSource --property password=admin:user=admin:databaseName=prod:serverName=localhost:portNumber=1527:loginTimeout=0 ProdDBPool
> asadmin.bat ping-connection-pool ProdDBPool
> asadmin.bat create-jdbc-resource --connectionpoolid ProdDBPool jdbc/ProdDBPool

Configuration Mechanisms

The platform provides two mechanisms for modifying connection properties:

  1. Application Variables: define variables in a binding component service unit and provide values for those variables in the Binding itself.
  2. Application Configuration Objects: a predefined set of properties for a Binding. Define a instance of this object in the Binding itself and set the values for the predefined properties. Then configure a binding component service unit to make use of this particular named instance
    E.g., here's how Application Configuration Objects and Variables work for HTTP BC

In both alternatives, the composite applications you build can reuse named Application Variables and Application Configuration Objects.

Its not easy to see why there needs to be two mechanisms for doing this, but as a general rule of thumb, you can check if a Binding supports the property you need to configure in its Application Configuration Object. If not, then you can try an Application Variable instead.

Configuring the Scenario


The first configuration we need to make is to change the expected input filename. You can see from the File BC Application Configuration Object that its not possible to do this with an ACO. So this how-to will use an Application Variable instead.

The second configuration is to change the database connection from the Test DB to the Prod DB. This config is done by modifying the JNDI name of the AppServer JDBC Resource that our Database BC Service Unit uses.

In both cases, when the composite application is modified to make use of the Application Variable or Application Configuration Object then it needs to be redeployed. However, once it is setup correctly, then both the Application Variable or Application Configuration Object can be modified by independantly of the composite application. The composite app only needs to be restarted - not redeployed - for the new configuration information to take affect.

Screencast

Here's the screencast of the scenario

Labels

platform-javacaps platform-javacaps Delete
platform-openesb platform-openesb Delete
platform-glassfishesb platform-glassfishesb Delete
type-howto type-howto Delete
type-workshop type-workshop Delete
task-configure task-configure Delete
component-bindingcomponent component-bindingcomponent Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact