Show TOC Start of Content Area

Syntax documentation Implementation Example for Locking Business Objects  Locate the document in its SAP Library structure

Methods Signature

The following code example for com.sap.caf.rt.bol.IBusinessEntityService provides the following lock-related methods:

    /**

     *   Locks an argument, which belongs to a name.

     *

     * @param argument The argument that you want to lock. The maximum size is MAX_ARGUMENT_LENGTH characters.

     * @param mode The mode can be IBusinessEntityService.MODE_SHARED or IBusinessEntityService.MODE_EXCLUSIVE.

     *

     * @exception LockException if the argument is already locked

     */

    public void lock(String argument, char mode)

        throws CAFLockException;

 

    /**

     * Locks an argument, which belongs to a name.

     *

     * @param argument The argument that you want to lock. The maximum size is MAX_ARGUMENT_LENGTH characters.

     * @param mode The mode can be IBusinessEntityService.MODE_SHARED or IBusinessEntityService.MODE_EXCLUSIVE.

     * @param timeout time period in milliseconds within this the lock will be requested several times if there is a lock collision

     *

     * @exception LockException if the argument is already locked

     */

    public void lock(String argument, char mode, int timeout)

        throws CAFLockException;

 

    /**

     * Unlocks an argument, which belongs to a name.

     * By default the unlock may be done asynchronously.

     *

     * @param argument The argument that you want to lock. The maximum size is MAX_ARGUMENT_LENGTH characters.

     * @param mode The mode can be IBusinessEntityService.MODE_SHARED or IBusinessEntityService.MODE_EXCLUSIVE.

     */

    public void unlock(String argument, char mode)

        throws CAFLockException;

 

    /**

     * Unlocks an argument, which belongs to a name.

     *

     * @param argument The argument that you want to lock. The maximum size is MAX_ARGUMENT_LENGTH characters.

     * @param mode The mode can be IBusinessEntityService.MODE_SHARED or IBusinessEntityService.MODE_EXCLUSIVE.

     * @param asynchronous If true, then the unlock may be done asynchronously, otherwise it is guaranteed to be done synchronously.

     */

    public void unlock(String argument, char mode, boolean asynchronous)

        throws CAFLockException;

 

    /**

     * Returns if locking is currently allowed.

     * <p>

     * This method is typically not needed to use the locking.

     * It is meant mainly for debugging-purposes and to support better tracing.

     *

     *

     * @exception TechnicalLockException if the lifetime is currently not allowed.

     */

    public void assertLocking()

        throws CAFLockException;

 

    /**

     * Returns the current owner-id, to which all locks belong.

     * It is dependent on the current session or the current transaction.

     * <p>

     * This method is not needed to use the locking.

     * It is meant mainly for debugging-purposes and to support better tracing.

     */

    public String getCurrentOwner()

        throws CAFLockException;

 

Exception Handling

All the methods declared above in IBusinessEntityServicethrow a CAF lock exception (CAFLockException). The lock exception CAFLockException encapsulates all thrown exceptions by the enqueue server.

Furthermore, you can get the type of the lower level exception by calling:

/**

 * @return one of the following:

 *      CAFLockException.TYPE_UNDEFINED

 *      CAFLockException.TYPE_NO_FACTORY_FOUND

 *      CAFLockException.TYPE_LOCK_EXCEPTION 

 *      CAFLockException.TYPE_TECHNICAL_LOCK_EXCEPTION

 *      CAFLockException.TYPE_ILLIGAL_ARGUMENT_EXCEPTION

 *      CAFLockException.TYPE_LOCK_NOT_SUPPORTED

*/

public int getType();




End of Content Area