Class DelegatingTransactionSynchronizationRegistry

  • All Implemented Interfaces:
    javax.transaction.TransactionSynchronizationRegistry

    @Deprecated(forRemoval=true)
    public abstract class DelegatingTransactionSynchronizationRegistry
    extends Object
    implements javax.transaction.TransactionSynchronizationRegistry
    Deprecated, for removal: This API element is subject to removal in a future version.
    An equivalent class now exists in Narayana itself.
    An abstract TransactionSynchronizationRegistry implementation that delegates all method invocations to another TransactionSynchronizationRegistry.

    Design Notes

    This class is public for convenience. It is extended by other non-public internal classes.

    See Also:
    TransactionSynchronizationRegistry
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      Object getResource​(Object key)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
      boolean getRollbackOnly()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
      Object getTransactionKey()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return an opaque object to represent the transaction bound to the current thread at the time this method is called.
      int getTransactionStatus()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the status of the transaction bound to the current thread at the time this method is called.
      void putResource​(Object key, Object value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adds or replaces an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
      void registerInterposedSynchronization​(javax.transaction.Synchronization synchronization)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Registers a Synchronization instance with special ordering semantics.
      void setRollbackOnly()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
    • Constructor Detail

      • DelegatingTransactionSynchronizationRegistry

        protected DelegatingTransactionSynchronizationRegistry​(javax.transaction.TransactionSynchronizationRegistry delegate)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Parameters:
        delegate - the TransactionSynchronizationRegistry to which all method invocations will be delegated; may be null in which case every method in this class will throw an IllegalStateException when invoked
    • Method Detail

      • getTransactionKey

        public Object getTransactionKey()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Return an opaque object to represent the transaction bound to the current thread at the time this method is called.

        This method may return null.

        This object overrides Object.hashCode() and Object.equals(Object) to allow its use as the key in a Map for use by the caller. If there is no transaction currently active, this method will return null.

        The Object returned will return the same hashCode and compare equal to all other objects returned by calling this method from any component executing in the same transaction context in the same application server.

        The Object.toString() method returns a String that might be usable by a human reader to usefully understand the transaction context. The Object.toString() result is otherwise not defined. Specifically, there is no forward or backward compatibility guarantee of the results of the returned Object's Object.toString() override.

        The object is not necessarily serializable, and has no defined behavior outside the virtual machine whence it was obtained.

        Specified by:
        getTransactionKey in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        an opaque object representing the transaction bound to the current thread at the time this method is called, or null
        Throws:
        IllegalStateException - if a null delegate was supplied at construction time
      • putResource

        public void putResource​(Object key,
                                Object value)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Adds or replaces an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.

        The supplied key should be of an caller-defined class so as not to conflict with other users. The class of the key must guarantee that the hashCode() and equals(Object) methods are suitable for use as keys in a Map. The key and value are not examined or used by the implementation. The general contract of this method is that of Map.put(Object, Object) for a Map that supports non-null keys and null values. For example, if there is already an value associated with the key, it is replaced by the value parameter.

        Specified by:
        putResource in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        key - the key for the Map entry; must not be null
        value - the value for the Map entry
        Throws:
        IllegalStateException - if no transaction is active or if a null delegate was supplied at construction time
        NullPointerException - if the parameter key is null
      • getResource

        public Object getResource​(Object key)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Gets an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.

        The key should have been supplied earlier by a call to putResource(Object, Object) in the same transaction. If the key cannot be found in the current resource Map, null is returned. The general contract of this method is that of Map.get(Object) for a Map that supports non-null keys and null values. For example, the returned value is null if there is no entry for the parameter key or if the value associated with the key is actually null.

        Specified by:
        getResource in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        key - the key for the Map entry
        Returns:
        the value associated with the supplied key; may be null
        Throws:
        IllegalStateException - if no transaction is active or if a null delegate was supplied at construction time
        NullPointerException - if the parameter key is null
      • registerInterposedSynchronization

        public void registerInterposedSynchronization​(javax.transaction.Synchronization synchronization)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Registers a Synchronization instance with special ordering semantics.

        The supplied Synchronization's Synchronization.beforeCompletion() method will be called after all SessionSynchronization#beforeCompletion() callbacks and callbacks registered directly with the Transaction, but before the 2-phase commit process starts. Similarly, the Synchronization.afterCompletion(int) callback will be called after 2-phase commit completes but before any SessionSynchronization and Transaction afterCompletion(int) callbacks.

        The Synchronization.beforeCompletion() callback will be invoked in the transaction context of the transaction bound to the current thread at the time this method is called. Allowable methods include access to resources, e.g. connectors. No access is allowed to "user components" (e.g. timer services or bean methods), as these might change the state of data being managed by the caller, and might change the state of data that has already been flushed by another caller of registerInterposedSynchronization(Synchronization). The general context is the component context of the caller of registerInterposedSynchronization(Synchronization).

        The Synchronization.afterCompletion(int) callback will be invoked in an undefined context. No access is permitted to "user components" as defined above. Resources can be closed but no transactional work can be performed with them.

        If this method is invoked without an active transaction context, an IllegalStateException is thrown.

        If this method is invoked after the two-phase commit processing has started, an IllegalStateException is thrown.

        Specified by:
        registerInterposedSynchronization in interface javax.transaction.TransactionSynchronizationRegistry
        Parameters:
        synchronization - the Synchronization to register; must not be null
        Throws:
        IllegalStateException - if no transaction is active or two-phase commit processing has started or if a null delegate was supplied at construction time
        See Also:
        Synchronization, Synchronization.beforeCompletion(), Synchronization.afterCompletion(int)
      • getTransactionStatus

        public int getTransactionStatus()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Return the status of the transaction bound to the current thread at the time this method is called.

        This is the result of executing TransactionManager.getStatus() in the context of the transaction bound to the current thread at the time this method is called.

        Specified by:
        getTransactionStatus in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        the status of the transaction bound to the current thread at the time this method is called; will be equal the value of one of the constants defined in the Status class
        Throws:
        IllegalStateException - if a null delegate was supplied at construction time
        See Also:
        TransactionManager.getStatus(), Status
      • setRollbackOnly

        public void setRollbackOnly()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Sets the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
        Specified by:
        setRollbackOnly in interface javax.transaction.TransactionSynchronizationRegistry
        Throws:
        IllegalStateException - if no transaction is active or if a null delegate was supplied at construction time
      • getRollbackOnly

        public boolean getRollbackOnly()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
        Specified by:
        getRollbackOnly in interface javax.transaction.TransactionSynchronizationRegistry
        Returns:
        the rollbackOnly status
        Throws:
        IllegalStateException - if no transaction is active or if a null delegate was supplied at construction time