All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rapture.kernel.LockApiImplWrapper Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
/**
 * The MIT License (MIT)
 *
 * Copyright (C) 2011-2016 Incapture Technologies LLC
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * This is an autogenerated file. You should not edit this file as any changes
 * will be overwritten.
 */

package rapture.kernel;

import org.apache.log4j.Logger;

import java.util.List;
import java.util.Map;

import rapture.common.api.LockApi;
import rapture.common.CallingContext;
import rapture.common.RaptureEntitlementsContext;

import rapture.common.hooks.CallName;

import rapture.common.model.BasePayload;
import rapture.common.EntitlementSet;
import rapture.kernel.context.ContextValidator;

import rapture.common.RaptureLockConfig;
import rapture.common.LockHandle;

import rapture.common.shared.lock.GetLockManagerConfigsPayload;

import rapture.common.shared.lock.CreateLockManagerPayload;

import rapture.common.shared.lock.LockManagerExistsPayload;

import rapture.common.shared.lock.GetLockManagerConfigPayload;

import rapture.common.shared.lock.DeleteLockManagerPayload;

import rapture.common.shared.lock.AcquireLockPayload;

import rapture.common.shared.lock.ReleaseLockPayload;

import rapture.common.shared.lock.ForceReleaseLockPayload;


/**
 * This class is a wrapper around the class {@link LockApiImpl}. This is an auto-generated class that gives us the ability to add hooks such as entitlmeent
 * checks before each function call in the implementation. Since we always want to call these hooks, an instance of this class should be used 
 * (in {@link Kernel}) instead of using the implementation directly.
 * implementation directly. 
 *
 */
@SuppressWarnings("all")
public class LockApiImplWrapper implements LockApi, KernelApi {
    private static final Logger log = Logger.getLogger(LockApiImplWrapper.class);
    private LockApiImpl apiImpl;

    public LockApiImplWrapper(Kernel kernel) {
        apiImpl = new LockApiImpl(kernel);
    }

    /**
     * Returns the underlying implementation object. This should be used when a call is deliberately bypassing entitlement checks.
     * @return {@link Lock}
     */
    public LockApiImpl getTrusted() {
        return apiImpl;
    }

    @Override
    public void start() {
        apiImpl.start();
    }

    /**
    * 
    */
    @Override
    public List getLockManagerConfigs(CallingContext context, String managerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetLockManagerConfigsPayload requestObj = new GetLockManagerConfigsPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        ContextValidator.validateContext(context, EntitlementSet.Lock_getLockManagerConfigs, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_getLockManagerConfigs);
        List returnValue = apiImpl.getLockManagerConfigs(context, managerUri);    Kernel.getApiHooksService().post(context, CallName.Lock_getLockManagerConfigs);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.getLockManagerConfigs.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.getLockManagerConfigs.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public RaptureLockConfig createLockManager(CallingContext context, String managerUri, String config, String pathPosition) {
        long functionStartTime = System.currentTimeMillis();
       
        CreateLockManagerPayload requestObj = new CreateLockManagerPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        requestObj.setConfig(config);
        requestObj.setPathPosition(pathPosition);
        ContextValidator.validateContext(context, EntitlementSet.Lock_createLockManager, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_createLockManager);
        RaptureLockConfig returnValue = apiImpl.createLockManager(context, managerUri, config, pathPosition);    Kernel.getApiHooksService().post(context, CallName.Lock_createLockManager);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.createLockManager.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.createLockManager.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Boolean lockManagerExists(CallingContext context, String managerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        LockManagerExistsPayload requestObj = new LockManagerExistsPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        ContextValidator.validateContext(context, EntitlementSet.Lock_lockManagerExists, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_lockManagerExists);
        Boolean returnValue = apiImpl.lockManagerExists(context, managerUri);    Kernel.getApiHooksService().post(context, CallName.Lock_lockManagerExists);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.lockManagerExists.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.lockManagerExists.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public RaptureLockConfig getLockManagerConfig(CallingContext context, String managerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        GetLockManagerConfigPayload requestObj = new GetLockManagerConfigPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        ContextValidator.validateContext(context, EntitlementSet.Lock_getLockManagerConfig, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_getLockManagerConfig);
        RaptureLockConfig returnValue = apiImpl.getLockManagerConfig(context, managerUri);    Kernel.getApiHooksService().post(context, CallName.Lock_getLockManagerConfig);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.getLockManagerConfig.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.getLockManagerConfig.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void deleteLockManager(CallingContext context, String managerUri) {
        long functionStartTime = System.currentTimeMillis();
       
        DeleteLockManagerPayload requestObj = new DeleteLockManagerPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        ContextValidator.validateContext(context, EntitlementSet.Lock_deleteLockManager, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_deleteLockManager);
        apiImpl.deleteLockManager(context, managerUri);    Kernel.getApiHooksService().post(context, CallName.Lock_deleteLockManager);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.deleteLockManager.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.deleteLockManager.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

    /**
    * 
    */
    @Override
    public LockHandle acquireLock(CallingContext context, String managerUri, String lockName, long secondsToWait, long secondsToKeep) {
        long functionStartTime = System.currentTimeMillis();
       
        AcquireLockPayload requestObj = new AcquireLockPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        requestObj.setLockName(lockName);
        requestObj.setSecondsToWait(secondsToWait);
        requestObj.setSecondsToKeep(secondsToKeep);
        ContextValidator.validateContext(context, EntitlementSet.Lock_acquireLock, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_acquireLock);
        LockHandle returnValue = apiImpl.acquireLock(context, managerUri, lockName, secondsToWait, secondsToKeep);    Kernel.getApiHooksService().post(context, CallName.Lock_acquireLock);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.acquireLock.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.acquireLock.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public Boolean releaseLock(CallingContext context, String managerUri, String lockName, LockHandle lockHandle) {
        long functionStartTime = System.currentTimeMillis();
       
        ReleaseLockPayload requestObj = new ReleaseLockPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        requestObj.setLockName(lockName);
        requestObj.setLockHandle(lockHandle);
        ContextValidator.validateContext(context, EntitlementSet.Lock_releaseLock, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_releaseLock);
        Boolean returnValue = apiImpl.releaseLock(context, managerUri, lockName, lockHandle);    Kernel.getApiHooksService().post(context, CallName.Lock_releaseLock);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.releaseLock.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.releaseLock.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
        return returnValue;}

    /**
    * 
    */
    @Override
    public void forceReleaseLock(CallingContext context, String managerUri, String lockName) {
        long functionStartTime = System.currentTimeMillis();
       
        ForceReleaseLockPayload requestObj = new ForceReleaseLockPayload();
        requestObj.setContext(context);
        requestObj.setManagerUri(managerUri);
        requestObj.setLockName(lockName);
        ContextValidator.validateContext(context, EntitlementSet.Lock_forceReleaseLock, requestObj); 
        
        long preToPostStartTime = System.currentTimeMillis();
        
        Kernel.getApiHooksService().pre(context, CallName.Lock_forceReleaseLock);
        apiImpl.forceReleaseLock(context, managerUri, lockName);    Kernel.getApiHooksService().post(context, CallName.Lock_forceReleaseLock);
        
        long endFunctionTime = System.currentTimeMillis();
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.forceReleaseLock.fullFunctionTime.succeeded", (endFunctionTime-functionStartTime));
        Kernel.getMetricsService().recordTimeDifference("apiMetrics.lockApi.forceReleaseLock.preToPostTime.succeeded", (endFunctionTime-preToPostStartTime));
            
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy