public class SampleManagedConnection
extends java.lang.Object
implements javax.resource.spi.ManagedConnection
This class represents a physical connection managed by an application server.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
Copyright statement.
|
Constructor and Description |
---|
SampleManagedConnection()
SampleManagedConnection default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionEventListener(javax.resource.spi.ConnectionEventListener evtListener)
This method adds a connection event listener to the existing event listener list.
|
void |
associateConnection(java.lang.Object connection)
This method associates this managed connection to SampleConnection.
|
void |
cleanup()
This method cleans up the connections.
|
void |
destroy()
This method destroys the connection.
|
java.lang.Object |
getConnection(javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo cri)
This method gets the connection.
|
javax.resource.spi.LocalTransaction |
getLocalTransaction()
This method gets the local transaction.
|
java.io.PrintWriter |
getLogWriter()
This method gets the log writer.
|
javax.resource.spi.ManagedConnectionMetaData |
getMetaData()
This method gets the managed connection metadata.
|
javax.transaction.xa.XAResource |
getXAResource()
This method gets the XA resource.
|
void |
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
This method removes a ConnectionEventListener from the existing event listener list.
|
void |
sendEvent(int eventType,
java.lang.Exception ex)
This method sends an event.
|
void |
sendEvent(int eventType,
java.lang.Exception ex,
java.lang.Object connectionHandle)
This method sends an event to the event listener.
|
void |
setConnection(SampleConnection con)
This method sets the connection.
|
void |
setLogWriter(java.io.PrintWriter pw)
This method sets the log writer.
|
public static final java.lang.String COPYRIGHT
public SampleManagedConnection() throws javax.resource.ResourceException
javax.resource.ResoureceException
javax.resource.ResourceException
public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener evtListener)
addConnectionEventListener
in interface javax.resource.spi.ManagedConnection
The
- javax.resource.spi.ConnectionEventListener that need to be added.public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
removeConnectionEventListener
in interface javax.resource.spi.ManagedConnection
The
- ConnectionEventListener that needs to be removed.public javax.resource.spi.ManagedConnectionMetaData getMetaData() throws javax.resource.ResourceException
getMetaData
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
- Raised when any error occured.public void destroy() throws javax.resource.ResourceException
destroy
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
- Raised when unable to destroy the connection.public void associateConnection(java.lang.Object connection) throws javax.resource.ResourceException
associateConnection
in interface javax.resource.spi.ManagedConnection
connection
- The connection Objectjavax.resource.ResourceException
- Raised when IllegalStateException
is thrown.public java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri) throws javax.resource.ResourceException
getConnection
in interface javax.resource.spi.ManagedConnection
subject
- The Subject,cri
- The ConnectionRequestInfojavax.resource.ResourceException
public void setConnection(SampleConnection con)
SampleConnection
- public javax.transaction.xa.XAResource getXAResource() throws javax.resource.ResourceException
getXAResource
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public void cleanup() throws javax.resource.ResourceException
cleanup
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public javax.resource.spi.LocalTransaction getLocalTransaction() throws javax.resource.ResourceException
getLocalTransaction
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public void sendEvent(int eventType, java.lang.Exception ex)
sendEvent(eventType, ex, null)
method.The
- eventTypeThe
- Exception object.public void sendEvent(int eventType, java.lang.Exception ex, java.lang.Object connectionHandle)
eventType
- The event type.Exception
- The resouce exception raised when the connection is closed.connectionHandle
- The connection handlepublic void setLogWriter(java.io.PrintWriter pw) throws javax.resource.ResourceException
setLogWriter
in interface javax.resource.spi.ManagedConnection
PrintWriter
- javax.resource.ResourceException
public java.io.PrintWriter getLogWriter() throws javax.resource.ResourceException
getLogWriter
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException