28
J2EE Connector Architect ure

J2EE Connector Architecture

  • Upload
    belva

  • View
    52

  • Download
    1

Embed Size (px)

DESCRIPTION

J2EE Connector Architecture. Outline. Connector Overview Goals J2EE Integration Common Client Interface (CCI) Object Model Example Usage System Contracts Connection Pooling Transactions Security Deployment (.rar files) Future Direction. Connector Goals. - PowerPoint PPT Presentation

Citation preview

Page 1: J2EE Connector Architecture

J2EE Connector

Architecture

Page 2: J2EE Connector Architecture

J2EE Connector Architecture

(2)

CopyrightObject Computing, Inc.

Outline

• Connector Overview– Goals

– J2EE Integration

• Common Client Interface (CCI)– Object Model

– Example Usage

• System Contracts– Connection Pooling

– Transactions

– Security

• Deployment (.rar files)

• Future Direction

Page 3: J2EE Connector Architecture

J2EE Connector Architecture

(3)

CopyrightObject Computing, Inc.

Connector Goals

• Provide standardized interfaces to Enterprise Information Systems (EIS)

– Mainframe Transaction Processing (TPs) - CICS, Tuxedo

– Enterprise Resource Planning (ERP) - PeopleSoft, SAP

– Database Systems - JDBC, LDAP

• The Resource Adapter (RA) is a system-level software driver used to connect to an EIS

• The resource adapter may be utilized in a managed (application server) or non-managed environment

– Primary goal is to smoothly integrate J2EE components and EIS systems

– Support general capabilities of J2EE 1.3 application servers» Scalability (typically via Pooling, Lifecycle management, clustering)

» Distributed Transactions

» Security

Page 4: J2EE Connector Architecture

J2EE Connector Architecture

(4)

CopyrightObject Computing, Inc.

Contracts

• A resource adapter supports three types of contracts– The Application contract (may support CCI)

» A JCA Resource Adapter is not required to support any specific application contract (e.g. future versions of JDBC)

– The JCA System contracts » Connection Management

» Transaction Management

» Security Management

– The EIS protocol contract (typically proprietary)

• The packaging of the adapter could also be considered a contract– Follows J2EE jar and deployment descriptor pattern

Page 5: J2EE Connector Architecture

J2EE Connector Architecture

(5)

CopyrightObject Computing, Inc.

High-Level Connector Architecture

EIS

JCA ResourceAdapter

App Server

SecurityManager

TransactionManager

ConnectionManager

ApplicationComponent

JCASystem

Contracts

Application Contract(may be CCI)

EIS-SpecificProtocol

Container-ComponentContract

Page 6: J2EE Connector Architecture

J2EE Connector Architecture

(6)

CopyrightObject Computing, Inc.

Application Contracts

• The application contracts apply to user interaction with the Resource Adapter

– Whether from a J2EE component or standalone

• Ideally, the contracts extend standard interfaces detailed in the Connector Specification

– Called the “Common Client Interface” or CCI

– Interfaces provide standardization for:» obtaining connections

» submitting synchronous requests for record-based data

» querying metadata

» controlling local transactions

• Support for CCI is NOT required– Vendor may provide totally proprietary interfaces

Page 7: J2EE Connector Architecture

J2EE Connector Architecture

(7)

CopyrightObject Computing, Inc.

Common Client Interface and JDBC

• Like JDBC, CCI deals with record-oriented queries and follows a similar usage pattern

Function JDBC (java.sql) CCI (javax.resource.cci)

Create Connection javax.sql.DataSourceConnectionFactory + ConnectionSpec

Create Commands Connection Connection

Format Commands Statement Interaction + InteractionSpecObtain Results ResultSet RecordFactory & Records

Page 8: J2EE Connector Architecture

J2EE Connector Architecture

(8)

CopyrightObject Computing, Inc.

“Spec” classes

• CCI includes the ConnectionSpec to pass arbitrary information– An empty interface

– Implementation defines properties following JavaBean conventions (get/set)

– Standard Properties: UserName, Password

• InteractionSpec– connection.getInteraction() takes an InteractionSpec argument

– Also a JavaBean with standard properties» FunctionName

» ExecutionTimeout

» FetchSize

» InteractionVerb - synchronous actions• SYNC_SEND

• SYNC_SEND_RECEIVE (default)

