Java Connector Introduction

Use the Java Connector to create Java applications that integrate host data into web applications or client/server applications. This section describes the Java connector and provides tips on how to build powerful and robust applications that take advantage of the connector's features and options.

You can use the Web Builder tool to create Java projects, based on the "demo" models provided with Verastream Host Integrator, and then examine the Java code in your projects to see how the Java connector works.

EJB Support for the Java Connector

The Java connector can be used inside a stateful session EJB. In addition to the data-driven EJB approach described below, Host Integrator also supports that use the J2EE Connector Architecture (JCA) Resource Adapter.

The AppConnChannel interfaces with two Host Integrator methods: suspendConnection() and resumeConnection(). These allow an EJB to respond to the ejbPassivate() and ejbActivate() methods, respectively. Follow the guidelines below when embedding Host Integrator in EJBs:

Single-threading
Do not embed Host Integrator model connectors in multi-threaded EJBs. One of the strengths of an EJB is that it can be halted, swapped to disk, and restarted. But it is difficult to maintain a predictable host state if multiple threads are accessing the same host session. For this reason you should use only single-threaded EJB applications whenever possible.

Connector beans
The EJB specification and the J2EE application programming manual for connecting legacy data sources recommend that you use a non-visual Java Bean (“connector bean”) that represents a connection to the data source. This allows you to break down your Host Integrator solution into components--for example, one component that connects to the host, one that reads host data, another that manages internal variables, and so forth. Connector bean descriptors for Host Integrator must be marked as “don’t swap out this bean.” This restriction is required because the Host Integrator connector must maintain a TCP/IP connection to the Host Integrator Server while the connector is active.

“Passivate” and “activate” calls
If an EJB holds open database or host system connections across method calls, EJB specification requires the EJB implementer to respond to “passivate” and “activate” calls by shutting down and restoring any such connections; the implementer is also responsible for managing the persistence of any data stored by the bean (“bean-managed persistence”).

Stateless session beans

One advantage to using stateless session beans is that you can dedicate one or more of them to a particular host application model. So when a request for that session bean is received, the bean can be used to access the host and can then be immediately shut down and reinitialized, ready for the next request. Because the bean is active for only a short time, each one can service multiple users, which means it uses resources very efficiently.

You can also create stateless session bean pools, with each bean in the pool dedicated to a particular task. When an application server shuts down a stateless session bean, there’s no state to be saved. The efficiency of this approach does depend on the structure of the host application model. As a rule, when a stateless session bean is reset, it should be able to traverse to its home entity and be ready for the next request without being dependent on any previous transactions.







 

 

  Attachmate