Class RecoverableContainer<T>

java.lang.Object
org.jboss.stm.internal.RecoverableContainer<T>
Direct Known Subclasses:
PersistentContainer

public class RecoverableContainer<T> extends Object
Instances of this class represent the transactional memory within which non-persistent user objects can be placed and managed. Objects must implement an interface through which all transactional accesses occur. We don't mandate what the interface is, since that will depend upon the business logic. The interface, or the implementing class, must also use the @Transactional annotation.
Author:
marklittle
  • Field Details

    • _transactionalProxies

      protected WeakHashMap<T,T> _transactionalProxies
    • _type

      protected int _type
    • _objectModel

      protected int _objectModel
  • Constructor Details

    • RecoverableContainer

      public RecoverableContainer()
      Create a container without a name. A name will be assigned automatically.
    • RecoverableContainer

      public RecoverableContainer(String name)
      Create a named container.
      Parameters:
      name - the name (should be unique, but this is not enforced).
    • RecoverableContainer

      protected RecoverableContainer(int objectModel)
    • RecoverableContainer

      protected RecoverableContainer(String name, int objectModel)
  • Method Details

    • name

      public final String name()
      Get the name of the container.
      Returns:
      the name.
    • enlist

      public T enlist(T member)
      Given an object we create a new transactional instance of it and return that for future use. All accesses on the returned object will be managed according to the rules defined in the various annotations. If the original object instance is used then no transactional manipulation will occur so you need to be careful! All handles are uniquely identified using Uid.
      Parameters:
      member - the instance of type T that you want to be made transactional and persistent.
      Returns:
      a handle into the transactional memory that the application should use to manipulate the object.
    • enlist

      public T enlist(T member, Uid id)
      Given an identified for an existing object, create another handle. This is particularly useful when using pessimistic concurrency control and we need one object instance per thread to ensure that state is safely managed.
      Parameters:
      member - the instance of type T that you want to be made transactional and persistent.
      id - the Uid of the object.
      Returns:
      a handle into the transactional memory that the application should use to manipulate the object.
    • createHandle

      protected T createHandle(T member, int ot)
      Return a handle through which the object should be used, rather than the one passed in. Can specify the type of the object (recoverable, persistent, neither).
    • getHandle

      public T getHandle(Uid reference)
      Given a Uid, return the proxy for that instance.
      Parameters:
      reference - the unique identifier for the handle.
      Returns:
      the handle or null if not present.
    • getUidForOriginal

      public Uid getUidForOriginal(T member)
      Given a real object, return the Uid if it exists in this container.
      Parameters:
      member - the real object.
      Returns:
      the Uid for the object.
    • getUidForHandle

      public Uid getUidForHandle(T proxy)
      Given a real object, return the Uid if it exists in this container.
      Parameters:
      member - the real object.
      Returns:
      the Uid for the object if it exists in the container.
    • toString

      public String toString()
      Gives the name of the container.
      Overrides:
      toString in class Object
    • objectType

      public final int objectType()
    • objectModel

      public final int objectModel()
    • isPessimistic

      public final boolean isPessimistic(Object member)
    • checkObjectType

      protected final void checkObjectType(Object member)