Example usage for org.aspectj.lang ProceedingJoinPoint getArgs

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

Introduction

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

Prototype

Object[] getArgs();

Source Link

Usage

From source file:org.grouter.common.logging.MethodLogger.java

License:Apache License

private Object log(ProceedingJoinPoint joinPoint) throws Throwable {
    log.info("Starting stopwatch");
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from w w w .j  a v a 2s.c o  m

    Object[] args = joinPoint.getArgs();
    // E.g. public abstract org.grouter.domain.entities.User org.grouter.domain.service.UserService.findById(java.lang.Long)
    String name = joinPoint.getSignature().toLongString();
    StringBuffer sb = new StringBuffer(name + " called with: [");
    for (int i = 0; i < args.length; i++) {
        Object o = args[i];
        sb.append(o);
        sb.append((i == args.length - 1) ? "]" : ", ");
    }
    log.info(sb);
    Object retVal = joinPoint.proceed();
    stopWatch.stop();

    log.info(" return: " + retVal + ", time: " + stopWatch.getTime());
    return retVal;
}

From source file:org.hellojavaer.ddal.spring.scan.EnableDBClusterRouteAnnotation.java

License:Apache License

@Around("@annotation(dbClusterRoute)")
public Object around(ProceedingJoinPoint joinPoint, DBClusterRoute dbClusterRoute) throws Throwable {
    try {//from  ww w . j  a  va  2s  . c  o m
        DBClusterRouteContext.pushContext();
        Object[] args = joinPoint.getArgs();
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        MethodBasedSpelExpression expression = expressionCache.get(method);
        if (expression == null) {
            synchronized (expressionCache) {
                expression = expressionCache.get(method);
                if (expression == null) {
                    expression = new MethodBasedSpelExpression(dbClusterRoute.clusterName(), method);
                    expressionCache.put(method, expression);
                }
            }
        }
        String targetClusterName = expression.parse(String.class, args);
        DBClusterRouteContext.setClusterName(targetClusterName);
        return joinPoint.proceed(args);
    } finally {
        DBClusterRouteContext.popContext();
    }
}

From source file:org.hellojavaer.ddal.spring.scan.EnableShardRouteAnnotation.java

License:Apache License

@Around("@annotation(shardRoute)")
public Object around(ProceedingJoinPoint joinPoint, ShardRoute shardRoute) throws Throwable {
    try {/*from www .  java  2 s. co m*/
        ShardRouteContext.pushContext();
        if (shardRoute.scName() != null && shardRoute.scName().length() > 0 //
                && shardRoute.sdValue() != null && shardRoute.sdValue().length() > 0) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            Method method = methodSignature.getMethod();
            MethodBasedSpelExpression expression = expressionCache.get(method);
            Object[] args = joinPoint.getArgs();
            if (expression == null) {
                synchronized (expressionCache) {
                    expression = expressionCache.get(method);
                    if (expression == null) {
                        expression = new MethodBasedSpelExpression(shardRoute.sdValue(), method);
                        expressionCache.put(method, expression);
                    }
                }
            }
            Object val = expression.parse(Object.class, args);
            String[] scNames = shardRoute.scName().split(",");
            for (String scName : scNames) {
                ShardRouteContext.setRouteInfo(scName, val);
            }
        } else {
            if ((shardRoute.scName() == null || shardRoute.scName().length() == 0)
                    && (shardRoute.sdValue() == null || shardRoute.sdValue().length() == 0)) {
                // ok
            } else {
                throw new IllegalArgumentException(
                        "scName and sdValue should either both have a non-empty value or both have a empty value");
            }
        }
        return joinPoint.proceed(joinPoint.getArgs());
    } finally {
        ShardRouteContext.popContext();
    }
}

From source file:org.hippoecm.hst.demo.components.ExampleProfilingHstComponentAspect.java

License:Apache License

public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from ww  w .  j a  va  2 s . com

    final HstResponse hstResponse = (HstResponse) pjp.getArgs()[1];
    final String compNamespace = hstResponse.getNamespace();

    Object retVal = pjp.proceed();

    stopWatch.stop();
    log.info("Example profiling for '{}': {}ms.", compNamespace, stopWatch.getTime());

    return retVal;
}

