Package org.jboss.stm
Class Container<T>
java.lang.Object
org.jboss.stm.Container<T>
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The sharing MODEL of the objects created by this instance.static enum
The TYPE of the objects created by this instance. -
Constructor Summary
ConstructorDescriptionCreate a container without a name.Create a named container.Container
(String name, Container.TYPE type) Create a named container.Container
(String name, Container.TYPE type, Container.MODEL model) Create a named container.Container
(Container.TYPE type) Create a container (system assigned name) of the specified type.Container
(Container.TYPE type, Container.MODEL model) Create a container (system assigned name) of the specified type and model. -
Method Summary
Modifier and TypeMethodDescriptionGiven an identified for an existing object, create another handle.Given an existing object, create another handle.Given an object we create a new transactional instance of it and return that for future use.static final Container
<?> getContainer
(Object proxy) Given the proxy return the container that is managing it.getIdentifier
(T proxy) final Container.MODEL
model()
final String
name()
Get the name of the container.final Container.TYPE
type()
-
Constructor Details
-
Container
public Container()Create a container without a name. A name will be assigned automatically. -
Container
Create a container (system assigned name) of the specified type. Objects will be EXCLUSIVE.- Parameters:
type
- the type of objects created.
-
Container
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
Create a named container. Objects will be RECOVERABLE and EXCLUSIVE.- Parameters:
name
- the name (should be unique, but this is not enforced).
-
Container
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
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
Get the name of the container.- Returns:
- the name.
-
type
- Returns:
- the TYPE of objects created by this instance.
-
model
- Returns:
- the MODEL of the objects created by this instance.
-
create
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
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
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
- Returns:
- the unique name for the instance.
-
getContainer
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!
-