Architecture of the Locking Adapter Service

Applications running on the J2EE Engine can only use the interfaces LogicalLocking and TableLocking, which are provided by the Locking Adapter service. These have access to the Locking Manager that provides the ServerInternalLockinginterface. This ensures that a J2EE application can only set or release locks for the current user using the application.

The figure below shows the interfaces and how they are related to each other.

Interfaces

There are the following interfaces to set and release locks.

ServerInternalLocking

This interface is provided by the Locking Manager and offers central functions.

It takes the following input parameters:

·        Lock owner

·        Lock name

·        Lock argument

·        Lock mode

Any lock can be set with this interface. It can only be used by the J2EE Engine components (directly) or indirectly by the LogicalLocking interface.

LogicalLocking

Using the LogicalLocking interface you cannot specify the lock owner. The system determines the owner from the context of the user session or the transaction. What is used to determine the user can be specified in the lifetime parameter. After the transaction or the user session has finished, all associated locks are released.

A user session ends when the user logs off or a timeout occurs. A transaction ends when commit or rollback is called or when a timeout occurs.

A transaction’s lifetime does not necessarily have to be the same as the lifetime of the user session. If the user logs off without calling a commit or rollback in the transaction, locks restricted to the transaction can continue to be effective until the transaction terminates with a timeout.

No locks can be set for the system user because of security reasons. 

This interface takes the following input parameters:

·        Lifetime of the lock (running user session or running transaction)

·        Lock name

·        Lock argument

·        Lock mode

You can change your own locks only. You can, however, still select the format and lock mode.

TableLocking

Using this interface, you can lock/unlock a whole row of a database table. The row is identified by the argument primaryKeys. The database connection is identified by the argument dbconnection.

This interface takes the following input parameters:

·        Lifetime of the lock (separate user session or transaction)

·        Database connection (instance of SQL connection created from a data source that has a transaction in the deployment descriptor of the DB pool)

·        Name of the database table

·        Primary key of the database table

·        Lock mode

Additional Information

·        You can find more information and examples about working with locks under Locks in the Development Manual.

·        Detailed javadoc documentation is available as part of the SAP NetWeaver Developer Studio help.

·        Java Dictionary in the Development Manual.