Example usage for org.aspectj.lang ProceedingJoinPoint getTarget

List of usage examples for org.aspectj.lang ProceedingJoinPoint getTarget

Introduction

In this page you can find the example usage for org.aspectj.lang ProceedingJoinPoint getTarget.

Prototype

Object getTarget();

Source Link

Document

Returns the target object.

Usage

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.itemPropertiesDao.FindByItemAndModelAspect.java

License:Open Source License

@Around("execution(* uk.gov.ofwat.fountain.dao.ItemPropertiesDao+.findByItemAndModel(int, int))")
public Object cacheOnFindByItemAndModel(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from  w  ww. j a  v  a  2  s .c  om*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1];

    Object retVal = null;
    if (cacheByItemAndModel.containsKey(key)) {
        retVal = cacheByItemAndModel.get(key);
    } else {
        retVal = pjp.proceed();
        if (null != retVal) {
            // don't store nulls. Items may be added to the model later. 
            cacheByItemAndModel.put(key, (Object) retVal);
            incrementCache(pjp);
        }
    }
    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.lineDao.FindByTableItemAspect.java

License:Open Source License

@Around("execution(* uk.gov.ofwat.fountain.dao.LineDao+.findByTableItem(int, int))")
public Object cacheOnFindByTableAndItem(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }//  w  ww . ja v a  2  s .c o  m
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1];

    Object retVal = null;
    if (cacheByTableAndItem.containsKey(key)) {
        retVal = cacheByTableAndItem.get(key);
    } else {
        retVal = pjp.proceed();
        cacheByTableAndItem.put(key, (Object) retVal);
        incrementCache(pjp);
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.lockDao.LockDaoAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(public * uk.gov.ofwat.fountain.dao.LockDao+.create(uk.gov.ofwat.fountain.domain.Lock))")
public int cacheOnCreate(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return (Integer) pjp.proceed();
    }/*from  w ww  .j av  a  2s  .  c  o  m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    Lock lock = (Lock) args[0];

    DataKey key = new DataKey();
    key.setItemId(lock.getItemId());
    key.setIntervalId(lock.getIntervalId());
    key.setCompanyId(lock.getCompanyId());

    Integer retVal = null;
    if (cacheByKey.containsKey(key.getKey(false))) {
        Lock lockFromCache = cacheByKey.get(key.getKey(false));
        retVal = lockFromCache.getId();
    } else {
        retVal = (Integer) pjp.proceed();
        cacheByKey.put(key.getKey(false), lock);
        incrementCache(pjp);
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.lockDao.LockDaoAspect.java

License:Open Source License

@Around("execution(public uk.gov.ofwat.fountain.domain.User uk.gov.ofwat.fountain.dao.LockDao+.getLockingUser(int, int, int))")
public User cacheOnGetLockingUser(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return (User) pjp.proceed();
    }// w ww. j  a  v  a2s . co  m
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    DataKey key = new DataKey();
    key.setItemId((Integer) args[0]);
    key.setIntervalId((Integer) args[1]);
    key.setCompanyId((Integer) args[2]);

    User retVal = null;
    if (cacheByKey.containsKey(key.getKey(false))) {
        retVal = cacheByKey.get(key.getKey(false)).getUser();
    } else {
        retVal = null;
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.modelDao.GetModelByNameAspect.java

License:Open Source License

@Around("execution(uk.gov.ofwat.fountain.domain.Model uk.gov.ofwat.fountain.dao.ModelDao+.getModelByName(String))")
public Object cacheOnFindByCode(ProceedingJoinPoint pjp) throws Throwable {

    if (!isEnabled()) {
        return pjp.proceed();
    }/*from  ww  w  .j a  v  a 2 s. co m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }
    Object[] args = pjp.getArgs();
    String key = (String) args[0];

    Object retVal = null;
    if (cacheModelByName.containsKey(key)) {
        retVal = cacheModelByName.get(key);
    } else {
        retVal = pjp.proceed();
        if (null != retVal) {
            // don't store nulls.
            cacheModelByName.put(key, (Object) retVal);
            incrementCache(pjp);
        }
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.modelPropertiesMapDao.FindByModelAndItemAspect.java

License:Open Source License

@Around("execution(* uk.gov.ofwat.fountain.dao.ModelPropertiesMapDao+.findByModelAndItem(int, int))")
public Object cacheOnFindByModelAndItem(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from   w  ww .  jav  a2  s.c  om*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1];

    Object retVal = null;
    if (cacheByModelAndItem.containsKey(key)) {
        retVal = cacheByModelAndItem.get(key);
    } else {
        retVal = pjp.proceed();
        if (null != retVal) {
            // don't store nulls.
            cacheByModelAndItem.put(key, (Object) retVal);
            incrementCache(pjp);
        }
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.potDao.FindByTableIdAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(* uk.gov.ofwat.fountain.dao.PotDao+.findByTableId(int))")
public List<Pot> cacheOnFindByTableId(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return (List<Pot>) pjp.proceed();
    }/*from ww w .j  ava 2 s .co m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = "" + (Integer) args[0];

    List<Pot> retVal = null;
    if (cacheByTableId.containsKey(key)) {
        retVal = cacheByTableId.get(key);
    } else {
        retVal = (List<Pot>) pjp.proceed();
        cacheByTableId.put(key, retVal);
        incrementCache(pjp);
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.RunModelDao.FindByRunAndCompanyAspect.java

License:Open Source License

@Around("execution(* uk.gov.ofwat.fountain.dao.RunModelDao+.findByRunAndCompany(int, int))")
public Object cacheOnFindByItemAndModel(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from  ww  w .  j  a  va 2 s .co  m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1];

    Object retVal = null;
    if (cacheByRunAndCompany.containsKey(key)) {
        retVal = cacheByRunAndCompany.get(key);
    } else {
        retVal = pjp.proceed();
        cacheByRunAndCompany.put(key, (Object) retVal);
        incrementCache(pjp);
    }
    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.RunModelDao.FindByRunAndModelAndCompanyAspect.java

License:Open Source License

@Around("execution(* uk.gov.ofwat.fountain.dao.RunModelDao+.findByRunAndModelAndCompany(int, int, int))")
public Object cacheOnFindByItemAndModel(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }// w w w .  j a  v  a2s. c  o  m
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1] + "-" + (Integer) args[2];

    Object retVal = null;
    if (cacheByRunAndModelAndCompany.containsKey(key)) {
        retVal = cacheByRunAndModelAndCompany.get(key);
    } else {
        retVal = pjp.proceed();
        cacheByRunAndModelAndCompany.put(key, (Object) retVal);
        incrementCache(pjp);
    }
    return retVal;
}

From source file:uk.org.thegatekeeper.aop.AspectJGateController.java

License:Apache License

public Object invoke(ProceedingJoinPoint pjp) throws Throwable {
    tryGates(pjp.getTarget().getClass(), pjp.getSignature().getName(), pjp.getArgs());
    return pjp.proceed();
}