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 components of the AS Java which are related to locking and how they are related to each other.
Locking in the AS Java: components
Each server process of the AS Java is controlled by the Startup Framework, which is started by the start service. The enqueue service which manages the locks is part of the Central Services Instance. As far as locking is concerned, an AS Java server process contains the following layered components (refer to figure):
JENQUEUE library
This library is the basic layer which holds a TCP/IP connection to the enqueue server and contains the functions used to operate the enqueue server.
Locking Manager
The Locking Manager is one of the basic managers of AS Java and provides the Java classes and methods to set, release, and manage locks.
Application Locking Service
The Application Locking Service is based on the Locking Manager and implements the interfaces which are used by JEE applications running on AS Java.
Locking Service
The Locking Service is based on the Locking Manager and provides administration functions to the NetWeaver Administrator. The functions can also be executed using shell commands.
More information: Administration of the Locking Service Using the Console
Startup Framework, SAP start service and SAP Management Console
The start service starts the SCS instance and the Startup Framework for AS Java, which itself starts the server processes. The start service provides a Web service interface for the SAP Management Console / SAP MMC to provide monitoring and administration functions.
In addition, the Startup Framework can remove dangling locks after an uncontrolled shutdown of the server process. To do this, the jstart process connects directly to the enqueue server.
The following interfaces can set and release locks.
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 the AS Java services, not by JEE applications.
The Locking Manager has the following properties.
Caution
The settings should not be changed!
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 if 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:
Caution Should only be set by SAP development support! End of the caution. |
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
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.
Note
For security reasons, locks can not be set for the system user.
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.
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.
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 has the following input parameters:
Lifetime of the lock (separate user session or transaction)
Database connection (instance of a 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
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.