diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration')
18 files changed, 1030 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/Readme.txt b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/Readme.txt new file mode 100644 index 0000000..98c39f3 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/Readme.txt @@ -0,0 +1,61 @@ +J2EE Connector Example
+----------------------
+
+The following are the steps to build, deploy, and run this sample.
+Make sure that the Java EE 5 server is running before deployment.
+
+1) Make sure the following DLLs are in the system classpath
+ (ideally, in c:\winnt\system32):
+ mfc71d.dll
+ msvcr71d.dll
+
+ You can download these DLLs from:
+ http://www.dll-files.com/dllindex/dll-files.shtml?mfc71d
+ http://www.dll-files.com/dllindex/dll-files.shtml?msvcr71d
+
+2) Copy /src/examples/jni/nativelib/LoanApp.dll to your C drive
+ (C:\LoanApp.dll).
+
+3) Make sure that the appropriate security permissions are granted to
+ the resource adapter for linking the dynamic library (LoanApp.dll)
+ by inserting the following line in the java.policy file under
+ <JDK Installation Directory>\jre\lib\security directory.
+
+ permission java.lang.RuntimePermission "loadLibrary.*";
+
+4) Compile and jar the JavaLoanApp.java, which uses JNI calls to
+ invoke functionality of LoanApp.dll library, by typing the following:
+
+ asant jnijar
+
+5) Compile the connector source files and and create the corresponding
+ connector RAR file by using the following target:
+
+ asant rar
+
+6) Deploy the connector, alongwith connector resources such as
+ connector connection pool and the associated JNDI name resource.
+
+ asant deploy_connector
+
+7) Now compile LoanRatesEJB files and create the corresponding ejbjar.
+
+ asant jar
+
+8) Deploy LoanRatesEjb.
+
+ asant deploy_common
+
+9) Compile and jar the LoanRatesEJB client application.
+
+ asant base_clientjar_common.
+
+10) Turn off the firewall, if any, and run the client now.
+
+ asant run_client
+
+11) Undeploy the connector and the EJB, and delete the build classes
+
+ asant undeploy_connector
+ asant undeploy_common
+ asant clean_all
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/build.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/build.xml new file mode 100644 index 0000000..f42b509 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/build.xml @@ -0,0 +1,47 @@ +<?xml version="1.0"?>
+<!DOCTYPE project [ <!ENTITY include SYSTEM "../../../etc/common.xml"> ]>
+
+<project name="ejb3-examples-integration" default="jar"
+ basedir="../../..">
+
+ <!-- basic settings -->
+ <property name="src.dir" value="${basedir}/src"/>
+ <property name="build.dir" value="${basedir}/build"/>
+ <property name="appname" value="LoanApplication"/>
+ <property name="client.class" value="examples.integration.loanratesejb.LoanRatesClient"/>
+ <property name="app.pkg" value="examples/integration/loanratesejb"/>
+ <property name="package" value="${app.pkg}"/>
+ <property name="pack.dir" value="${src.dir}/${app.pkg}"/>
+ <property name="jar.pkg" value="examples/integration/loanratesejb"/>
+
+ <!-- Connector specific properties -->
+
+ <property name="jnijarname" value="JavaLoanApp"/>
+ <property name="jniapp.pkg" value="examples/jni"/>
+ <property name="jni.pack.dir" value="${src.dir}/examples/jni"/>
+
+ <property name="raname" value="OutboundLoanRa"/>
+ <property name="rar.pkg" value="examples/integration/out_loan_ra"/>
+ <property name="connector.pack.dir" value="${src.dir}/examples/integration/out_loan_ra"/>
+ <property name="connector.connection.pool.name" value="OutboundLoanRaPool"/>
+ <property name="connector.connection.pool.jndiname" value="OutboundLoanJNDIName"/>
+ <property name="connector.connectiondefinition" value="javax.resource.cci.ConnectionFactory"/>
+
+
+ <!-- Include common.xml -->
+ &include;
+
+ <property name="assemble.dir" value="${assemble.ejbjar}"/>
+ <property name="deploy.file" value="${ejbjar}"/>
+
+ <target name="jar" depends="compile_common, create_ejbjar_common"/>
+ <target name="ear" depends="jar,create_ear_common"/>
+
+ <target name="clean_all" depends="clean_common, clean_ejbjar_common, clean_clientjar_common, clean_jnijar_common, clean_rar_common"/>
+
+ <!-- Targets pertaining to Connector -->
+ <target name="jnijar" depends="compile_jni_common,create_jnijar_common"/>
+ <target name="rar" depends="compile_connector_common,create_rar_common"/>
+ <target name="deploy_connector" depends="deploy_connector_common, deploy-connector-resource_common"/>
+ <target name="undeploy_connector" depends="undeploy_connector_resource_common, undeploy_connector_common"/>
+</project>
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java new file mode 100644 index 0000000..39efddd --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java @@ -0,0 +1,9 @@ +package examples.integration.loanratesejb;
+
+public interface LoanRates{
+
+ public float getHomeEquityRate();
+}
+
+
+
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java new file mode 100644 index 0000000..f01f25e --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java @@ -0,0 +1,46 @@ +package examples.integration.loanratesejb;
+
+import javax.resource.cci.*;
+
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.annotation.*;
+
+@Stateless
+@Remote(LoanRates.class)
+@TransactionManagement(TransactionManagementType.BEAN)
+public class LoanRatesBean implements LoanRates{
+
+ @Resource (name="OutboundLoanJNDIName")
+ public javax.resource.cci.ConnectionFactory connFactory;
+
+ public float getHomeEquityRate() {
+ float retVal=0;
+
+ System.out.println("LoanRatesBean.getHomeEquityRate() called");
+
+ try {
+ javax.resource.cci.Connection myCon = connFactory.getConnection();
+ javax.resource.cci.Interaction interaction = myCon.createInteraction();
+ javax.resource.cci.MappedRecord recordIn = connFactory.getRecordFactory().createMappedRecord("");
+
+ recordIn.put("HomeEquityRate","");
+
+ javax.resource.cci.MappedRecord recordOut =
+ (javax.resource.cci.MappedRecord)interaction.execute(null, (javax.resource.cci.Record)recordIn);
+
+ myCon.close();
+
+ Object result = recordOut.get("HomeEquityRate");
+ retVal = ((Float)result).floatValue();
+
+ } catch(Exception e) {
+
+ e.printStackTrace();
+ }
+
+ return retVal;
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java new file mode 100644 index 0000000..8a10952 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java @@ -0,0 +1,18 @@ +package examples.integration.loanratesejb;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Hashtable;
+import javax.naming.*;
+
+public class LoanRatesClient {
+
+ public static void main(String[] args) throws Exception{
+
+ Context ctx = new InitialContext();
+
+ LoanRates loanRates = (LoanRates) ctx.lookup("examples.integration.loanratesejb.LoanRates");
+
+ System.out.println("getHomeEquityRate() returned: " + loanRates.getHomeEquityRate() + ". Take a look at application server log or console for messages from LoanRatesEJB and OutboundLoanRA.");
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionFactoryImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionFactoryImpl.java new file mode 100644 index 0000000..02e4aaf --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionFactoryImpl.java @@ -0,0 +1,69 @@ +package examples.integration.out_loan_ra;
+
+import java.io.*;
+
+import javax.resource.Referenceable;
+import javax.resource.*;
+import javax.resource.spi.*;
+import javax.naming.Reference;
+import javax.resource.cci.*;
+
+public class ConnectionFactoryImpl implements ConnectionFactory, Serializable, Referenceable {
+
+ private ManagedConnectionFactory manConnFactory;
+ private ConnectionManager connManager;
+ private Reference ref;
+
+ public ConnectionFactoryImpl(ManagedConnectionFactory manConnFactory, ConnectionManager connManager) {
+
+ System.out.println("ConnectionFactoryImpl(ManagedConnectionFactory manConnFactory, ConnectionManager connManager) called");
+
+ this.manConnFactory = manConnFactory;
+
+ this.connManager = connManager;
+ }
+
+ public javax.resource.cci.Connection getConnection() throws ResourceException {
+
+ System.out.println("ConnectionFactoryImpl.getConnection() called");
+
+ javax.resource.cci.Connection conn = null;
+
+ conn = (javax.resource.cci.Connection) connManager.allocateConnection(manConnFactory, null);
+
+ return conn;
+ }
+
+ public javax.resource.cci.Connection getConnection(ConnectionSpec cSpec) throws ResourceException {
+
+ System.out.println("ConnectionFactoryImpl.getConnection(ConnectionSpec cSpec) called");
+
+ javax.resource.cci.Connection conn = null;
+
+ ConnectionRequestInfo connRequestInfo = new ConnectionRequestInfoImpl();
+
+ conn = (javax.resource.cci.Connection) connManager.allocateConnection(manConnFactory, connRequestInfo);
+
+ return conn;
+ }
+
+ public ResourceAdapterMetaData getMetaData() throws ResourceException {
+
+ return new ResourceAdapterMetaDataImpl();
+ }
+
+ public RecordFactory getRecordFactory() throws ResourceException {
+
+ return new RecordFactoryImpl();
+ }
+
+ public void setReference(Reference ref) {
+
+ this.ref = ref;
+ }
+
+ public Reference getReference() {
+
+ return ref;
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionImpl.java new file mode 100644 index 0000000..5cd6b72 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionImpl.java @@ -0,0 +1,54 @@ +package examples.integration.out_loan_ra;
+
+import java.util.*;
+
+import javax.resource.cci.*;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.IllegalStateException;
+import javax.resource.spi.*;
+import javax.resource.NotSupportedException;
+
+public class ConnectionImpl implements javax.resource.cci.Connection {
+
+ private ManagedConnectionImpl manConn;
+
+ ConnectionImpl(ManagedConnectionImpl manConn) {
+
+ System.out.println("ConnectionImpl(ManagedConnectionImpl) called");
+
+ this.manConn = manConn;
+ }
+
+ public Interaction createInteraction() throws ResourceException {
+
+ return new InteractionImpl(this);
+ }
+
+ public javax.resource.cci.LocalTransaction getLocalTransaction() throws ResourceException {
+
+ throw new NotSupportedException("Local transactions are not supported.");
+ }
+
+ public ResultSetInfo getResultSetInfo() throws ResourceException {
+
+ throw new NotSupportedException("ResultSet records are not supported.");
+ }
+
+ public void close() throws ResourceException {
+
+ System.out.println("ConnectionImpl.close() called");
+
+ if (manConn == null)
+ return;
+
+ manConn.sendEvent(ConnectionEvent.CONNECTION_CLOSED, null, this);
+
+ manConn = null;
+ }
+
+ public ConnectionMetaData getMetaData() throws ResourceException {
+
+ return new ConnectionMetaDataImpl(manConn);
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionMetaDataImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionMetaDataImpl.java new file mode 100644 index 0000000..e51860b --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionMetaDataImpl.java @@ -0,0 +1,31 @@ +package examples.integration.out_loan_ra;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.*;
+import javax.resource.spi.*;
+
+public class ConnectionMetaDataImpl implements ConnectionMetaData {
+
+ private ManagedConnectionImpl manConn;
+
+ public ConnectionMetaDataImpl (ManagedConnectionImpl manConn) {
+
+ this.manConn = manConn;
+ }
+
+ public String getEISProductName() throws ResourceException {
+
+ return "Loan Application DLL";
+ }
+
+ public String getEISProductVersion() throws ResourceException {
+
+ return "1.0";
+ }
+
+ public String getUserName() throws ResourceException {
+
+ return null;
+ }
+}
+
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionRequestInfoImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionRequestInfoImpl.java new file mode 100644 index 0000000..cbfa9d8 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionRequestInfoImpl.java @@ -0,0 +1,27 @@ +package examples.integration.out_loan_ra;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+public class ConnectionRequestInfoImpl implements ConnectionRequestInfo {
+
+ public ConnectionRequestInfoImpl() {
+ }
+
+ public boolean equals(Object object) {
+
+ if (object == null) return false;
+
+ if (object instanceof ConnectionRequestInfoImpl) {
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+
+ public int hashCode() {
+
+ return (new String("ConnectionRequestInfoImpl")).hashCode();
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionSpecImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionSpecImpl.java new file mode 100644 index 0000000..dd426f0 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionSpecImpl.java @@ -0,0 +1,9 @@ +package examples.integration.out_loan_ra;
+
+import javax.resource.cci.*;
+
+public class ConnectionSpecImpl implements ConnectionSpec {
+
+ public ConnectionSpecImpl() {
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/InteractionImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/InteractionImpl.java new file mode 100644 index 0000000..2f532f9 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/InteractionImpl.java @@ -0,0 +1,96 @@ +package examples.integration.out_loan_ra;
+
+import examples.jni.JavaLoanApp;
+
+import java.util.*;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.IllegalStateException;
+import javax.resource.cci.*;
+import java.lang.reflect.*;
+import java.lang.*;
+
+public class InteractionImpl implements Interaction {
+
+ Connection conn = null;
+
+ public InteractionImpl(Connection conn) {
+
+ System.out.println("InteractionImpl(Connection conn) called");
+
+ this.conn = conn;
+ }
+
+ public javax.resource.cci.Connection getConnection() {
+
+ return conn;
+ }
+
+ public void close() throws ResourceException {
+
+ conn = null;
+ }
+
+ public boolean execute (InteractionSpec iSpec, Record in, Record out) throws ResourceException {
+
+ System.out.println ("InteractionImpl.execute(InteractionSpec iSpec, Record in, Record out) called");
+
+ out = exec((MappedRecord)in,(MappedRecord)out);
+
+ if (out != null) {
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+
+ public Record execute (InteractionSpec iSpec, Record in) throws ResourceException {
+
+ System.out.println ("InteractionImpl.execute(InteractionSpec iSpec, Record in) called");
+
+ MappedRecord out = new MappedRecordImpl();
+
+ return exec((MappedRecord)in, out);
+ }
+
+ Record exec(MappedRecord in, MappedRecord out) throws ResourceException {
+
+ try {
+
+ System.out.println("InteractionImpl.exec(MappedRecord in, MappedRecord out) called");
+
+ Set keys = in.keySet();
+ Iterator iterator = keys.iterator();
+
+ while (iterator.hasNext()) {
+
+ String key = (String)iterator.next();
+
+ if (key.equalsIgnoreCase("HomeEquityRate")) {
+
+ JavaLoanApp jlaObj = new JavaLoanApp("C:\\LoanApp.dll");
+ float equityRate = jlaObj.getHomeEquityLoanRate();
+ System.out.println ("JNI Call Returned: " + equityRate);
+ out.put(key, new Float(equityRate));
+ }
+ }
+
+ return out;
+ }
+ catch(Exception e) {
+
+ throw new ResourceException(e.getMessage());
+ }
+ }
+
+ public ResourceWarning getWarnings() throws ResourceException {
+
+ return null;
+ }
+
+ public void clearWarnings() throws ResourceException {
+
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/META-INF/ra.xml b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/META-INF/ra.xml new file mode 100644 index 0000000..7e08c79 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/META-INF/ra.xml @@ -0,0 +1,28 @@ +<?xml version='1.0' encoding='UTF-8'?>
+<connector
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ version="1.5"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ >
+ <display-name>OutboundLoanRa</display-name>
+ <vendor-name>Vendor Name</vendor-name>
+ <eis-type>EIS Type</eis-type>
+ <resourceadapter-version>1.5</resourceadapter-version>
+ <license>
+ <license-required>false</license-required>
+ </license>
+ <resourceadapter>
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>examples.integration.out_loan_ra.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
+ <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>examples.integration.out_loan_ra.ConnectionFactoryImpl</connectionfactory-impl-class>
+ <connection-interface>javax.resource.cci.Connection</connection-interface>
+ <connection-impl-class>examples.integration.out_loan_ra.ConnectionImpl</connection-impl-class>
+ </connection-definition>
+ <transaction-support>LocalTransaction</transaction-support>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java new file mode 100644 index 0000000..3d3407e --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java @@ -0,0 +1,100 @@ +package examples.integration.out_loan_ra;
+
+import java.io.*;
+import java.util.*;
+
+import javax.resource.*;
+import javax.resource.spi.*;
+import javax.resource.spi.security.PasswordCredential;
+import javax.resource.spi.SecurityException;
+import javax.security.auth.Subject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+public class ManagedConnectionFactoryImpl implements ManagedConnectionFactory, Serializable {
+
+ private PrintWriter manConnLogWriter;
+
+ public ManagedConnectionFactoryImpl() {
+
+ System.out.println("ManagedConnectionFactoryImpl() called");
+ }
+
+ public Object createConnectionFactory(ConnectionManager connManager) throws ResourceException {
+
+ System.out.println("ManagedConnectionFactoryImpl.createConnectionFactory(ConnectionManager) called");
+
+ return new ConnectionFactoryImpl(this, connManager);
+ }
+
+ public Object createConnectionFactory() throws ResourceException {
+ throw new ResourceException ("How can you call this method in a managed environment?");
+ }
+
+
+ public ManagedConnection createManagedConnection (Subject subject, ConnectionRequestInfo connRequestInfo) {
+
+ System.out.println ("ManagedConnectionFactoryImpl.createManagedConnection (Subject, ConnectionRequestInfo) called");
+
+ return new ManagedConnectionImpl (this);
+ }
+
+
+ public ManagedConnection matchManagedConnections(Set connSet, Subject subject, ConnectionRequestInfo connRequestInfo)
+ throws ResourceException {
+
+ System.out.println("ManagedConnectionFactoryImpl.matchManagedConnections(Set, Subject, ConnectionRequestInfo) called");
+
+ Iterator iterator = connSet.iterator();
+
+ while (iterator.hasNext()) {
+
+ Object object = iterator.next();
+
+ if (object instanceof ManagedConnectionImpl) {
+
+ ManagedConnectionImpl manConn = (ManagedConnectionImpl) object;
+ ManagedConnectionFactory manConnFactory = manConn.getManagedConnectionFactory();
+
+ if (manConnFactory.equals(this)) {
+
+ System.out.println("From ManagedConnectionFactoryImpl.matchManagedConnections() -> Connection matched");
+
+ return manConn;
+ }
+ }
+ }
+
+ System.out.println("From ManagedConnectionFactoryImpl.matchManagedConnections() -> Connection did not match");
+
+ return null;
+ }
+
+ public void setLogWriter(PrintWriter manConnLogWriter) {
+
+ this.manConnLogWriter = manConnLogWriter;
+ }
+
+ public PrintWriter getLogWriter() {
+
+ return manConnLogWriter;
+ }
+
+ public boolean equals(Object object) {
+
+ if (object == null) return false;
+
+ if (object instanceof ManagedConnectionFactoryImpl) {
+
+ return true;
+ } else {
+
+ return false;
+ }
+ }
+
+ public int hashCode() {
+
+ return (new String("ManagedConnectionFactoryImpl")).hashCode();
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java new file mode 100644 index 0000000..2087172 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java @@ -0,0 +1,135 @@ +package examples.integration.out_loan_ra;
+
+import java.io.*;
+import java.util.*;
+
+import javax.resource.*;
+import javax.resource.spi.*;
+import javax.resource.spi.security.PasswordCredential;
+import javax.resource.spi.IllegalStateException;
+import javax.resource.spi.SecurityException;
+import javax.resource.NotSupportedException;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+public class ManagedConnectionImpl implements ManagedConnection {
+
+ private ConnectionEventListener connEventListener;
+ private ManagedConnectionFactory manConnFactory;
+ private boolean isDestroyed;
+ private PrintWriter manConnLogWriter;
+
+ ManagedConnectionImpl (ManagedConnectionFactory manConnFactory) {
+
+ System.out.println("ManagedConnectionImpl(ManagedConnectionFactory) called");
+
+ this.manConnFactory = manConnFactory;
+ }
+
+ public Object getConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo)
+ throws ResourceException {
+
+ System.out.println("ManagedConnectionImpl.getConnection(Subject, ConnectionRequestInfo) called");
+
+ ConnectionImpl conn = new ConnectionImpl(this);
+
+ return conn;
+ }
+
+ public void destroy() throws ResourceException {
+
+ System.out.println("ManagedConnectionImpl.destroy() called");
+
+ isDestroyed=true;
+
+ cleanup();
+ }
+
+ public void cleanup() throws ResourceException {
+
+ System.out.println("ManagedConnectionImpl.cleanup() called");
+ }
+
+ public void associateConnection(Object connection) throws ResourceException {
+
+ throw new NotSupportedException("ManagedConnectionImpl.associateConnection() not supported.");
+ }
+
+ public void addConnectionEventListener(ConnectionEventListener connEventListener) {
+
+ System.out.println("ManagedConnectionImpl.addConnectionEventListener(ConnectionEventListener) called");
+
+ this.connEventListener = connEventListener;
+ }
+
+ public void removeConnectionEventListener (ConnectionEventListener connEventListener) {
+
+ }
+
+ public XAResource getXAResource() throws ResourceException {
+
+ throw new NotSupportedException("Global transactions are not supported");
+ }
+
+ public LocalTransaction getLocalTransaction() throws ResourceException {
+
+ throw new NotSupportedException("Local transactions are not supported");
+ }
+
+ public ManagedConnectionMetaData getMetaData() throws ResourceException {
+
+ if (isDestroyed)
+ throw new ResourceException ("Managed connection has already been closed.");
+
+ return new ManagedConnectionMetaDataImpl (this);
+ }
+
+ public void setLogWriter(PrintWriter manConnLogWriter) {
+
+ this.manConnLogWriter = manConnLogWriter;
+ }
+
+ public PrintWriter getLogWriter() {
+
+ return manConnLogWriter;
+ }
+
+ void sendEvent(int eventType, Exception e, Object connHandle) {
+
+ System.out.println("ManagedConnectionImpl.sendEvent(int, e, connHandle) called");
+
+ ConnectionEvent connEvent = null;
+
+ if (e == null)
+ connEvent = new ConnectionEvent(this, eventType);
+ else
+ connEvent = new ConnectionEvent(this, eventType, e);
+
+ connEvent.setConnectionHandle(connHandle);
+
+ switch (connEvent.getId()) {
+ case ConnectionEvent.CONNECTION_CLOSED:
+ this.connEventListener.connectionClosed(connEvent);
+ break;
+ case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
+ this.connEventListener.localTransactionStarted(connEvent);
+ break;
+ case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
+ this.connEventListener.localTransactionCommitted(connEvent);
+ break;
+ case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
+ this.connEventListener.localTransactionRolledback(connEvent);
+ break;
+ case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
+ this.connEventListener.connectionErrorOccurred(connEvent);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported event: " + connEvent.getId());
+ }
+ }
+
+ ManagedConnectionFactory getManagedConnectionFactory() {
+
+ return manConnFactory;
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionMetaDataImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionMetaDataImpl.java new file mode 100644 index 0000000..cc47162 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionMetaDataImpl.java @@ -0,0 +1,35 @@ +package examples.integration.out_loan_ra;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.IllegalStateException;
+import javax.resource.spi.*;
+
+public class ManagedConnectionMetaDataImpl implements ManagedConnectionMetaData {
+
+ private ManagedConnectionImpl manConn;
+
+ public ManagedConnectionMetaDataImpl(ManagedConnectionImpl manConn) {
+
+ this.manConn = manConn;
+ }
+
+ public String getEISProductName() throws ResourceException {
+
+ return "Loan Application DLL";
+ }
+
+ public String getEISProductVersion() throws ResourceException {
+
+ return "1.0";
+ }
+
+ public int getMaxConnections() throws ResourceException {
+
+ return 1;
+ }
+
+ public String getUserName() throws ResourceException {
+
+ return null;
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/MappedRecordImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/MappedRecordImpl.java new file mode 100644 index 0000000..7ade217 --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/MappedRecordImpl.java @@ -0,0 +1,121 @@ +package examples.integration.out_loan_ra;
+
+import java.util.*;
+
+public class MappedRecordImpl implements javax.resource.cci.MappedRecord {
+
+ private String recordName;
+ private String recordDescription;
+ private HashMap mappedRecord;
+
+ public MappedRecordImpl() {
+
+ mappedRecord = new HashMap();
+ }
+
+ public MappedRecordImpl (String recordName) {
+
+ mappedRecord = new HashMap();
+ this.recordName = recordName;
+ }
+
+ public String getRecordName() {
+
+ return this.recordName;
+ }
+
+ public void setRecordName(String recordName) {
+
+ this.recordName = recordName;
+ }
+
+ public String getRecordShortDescription() {
+
+ return recordDescription;
+ }
+
+ public void setRecordShortDescription(String recordDescription) {
+
+ this.recordDescription = recordDescription;
+ }
+
+ public boolean equals(Object object) {
+
+ if(!(object instanceof MappedRecordImpl))
+ return false;
+
+ MappedRecordImpl mappedRecordObject = (MappedRecordImpl)object;
+
+ return (recordName == mappedRecordObject.recordName) && mappedRecord.equals(mappedRecordObject.mappedRecord);
+ }
+
+ public int hashCode() {
+
+ return (new String("MappedRecordImpl")).hashCode();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+
+ return this.clone();
+ }
+
+ public void clear() {
+
+ mappedRecord.clear();
+ }
+
+ public boolean containsKey(Object key) {
+
+ return mappedRecord.containsKey(key);
+ }
+
+ public boolean containsValue(Object value) {
+
+ return mappedRecord.containsValue(value);
+ }
+
+ public Set entrySet() {
+
+ return mappedRecord.entrySet();
+ }
+
+ public Object get(Object object) {
+
+ return mappedRecord.get(object);
+ }
+
+ public boolean isEmpty(){
+
+ return mappedRecord.isEmpty();
+ }
+
+ public Set keySet(){
+
+ return mappedRecord.keySet();
+ }
+
+ public Object put(Object key, Object value) {
+
+ return mappedRecord.put(key, value);
+ }
+
+ public void putAll(Map map) {
+
+ mappedRecord.putAll (map);
+ }
+
+ public Object remove(Object object) {
+
+ return mappedRecord.remove(object);
+ }
+
+ public int size() {
+
+ return mappedRecord.size();
+ }
+
+ public Collection values() {
+
+ return mappedRecord.values();
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/RecordFactoryImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/RecordFactoryImpl.java new file mode 100644 index 0000000..d3f051a --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/RecordFactoryImpl.java @@ -0,0 +1,20 @@ +package examples.integration.out_loan_ra;
+
+import javax.resource.cci.*;
+import java.util.Map;
+import java.util.Collection;
+import javax.resource.ResourceException;
+import javax.resource.NotSupportedException;
+
+public class RecordFactoryImpl implements javax.resource.cci.RecordFactory{
+
+ public MappedRecord createMappedRecord(String recordName) throws ResourceException {
+
+ return new MappedRecordImpl(recordName);
+ }
+
+ public IndexedRecord createIndexedRecord(String recordName) throws ResourceException {
+
+ throw new NotSupportedException("IndexedRecords are not supported.");
+ }
+}
\ No newline at end of file diff --git a/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ResourceAdapterMetaDataImpl.java b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ResourceAdapterMetaDataImpl.java new file mode 100644 index 0000000..44c153f --- /dev/null +++ b/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ResourceAdapterMetaDataImpl.java @@ -0,0 +1,124 @@ +package examples.integration.out_loan_ra;
+
+import java.io.*;
+
+import javax.resource.Referenceable;
+import javax.resource.*;
+import javax.resource.spi.*;
+import javax.naming.Reference;
+import javax.resource.cci.*;
+
+public class ResourceAdapterMetaDataImpl implements ResourceAdapterMetaData {
+
+ private String adapterName;
+ private String adapterShortDescription;
+ private String adapterVendorName;
+ private String adapterVersion;
+ private String[] interactionSpecsSupported;
+ private String specVersion;
+ private boolean supportsExecuteWithInputAndOutputRecord;
+ private boolean supportsExecuteWithInputRecordOnly;
+ private boolean supportsLocalTransactionDemarcation;
+
+ // Additional properties
+ private boolean supportsGlobalTransactions;
+ private boolean supportsLifecycleManagement;
+ private boolean supportsMessageInflow;
+ private boolean supportsTransactionInflow;
+ private boolean supportsConnectionManagement;
+ private boolean supportsSecurityManagement;
+
+ public ResourceAdapterMetaDataImpl() {
+
+ adapterName = "Loan Application Resource Adapter";
+ adapterShortDescription = "Loan Application Resource Adapter provides connectivity to Loan Application DLL";
+ adapterVendorName = "Connectors Inc.";
+ adapterVersion = "1.0";
+ interactionSpecsSupported[0] = "InteractionImpl";
+ specVersion = "1.5";
+ supportsExecuteWithInputAndOutputRecord = true;
+ supportsExecuteWithInputRecordOnly = true;
+ supportsLocalTransactionDemarcation = false;
+ supportsGlobalTransactions = false;
+ supportsLifecycleManagement = false;
+ supportsMessageInflow = false;
+ supportsTransactionInflow = false;
+ supportsConnectionManagement = true;
+ supportsSecurityManagement = false;
+ }
+
+ public String getAdapterName() {
+
+ return adapterName;
+ }
+
+ public String getAdapterShortDescription() {
+
+ return adapterShortDescription;
+ }
+
+ public String getAdapterVendorName() {
+
+ return adapterVendorName;
+ }
+
+ public String getAdapterVersion() {
+
+ return adapterVersion;
+ }
+
+ public String[] getInteractionSpecsSupported() {
+
+ return interactionSpecsSupported;
+ }
+
+ public String getSpecVersion() {
+
+ return specVersion;
+ }
+
+ public boolean supportsExecuteWithInputAndOutputRecord() {
+
+ return supportsExecuteWithInputAndOutputRecord;
+ }
+
+ public boolean supportsExecuteWithInputRecordOnly() {
+
+ return supportsExecuteWithInputRecordOnly;
+ }
+
+ public boolean supportsLocalTransactionDemarcation() {
+
+ return supportsLocalTransactionDemarcation;
+ }
+
+ public boolean supportsGlobalTransactions() {
+
+ return supportsGlobalTransactions;
+ }
+
+ public boolean supportsLifecycleManagement() {
+
+ return supportsLifecycleManagement;
+ }
+
+ public boolean supportsMessageInflow() {
+
+ return supportsMessageInflow;
+ }
+
+ public boolean supportsTransactionInflow() {
+
+ return supportsTransactionInflow;
+ }
+
+ public boolean supportsConnectionManagement() {
+
+ return supportsConnectionManagement;
+ }
+
+ public boolean supportsSecurityManagement() {
+
+ return supportsSecurityManagement;
+ }
+}
\ No newline at end of file |
