diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/EJB 3.0 Code/Rima Examples/src/examples/integration/out_loan_ra/ManagedConnectionImpl.java | 135 |
1 files changed, 135 insertions, 0 deletions
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 |
