Example usage for org.aspectj.lang Signature getDeclaringTypeName

List of usage examples for org.aspectj.lang Signature getDeclaringTypeName

Introduction

In this page you can find the example usage for org.aspectj.lang Signature getDeclaringTypeName.

Prototype

String getDeclaringTypeName();

Source Link

Document

This is equivalent to calling getDeclaringType().getName(), but caches the result for greater efficiency.

Usage

From source file:com.github.woozoo73.ht.SignatureInfo.java

License:Apache License

public SignatureInfo(Signature signature) {
    if (signature == null) {
        return;/* w w w .j  av a 2s.  c o  m*/
    }

    this.shortString = signature.toShortString();
    this.longString = signature.toLongString();
    this.name = signature.getName();
    this.modifiers = signature.getModifiers();
    this.declaringType = signature.getDeclaringType();
    this.declaringTypeName = signature.getDeclaringTypeName();
}

From source file:com.klistret.cmdb.utility.spring.OptimisticLocking.java

License:Open Source License

public Object commitTransaction(ProceedingJoinPoint pjp) throws Throwable {
    try {//  w ww  .j a v a2  s.c o m
        return pjp.proceed();
    } catch (HibernateOptimisticLockingFailureException e) {
        Signature signature = pjp.getSignature();
        logger.error("Stale in declaration:{}, name: {}, long: {} message: {}", new Object[] {
                signature.getDeclaringTypeName(), signature.getName(), pjp.toLongString(), e.getMessage() });
        throw new ApplicationException("Stale entity captured.");
    }
}

From source file:com.mpobjects.rtcalltree.rec.AspectJRecorder.java

License:Apache License

/**
 * @param aJoinPoint//from w w w  .j a  va2  s . co  m
 * @return
 */
protected MutableCalltreeEntry createEntry(ProceedingJoinPoint aJoinPoint) {
    final Signature signature = aJoinPoint.getSignature();
    String className = signature.getDeclaringTypeName();
    final String methodName = signature.getName();
    final Object target = aJoinPoint.getTarget();
    if (target != null) {
        if (!Proxy.isProxyClass(target.getClass())) {
            className = target.getClass().getName();
        }
    }
    CalltreeEntryImpl entry = new CalltreeEntryImpl(className, methodName);
    /* Spring AOP throws exceptions on getFileName() etc. instead of just returning null for SourceLocation */
    // if (aJoinPoint.getSourceLocation() != null) {
    // entry.setSourceFilename(aJoinPoint.getSourceLocation().getFileName());
    // entry.setSourceLine(aJoinPoint.getSourceLocation().getLine());
    // }
    if (argumentConverter != null && aJoinPoint.getArgs() != null) {
        entry.setParameterValues(argumentConverter.convertArguments(aJoinPoint.getArgs()));
    }
    if (signature instanceof CodeSignature) {
        entry.setParameterTypes(getTypeNames(((CodeSignature) signature).getParameterTypes()));
    }
    return entry;
}

From source file:com.nc.common.interceptors.ControllerAspect.java

License:Open Source License

