JCA Resource Adapter

Hammurapi Rules features a JCA Resource Adapter. With the adapter, rule engine can be easily integrated in J2EE environment. Here we will show how to integrate family relationships inference into a web application on Apache Geronimo J2EE Application server. Once integrated, relationship inference could be another service provided by the application server. This new service could be used by multiple applications. Inference services can be used for:

  1. Infer relationships between people interactively online (as in this example).
  2. Input data verification.
  3. Insurance policy quoting.

This example demonstrate the Rule engine integration with JEE Application server through JCA resource adapter. JCA 1.5 resource adapter integrates backward and forward reasoning into J2EE environment. This example demonstrate Forward reasoning through outbound connection.Although this resource adapter can be deployed to any application server(which supports JCA 1.5), Apache Geronimo 2.1.4 is used for demonstration purpose.

Dependencies and class loading

The picture above shows dependencies between solution components.

  • The rules engine consists of specification and implementation. The client code (Web application) depends on specification.
  • The Family ties tutorial consists of the object model and rules. The client code depends on the object model, but not on the rules.
  • The resource adapter code depends on the engine, but not on the tutorial classes (rules and object model). Tutorial classes are loaded by the engine when rule session is created.

As you can see from the dependency graph, the object model and the rules specification shall be loaded by a classloader which is shared (e.g. parent classloader) by the web application and the resource adapter.

Hot deployment

As you can see from the dependency diagram, neither the client, nor the adapter depend on the rule set classes. Each managed session has its own classloader which loads rule classes. Therefore, when there is a change in the rule set, it will be picked up by the application server at the time of creation of a new managed connection (backing rule session). Applications servers (at least some of them) allow to specify connections refresh time interval so they don't get stale. Also (some) application servers allow to forcibly clear connection pools. If you use one of such application severs, you won't have to restart it after you make changes in rule sets. Changes will be picked up without interruption of operation either after the connection refresh interval, or after the connection pool cleanup.

Deployment

  1. Download and install Geronimo 2.1.4 from Apache(http://geronimo.apache.org/downloads.html).
  2. Start Geronimo server (GERONIMO_HOME\bin\start-server.bat). Make sure it starts without errors.
  3. Install Hammurapi Rules to the default location 1).
  4. Open a browser and navigate to Geronimo Administrative console http://localhost:8080/console.
  5. Login with user=system and password=manager.
  6. Click on Repositories and create a repository from the tutorial object model (Show me!).
  7. Deploy com.hammurapi.reasoning.ra.rar file from the installation using geronimo-ra.xml deployment plan (Show me!).
  8. Deploy FamilyTies.war, the deployment shall have the tutorial object model and the rar file in its dependencies (Show me!).

Infer family relationships online

  1. Open a browser and navigate to the Family ties Web tutorial home page http://localhost:8080/FamilyTies.
  2. Enter names of family members, their genders and ages, click Submit.
  3. On the next page enter source relationships between family members, click Submit.
  4. The next page displays source and inferred family relationships.

Show me!

References

1) If you install to a different location, you'll have to modify ra.xml in the .rar file.
Last modified: 2010/02/18 20:16 by Pavel Vlasov
   
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Hammurapi Group