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.generic.FindByIdAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("uk.gov.ofwat.fountain.aspect.cache.dao.DaoCache.findByIdEntityPC()")
public Object cacheOnFindByID(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from w w w .  jav a2s.  co m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

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

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

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.generic.GetAllAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("uk.gov.ofwat.fountain.aspect.cache.dao.DaoCache.getAllEntityPC()")
public List cacheOnGetAll(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return (List) pjp.proceed();
    }/*from w ww. ja  va 2  s.c om*/
    if (null == cacheAll || cacheAll.isEmpty()) {
        cacheAll = (List<Object>) pjp.proceed();
        initialiseCache(pjp.getTarget().getClass());
    }
    return cacheAll;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.branchDao.FindByCompanyAndRunAspect.java

License:Open Source License

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

    Object[] args = pjp.getArgs();
    String key = (Integer) args[0] + "-" + (Integer) args[1];
    if (key.equals("0-0")) {
        // old style branches that don't have a company or run 
        return pjp.proceed();
    }

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

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.GetBranchDataAspect.java

License:Open Source License

@Around("execution(public * uk.gov.ofwat.fountain.dao.DataDao.getBranchData(int, int, int, int, int))")
public Object cacheOnBranchData(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from ww  w . j  a va  2 s.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] + "-" + (Integer) args[3]
            + "-" + (Integer) args[4];

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

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.GetBranchDataAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(public void uk.gov.ofwat.fountain.dao.DataDao.addToCache(java.util.Map<String, Object>))")
public void addToCache(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return;//from   www. j av a2 s .  c  o  m
    }
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    log.debug("start addToCache");
    Object[] args = pjp.getArgs();
    Map<String, Object> dataMap = (Map<String, Object>) args[0];
    cacheBranchData.putAll(dataMap);
    log.debug("end addToCache");
    return;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.GetBranchDataAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(public * uk.gov.ofwat.fountain.dao.DataDao.isDataInCache(String))")
public Boolean isDataInCache(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return false;
    }/*from w w w  .j av a  2s  .  co  m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

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

    if (cacheBranchData.containsKey(key)) {
        return true;
    }

    return false;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.LatestDataAspect.java

License:Open Source License

@Around("execution(public uk.gov.ofwat.fountain.domain.Data uk.gov.ofwat.fountain.dao.DataDao.getLatestData(int, int, int, int))")
public Object cacheOnLatestData(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }// w w w. ja v a 2  s .co  m
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    Object[] args = pjp.getArgs();
    String key = "";
    for (int i = 0; i < args.length; i++) {
        key = key + (Integer) args[i] + "-";
    }

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

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.TaggedDataAspect.java

License:Open Source License

@Around("execution(public * uk.gov.ofwat.fountain.dao.DataDao.getTaggedData(int, int, int, int, int, long))")
public Object cacheOnBranchData(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return pjp.proceed();
    }/*from  w ww.j ava2 s.  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] + "-" + (Integer) args[3]
            + "-" + (Integer) args[4] + "-" + (Long) args[5];

    Object retVal = null;
    if (taggedData.containsKey(key)) {
        retVal = taggedData.get(key);
    } else {
        logger.warn("Tagged data not found in cache: " + key);
    }

    return retVal;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.dataDao.TaggedDataAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(public void uk.gov.ofwat.fountain.dao.DataDao.addToTaggedCache(java.util.Map<String, Object>))")
public void addToCache(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return;//  w ww.ja  va 2s  .  co  m
    }
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

    logger.debug("start addToTaggedCache");
    Object[] args = pjp.getArgs();
    Map<String, Object> dataMap = (Map<String, Object>) args[0];
    taggedData.putAll(dataMap);
    logger.debug("end addToTaggedCache");
    return;
}

From source file:uk.gov.ofwat.fountain.aspect.cache.dao.specific.groupDao.FindEntriesForCompanyAndGroupAspect.java

License:Open Source License

@SuppressWarnings("unchecked")
@Around("execution(public * uk.gov.ofwat.fountain.dao.GroupDao+.findEntriesForCompanyAndGroup(uk.gov.ofwat.fountain.domain.Company, uk.gov.ofwat.fountain.domain.Group))")
public List<GroupEntry> cacheOnFindEntriesForCompanyAndGroup(ProceedingJoinPoint pjp) throws Throwable {
    if (!isEnabled()) {
        return (List) pjp.proceed();
    }/*from w  w w .java  2s. c o m*/
    if (null == getCache()) {
        initialiseCache(pjp.getTarget().getClass());
    }

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

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

    return retVal;
}