From source file:org.hoteia.qalingo.core.aop.cache.CacheManagementAspect.java

License:Apache License

public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
    Object returnObject = null;/*from w  ww . j av a2s .co m*/
    try {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Class classTarget = signature.getReturnType();
        Object[] args = joinPoint.getArgs();
        String suffix = "";
        FetchPlan askedFetchPlan = null;
        FetchPlan loadedFetchPlan = null;
        String cacheType = CACHE_TYPE_MISC;

        // TOD : Denis : blind le code pour tester les arg differement entre une method get* et find* et autre

        if (joinPoint.getSignature().toShortString().contains("ById")) {
            // FIRST ARG IS A LONG FOR THE GET METHOD : SO THIS A GET BY ID
            cacheType = CACHE_BY_ID;
        } else if (joinPoint.getSignature().toShortString().contains("ByCode")) {
            // FIRST ARG IS A STRING FOR THE GET METHOD : SO THIS A GET BY CODE
            cacheType = CACHE_BY_CODE;
        }

        for (int i = 0; i < args.length; i++) {
            Object arg = args[i];
            if (arg instanceof Object[]) {
                Object[] objects = (Object[]) arg;
                for (int j = 0; j < objects.length; j++) {
                    Object object = (Object) objects[j];
                    if (object instanceof FetchPlan) {
                        FetchPlan fetchPlan = (FetchPlan) object;
                        if (fetchPlan != null && !fetchPlan.getFetchModes().isEmpty()) {
                            askedFetchPlan = fetchPlan;
                        }
                    }
                }
            }
            if (arg instanceof RequestData) {
                RequestData requestData = (RequestData) arg;
                if (!suffix.endsWith("_")) {
                    suffix = suffix + "_";
                }
                suffix = suffix + requestData.getMarketPlace().getCode() + "_"
                        + requestData.getMarket().getCode() + "_" + requestData.getMarketArea().getCode() + "_"
                        + requestData.getMarketAreaLocalization().getCode() + "_"
                        + requestData.getMarketAreaRetailer().getCode() + "_"
                        + requestData.getMarketAreaCurrency().getCode();

            } else if (arg instanceof AbstractEntity) {
                AbstractEntity argEntity = (AbstractEntity) arg;
                if (!suffix.endsWith("_")) {
                    suffix = suffix + "_";
                }
                Method[] methods = argEntity.getClass().getMethods();
                for (int j = 0; j < methods.length; j++) {
                    Method methodIt = methods[j];
                    if (methodIt.getName().equals("getId")) {
                        Long id = (Long) methodIt.invoke(argEntity);
                        suffix = suffix + id;
                    }
                }

            } else {
                if (arg != null && !(arg instanceof java.lang.Object[]) && !(arg instanceof AbstractEntity)) {
                    if (!suffix.endsWith("_")) {
                        suffix = suffix + "_";
                    }
                    suffix = suffix + arg.toString();
                }
            }
        }
        String key = null;
        String cacheName = DEFAULT_CACHE_NAME;
        if (classTarget != null) {
            try {
                Field cacheField = null;
                Field[] fields = classTarget.getFields();
                for (int i = 0; i < fields.length; i++) {
                    Field fieldIt = fields[i];
                    if (fieldIt.getName().equals(CACHE_NAME)) {
                        cacheField = fieldIt;
                    }
                }
                if (cacheField != null) {
                    cacheName = (String) cacheField.get(CACHE_NAME);
                }
            } catch (IllegalAccessException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("IllegalAccessException code.", e);
                }
            }
        }

        // CACHE TYPE
        if (cacheType.equals(CACHE_TYPE_MISC)) {
            key = joinPoint.getSignature().toShortString() + suffix;
            if (!cacheName.contains("_misc")) {
                cacheName = cacheName + "_misc";
            }
        } else if (cacheType.equals(CACHE_BY_CODE)) {
            // TODO : Denis : utiliser un cache de type cacheName_link_code_id pour avoir l'id en fonction du code
            key = classTarget.getName() + suffix;
            cacheName = cacheName + "_link_code_id";
        } else {
            key = classTarget.getName() + suffix;
        }

        Cache cache = getCacheManager() != null && StringUtils.isNotEmpty(cacheName)
                ? getCacheManager().getCache(cacheName)
                : null;
        if (cache != null) {
            if (cache.isKeyInCache(key)) {
                Element element = cache.get(key);
                if (element != null && !element.isExpired()) {
                    // WE TEST IF THE FETCH PLAN ARE EQUALS
                    returnObject = element.getObjectValue();
                    if (returnObject instanceof AbstractEntity) {
                        AbstractEntity entity = (AbstractEntity) returnObject;
                        if (entity.getFetchPlan() != null) {
                            loadedFetchPlan = entity.getFetchPlan();
                        }

                        if (cacheType.equals(CACHE_BY_ID)) {
                            // ENTITY : UPDATE THE CACHE LINK ID CODE
                            String cacheNameIdCodeLink = cacheName + "_link_code_id";
                            Cache cacheLinkIdCode = getCacheManager() != null
                                    && StringUtils.isNotEmpty(cacheNameIdCodeLink)
                                            ? getCacheManager().getCache(cacheNameIdCodeLink)
                                            : null;
                            if (cacheLinkIdCode != null) {
                                String newKey = null;
                                String codeValue = null;
                                try {
                                    Method[] methods = classTarget.getMethods();
                                    for (int i = 0; i < methods.length; i++) {
                                        Method methodIt = methods[i];
                                        if (methodIt.getName().equals("getId")) {
                                            Long id = (Long) methodIt.invoke(returnObject);
                                            newKey = classTarget.getName() + "_" + id;
                                        }
                                        if (methodIt.getName().equals("getCode")) {
                                            codeValue = (String) methodIt.invoke(returnObject);
                                        }
                                        if (newKey != null && codeValue != null) {
                                            break;
                                        }
                                    }
                                } catch (Exception e) {
                                    if (logger.isDebugEnabled()) {
                                        logger.debug("IllegalAccessException.", e);
                                    }
                                }
                                if (newKey != null) {
                                    cacheLinkIdCode.put(new Element(newKey, codeValue));
                                }
                            }
                        }

                        if (cacheType.equals(CACHE_BY_CODE)) {
                            String cacheNameEntityById = cacheName.replace("_link_code_id", "");
                            Cache cacheEntityById = getCacheManager() != null
                                    && StringUtils.isNotEmpty(cacheNameEntityById)
                                            ? getCacheManager().getCache(cacheNameEntityById)
                                            : null;

                            String newKey = null;
                            Method[] methods = classTarget.getMethods();
                            for (int i = 0; i < methods.length; i++) {
                                Method methodIt = methods[i];
                                if (methodIt.getName().equals("getId")) {
                                    Long id = (Long) methodIt.invoke(returnObject);
                                    newKey = classTarget.getName() + "_" + id;
                                    break;
                                }
                            }

                            if (cacheEntityById != null) {
                                if (cacheEntityById.isKeyInCache(newKey)) {
                                    Element elementEntityById = cacheEntityById.get(newKey);
                                    if (elementEntityById != null && !elementEntityById.isExpired()) {
                                        returnObject = elementEntityById.getObjectValue();
                                    }
                                }
                            }

                        }
                    } else if (returnObject instanceof Long) {
                        if (cacheType.equals(CACHE_BY_CODE)) {
                            String cacheNameEntityById = cacheName.replace("_link_code_id", "");
                            Cache cacheEntityById = getCacheManager() != null
                                    && StringUtils.isNotEmpty(cacheNameEntityById)
                                            ? getCacheManager().getCache(cacheNameEntityById)
                                            : null;
                            String newKey = classTarget.getName() + "_" + returnObject;
                            if (cacheEntityById.isKeyInCache(newKey)) {
                                Element finalElement = cacheEntityById.get(newKey);
                                if (finalElement != null && !finalElement.isExpired()) {
                                    // WE WILL TEST IF THE FETCH PLAN ARE EQUALS
                                    returnObject = finalElement.getObjectValue();
                                }
                            } else {
                                // WE RESET THE returnObject WHICH HAS THE LONG VALUE - THIS WILL TRIGGER THE LOAD BY DAO
                                returnObject = null;
                            }
                        }
                    }
                }
            }
            if (returnObject == null) {
                if (loadedFetchPlan != null) {
                    args = ArrayUtils.add(args, loadedFetchPlan);
                    returnObject = joinPoint.proceed(args);
                } else {
                    returnObject = joinPoint.proceed();
                }
                if (returnObject != null && cacheType.equals(CACHE_BY_CODE)) {
                    // PUT IN THE RIGHT ENTITY CACHE
                    String cacheNameEntityById = cacheName.replace("_link_code_id", "");
                    Cache cacheEntityById = getCacheManager() != null
                            && StringUtils.isNotEmpty(cacheNameEntityById)
                                    ? getCacheManager().getCache(cacheNameEntityById)
                                    : null;
                    String newKey = null;
                    Method[] methods = classTarget.getMethods();
                    Long value = null;
                    for (int i = 0; i < methods.length; i++) {
                        Method methodIt = methods[i];
                        if (methodIt.getName().equals("getId")) {
                            Long id = (Long) methodIt.invoke(returnObject);
                            newKey = classTarget.getName() + "_" + id;
                            value = id;
                            break;
                        }
                    }
                    if (cacheEntityById != null) {
                        cacheEntityById.put(new Element(newKey, returnObject));
                    }

                    cache.put(new Element(key, value));

                } else {
                    cache.put(new Element(key, returnObject));
                }
            } else {
                if (returnObject instanceof AbstractEntity) {
                    AbstractEntity entity = (AbstractEntity) returnObject;
                    if (entity.getFetchPlan() != null) {
                        loadedFetchPlan = entity.getFetchPlan();
                    }
                    if (askedFetchPlan != null) {
                        if (loadedFetchPlan != null
                                && !loadedFetchPlan.containAllTargetFetchPlans(askedFetchPlan)) {
                            // ENTITY IS LOAD WITHOUT FETCHPLAN - WE RESET THE returnObject TO TRIGGER THE RELOAD WITH THE FETCHPLAN
                            // WE WILL ADD LOADED FETCH PLAN AND ASKED FETCH PLAN TO THE INVOCATED METHOD
                            returnObject = null;

                        }

                        //                            for (Iterator<SpecificFetchMode> iterator = askedFetchPlan.iterator(); iterator.hasNext();) {
                        //                                SpecificFetchMode specificFetchMode = (SpecificFetchMode) iterator.next();
                        //                                if(loadedFetchPlan == null){
                        //                                    // ENTITY IS LOAD WITHOUT FETCHPLAN - WE RESET THE returnObject TO TRIGGER THE RELOAD WITH THE FETCHPLAN
                        //                                    returnObject = null;
                        //                                    break;
                        //                                } else if (!loadedFetchPlan.contains(specificFetchMode)){
                        //                                    // ENTITY IS LOAD WITH A DIFF FETCHPLAN - WE RESET THE returnObject TO TRIGGER THE RELOAD
                        //                                    returnObject = null;
                        //                                    break;
                        //                                }
                        //                            }

                        if (returnObject == null) {
                            if (loadedFetchPlan != null) {
                                for (int i = 0; i < args.length; i++) {
                                    Object arg = args[i];
                                    if (arg instanceof Object[]) {
                                        Object[] objects = (Object[]) arg;
                                        for (int j = 0; j < objects.length; j++) {
                                            Object object = (Object) objects[j];
                                            if (object instanceof FetchPlan) {
                                                // WE ARE IN THE FETCHPLAN OBJECT ARRAY
                                                objects = ArrayUtils.add(objects, entity.getFetchPlan());
                                                args = ArrayUtils.remove(args, i);
                                                args = ArrayUtils.add(args, objects);
                                                break;
                                            }
                                        }
                                    }
                                }

                                returnObject = joinPoint.proceed(args);
                            }
                            //                                else {
                            //                                    returnObject = joinPoint.proceed();
                            //                                }

                            if (returnObject != null) {
                                if (cacheType.equals(CACHE_BY_CODE)) {
                                    // PUT IN THE RIGHT ENTITY CACHE
                                    String cacheNameEntityById = cacheName.replace("_link_code_id", "");
                                    Cache cacheEntityById = getCacheManager() != null
                                            && StringUtils.isNotEmpty(cacheNameEntityById)
                                                    ? getCacheManager().getCache(cacheNameEntityById)
                                                    : null;
                                    String newKey = null;
                                    Method[] methods = classTarget.getMethods();
                                    Long value = null;
                                    for (int i = 0; i < methods.length; i++) {
                                        Method methodIt = methods[i];
                                        if (methodIt.getName().equals("getId")) {
                                            Long id = (Long) methodIt.invoke(returnObject);
                                            newKey = classTarget.getName() + "_" + id;
                                            value = id;
                                            break;
                                        }
                                    }
                                    if (cacheEntityById != null) {
                                        cacheEntityById.put(new Element(newKey, returnObject));
                                    }

                                    cache.put(new Element(key, value));

                                } else {
                                    cache.put(new Element(key, returnObject));
                                }
                            }
                        }
                    }
                }
            }

        }

    } catch (Exception e) {
        logger.error("Failed to load datas with Cache AOP!", e);
    }
    return returnObject;
}

