com.sap.engine.services.applocking

Interface TableLocking

All Superinterfaces:
com.sap.engine.frame.core.locking.LockingConstants

public interface TableLocking
extends com.sap.engine.frame.core.locking.LockingConstants

Provides methods to lock and unlock rows in database tables. The database table belongs to the given connection. The locks may be in the context of a local transaction, a JTA transaction or an user session. All locks are removed automatically when the session/transaction ends.

See Also:
LogicalLocking

Field Summary
static String JNDI_NAME
          The name, under wich the TableLocking is bound in the jndi.
 
Fields inherited from interface com.sap.engine.frame.core.locking.LockingConstants
FILL_CHARACTER, LIFETIME_TRANSACTION, LIFETIME_USERSESSION, MAX_ARGUMENT_LENGTH, MAX_NAME_LENGTH, MAX_OWNER_LENGTH, MAX_USER_LENGTH, MODE_EXCLUSIVE_CUMULATIVE, MODE_EXCLUSIVE_NONCUMULATIVE, MODE_OPTIMISTIC, MODE_OPTIMISTIC_TO_EXCLUSIVE, MODE_SHARED, OWNER_WILDCARD_CHARACTER, WILDCARD_CHARACTER_MULTI, WILDCARD_CHARACTER_SINGLE
 
Method Summary
 void assertLifetime(byte lifetime)
          Deprecated. does not work for local transactions
 String getCurrentOwner(byte lifetime)
          Deprecated. use getCurrentOwner(byte, Connection) instead, because does not work for local transactions
 String getCurrentOwner(byte lifetime, Connection connection)
          Returns the current owner-id, to which all locks belong.
 long getUniqueIncreasingNumber()
          Returns a number with the following properties: every method-call returns a higher number than the previous ones the number contains the timestamp of the central server, so this will work correctly in a distrubuted environment and also after a restart of the cluster This number can be used for every purpose, it is not locking-specific.
 void lock(byte lifetime, Connection connection, String tableName, Map primaryKeys, char mode)
          Creates a lock for a row in a table contained in the specified SQL connection.
 void lock(byte lifetime, Connection connection, String tableName, Map primaryKeys, char mode, int timeout)
          Creates a lock for a row in a table contained in the specified SQL connection.
 void unlock(byte lifetime, Connection connection, String tableName, Map primaryKeys, char mode)
          Releases a lock for a row in a table contained in the specified SQL connection.
 void unlock(byte lifetime, Connection connection, String tableName, Map primaryKeys, char mode, boolean asynchronous)
          Releases a lock for a row in a table contained in the specified SQL connection.
 void unlockAll(byte lifetime)
          Deprecated. use unlockAll(byte, Connection) instead, because does not work for local transactions
 void unlockAll(byte lifetime, boolean asynchronous)
          Deprecated. use unlockAll(byte, Connection, boolean) instead, because does not work for local transactions
 void unlockAll(byte lifetime, Connection connection)
          Releases all granted locks.
 void unlockAll(byte lifetime, Connection connection, boolean asynchronous)
          Releases all granted locks.
 

Field Detail

JNDI_NAME

public static final String JNDI_NAME
The name, under wich the TableLocking is bound in the jndi.

See Also:
Constant Field Values
Method Detail

lock

public void lock(byte lifetime,
                 Connection connection,
                 String tableName,
                 Map primaryKeys,
                 char mode)
          throws com.sap.engine.frame.core.locking.LockException,
                 com.sap.engine.frame.core.locking.TechnicalLockException,
                 IllegalArgumentException
Creates a lock for a row in a table contained in the specified SQL connection. The row is identified using the argument 'primaryKeys'. This map is required to the have primary key column names as keys and the primary key column values as values. For all primary key columns in the given table, there must be an entry in the map. The value must not be null. All entries in the map must be primary key columns in the given table. There is a restriction on the java types supported, at the moment, only wrapper types of primitives types and and the string type is supported. For generic locks on columns, use the constants defined in the static class TableLocking.GenericLock. Note: The map 'primaryKeys' is required to contain values as they are returned by getter methods on java.sql.ResultSet instances, or, it must contain instances of java.lang wrapper classes in case of primitives. This method looks up a table in the catalog corresponding with the specified SQL connection.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool. in the deployment descriptor of the DB pool.
tableName - The unqualified name of a table contained in the SQL connection.
primaryKeys - Contains primary key column names to primary key value mappings.
mode - The mode can be MODE_SHARED or MODE_EXCLUSIVE_CUMULATIVE or MODE_EXCLUSIVE_NONCUMULATIVE.
Throws:
com.sap.engine.frame.core.locking.LockException - if the lock can not be granted.
IllegalArgumentException - if the given primary key map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

