001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.lock;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.util.ProxyFactory;
019    
020    /**
021     * @author Tina Tian
022     */
023    public class LockManagerUtil {
024    
025            public static void clear() {
026                    _lockManager.clear();
027            }
028    
029            public static Lock createLock(
030                    long lockId, long companyId, long userId, String userName) {
031    
032                    return _lockManager.createLock(lockId, companyId, userId, userName);
033            }
034    
035            public static Lock getLock(String className, long key)
036                    throws PortalException {
037    
038                    return _lockManager.getLock(className, key);
039            }
040    
041            public static Lock getLock(String className, String key)
042                    throws PortalException {
043    
044                    return _lockManager.getLock(className, key);
045            }
046    
047            public static Lock getLockByUuidAndCompanyId(String uuid, long companyId)
048                    throws PortalException {
049    
050                    return _lockManager.getLockByUuidAndCompanyId(uuid, companyId);
051            }
052    
053            public static boolean hasLock(long userId, String className, long key) {
054                    return _lockManager.hasLock(userId, className, key);
055            }
056    
057            public static boolean hasLock(long userId, String className, String key) {
058                    return _lockManager.hasLock(userId, className, key);
059            }
060    
061            public static boolean isLocked(String className, long key) {
062                    return _lockManager.isLocked(className, key);
063            }
064    
065            public static boolean isLocked(String className, String key) {
066                    return _lockManager.isLocked(className, key);
067            }
068    
069            public static Lock lock(
070                            long userId, String className, long key, String owner,
071                            boolean inheritable, long expirationTime)
072                    throws PortalException {
073    
074                    return _lockManager.lock(
075                            userId, className, key, owner, inheritable, expirationTime);
076            }
077    
078            public static Lock lock(
079                            long userId, String className, String key, String owner,
080                            boolean inheritable, long expirationTime)
081                    throws PortalException {
082    
083                    return _lockManager.lock(
084                            userId, className, key, owner, inheritable, expirationTime);
085            }
086    
087            public static Lock lock(String className, String key, String owner) {
088                    return _lockManager.lock(className, key, owner);
089            }
090    
091            public static Lock lock(
092                    String className, String key, String expectedOwner,
093                    String updatedOwner) {
094    
095                    return _lockManager.lock(className, key, expectedOwner, updatedOwner);
096            }
097    
098            public static Lock refresh(String uuid, long companyId, long expirationTime)
099                    throws PortalException {
100    
101                    return _lockManager.refresh(uuid, companyId, expirationTime);
102            }
103    
104            public static void unlock(String className, long key) {
105                    _lockManager.unlock(className, key);
106            }
107    
108            public static void unlock(String className, String key) {
109                    _lockManager.unlock(className, key);
110            }
111    
112            public static void unlock(String className, String key, String owner) {
113                    _lockManager.unlock(className, key, owner);
114            }
115    
116            private static final LockManager _lockManager =
117                    ProxyFactory.newServiceTrackedInstance(LockManager.class);
118    
119    }