From source file:org.imsglobal.aspect.LtiLaunchVerifier.java

@Around("@annotation(launch)")
public Object verifyLtiLaunch(ProceedingJoinPoint pjp, Lti launch) throws Throwable {
    HttpServletRequest request = null;/*w  w  w.j av  a 2  s  . c o  m*/
    for (Object arg : pjp.getArgs()) {
        if (HttpServletRequest.class.isInstance(arg)) {
            request = (HttpServletRequest) arg;
        }
    }
    if (request == null) {
        throw new IllegalStateException(
                getErrorMessageForArgumentClass("HttpServletRequest", pjp.getSignature().toLongString()));
    }

    String oauthSecret = keyService.getSecretForKey(request.getParameter("oauth_consumer_key"));
    LtiVerificationResult ltiResult = ltiVerifier.verify(request, oauthSecret);//BasicLTIUtil.validateMessage(request, request.getRequestURL().toString(), oauthSecret);

    Boolean ltiVerificationResultExists = false;
    //This array will hold the arguments to the join point, so we can pass them along to the advised function.
    List<Object> args = new ArrayList<>(pjp.getArgs().length);
    for (Object arg : pjp.getArgs()) {
        if (arg.getClass().equals(LtiVerificationResult.class)) {
            args.add(ltiResult);
            ltiVerificationResultExists = true;
        } else {
            args.add(arg);
        }
    }
    if (!ltiVerificationResultExists) {
        throw new IllegalStateException(
                getErrorMessageForArgumentClass("LtiVerificationResult", pjp.getSignature().toLongString()));
    }

    return pjp.proceed(args.toArray());
}