lock

public void lock(byte lifetime,
                 Connection connection,
                 String tableName,
                 Map primaryKeys,
                 char mode,
                 int timeout)
          throws com.sap.engine.frame.core.locking.LockException,
                 com.sap.engine.frame.core.locking.TechnicalLockException,
                 IllegalArgumentException
Creates a lock for a row in a table contained in the specified SQL connection. The row is identified using the argument 'primaryKeys'. This map is required to the have primary key column names as keys and the primary key column values as values. For all primary key columns in the given table, there must be an entry in the map. The value must not be null. All entries in the map must be primary key columns in the given table. There is a restriction on the java types supported, at the moment, only wrapper types of primitives types and and the string type is supported. For generic locks on columns, use the constants defined in the static class TableLocking.GenericLock. Note: The map 'primaryKeys' is required to contain values as they are returned by getter methods on java.sql.ResultSet instances, or, it must contain instances of java.lang wrapper classes in case of primitives. This method looks up a table in the catalog corresponding with the specified SQL connection.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool. in the deployment descriptor of the DB pool.
tableName - The unqualified name of a table contained in the SQL connection.
primaryKeys - Contains primary key column names to primary key value mappings.
mode - The mode can be MODE_SHARED or MODE_EXCLUSIVE_CUMULATIVE or MODE_EXCLUSIVE_NONCUMULATIVE.
timeout - time period in milliseconds within this the lock will be requested several times if there is a lock collision
Throws:
com.sap.engine.frame.core.locking.LockException - if the lock can not be granted.
IllegalArgumentException - if the given primary key map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

unlock

public void unlock(byte lifetime,
                   Connection connection,
                   String tableName,
                   Map primaryKeys,
                   char mode)
            throws com.sap.engine.frame.core.locking.TechnicalLockException,
                   IllegalArgumentException
Releases a lock for a row in a table contained in the specified SQL connection. The row is identified using the argument 'primaryKeys'. This map is required to the have primary key column names as keys and the primary key column values as values. For all primary key columns in the given table, there must be an entry in the map. The value must not be null. All entries in the map must be primary key columns in the given table. There is a restriction on the java types supported, at the moment, only wrapper types of primitives types and and the string type is supported. For generic locks on columns, use the constants defined in the static class TableLocking.GenericLock. By default the unlock may be done asynchronously (depends on the enqueue server configuration) Note: The map 'primaryKeys' is required to contain values as they are returned by getter methods on java.sql.ResultSet instances, or, it must contain instances of java.lang wrapper classes in case of primitives. This method looks up a table in the catalog corresponding with the specified SQL connection.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool.
tableName - The unqualified name of a table contained in the SQL connection.
primaryKeys - Contains primary key column to primary key value mappings.
mode - The mode can be MODE_SHARED or MODE_EXCLUSIVE_CUMULATIVE or MODE_EXCLUSIVE_NONCUMULATIVE.
Throws:
IllegalArgumentException - if the given primary key map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

unlock

public void unlock(byte lifetime,
                   Connection connection,
                   String tableName,
                   Map primaryKeys,
                   char mode,
                   boolean asynchronous)
            throws com.sap.engine.frame.core.locking.TechnicalLockException,
                   IllegalArgumentException
Releases a lock for a row in a table contained in the specified SQL connection. The row is identified using the argument 'primaryKeys'. This map is required to the have primary key column names as keys and the primary key column values as values. For all primary key columns in the given table, there must be an entry in the map. The value must not be null. All entries in the map must be primary key columns in the given table. There is a restriction on the java types supported, at the moment, only wrapper types of primitives types and and the string type is supported. For generic locks on columns, use the constants defined in the static class TableLocking.GenericLock. By default the unlock may be done asynchronously (depends on the enqueue server configuration) Note: The map 'primaryKeys' is required to contain values as they are returned by getter methods on java.sql.ResultSet instances, or, it must contain instances of java.lang wrapper classes in case of primitives. This method looks up a table in the catalog corresponding with the specified SQL connection.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool.
tableName - The unqualified name of a table contained in the SQL connection.
primaryKeys - Contains primary key column to primary key value mappings.
mode - The mode can be MODE_SHARED or MODE_EXCLUSIVE_CUMULATIVE or MODE_EXCLUSIVE_NONCUMULATIVE.
asynchronous - If false, then the unlock is done synchronously.
Throws:
IllegalArgumentException - if the given primary key map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

