Java Code Examples for org.aspectj.lang.reflect.ConstructorSignature

The following examples show how to use org.aspectj.lang.reflect.ConstructorSignature. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: oval   Source File:    License: Eclipse Public License 2.0 6 votes vote down vote up
@Around("execution((@net.sf.oval.guard.Guarded *).new(..))")
public Object allConstructors(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // CHECKSTYLE:IGNORE IllegalThrow
   final ConstructorSignature signature = (ConstructorSignature) thisJoinPoint.getSignature();

   LOG.debug("aroundConstructor() {1}", signature);

   final Constructor<?> ctor = signature.getConstructor();
   final Object[] args = thisJoinPoint.getArgs();
   final Object target = thisJoinPoint.getTarget();

   // pre conditions
      guard.guardConstructorPre(target, ctor, args);

   final Object result = thisJoinPoint.proceed();

   // post conditions
      guard.guardConstructorPost(target, ctor, args);

   return result;
Example 2
Source Project: joinery   Source File:    License: GNU General Public License v3.0 6 votes vote down vote up
private static Annotation getAnnotation(final Signature signature,
                            final Class<? extends Annotation> annotationClass) {
    if (signature instanceof ConstructorSignature) {
        final Constructor<?> ctor = ConstructorSignature.class.cast(signature)
        return ctor.getAnnotation(annotationClass);
    } else if (signature instanceof MethodSignature) {
        return MethodSignature.class.cast(signature)
    } else if (signature instanceof FieldSignature) {
        return FieldSignature.class.cast(signature)

    throw new RuntimeException(
            "Unsupported signature type " + signature.getClass().getName()