Package org.jboss.stm

Class Container<T>

java.lang.Object
org.jboss.stm.Container<T>

public class Container<T> extends Object
Instances of this class represent the transactional memory within which 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. Unless either the Nested or NestedTopLevel annotation is used, all method invocations on objects returned from a Container should be done within the context of an active transaction.
Author:
marklittle
  • Constructor Details

    • Container

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

      public Container(Container.TYPE type)
      Create a container (system assigned name) of the specified type. Objects will be EXCLUSIVE.
      Parameters:
      type - the type of objects created.
    • Container

      public Container(Container.TYPE type, Container.MODEL model)
      Create a container (system assigned name) of the specified type and model.
      Parameters:
      type - the TYPE of objects.
      model - the MODEL of the objects.
    • Container

      public Container(String name)
      Create a named container. Objects will be RECOVERABLE and EXCLUSIVE.
      Parameters:
      name - the name (should be unique, but this is not enforced).
    • Container

      public Container(String name, Container.TYPE type)
      Create a named container. Objects will be EXCLUSIVE.
      Parameters:
      name - the name (should be unique, but this is not enforced).
      type - the TYPE of objects.
    • Container

      public Container(String name, Container.TYPE type, Container.MODEL model)
      Create a named container.
      Parameters:
      name - the name (should be unique, but this is not enforced).
      type - the TYPE of objects.
      model - the MODEL of objects.
  • Method Details

    • name

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

      public final Container.TYPE type()
      Returns:
      the TYPE of objects created by this instance.
    • model

      public final Container.MODEL model()
      Returns:
      the MODEL of the objects created by this instance.
    • create

      public T create(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.
    • clone

      public T clone(T member, T proxy)
      Given 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.
      proxy - the instance you want to copy.
    • clone

      public T clone(T member, Uid id)
      Given an identified for an existing object, create another handle. This is particularly useful when using optimistic concurrency control and we need one object instance per thread to ensure that state is safely managed. WARNING: if the Uid is invalid, e.g., points to a state that no longer exists, then a handle will still be returned because checks for validity (other than null parameter) cannot be done until you try to use the state. At that time a lock will be refused (state cannot be activated) and a suitable warning message will be output.
      Parameters:
      member - the instance of type T that you want to be made transactional and persistent.
      id - the Uid of the object.
    • getIdentifier

      public Uid getIdentifier(T proxy)
      Returns:
      the unique name for the instance.
    • getContainer

      public static final Container<?> getContainer(Object proxy)
      Given the proxy return the container that is managing it.
      Parameters:
      proxy - the instance within the container we're looking for.
      Returns:
      the container or null. Shouldn't really be possible to get null!