Object Locking Overview

JADE objects are locked individually.

Locking a JADE object does two things. Firstly, it controls concurrent access to an object. Secondly, it ensures that a JADE session accesses the most up-to-date edition of the object.

JADE provides four types of lock.

Update and exclusive locks are write locks, which allow JADE sessions to update an object and prevent other sessions from updating the object. An exclusive lock also prevents the acquisition of read locks.

Shared and reserve locks are read locks, which prevent other JADE sessions from applying updates to an object without prohibiting other read locks.

Lock types are discussed in more detail in the following section.

Although JADE sessions can access a JADE object without locking, they cannot update it, and the view of the object’s data can change if it is updated by another session.

If a JADE session does not want to update an object but wants to have a consistent view that will not change while it is being accessed, it must obtain a lock on the JADE object (of any type). The object cannot have updates committed by another JADE session until the object is unlocked.

If a JADE session wants to update a JADE object, this must be done within a transaction and an exclusive or an update lock must first be acquired, either implicitly or explicitly. This ensures that no other JADE session can update the object, as only one session at a time is allowed an exclusive or update lock on an object. In addition, the lock always remains in place until the transaction has been committed or rolled back.

JADE automatically acquires an implicit exclusive or update lock for any object being updated, if it is not already so locked.

When a JADE session requests a type of lock that is not compatible with the current locks in place by other sessions, it is queued until those locks get unlocked (up to a specific time limit) and the session can acquire the requested lock.

The locking concept helps to implement the standard transaction ACID principle of consistency (that is, data is always consistent).