Show TOC

Background documentationLocking in AS Java: Architecture Locate this document in the navigation structure

 

Applications running on AS Java can only use the interfaces LogicalLocking and TableLocking, which are provided by the Application Locking service. These have access to the Locking Manager. This ensures that a JEE application can only set or release locks for the user who is currently using the application, or for the current transaction.

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

This graphic is explained in the accompanying text.

Interfaces

The following interfaces set and release locks.

ServerInternalLocking

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

It takes the following input parameters:

  • Lock name

  • Lock argument

  • Lock mode

The lock owner is set automatically

A lock can be set or released with this interface. It can only be used by AS Java services, not by JEE applications.

Properties

The Locking Manager has the following properties.

Caution Caution

The settings should not be changed!

End of the caution.

Property

Description

enq.clientlib.tracelevel

Outdated, only needed for backward compatibility.

enq.profile.filename

Path to the profile file that contains settings for the enqueue server.

enqu.check.restart

Check if the enqueue server restart has taken place. This flag indicates whether action should be taken if the enqueue server is restarted while the Application Server instances are running.

The value true means that the check is enabled, false means that the check is disabled

enqu.host

enqueue server host. This is the host on which the enqueue server runs.

enqu.port

enqueue server port. TCP/IP port on which the enqueue server listens for incoming requests.

timestatisticslevel

Time statistics level. The following values can be set:

  • 0: no time statistics

  • 1: time statistics with typical granularity

  • 2: time statistics with maximum granularity

Caution Caution

Should only be set by SAP development support!

End of the caution.
LogicalLocking

You cannot specify the lock owner using the Logical Locking interface. The system determines the owner from the context of the user session or the transaction. You can specify what is used to determine the user 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.

Note Note

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.

End of the note.

Note Note

For security reasons, locks can not be set for the system user.

End of the note.

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 only change your own locks. 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 primaryKeys argument. The database connection is identified by the argument dbconnection.

The locks may be in the context of a local transaction, a JTA transaction or a user session. All locks are removed automatically when the session/transaction ends.

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

More Information