unlockAll

public void unlockAll(byte lifetime)
               throws com.sap.engine.frame.core.locking.TechnicalLockException,
                      IllegalArgumentException
Deprecated. use unlockAll(byte, Connection) instead, because does not work for local transactions

Releases all granted locks. By default the unlock may be done asynchronously (depends on the enqueue server configuration)

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

unlockAll

public void unlockAll(byte lifetime,
                      Connection connection)
               throws com.sap.engine.frame.core.locking.TechnicalLockException,
                      IllegalArgumentException
Releases all granted locks. By default the unlock may be done asynchronously (depends on the enqueue server configuration)

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred. which has a corresponding entry in the deployment descriptor of the DB pool.

unlockAll

public void unlockAll(byte lifetime,
                      boolean asynchronous)
               throws com.sap.engine.frame.core.locking.TechnicalLockException,
                      IllegalArgumentException
Deprecated. use unlockAll(byte, Connection, boolean) instead, because does not work for local transactions

Releases all granted locks. By default the unlock may be done asynchronously (depends on the enqueue server configuration)

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
asynchronous - If false, then the unlock is done synchronously.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

unlockAll

public void unlockAll(byte lifetime,
                      Connection connection,
                      boolean asynchronous)
               throws com.sap.engine.frame.core.locking.TechnicalLockException,
                      IllegalArgumentException
Releases all granted locks. By default the unlock may be done asynchronously (depends on the enqueue server configuration)

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool.
asynchronous - If false, then the unlock is done synchronously.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if an technical error occurred.

assertLifetime

public void assertLifetime(byte lifetime)
                    throws com.sap.engine.frame.core.locking.TechnicalLockException,
                           IllegalArgumentException
Deprecated. does not work for local transactions

Returns if locking is currently allowed for the given lifetime. For example LIFETIME_TRANSACTION is not possible, if there is no transaction active.

This method is typically not needed to use the locking. It is meant mainly for debugging-purposes and to support better tracing.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if the lifetime is currently not allowed.
NotSupportedException - if called in a local transaction

getCurrentOwner

public String getCurrentOwner(byte lifetime)
                       throws com.sap.engine.frame.core.locking.TechnicalLockException,
                              IllegalArgumentException
Deprecated. use getCurrentOwner(byte, Connection) instead, because does not work for local transactions

Returns the current owner-id, to which all locks belong. It is dependent on the current session or the current transaction.

This method is not needed to use the locking. It is meant mainly for debugging-purposes and to support better tracing.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if the lifetime is currently not allowed.
NotSupportedException - if called in a local transaction

getCurrentOwner

public String getCurrentOwner(byte lifetime,
                              Connection connection)
                       throws com.sap.engine.frame.core.locking.TechnicalLockException,
                              IllegalArgumentException
Returns the current owner-id, to which all locks belong. It is dependent on the current session or the current transaction.

This method is not needed to use the locking. It is meant mainly for debugging-purposes and to support better tracing.

Parameters:
lifetime - The lifetime can be either LIFETIME_TRANSACTION or LIFETIME_USERSESSION.
connection - The SQL connection instance created by a data source instance which has a corresponding entry in the deployment descriptor of the DB pool.
Throws:
IllegalArgumentException - if the given lifetime map is illegal.
com.sap.engine.frame.core.locking.TechnicalLockException - if the lifetime is currently not allowed.

getUniqueIncreasingNumber

public long getUniqueIncreasingNumber()
                               throws com.sap.engine.frame.core.locking.TechnicalLockException
Returns a number with the following properties: This number can be used for every purpose, it is not locking-specific.

ATTENTION: if the system-time of the central server is changed this will probably not work correctly any more.

Throws:
com.sap.engine.frame.core.locking.TechnicalLockException


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.