JBoss.orgCommunity Documentation

Chapter 2. JBossTS Basics

2.1. Introduction
2.1.1. Raw OTS
2.1.2. Enhanced OTS functionality
2.1.3. Advanced API
2.2. JBossTS and the OTS implementation
2.3. Thread class
2.4. ORB portability issues

JBossTS is based upon the original Arjuna system developed at the University of Newcastle between 1986 and 1995. Arjuna predates the OTS specification and includes many features not found in the OTS. JBossTS is a superset of the OTS. Applications written using the standard OTS interfaces are portable across OTS implementations.

You can use JBossTS in three different levels, which correspond to the sections in this chapter, and are each explored in their own chapters as well.

Because of differences in ORB implementations, JBossTS uses a separate ORB Portability library which acts as an abstraction later. Many of the examples used throughout this manual use this library. Refer to the ORB Portability Manual for more details.

The OTS does not provide any Resource implementations. You are responsible for implementing these interfaces. The interfaces defined within the OTS specification are too low-level for most application programmers. Therefore, JBossTS includes Transactional Objects for Java (TXOJ), which makes use of the raw Common Object Services interfaces but provides a higher-level API for building transactional applications and frameworks. This API automates much of the activities concerned with participating in an OTS transaction, freeing you to concentrate on application development, rather than transactions.

The architecture of the system is shown in Figure 2. The API interacts with the concurrency control and persistence services, and automatically registers appropriate resources for transactional objects. These resources may also use the persistence and concurrency services.

JBossTS exploits object-oriented techniques to provide you with a toolkit of Java classes which are inheritable by application classes, to obtain transactional properties. These classes form a hierarchy, illustrated in Figure 2.1, “JBossTS class hierarchy”.

Figure 2.1. JBossTS class hierarchy


Your main responsibilities are specifying the scope of transactions and setting appropriate locks within objects. JBossTS guarantees that transactional objects will be registered with, and be driven by, the appropriate transactions. Crash recovery mechanisms are invoked automatically in the event of failures. When using the provided interfaces, you do not need to create or register Resource objects or call services controlling persistence or recovery. If a transaction is nested, resources are automatically propagated to the transaction’s parent upon commit.

The design and implementation goal of JBossTS was to provide a programming system for constructing fault-tolerant distributed applications. Three system properties were considered highly important:

Integration of Mechanisms

Fault-tolerant distributed systems require a variety of system functions for naming, locating and invoking operations upon objects, as well as for concurrency control, error detection and recovery from failures. These mechanisms are integrated in a way that is easy for you to use.

Flexibility

Mechanisms must be flexible, permitting implementation of application-specific enhancements, such as type-specific concurrency and recovery control, using system defaults.

Portability

You need to be able to run JBossTS on any ORB.

JBossTS is implemented in Java and extensively uses the type-inheritance facilities provided by the language to provide user-defined objects with characteristics such as persistence and recoverability.

The OTS specification is written with flexibility in mind, to cope with different application requirements for transactions. JBossTS supports all optional parts of the OTS specification. In addition, if the specification allows functionality to be implemented in a variety of different ways, JBossTS supports all possible implementations.

Table 2.1. JBossTS implementation of OTS specifications

OTS specificationJBossTS default implementation

If the transaction service chooses to restrict the availability of the transaction context, then it should raise the Unavailable exception.

JBossTS does not restrict the availability of the transaction context.

An implementation of the transaction service need not initialize the transaction context for every request.

JBossTS only initializes the transaction context if the interface supported by the target object extends the TransactionalObject interface.

An implementation of the transaction service may restrict the ability for the Coordinator, Terminator, and Control objects to be transmitted or used in other execution environments to enable it to guarantee transaction integrity.

JBossTS does not impose restrictions on the propagation of these objects.

The transaction service may restrict the termination of a transaction to the client that started it.

JBossTS allows the termination of a transaction by any client that uses the Terminator interface. In addition, JBossTS does not impose restrictions when clients use the Current interface.

A TransactionFactory is located using the FactoryFinder interface of the life-cycle service.

JBossTS provides multiple ways in which the TransactionFactory can be located.

A transaction service implementation may use the Event Service to report heuristic decisions.

JBossTS does not use the Event Service to report heuristic decisions.

An implementation of the transaction service does not need to support nested transactions.

JBossTS supports nested transactions.

Synchronization objects must be called whenever the transaction commits.

JBossTS allows Synchronizations to be called no matter what state the transaction terminates with.

A transaction service implementation is not required to support interposition.

JBossTS supports various types of interposition.


JBossTS is fully multi-threaded and supports the OTS notion of allowing multiple threads to be active within a transaction, and for a thread to execute multiple transactions. A thread can only be active within a single transaction at a time, however. By default, if a thread is created within the scope of a transaction, the new thread is not associated with the transaction. If the thread needs to be associated with the transaction, use the resume method of either the AtomicTransaction class or the Current class.

However, if newly created threads need to automatically inherit the transaction context of their parent, then they should extend the OTS_Thread class.


Call the run method of OTS_Thread at the start of the application thread class's run method. Call terminate before you exit the body of the application thread’s run method.

Although the CORBA specification is a standard, it is written so that an ORB can be implemented in multiple ways. As such, writing portable client and server code can be difficult. Because JBossTS has been ported to most of the widely available ORBs, it includes a series of ORB Portability classes and macros. If you write your application using these classes, it should be mostly portable between different ORBs. These classes are described in the separate ORB Portability Manual.