• SYNC_RECEIVE

» ResultSetType - java.sql.ResultSet (FORWARD, SCROLL_SENSITIVE)

» ResultSetConcurrency - java.sql.ResultSet (READ_ONLY, UPDATABLE)

– May be bound in JNDI as a resource environment reference (like JMS Topics)

public interface javax.resource.cci.InteractionSpec extends Serializable { public static final int SYNC_SEND = 0; public static final int SYNC_SEND_RECEIVE = 1; public static final int SYNC_RECEIVE = 2;}

Page 9: J2EE Connector Architecture

J2EE Connector Architecture

(9)

CopyrightObject Computing, Inc.

Records

• An Interaction uses Record objects to qualify invocations and receive data in response

Page 10: J2EE Connector Architecture

J2EE Connector Architecture

(10)

CopyrightObject Computing, Inc.

Records (cont’d)

• Records may be created through a provided implementation of the RecordFactory interface

– The MappedRecord is a Map

– The IndexedRecord is a List

– Either may contain hierarchical structures of Records

• The create() methods of the factory take a recordName as an argument

– The factory will utilize this name to reference meta information related to the construction of the record type

• The resource adapter may include additional means to create custom records

Page 11: J2EE Connector Architecture

J2EE Connector Architecture

(11)

CopyrightObject Computing, Inc.

ResultSet

• The CCI ResultSet extends the JDBC ResultSet– Provides similar support for scrolling, type mapping, updatability

• It may not support more advanced JDBC types– Blob, Clob, Array, Ref, Distinct, Struct, customized mapping

• java.sql.ResultSetMetaData is reused– Query column name, type, etc.

• ResultSetInfo provides information on the supported ResultSet functionality

– e.g. visibility of updates and inserts

Page 12: J2EE Connector Architecture

J2EE Connector Architecture

(12)

CopyrightObject Computing, Inc.

CCI Example - CICS Connector

// STANDALONE

//create and set values for a managed connection factory for EPI

EPIManagedConnectionFactory mcf =new EPIManagedConnectionFactory();

cf.setConnectionURL("tcp://gunner.almaden.ibm.com");

cf.setServerName("SCSCPAA6");

ConnectionFactory cxf=(ConnectionFactory)mcf.createConnectionFactory();

// or J2EE (using Environment Naming Context)

InitialContext ctx = new InitialContext();

ConnectionFactory cxf = (ConnectionFactory)ctx.lookup(“java:comp/env/jca/myConnector”);

//create a connection object

Connection connection =cxf.getConnection();

//create an interaction with CICS to start transaction EPIP

Interaction interaction =connection.createInteraction();

May pass ConnectionSpec to

define identity, context, etc.

Page 13: J2EE Connector Architecture

J2EE Connector Architecture

(13)

CopyrightObject Computing, Inc.

CCI Example - CICS Connector

// Implements InteractionSpec

EPIInteractionSpec iSpec =new EPIInteractionSpec();

iSpec.setFunctionName("EPIP"); // well-known property

iSpec.setAID(AIDKey.enter); // vendor-specific property

iSpec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE); // default

// Create a record to store the response from CICS - implements Record

// Can create records in this way or through RecordFactory implementations

// obtained via ConnectionFactory.getRecordFactory()

EPIScreenRecord screen =new EPIScreenRecordImpl();

// execute w/ InteractionSpec, InputRecord, OutputRecord

boolean rc =interaction.execute(iSpec,null,screen);

//close the interaction and connection

interaction.close();

connection.close();

Page 14: J2EE Connector Architecture

J2EE Connector Architecture

(14)

CopyrightObject Computing, Inc.

Connection Management

• The connection management contract allows the resource adapter to leverage application server support for connection pooling

– May manage their own pools in a non-managed environment

• Application component (EJB, servlet, client) looks up a Connection Factory in JNDI using the Environment Naming Context (ENC)

• Component requests a Connection Handle - possibly passing additional information

import javax.resource.cci.ConnectionFactory;import javax.resource.cci.ConnectionFactory;import javax.naming.InitialContext;...InitialContext ctx = new InitialContext();ConnectionFactory fcty = (ConnectionFactory)ctx.lookup(“java:comp/env/eis/myEIS”);Connection conn = fcty.getConnection(new MyEISConnectionSpec(data));

