com.ibm.commerce.messaging.adapters.jcasample

Class SampleManagedConnection

  • java.lang.Object
    • com.ibm.commerce.messaging.adapters.jcasample.SampleManagedConnection
  • All Implemented Interfaces:
    javax.resource.spi.ManagedConnection


    public class SampleManagedConnection
    extends java.lang.Object
    implements javax.resource.spi.ManagedConnection

    This class represents a physical connection managed by an application server.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      Copyright statement.
    • Constructor Summary

      Constructors 
      Constructor and Description
      SampleManagedConnection()
      SampleManagedConnection default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        Copyright statement.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SampleManagedConnection

        public SampleManagedConnection()
                                throws javax.resource.ResourceException
        SampleManagedConnection default constructor
        Throws:
        javax.resource.ResoureceException
        javax.resource.ResourceException
    • Method Detail

      • addConnectionEventListener

        public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener evtListener)
        This method adds a connection event listener to the existing event listener list.
        Specified by:
        addConnectionEventListener in interface javax.resource.spi.ManagedConnection
        Parameters:
        The - javax.resource.spi.ConnectionEventListener that need to be added.
      • removeConnectionEventListener

        public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
        This method removes a ConnectionEventListener from the existing event listener list.
        Specified by:
        removeConnectionEventListener in interface javax.resource.spi.ManagedConnection
        Parameters:
        The - ConnectionEventListener that needs to be removed.
      • getMetaData

        public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                                 throws javax.resource.ResourceException
        This method gets the managed connection metadata.
        Specified by:
        getMetaData in interface javax.resource.spi.ManagedConnection
        Returns:
        ManagedConnectionMetaData
        Throws:
        javax.resource.ResourceException - Raised when any error occured.
      • destroy

        public void destroy()
                     throws javax.resource.ResourceException
        This method destroys the connection.
        Specified by:
        destroy in interface javax.resource.spi.ManagedConnection
        Throws:
        javax.resource.ResourceException - Raised when unable to destroy the connection.
      • associateConnection

        public void associateConnection(java.lang.Object connection)
                                 throws javax.resource.ResourceException
        This method associates this managed connection to SampleConnection. It will check if the connection is a SampleConnection.
        Specified by:
        associateConnection in interface javax.resource.spi.ManagedConnection
        Parameters:
        connection - The connection Object
        Throws:
        javax.resource.ResourceException - Raised when IllegalStateException is thrown.
      • getConnection

        public java.lang.Object getConnection(javax.security.auth.Subject subject,
                                              javax.resource.spi.ConnectionRequestInfo cri)
                                       throws javax.resource.ResourceException
        This method gets the connection.
        Specified by:
        getConnection in interface javax.resource.spi.ManagedConnection
        Parameters:
        subject - The Subject,
        cri - The ConnectionRequestInfo
        Returns:
        connection
        Throws:
        javax.resource.ResourceException
      • setConnection

        public void setConnection(SampleConnection con)
        This method sets the connection.
        Parameters:
        SampleConnection -
      • getXAResource

        public javax.transaction.xa.XAResource getXAResource()
                                                      throws javax.resource.ResourceException
        This method gets the XA resource.
        Specified by:
        getXAResource in interface javax.resource.spi.ManagedConnection
        Returns:
        This method always returns null. This method does nothing in current implementation.
        Throws:
        javax.resource.ResourceException
      • cleanup

        public void cleanup()
                     throws javax.resource.ResourceException
        This method cleans up the connections. The connection will be destroyed.
        Specified by:
        cleanup in interface javax.resource.spi.ManagedConnection
        Throws:
        javax.resource.ResourceException
      • getLocalTransaction

        public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                                throws javax.resource.ResourceException
        This method gets the local transaction.
        Specified by:
        getLocalTransaction in interface javax.resource.spi.ManagedConnection
        Returns:
        This method always returns null. This method does nothing in current implementation.
        Throws:
        javax.resource.ResourceException
      • sendEvent

        public void sendEvent(int eventType,
                              java.lang.Exception ex)
        This method sends an event. This method will invoke sendEvent(eventType, ex, null) method.
        Parameters:
        The - eventType
        The - Exception object.
      • sendEvent

        public void sendEvent(int eventType,
                              java.lang.Exception ex,
                              java.lang.Object connectionHandle)
        This method sends an event to the event listener.
        Parameters:
        eventType - The event type.
        Exception - The resouce exception raised when the connection is closed.
        connectionHandle - The connection handle
      • setLogWriter

        public void setLogWriter(java.io.PrintWriter pw)
                          throws javax.resource.ResourceException
        This method sets the log writer.
        Specified by:
        setLogWriter in interface javax.resource.spi.ManagedConnection
        Parameters:
        PrintWriter -
        Throws:
        javax.resource.ResourceException
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
                                         throws javax.resource.ResourceException
        This method gets the log writer.
        Specified by:
        getLogWriter in interface javax.resource.spi.ManagedConnection
        Returns:
        PrintWriter
        Throws:
        javax.resource.ResourceException