Example usage for org.aspectj.lang JoinPoint toShortString

List of usage examples for org.aspectj.lang JoinPoint toShortString

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint toShortString.

Prototype

String toShortString();

Source Link

Usage

From source file:ataspectj.ltwlog.Aspect1.java

License:Open Source License

@Before("execution(* ataspectj.ltwlog.Main*.target())")
public void before(JoinPoint jp) {
    System.out.println(jp.toShortString());
}

From source file:com.ciphertool.genetics.aspects.CleanAspect.java

License:Open Source License

@After("methodsMarkedWithAtClean()")
public void afterMethodsMarkedWithAtClean(JoinPoint jp) throws Throwable {
    if (log.isDebugEnabled()) {
        log.debug("executing advice for pointcut afterMethodsMarkedWithAtClean() at join point "
                + jp.toShortString());
    }/*  w w w. j  a v a2  s.  com*/

    Object chromosome = jp.getTarget();

    if (chromosome instanceof Chromosome) {
        ((Chromosome) chromosome).setDirty(false);
    }
}

From source file:com.ciphertool.genetics.aspects.DirtyAspect.java

License:Open Source License

@Before("methodsMarkedWithAtDirty()")
public void beforeMethodsMarkedWithAtDirty(JoinPoint jp) throws Throwable {
    if (log.isDebugEnabled()) {
        log.debug("executing advice for pointcut beforeMethodsMarkedWithAtDirty() at join point "
                + jp.toShortString());
    }//from   w ww.java2 s .c  o  m

    Object entity = jp.getTarget();

    if (entity instanceof Chromosome) {
        ((Chromosome) entity).setDirty(true);
    } else if (entity instanceof Gene) {
        ((Gene) entity).getChromosome().setDirty(true);
    } else if (entity instanceof Sequence) {
        ((Sequence) entity).getGene().getChromosome().setDirty(true);
    }
}

From source file:com.google.code.ssm.aop.counter.CounterInCacheBase.java

License:Open Source License

protected boolean checkData(final Object data, final JoinPoint pjp) {
    if (!isTypeSupported(data)) {
        getLogger().warn(//from w  w w .  j a va2s.c o m
                "Caching on {} aborted due to incorrect return type. Should be int, long, Integer or Long is {}",
                new Object[] { pjp.toShortString(), (data == null) ? null : data.getClass() });
        return false;
    }

    return true;
}

From source file:com.google.code.ssm.aop.counter.DecrementCounterInCacheAdvice.java

License:Open Source License

@AfterReturning("decrementSingleCounter()")
public void decrementSingle(final JoinPoint jp) throws Throwable {
    if (isDisabled()) {
        getLogger().info("Cache disabled");
        return;/*from  ww  w  .ja  v  a2 s .c om*/
    }
    // This is injected caching. If anything goes wrong in the caching, LOG
    // the crap outta it, but do not let it surface up past the AOP injection itself.
    // It will be invoked only if underlying method completes successfully.
    String cacheKey = null;
    DecrementCounterInCache annotation;
    try {
        Method methodToCache = getCacheBase().getMethodToCache(jp);
        annotation = methodToCache.getAnnotation(DecrementCounterInCache.class);
        AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation,
                DecrementCounterInCache.class, methodToCache);
        cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(data, jp.getArgs(),
                methodToCache.toString());
        getCacheBase().getCache(data).decr(cacheKey, 1);
    } catch (Exception ex) {
        warn(ex, "Decrementing counter [%s] via %s aborted due to an error.", cacheKey, jp.toShortString());
    }
}

From source file:com.google.code.ssm.aop.counter.IncrementCounterInCacheAdvice.java

License:Open Source License

@AfterReturning("incrementSingleCounter()")
public void incrementSingle(final JoinPoint jp) throws Throwable {
    if (isDisabled()) {
        getLogger().info("Cache disabled");
        return;//from  w ww  . j  ava 2 s.  c om
    }

    // This is injected caching. If anything goes wrong in the caching, LOG
    // the crap outta it, but do not let it surface up past the AOP injection itself.
    // It will be invoked only if underlying method completes successfully.
    String cacheKey = null;
    IncrementCounterInCache annotation;
    try {
        Method methodToCache = getCacheBase().getMethodToCache(jp);
        annotation = methodToCache.getAnnotation(IncrementCounterInCache.class);
        AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation,
                IncrementCounterInCache.class, methodToCache);
        cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(data, jp.getArgs(),
                methodToCache.toString());
        getCacheBase().getCache(data).incr(cacheKey, 1, 1);
    } catch (Exception ex) {
        warn(ex, "Incrementing counter [%s] via %s aborted due to an error.", cacheKey, jp.toShortString());
    }
}

From source file:com.google.code.ssm.aop.counter.UpdateCounterInCacheAdvice.java

License:Open Source License

@AfterReturning(pointcut = "updateCounter()", returning = "retVal")
public void cacheCounterInCache(final JoinPoint jp, final Object retVal) throws Throwable {
    if (isDisabled()) {
        getLogger().info("Cache disabled");
        return;//from w  w  w. j av  a2  s  .  c o m
    }

    // For Update*Cache, an AfterReturning aspect is fine. We will only
    // apply our caching after the underlying method completes successfully, and we will have
    // the same access to the method params.
    String cacheKey = null;
    UpdateCounterInCache annotation;
    try {
        Method methodToCache = getCacheBase().getMethodToCache(jp);
        annotation = methodToCache.getAnnotation(UpdateCounterInCache.class);
        AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation, UpdateCounterInCache.class,
                methodToCache);
        cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(data, jp.getArgs(),
                methodToCache.toString());

        Object dataObject = getCacheBase().getUpdateData(data, methodToCache, jp.getArgs(), retVal);
        if (checkData(dataObject, jp)) {
            long value = ((Number) dataObject).longValue();
            getCacheBase().getCache(data).setCounter(cacheKey, annotation.expiration(), value);
        }
    } catch (Exception ex) {
        warn(ex, "Updating counter [%s] in cache via %s aborted due to an error.", cacheKey,
                jp.toShortString());
    }
}