@Before("logging()")
public void logging(JoinPoint joinPoint) {
    Signature signature = joinPoint.getSignature();
    String signatureStr = signature.toString();
    String paramStr = null;/*from www .  ja  va 2s .c o m*/
    int paramStart = signatureStr.indexOf("(");

    if (log.isDebugEnabled()) {
        log.debug("==========================================================================================");
        log.debug("Class : [{}]", signature.getDeclaringTypeName());
        log.debug("Method : [{}]", signature.getName());
    }

    if (paramStart > -1) {
        int paramEnd = signatureStr.lastIndexOf(")");
        if (paramEnd > -1) {
            paramStr = signatureStr.substring(paramStart + 1, paramEnd);
        }
    }

    if (paramStr != null) {
        String[] param = paramStr.split(",");
        Object[] args = joinPoint.getArgs();
        int argsSize = args.length;

        if (argsSize == param.length) {
            for (int i = 0; i < argsSize; i++) {
                if (log.isDebugEnabled()) {
                    log.debug("argument [{}] : [{}] : [{}]", new Object[] { i, param[i], args[i] });
                }
            }
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("==========================================================================================");
    }
}

From source file:com.samples.platform.util.ServiceExecutionLogAspect.java

License:Open Source License

/**
 * Get the name of the signature of the {@link ProceedingJoinPoint}.
 *
 * @param joinPoint//from  ww  w . j  a va 2  s  .  co m
 *            the {@link ProceedingJoinPoint}.
 * @return the name of the signature.
 */
private String getSignatureName(final ProceedingJoinPoint joinPoint) {
    Signature sig = joinPoint.getSignature();
    return new StringBuffer(64).append(sig.getDeclaringTypeName()).append("#").append(sig.getName()).toString();
}

From source file:com.sun.jersey.samples.springannotations.resources.aop.SecurityAdvice.java

License:Open Source License

@Before("@annotation(com.sun.jersey.samples.springannotations.resources.aop.Secure)")
public void check(JoinPoint jp) {
    /* this might get some authentication/authorization info from the request 
     * and throw a WebApplicationException with a response with status 401 (unauthorized)
     * if the request is not authorized.
     *//* w w w .ja v  a  2s  .com*/
    final Signature signature = jp.getSignature();
    LOGGER.info("Authorized execution of " + signature.getDeclaringTypeName() + "." + signature.getName());
}

From source file:com.sun.jersey.spring25.LoggingAdvice.java

License:Open Source License

@Around("execution(* com.sun.jersey.spring25.ProxiedResource.getBaseUri(..))")
public Object log(ProceedingJoinPoint pjp) throws Throwable {
    final Signature signature = pjp.getSignature();
    LOGGER.info("Starting to execute " + signature.getDeclaringTypeName() + "." + signature.getName());
    Object retVal = pjp.proceed();
    LOGGER.info("Finished to execute " + signature.getDeclaringTypeName() + "." + signature.getName());
    return retVal;
}

From source file:com.sun.jersey.spring25.LoggingAdvice.java

License:Open Source License

@Around("execution(* com.sun.jersey.spring25.ProxiedSubResource.getRequestUri(..))")
public Object logSubResource(ProceedingJoinPoint pjp) throws Throwable {
    final Signature signature = pjp.getSignature();
    LOGGER.info("Starting to execute " + signature.getDeclaringTypeName() + "." + signature.getName());
    Object retVal = pjp.proceed();
    LOGGER.info("Finished to execute " + signature.getDeclaringTypeName() + "." + signature.getName());
    return retVal;
}

From source file:edu.kit.dama.authorization.aspects.util.AuthorisationSignatureExtractor.java

License:Apache License

/**
 * Extract the authentication signature.
 *
 * @param jp The AspectJ JointPoint./*from www.  jav  a  2  s. c o m*/
 *
 * @return The extracted AuthSignature information.
 */
protected final AuthSignature extractAuthSignature(final JoinPoint jp) {
    AuthSignature result = new AuthSignature();
    Object[] args = jp.getArgs();
    Signature signature = jp.getStaticPart().getSignature();
    LOGGER.debug("Looking for method signature.");
    if (signature instanceof MethodSignature) {
        LOGGER.debug("Checking signature of method {}#{}", signature.getDeclaringTypeName(),
                signature.getName());
        MethodSignature methodSignature = (MethodSignature) signature;
        Method method = methodSignature.getMethod();
        Class[] parametersTypes = method.getParameterTypes();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        LOGGER.debug("Checking {} parameter annotations.", parameterAnnotations.length);
        for (int i = 0; i < parameterAnnotations.length; i++) {
            Annotation[] annotations = parameterAnnotations[i];
            LOGGER.debug("Checking {} annotations for parameter {} of type {}.", annotations.length, i,
                    parametersTypes[i]);
            for (Annotation annotation : annotations) {
                LOGGER.debug("Checking argument annotation {} of type {}", annotation,
                        annotation.annotationType());
                if (Context.class.isAssignableFrom(annotation.annotationType())) {
                    LOGGER.debug("Argument with @Context annotation found");
                    if (null == args[i]) {
                        throw new IllegalArgumentException(
                                "Argument annotated with @Context must not be 'null'. Argument skipped.");
                    } else if (!(args[i] instanceof IAuthorizationContext)) {
                        throw new IllegalArgumentException(
                                "Argument annotated with @Context does not implement IAuthorizationContext. Argument skipped.");
                    } else {
                        LOGGER.debug("Setting provided argument {} as authorization context.", args[i]);
                        result.setAuthContext((IAuthorizationContext) args[i]);
                    }
                } else if (SecuredArgument.class.isAssignableFrom(annotation.annotationType())) {
                    LOGGER.debug("Argument with @SecuredArgument annotation found");
                    if (null == args[i]) {
                        //Just ignore argument
                        LOGGER.debug("Argument {} is 'null' and therefore ignored.", i);
                    } else if (args[i] instanceof SecurableResourceId) {
                        LOGGER.debug("Adding SecurableResourceId {}.", args[i]);
                        result.addSecurableResourceId((SecurableResourceId) args[i]);
                    } else if (args[i] instanceof ISecurableResource) {
                        LOGGER.debug("Adding SecurableResource {}.", args[i]);
                        result.addSecurableResource((ISecurableResource) args[i]);
                    } else {
                        throw new IllegalArgumentException(
                                "Argument annotated with @SecuredArgument does not implement ISecurableResourceId or ISecurableResource. Argument ignored.");
                    }
                } else {
                    LOGGER.debug("Annotation with unknown type {} found. Ignoring it.",
                            annotation.annotationType());
                }
            }
            LOGGER.debug("Checks for parameter {} of type {} finished.", i, parametersTypes[i]);
        }
    } else {
        LOGGER.info("Provided signature is no MethodSignature");
    }

    if (!result.isValid()) {
        LOGGER.warn("No valid auth signature extracted.");
    }
    return result;
}

From source file:gov.nih.nci.cabig.ctms.acegi.csm.authorization.RegexSignatureToPrivilegeMapping.java

License:BSD License

public boolean matches(Signature sig) {

    String sigStr = sig.getDeclaringTypeName() + "." + sig.getName();
    logger.debug("Comparing " + getPattern() + " to " + sigStr);
    return sigStr.matches(getPattern());
}