From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../src/examples/integration/Readme.txt | 61 ++++++++++ .../src/examples/integration/build.xml | 47 +++++++ .../integration/loanratesejb/LoanRates.java | 9 ++ .../integration/loanratesejb/LoanRatesBean.java | 46 +++++++ .../integration/loanratesejb/LoanRatesClient.java | 18 +++ .../out_loan_ra/ConnectionFactoryImpl.java | 69 +++++++++++ .../integration/out_loan_ra/ConnectionImpl.java | 54 +++++++++ .../out_loan_ra/ConnectionMetaDataImpl.java | 31 +++++ .../out_loan_ra/ConnectionRequestInfoImpl.java | 27 +++++ .../out_loan_ra/ConnectionSpecImpl.java | 9 ++ .../integration/out_loan_ra/InteractionImpl.java | 96 +++++++++++++++ .../integration/out_loan_ra/META-INF/ra.xml | 28 +++++ .../out_loan_ra/ManagedConnectionFactoryImpl.java | 100 +++++++++++++++ .../out_loan_ra/ManagedConnectionImpl.java | 135 +++++++++++++++++++++ .../out_loan_ra/ManagedConnectionMetaDataImpl.java | 35 ++++++ .../integration/out_loan_ra/MappedRecordImpl.java | 121 ++++++++++++++++++ .../integration/out_loan_ra/RecordFactoryImpl.java | 20 +++ .../out_loan_ra/ResourceAdapterMetaDataImpl.java | 124 +++++++++++++++++++ 18 files changed, 1030 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/Readme.txt create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/build.xml create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRates.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesBean.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/loanratesejb/LoanRatesClient.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionFactoryImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionMetaDataImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionRequestInfoImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ConnectionSpecImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/InteractionImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/META-INF/ra.xml create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionMetaDataImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/MappedRecordImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/RecordFactoryImpl.java create mode 100644 Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ResourceAdapterMetaDataImpl.java (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration') 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 + \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 @@ + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &include; + + + + + + + + + + + + + + + \ 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 @@ + + + OutboundLoanRa + Vendor Name + EIS Type + 1.5 + + false + + + + + examples.integration.out_loan_ra.ManagedConnectionFactoryImpl + javax.resource.cci.ConnectionFactory + examples.integration.out_loan_ra.ConnectionFactoryImpl + javax.resource.cci.Connection + examples.integration.out_loan_ra.ConnectionImpl + + LocalTransaction + false + + + 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 -- cgit v1.2.3