From source file:org.iobserve.monitoring.probe.aspectj.AbstractOperationExecutionWithParameterAspect.java

License:Apache License

@Around("monitoredOperation() && this(thisObject) && notWithinKieker()")
public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS
                                                                                                             // (Throwable)
    if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }/*from ww  w.java  2  s . c om*/
    final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isProbeActivated(operationSignature)) {
        return thisJoinPoint.proceed();
    }

    // common fields
    TraceMetadata trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.registerTrace();
        AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(trace);
    }

    final long traceId = trace.getTraceId();
    final String clazz = thisObject.getClass().getName();

    /** extension over the original routine. */
    final String[] names = ((MethodSignature) thisJoinPoint.getSignature()).getParameterNames();

    final Object[] arguments = thisJoinPoint.getArgs();
    final String[] values = new String[arguments.length];

    int i = 0;
    for (final Object argument : arguments) {
        values[i++] = argument.toString();
    }

    /** exchanged return type. */
    // measure before execution
    AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(
            new EntryLevelBeforeOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(),
                    traceId, trace.getNextOrderId(), operationSignature, clazz, names, values, 0));
    // execution of the called method

    final Object retval;

    try {
        retval = thisJoinPoint.proceed();
    } catch (final Throwable th) { // NOPMD NOCS (catch throw might ok here)
        // measure after failed execution
        AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(
                new AfterOperationFailedEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(),
                        traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString()));
        throw th;
    } finally {
        if (newTrace) { // close the trace
            AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.unregisterTrace();
        }
    }
    // measure after successful execution
    AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(
            new AfterOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId,
                    trace.getNextOrderId(), operationSignature, clazz));
    return retval;
}