From source file:com.google.code.ssm.aop.SingleUpdateCacheAdvice.java

License:Open Source License

protected void update(final JoinPoint jp, final Object retVal) throws Throwable {
    if (isDisabled()) {
        getLogger().info("Cache disabled");
        return;/*from  w  w  w  . j ava2 s. com*/
    }

    // For Update*Cache, an AfterReturning aspect is fine. We will only
    // apply our caching after the underlying method completes successfully, and we will have
    // the same access to the method params.
    String cacheKey = null;
    try {
        final Method methodToCache = getCacheBase().getMethodToCache(jp);
        final T annotation = methodToCache.getAnnotation(annotationClass);
        final AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation, annotationClass,
                methodToCache);

        if (data.isReturnKeyIndex()) {
            cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(retVal, data.getNamespace());
        } else {
            cacheKey = getCacheKey(data, jp.getArgs(), methodToCache.toString());
        }

        final Object dataObject = getCacheBase().<Object>getUpdateData(data, methodToCache, jp.getArgs(),
                retVal);
        final SerializationType serializationType = getCacheBase().getSerializationType(methodToCache);
        final Object submission = getCacheBase().getSubmission(dataObject);
        getCacheBase().getCache(data).set(cacheKey, data.getExpiration(), submission, serializationType);
    } catch (Exception ex) {
        warn(ex, "Caching on method %s and key [%s] aborted due to an error.", jp.toShortString(), cacheKey);
    }
}

From source file:com.google.code.ssm.aop.UpdateMultiCacheAdvice.java

License:Open Source License

@AfterReturning(pointcut = "updateMulti()", returning = "retVal")
public void cacheUpdateMulti(final JoinPoint jp, final Object retVal) throws Throwable {
    if (isDisabled()) {
        getLogger().info("Cache disabled");
        return;//  w  ww.j  av  a 2s .c  om
    }

    // For Update*Cache, an AfterReturning aspect is fine. We will only
    // apply our caching after the underlying method completes successfully, and we will have
    // the same access to the method params.
    try {
        final Method methodToCache = getCacheBase().getMethodToCache(jp);
        final UpdateMultiCache annotation = methodToCache.getAnnotation(UpdateMultiCache.class);
        final AnnotationData data = AnnotationDataBuilder.buildAnnotationData(annotation,
                UpdateMultiCache.class, methodToCache);
        final List<Object> dataList = getCacheBase().<List<Object>>getUpdateData(data, methodToCache,
                jp.getArgs(), retVal);
        final SerializationType serializationType = getCacheBase().getSerializationType(methodToCache);
        final MultiCacheCoordinator coord = new MultiCacheCoordinator(methodToCache, data);
        coord.setAddNullsToCache(annotation.option().addNullsToCache());

        final List<String> cacheKeys;
        if (data.isReturnKeyIndex()) {
            @SuppressWarnings("unchecked")
            final List<Object> keyObjects = (List<Object>) retVal;
            coord.setHolder(convertIdObjectsToKeyMap(keyObjects, data));
            cacheKeys = getCacheBase().getCacheKeyBuilder().getCacheKeys(keyObjects, data.getNamespace());
        } else {
            // Create key->object and object->key mappings.
            coord.setHolder(
                    createObjectIdCacheKeyMapping(coord.getAnnotationData(), jp.getArgs(), coord.getMethod()));
            @SuppressWarnings("unchecked")
            List<Object> listKeyObjects = (List<Object>) Utils.getMethodArg(data.getListIndexInMethodArgs(),
                    jp.getArgs(), methodToCache.toString());
            coord.setListKeyObjects(listKeyObjects);
            // keySet is sorted
            cacheKeys = new ArrayList<String>(coord.getKey2Obj().keySet());
        }

        if (!annotation.option().addNullsToCache()) {
            updateCache(cacheKeys, dataList, methodToCache, data, serializationType);
        } else {
            Map<String, Object> key2Result = new HashMap<String, Object>();
            for (String cacheKey : cacheKeys) {
                key2Result.put(cacheKey, null);
            }
            coord.setInitialKey2Result(key2Result);
            updateCacheWithMissed(dataList, coord, annotation.option(), serializationType);
        }
    } catch (Exception ex) {
        warn(ex, "Updating caching via %s aborted due to an error.", jp.toShortString());
    }
}

From source file:com.gordondickens.bcf.logging.LogAdvice.java

License:Apache License

public void doBasicLogging(JoinPoint pjp) throws Throwable {
    Object[] args = pjp.getArgs();
    StringBuffer output = new StringBuffer();

    output.append(pjp.getTarget().getClass().getName()).append(": ");
    output.append(pjp.toShortString()).append(": ");

    for (Object arg : args) {
        output.append(arg).append(" ");
    }//  w  ww  .  j a v  a2  s.  c om

    logger.info("Basic: " + output.toString());
}