Example usage for org.springframework.aop.aspectj.annotation AspectMetadata getAjType

List of usage examples for org.springframework.aop.aspectj.annotation AspectMetadata getAjType

Introduction

In this page you can find the example usage for org.springframework.aop.aspectj.annotation AspectMetadata getAjType.

Prototype

public AjType<?> getAjType() 

Source Link

Document

Return AspectJ reflection information.

Usage

From source file:im.tym.wraop.impl.AspectJWrapperFactorySpi.java

/**
 * Create an {@link AspectMetadata} instance for the supplied aspect type.
 *//*from ww w.  j av a2 s . co  m*/
private AspectMetadata createAspectMetadata(Class aspectClass, String aspectName) {
    AspectMetadata am = new AspectMetadata(aspectClass, aspectName);
    if (!am.getAjType().isAspect()) {
        return null;
    }
    return am;
}

From source file:im.tym.wraop.impl.AspectJWrapperFactorySpi.java

@Override
public synchronized boolean addAspect(Object aspect) {
    if (super.addAspect(aspect)) {
        return true;
    }//  ww  w  . ja  v a 2 s  .co m
    if (!aspect.getClass().isAnnotationPresent(Aspect.class)) {
        return false;
    }
    Class aspectClass = aspect.getClass();
    String aspectName = aspectClass.getName();
    AspectMetadata am = createAspectMetadata(aspectClass, aspectName);
    if (am == null) {
        return false;
    }
    if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) {
        throw new IllegalArgumentException(
                "Aspect class [" + aspectClass.getName() + "] does not define a singleton aspect");
    }
    return addAdvisorsFromAspectInstanceFactory(
            new SingletonMetadataAwareAspectInstanceFactory(aspect, aspectName));
}