From source file:org.jasig.cas.aspect.LogAspect.java

License:Apache License

/**
 * Added TRACE-level log entries for the executing target.
 *
 * @param proceedingJoinPoint the proceeding join point
 * @return the object// ww w  . j  av  a 2s .  co m
 * @throws Throwable the throwable
 */
@Around("(execution (public * org.jasig.cas..*.*(..))) && !(execution( * org.jasig.cas..*.set*(..)))")
public Object traceMethod(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    Object returnVal = null;
    final Logger logger = this.getLog(proceedingJoinPoint);
    final String methodName = proceedingJoinPoint.getSignature().getName();

    try {
        if (logger.isTraceEnabled()) {
            final Object[] args = proceedingJoinPoint.getArgs();
            final String arguments;
            if (args == null || args.length == 0) {
                arguments = "";
            } else {
                arguments = Arrays.deepToString(args);
            }
            logger.trace("Entering method [{}] with arguments [{}]", methodName, arguments);
        }
        returnVal = proceedingJoinPoint.proceed();
        return returnVal;
    } finally {
        logger.trace("Leaving method [{}] with return value [{}].", methodName,
                (returnVal != null ? returnVal.toString() : "null"));
    }
}

From source file:org.kuali.student.common.test.spring.IdToObjectEhcacheAdvice.java