Note that this example assumes support of CCI

Page 15: J2EE Connector Architecture

J2EE Connector Architecture

(15)

CopyrightObject Computing, Inc.

Connection Management (cont’d)

• Multiple connection handles may refer to the same underlying ManagedConnection (physical connection)

• The app server will examine its pool of connections and determine a subset which could match the request (<res-sharing-scope>)

• The app server calls matchManagedConnection() on the resource adapter with parameters:

– Information passed to getConnection() (via a ConnectionSpec if CCI)

– Security information for the current principal (javax.security.auth.Subject)

– A subset of active connections (based on app server logic)

• If none of the candidates match, the app server will request a new connection

• Note that over time the app server may associate many different connection handles with a single ManagedConnection (@see associateConnection())

Page 16: J2EE Connector Architecture

J2EE Connector Architecture

(16)

CopyrightObject Computing, Inc.

Connection Management Interaction

RA must providefor non-managed

Page 17: J2EE Connector Architecture

J2EE Connector Architecture

(17)

CopyrightObject Computing, Inc.

Transaction Management Contract

• J2EE distinguishes two types of transactions and contracts for each

• A transaction controlled external to the resource manager is an XA or JTA transaction

– The resource manager may only support one-phase commit of XA transactions

• A transaction managed internal to the resource manager is a local transaction

• An adapter may support either, both, or neither (<transaction-support>)

public interface javax.resource.spi.ManagedConnection {… javax.transaction.xa.XAResource getXAResource() throws ResourceException; javax.resource.spi.LocalTransaction getLocalTransaction() throws ResourceException;...}

Page 18: J2EE Connector Architecture

J2EE Connector Architecture

(18)

CopyrightObject Computing, Inc.

Transaction Management

• Many scenarios are problematic if all resource managers do not support XA transactions with 2PC

– The same thread of execution (involving one or more app components) may only utilize a single non-XA RA

– In general, use of non-XA and XA capable RAs may not be mixed in the same thread of execution

– Local transactions may not span container boundaries (J2EE 1.3 spec)

• But... higher performance is attained through the use of only local transactions

– But how does server know a priori what resource managers will be involved in a transaction ?

– Some advantage may be achieved through 1-PC optimization

– 2PC “last resource optimization” may be provided by some app servers

• Any number of non-transactional resource managers may be mixed with transactional ones

Page 19: J2EE Connector Architecture

J2EE Connector Architecture

(19)

CopyrightObject Computing, Inc.

XA Transaction Management

• XA transactions are initiated and terminated (commit or rollback) in two basic ways in J2EE

– By the container based on deployment descriptor settings

– Explicitly by component code (Using JTA UserTransaction)

• In neither case are low-level XA interfaces visible to components

• Typically, container-managed transactions are used– In this scenario, a transaction context is active at the time the getConnection() call is

made (upon entry into the method implementation)

– After the app server obtains a ManagedConnection, it gets the XAResource from the connection and enlists it with the transaction manager

– The final Connection.close() causes the resource to be delisted

– At method completion, the container completes the transaction and the transaction manager utilizes the two-phase commit on all previously enlisted resources

Page 20: J2EE Connector Architecture

J2EE Connector Architecture

(20)

CopyrightObject Computing, Inc.

Local Transaction Management

• Local transactions may be either container-managed or component-managed

– Components manage local transactions using a RA-specific API (typically implementing javax.resource.cci.LocalTransaction)

– The LocalTransaction instance is obtained from the connection» contains only start(), commit(), rollback()

– In situations of component-managed local transactions the app server is notified of transaction events via the ConnectionEventListener

public interface javax.resource.spi.ConnectionEventListener {… void localTransactionStarted(ConnectionEvent event); void localTransactionCommitted(ConnectionEvent event); void localTransactionRolledback(ConnectionEvent event);...}

Page 21: J2EE Connector Architecture

J2EE Connector Architecture

(21)

CopyrightObject Computing, Inc.

Security Contracts

• The application component provider has 2 options for EIS sign-on– Container -> Authentication details defined by the deployer

– Application -> Passed to getConnection() by component code

– Choice is defined in component deployment descriptor <res-auth> element

• Adapters often provide default settings in their descriptors

• Application-level authentication information is passed directly to the RM

– Opaque to the connector architecture

