summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java')
-rw-r--r--Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionFactoryImpl.java100
1 files changed, 100 insertions, 0 deletions
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