License:Educational Community License

public Object invalidateCache(ProceedingJoinPoint pjp) throws Throwable {
    if (cacheManager == null) {
        cacheManager = CacheManager.getInstance();
        try {//ww  w . ja  v a2  s  .  c o  m
            cacheManager.addCache(cacheName);
        } catch (ObjectExistsException e) {

        }
    }
    LOG.info("Invalidating Cache");
    cacheManager.getCache(cacheName).remove(pjp.getArgs()[0]);
    return pjp.proceed();
}

From source file:org.kuali.student.common.test.spring.IdToObjectEhcacheAdvice.java

License:Educational Community License

@SuppressWarnings("unchecked")
public Object getFromCache(ProceedingJoinPoint pjp) throws Throwable {
    if (cacheManager == null) {
        cacheManager = CacheManager.getInstance();
        try {/*www  .  j av a  2s.c om*/
            cacheManager.addCache(cacheName);
        } catch (ObjectExistsException e) {

        }
    }
    // Have two caches for the one object? one by id, the other by method
    // call?
    if (pjp.getArgs().length == 1 && pjp.getArgs()[0] instanceof List) {
        List<Object> results = new ArrayList<Object>();
        List<String> uncachedIdList = new ArrayList<String>();
        for (String id : (List<String>) pjp.getArgs()[0]) {
            // Look in the cache
            LOG.info("Looking in Cache");
            Element cachedResult = cacheManager.getCache(cacheName).get(id);
            if (cachedResult == null) {
                uncachedIdList.add(id);
            } else {
                results.add(cachedResult.getValue());
            }
        }
        if (uncachedIdList.size() > 0) {
            List<Idable> uncachedResults = (List<Idable>) pjp.proceed();
            if (uncachedResults != null) {
                for (Idable uncachedResult : uncachedResults) {
                    // Add to the cache and add to results
                    LOG.info("Storing to Cache");
                    results.add(uncachedResult);
                    cacheManager.getCache(cacheName).put(new Element(uncachedResult.getId(), uncachedResult));
                }
            }
        }
        return results;
    }
    if (pjp.getArgs().length == 1 && pjp.getArgs()[0] instanceof String) {
        String id = (String) pjp.getArgs()[0];
        LOG.info("Looking in Cache");
        Element resultElement = cacheManager.getCache(cacheName).get(id);
        Object result;
        if (resultElement == null) {
            result = pjp.proceed();
            LOG.info("Storing to Cache");
            cacheManager.getCache(cacheName).put(new Element(id, result));
        } else {
            result = resultElement.getValue();
        }
        return result;
    }

    return pjp.proceed();
}