• Container-level authentication information is one two types– PasswordCredential

– GenericCredential

• The type passed to the adapter is defined by its deployment descriptor - <credential-interface>

Page 22: J2EE Connector Architecture

J2EE Connector Architecture

(22)

CopyrightObject Computing, Inc.

Container Authentication

• JCA utilizes the JAAS APIs to pass authentication information

• The app server creates a javax.security.auth.Subject object which contains a single principal and an instance of the correct Credential type

• The Subject instance is passed to the ManagedConnectionFactory matchManagedConnection() or createManagedConnection() methods by the app server

• The app server determines the contents of the Credential based on:– The principal identification in effect at the time of getConnection()

» May be different from the authenticated user (e.g. EJB 2.0 runAs)

– <authentication-mechanism-type> element(s)

– deployment settings for mapping of principal identifications

Page 23: J2EE Connector Architecture

J2EE Connector Architecture

(23)

CopyrightObject Computing, Inc.

Resource Principal Identification

• The resource principal identity for the adapter-EIS communication may be established by the deployer in various ways:

– Configured Identity (static)» Identity is defined in descriptor

– Principal Mapping» Each resource has a mapping of component principal -> resource principal

– Caller Impersonation» Resource principal acts on behalf of the caller principal

» Principal delegation specific to security mechanism (e.g. Kerberos)

– Credentials Mapping» The principal identity remains the same but credentials are mapped to a different

authentication domain

Page 24: J2EE Connector Architecture

J2EE Connector Architecture

(24)

CopyrightObject Computing, Inc.

Caching Manager

• Current JCA architecture includes minimal contracts for a Caching Manager

• The caching manager registers interest in transaction events– Similar to the EJB SessionSynchronization interface

– beforeCompletion() - just prior to commit()

– afterCompletion() - notifies whether transaction committed or rolledback

• The caching manager services CCI queries and resyncs with the EIS when appropriate based on the above callbacks

• Connector-based JDO implementations are Caching Managers

Page 25: J2EE Connector Architecture

J2EE Connector Architecture

(25)

CopyrightObject Computing, Inc.

Packaging and Deployment

• Resource adapters are packaged in jar files similar to application components (suffix is .rar)

• The Resource Adapter Archive contains all java and native files required to execute

• Also contains the RAR deployment descriptor - ra.xml

• Each application server typically provides a schema for an additional proprietary deployment descriptor

– JNDI bind location

– Details of security mapping

Page 26: J2EE Connector Architecture

J2EE Connector Architecture

(26)

CopyrightObject Computing, Inc.

Contents of the Deployment Descriptor

• Class file identification– <connection-interface> and <connection-impl-class>

– <connectionfactory-interface> and <connectionfactory-impl-class>

– <managedconnectionfactory-class>

• Security Settings– <authentication-mechanism-type>* - BasicPassword, Kerbv5, etc.

– <credential-interface> - PasswordCredential or GenericCredential

– <reauthentication-support> - Can ManagedConnections change principal ?

– <security-permission> - special security permissions (standard “grant” .policy syntax) » use privileged code blocks to exercise

• Misc– <license-required>

– <config-property> - misc configuration values

Page 27: J2EE Connector Architecture

J2EE Connector Architecture

(27)

CopyrightObject Computing, Inc.

Future Direction

• Specification– Pluggability of JMS Providers

– Thread Management Contract» Needed to allow asynchronous communication with EIS

» Finally have the ability to create threads (!?)

– CCI support requirement

– CCI XML support» Metadata - Query Interactions and Record types available

» Submit Interactions as XML

• Industry– Entity Bean CMP mapping to EIS ?

– Greater variety and ease of use of EIS

– Ability of new technologies to integrate with J2EE» JDO ?

Page 28: J2EE Connector Architecture

J2EE Connector Architecture

(28)

CopyrightObject Computing, Inc.

Vendors

• Insevo– CICS, IMS, JD Edwards, Baan, SAP, Siebel, PeopleSoft

– Support CCI and XML-based interface/schema repository

– Bi-directional communication

• Resource Adapters, Inc– SAP, PeopleSoft, Siebel, Oracle

– Also support XML interaction and Bi-directional communication

• SolarMetric, PrismTech, FastObjects, Versant– JDO Implementations w/JCA support

• Sonic– Can plug RAs into SonicXQ as services