wms-spring-framework-3.2.5

16:54:28.188 INFO  jd.cli.Main - Decompiling wms-spring-framework-3.2.5.jar
package org.springframework.aop;

import org.aopalliance.aop.Advice;

public abstract interface Advisor
{
  public abstract Advice getAdvice();
  
  public abstract boolean isPerInstance();
}

/* Location:
 * Qualified Name:     org.springframework.aop.Advisor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop;

import org.aopalliance.aop.Advice;

public abstract interface AfterAdvice
  extends Advice
{}

/* Location:
 * Qualified Name:     org.springframework.aop.AfterAdvice
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop;

import java.lang.reflect.Method;

public abstract interface AfterReturningAdvice
  extends AfterAdvice
{
  public abstract void afterReturning(Object paramObject1, Method paramMethod, Object[] paramArrayOfObject, Object paramObject2)
    throws Throwable;
}

/* Location:
 * Qualified Name:     org.springframework.aop.AfterReturningAdvice
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop;

import org.springframework.core.NestedRuntimeException;

public class AopInvocationException
  extends NestedRuntimeException
{
  public AopInvocationException(String msg)
  {
    super(msg);
  }
  
  public AopInvocationException(String msg, Throwable cause)
  {
    super(msg, cause);
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.AopInvocationException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj;

import java.lang.reflect.Method;
import org.springframework.aop.support.StaticMethodMatcher;

class AbstractAspectJAdvice$AdviceExcludingMethodMatcher
  extends StaticMethodMatcher
{
  private final Method adviceMethod;
  
  public AbstractAspectJAdvice$AdviceExcludingMethodMatcher(Method adviceMethod)
  {
    this.adviceMethod = adviceMethod;
  }
  
  public boolean matches(Method method, Class targetClass)
  {
    return !adviceMethod.equals(method);
  }
  
  public boolean equals(Object other)
  {
    if (this == other) {
      return true;
    }
    if (!(other instanceof AdviceExcludingMethodMatcher)) {
      return false;
    }
    AdviceExcludingMethodMatcher otherMm = (AdviceExcludingMethodMatcher)other;
    return adviceMethod.equals(adviceMethod);
  }
  
  public int hashCode()
  {
    return adviceMethod.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.AbstractAspectJAdvice.AdviceExcludingMethodMatcher
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInvocation;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.JoinPoint.StaticPart;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.weaver.tools.JoinPointMatch;
import org.aspectj.weaver.tools.PointcutParameter;
import org.springframework.aop.AopInvocationException;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.ProxyMethodInvocation;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.MethodMatchers;
import org.springframework.aop.support.StaticMethodMatcher;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.PrioritizedParameterNameDiscoverer;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;

public abstract class AbstractAspectJAdvice
  implements Advice, AspectJPrecedenceInformation
{
  protected static final String JOIN_POINT_KEY = JoinPoint.class.getName();
  protected final Method aspectJAdviceMethod;
  private final int adviceInvocationArgumentCount;
  private final AspectJExpressionPointcut pointcut;
  private final AspectInstanceFactory aspectInstanceFactory;
  private String aspectName;
  private int declarationOrder;
  
  public static JoinPoint currentJoinPoint()
  {
    MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
    if (!(mi instanceof ProxyMethodInvocation)) {
      throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
    }
    ProxyMethodInvocation pmi = (ProxyMethodInvocation)mi;
    JoinPoint jp = (JoinPoint)pmi.getUserAttribute(JOIN_POINT_KEY);
    if (jp == null)
    {
      jp = new MethodInvocationProceedingJoinPoint(pmi);
      pmi.setUserAttribute(JOIN_POINT_KEY, jp);
    }
    return jp;
  }
  
  private String[] argumentNames = null;
  private String throwingName = null;
  private String returningName = null;
  private Class discoveredReturningType = Object.class;
  private Class discoveredThrowingType = Object.class;
  private int joinPointArgumentIndex = -1;
  private int joinPointStaticPartArgumentIndex = -1;
  private Map<String, Integer> argumentBindings = null;
  private boolean argumentsIntrospected = false;
  private Type discoveredReturningGenericType;
  
  public AbstractAspectJAdvice(Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory)
  {
    Assert.notNull(aspectJAdviceMethod, "Advice method must not be null");
    this.aspectJAdviceMethod = aspectJAdviceMethod;
    adviceInvocationArgumentCount = this.aspectJAdviceMethod.getParameterTypes().length;
    this.pointcut = pointcut;
    this.aspectInstanceFactory = aspectInstanceFactory;
  }
  
  public final Method getAspectJAdviceMethod()
  {
    return aspectJAdviceMethod;
  }
  
  public final AspectJExpressionPointcut getPointcut()
  {
    calculateArgumentBindings();
    return pointcut;
  }
  
  public final Pointcut buildSafePointcut()
  {
    Pointcut pc = getPointcut();
    MethodMatcher safeMethodMatcher = MethodMatchers.intersection(new AdviceExcludingMethodMatcher(aspectJAdviceMethod), pc.getMethodMatcher());
    
    return new ComposablePointcut(pc.getClassFilter(), safeMethodMatcher);
  }
  
  public final AspectInstanceFactory getAspectInstanceFactory()
  {
    return aspectInstanceFactory;
  }
  
  public final ClassLoader getAspectClassLoader()
  {
    return aspectInstanceFactory.getAspectClassLoader();
  }
  
  public int getOrder()
  {
    return aspectInstanceFactory.getOrder();
  }
  
  public void setAspectName(String name)
  {
    aspectName = name;
  }
  
  public String getAspectName()
  {
    return aspectName;
  }
  
  public void setDeclarationOrder(int order)
  {
    declarationOrder = order;
  }
  
  public int getDeclarationOrder()
  {
    return declarationOrder;
  }
  
  public void setArgumentNames(String argNames)
  {
    String[] tokens = StringUtils.commaDelimitedListToStringArray(argNames);
    setArgumentNamesFromStringArray(tokens);
  }
  
  public void setArgumentNamesFromStringArray(String[] args)
  {
    argumentNames = new String[args.length];
    for (int i = 0; i < args.length; i++)
    {
      argumentNames[i] = StringUtils.trimWhitespace(args[i]);
      if (!isVariableName(argumentNames[i])) {
        throw new IllegalArgumentException("'argumentNames' property of AbstractAspectJAdvice contains an argument name '" + argumentNames[i] + "' that is not a valid Java identifier");
      }
    }
    if ((argumentNames != null) && 
      (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1))
    {
      Class firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
      if ((firstArgType == JoinPoint.class) || (firstArgType == ProceedingJoinPoint.class) || (firstArgType == JoinPoint.StaticPart.class))
      {
        String[] oldNames = argumentNames;
        argumentNames = new String[oldNames.length + 1];
        argumentNames[0] = "THIS_JOIN_POINT";
        System.arraycopy(oldNames, 0, argumentNames, 1, oldNames.length);
      }
    }
  }
  
  public void setReturningName(String name)
  {
    throw new UnsupportedOperationException("Only afterReturning advice can be used to bind a return value");
  }
  
  protected void setReturningNameNoCheck(String name)
  {
    if (isVariableName(name)) {
      returningName = name;
    } else {
      try
      {
        discoveredReturningType = ClassUtils.forName(name, getAspectClassLoader());
      }
      catch (Throwable ex)
      {
        throw new IllegalArgumentException("Returning name '" + name + "' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " + "Root cause: " + ex);
      }
    }
  }
  
  protected Class getDiscoveredReturningType()
  {
    return discoveredReturningType;
  }
  
  protected Type getDiscoveredReturningGenericType()
  {
    return discoveredReturningGenericType;
  }
  
  public void setThrowingName(String name)
  {
    throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception");
  }
  
  protected void setThrowingNameNoCheck(String name)
  {
    if (isVariableName(name)) {
      throwingName = name;
    } else {
      try
      {
        discoveredThrowingType = ClassUtils.forName(name, getAspectClassLoader());
      }
      catch (Throwable ex)
      {
        throw new IllegalArgumentException("Throwing name '" + name + "' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " + "Root cause: " + ex);
      }
    }
  }
  
  protected Class getDiscoveredThrowingType()
  {
    return discoveredThrowingType;
  }
  
  private boolean isVariableName(String name)
  {
    char[] chars = name.toCharArray();
    if (!Character.isJavaIdentifierStart(chars[0])) {
      return false;
    }
    for (int i = 1; i < chars.length; i++) {
      if (!Character.isJavaIdentifierPart(chars[i])) {
        return false;
      }
    }
    return true;
  }
  
  public final synchronized void calculateArgumentBindings()
  {
    if ((argumentsIntrospected) || (adviceInvocationArgumentCount == 0)) {
      return;
    }
    int numUnboundArgs = adviceInvocationArgumentCount;
    Class[] parameterTypes = aspectJAdviceMethod.getParameterTypes();
    if ((maybeBindJoinPoint(parameterTypes[0])) || (maybeBindProceedingJoinPoint(parameterTypes[0]))) {
      numUnboundArgs--;
    } else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
      numUnboundArgs--;
    }
    if (numUnboundArgs > 0) {
      bindArgumentsByName(numUnboundArgs);
    }
    argumentsIntrospected = true;
  }
  
  private boolean maybeBindJoinPoint(Class candidateParameterType)
  {
    if (candidateParameterType.equals(JoinPoint.class))
    {
      joinPointArgumentIndex = 0;
      return true;
    }
    return false;
  }
  
  private boolean maybeBindProceedingJoinPoint(Class candidateParameterType)
  {
    if (candidateParameterType.equals(ProceedingJoinPoint.class))
    {
      if (!supportsProceedingJoinPoint()) {
        throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
      }
      joinPointArgumentIndex = 0;
      return true;
    }
    return false;
  }
  
  protected boolean supportsProceedingJoinPoint()
  {
    return false;
  }
  
  private boolean maybeBindJoinPointStaticPart(Class candidateParameterType)
  {
    if (candidateParameterType.equals(JoinPoint.StaticPart.class))
    {
      joinPointStaticPartArgumentIndex = 0;
      return true;
    }
    return false;
  }
  
  private void bindArgumentsByName(int numArgumentsExpectingToBind)
  {
    if (argumentNames == null) {
      argumentNames = createParameterNameDiscoverer().getParameterNames(aspectJAdviceMethod);
    }
    if (argumentNames != null) {
      bindExplicitArguments(numArgumentsExpectingToBind);
    } else {
      throw new IllegalStateException("Advice method [" + aspectJAdviceMethod.getName() + "] " + "requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " + "the argument names were not specified and could not be discovered.");
    }
  }
  
  protected ParameterNameDiscoverer createParameterNameDiscoverer()
  {
    PrioritizedParameterNameDiscoverer discoverer = new PrioritizedParameterNameDiscoverer();
    discoverer.addDiscoverer(new LocalVariableTableParameterNameDiscoverer());
    AspectJAdviceParameterNameDiscoverer adviceParameterNameDiscoverer = new AspectJAdviceParameterNameDiscoverer(pointcut.getExpression());
    
    adviceParameterNameDiscoverer.setReturningName(returningName);
    adviceParameterNameDiscoverer.setThrowingName(throwingName);
    
    adviceParameterNameDiscoverer.setRaiseExceptions(true);
    discoverer.addDiscoverer(adviceParameterNameDiscoverer);
    return discoverer;
  }
  
  private void bindExplicitArguments(int numArgumentsLeftToBind)
  {
    argumentBindings = new HashMap();
    
    int numExpectedArgumentNames = aspectJAdviceMethod.getParameterTypes().length;
    if (argumentNames.length != numExpectedArgumentNames) {
      throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames + " arguments to bind by name in advice, but actually found " + argumentNames.length + " arguments.");
    }
    int argumentIndexOffset = adviceInvocationArgumentCount - numArgumentsLeftToBind;
    for (int i = argumentIndexOffset; i < argumentNames.length; i++) {
      argumentBindings.put(argumentNames[i], Integer.valueOf(i));
    }
    if (returningName != null)
    {
      if (!argumentBindings.containsKey(returningName)) {
        throw new IllegalStateException("Returning argument name '" + returningName + "' was not bound in advice arguments");
      }
      Integer index = (Integer)argumentBindings.get(returningName);
      discoveredReturningType = aspectJAdviceMethod.getParameterTypes()[index.intValue()];
      discoveredReturningGenericType = aspectJAdviceMethod.getGenericParameterTypes()[index.intValue()];
    }
    if (throwingName != null)
    {
      if (!argumentBindings.containsKey(throwingName)) {
        throw new IllegalStateException("Throwing argument name '" + throwingName + "' was not bound in advice arguments");
      }
      Integer index = (Integer)argumentBindings.get(throwingName);
      discoveredThrowingType = aspectJAdviceMethod.getParameterTypes()[index.intValue()];
    }
    configurePointcutParameters(argumentIndexOffset);
  }
  
  private void configurePointcutParameters(int argumentIndexOffset)
  {
    int numParametersToRemove = argumentIndexOffset;
    if (returningName != null) {
      numParametersToRemove++;
    }
    if (throwingName != null) {
      numParametersToRemove++;
    }
    String[] pointcutParameterNames = new String[argumentNames.length - numParametersToRemove];
    Class[] pointcutParameterTypes = new Class[pointcutParameterNames.length];
    Class[] methodParameterTypes = aspectJAdviceMethod.getParameterTypes();
    
    int index = 0;
    for (int i = 0; i < argumentNames.length; i++) {
      if (i >= argumentIndexOffset) {
        if ((!argumentNames[i].equals(returningName)) && (!argumentNames[i].equals(throwingName)))
        {
          pointcutParameterNames[index] = argumentNames[i];
          pointcutParameterTypes[index] = methodParameterTypes[i];
          index++;
        }
      }
    }
    pointcut.setParameterNames(pointcutParameterNames);
    pointcut.setParameterTypes(pointcutParameterTypes);
  }
  
  protected Object[] argBinding(JoinPoint jp, JoinPointMatch jpMatch, Object returnValue, Throwable ex)
  {
    calculateArgumentBindings();
    
    Object[] adviceInvocationArgs = new Object[adviceInvocationArgumentCount];
    int numBound = 0;
    if (joinPointArgumentIndex != -1)
    {
      adviceInvocationArgs[joinPointArgumentIndex] = jp;
      numBound++;
    }
    else if (joinPointStaticPartArgumentIndex != -1)
    {
      adviceInvocationArgs[joinPointStaticPartArgumentIndex] = jp.getStaticPart();
      numBound++;
    }
    if (!CollectionUtils.isEmpty(argumentBindings))
    {
      if (jpMatch != null)
      {
        PointcutParameter[] parameterBindings = jpMatch.getParameterBindings();
        for (PointcutParameter parameter : parameterBindings)
        {
          String name = parameter.getName();
          Integer index = (Integer)argumentBindings.get(name);
          adviceInvocationArgs[index.intValue()] = parameter.getBinding();
          numBound++;
        }
      }
      if (returningName != null)
      {
        Integer index = (Integer)argumentBindings.get(returningName);
        adviceInvocationArgs[index.intValue()] = returnValue;
        numBound++;
      }
      if (throwingName != null)
      {
        Integer index = (Integer)argumentBindings.get(throwingName);
        adviceInvocationArgs[index.intValue()] = ex;
        numBound++;
      }
    }
    if (numBound != adviceInvocationArgumentCount) {
      throw new IllegalStateException("Required to bind " + adviceInvocationArgumentCount + " arguments, but only bound " + numBound + " (JoinPointMatch " + (jpMatch == null ? "was NOT" : "WAS") + " bound in invocation)");
    }
    return adviceInvocationArgs;
  }
  
  protected Object invokeAdviceMethod(JoinPointMatch jpMatch, Object returnValue, Throwable ex)
    throws Throwable
  {
    return invokeAdviceMethodWithGivenArgs(argBinding(getJoinPoint(), jpMatch, returnValue, ex));
  }
  
  protected Object invokeAdviceMethod(JoinPoint jp, JoinPointMatch jpMatch, Object returnValue, Throwable t)
    throws Throwable
  {
    return invokeAdviceMethodWithGivenArgs(argBinding(jp, jpMatch, returnValue, t));
  }
  
  protected Object invokeAdviceMethodWithGivenArgs(Object[] args)
    throws Throwable
  {
    Object[] actualArgs = args;
    if (aspectJAdviceMethod.getParameterTypes().length == 0) {
      actualArgs = null;
    }
    try
    {
      ReflectionUtils.makeAccessible(aspectJAdviceMethod);
      
      return aspectJAdviceMethod.invoke(aspectInstanceFactory.getAspectInstance(), actualArgs);
    }
    catch (IllegalArgumentException ex)
    {
      throw new AopInvocationException("Mismatch on arguments to advice method [" + aspectJAdviceMethod + "]; pointcut expression [" + pointcut.getPointcutExpression() + "]", ex);
    }
    catch (InvocationTargetException ex)
    {
      throw ex.getTargetException();
    }
  }
  
  protected JoinPoint getJoinPoint()
  {
    return currentJoinPoint();
  }
  
  protected JoinPointMatch getJoinPointMatch()
  {
    MethodInvocation mi = ExposeInvocationInterceptor.currentInvocation();
    if (!(mi instanceof ProxyMethodInvocation)) {
      throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
    }
    return getJoinPointMatch((ProxyMethodInvocation)mi);
  }
  
  protected JoinPointMatch getJoinPointMatch(ProxyMethodInvocation pmi)
  {
    return (JoinPointMatch)pmi.getUserAttribute(pointcut.getExpression());
  }
  
  public String toString()
  {
    return getClass().getName() + ": advice method [" + aspectJAdviceMethod + "]; " + "aspect name '" + aspectName + "'";
  }
  
  private static class AdviceExcludingMethodMatcher
    extends StaticMethodMatcher
  {
    private final Method adviceMethod;
    
    public AdviceExcludingMethodMatcher(Method adviceMethod)
    {
      this.adviceMethod = adviceMethod;
    }
    
    public boolean matches(Method method, Class targetClass)
    {
      return !adviceMethod.equals(method);
    }
    
    public boolean equals(Object other)
    {
      if (this == other) {
        return true;
      }
      if (!(other instanceof AdviceExcludingMethodMatcher)) {
        return false;
      }
      AdviceExcludingMethodMatcher otherMm = (AdviceExcludingMethodMatcher)other;
      return adviceMethod.equals(adviceMethod);
    }
    
    public int hashCode()
    {
      return adviceMethod.hashCode();
    }
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.AbstractAspectJAdvice
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

class AbstractAspectJAdvisorFactory$1 {}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.util.StringUtils;

public class AbstractAspectJAdvisorFactory$AspectJAnnotation<A extends Annotation>
{
  private static final String[] EXPRESSION_PROPERTIES = { "value", "pointcut" };
  private static Map<Class, AbstractAspectJAdvisorFactory.AspectJAnnotationType> annotationTypes = new HashMap();
  private final A annotation;
  private final AbstractAspectJAdvisorFactory.AspectJAnnotationType annotationType;
  private final String pointcutExpression;
  private final String argumentNames;
  
  static
  {
    annotationTypes.put(Pointcut.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtPointcut);
    annotationTypes.put(After.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfter);
    annotationTypes.put(AfterReturning.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfterReturning);
    annotationTypes.put(AfterThrowing.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfterThrowing);
    annotationTypes.put(Around.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAround);
    annotationTypes.put(Before.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtBefore);
  }
  
  public AbstractAspectJAdvisorFactory$AspectJAnnotation(A annotation)
  {
    this.annotation = annotation;
    annotationType = determineAnnotationType(annotation);
    try
    {
      pointcutExpression = resolveExpression(annotation);
      argumentNames = ((String)annotation.getClass().getMethod("argNames", new Class[0]).invoke(annotation, new Object[0]));
    }
    catch (Exception ex)
    {
      throw new IllegalArgumentException(annotation + " cannot be an AspectJ annotation", ex);
    }
  }
  
  private AbstractAspectJAdvisorFactory.AspectJAnnotationType determineAnnotationType(A annotation)
  {
    for (Class type : annotationTypes.keySet()) {
      if (type.isInstance(annotation)) {
        return (AbstractAspectJAdvisorFactory.AspectJAnnotationType)annotationTypes.get(type);
      }
    }
    throw new IllegalStateException("Unknown annotation type: " + annotation.toString());
  }
  
  private String resolveExpression(A annotation)
    throws Exception
  {
    String expression = null;
    for (String methodName : EXPRESSION_PROPERTIES)
    {
      Method method;
      try
      {
        method = annotation.getClass().getDeclaredMethod(methodName, new Class[0]);
      }
      catch (NoSuchMethodException ex)
      {
        method = null;
      }
      if (method != null)
      {
        String candidate = (String)method.invoke(annotation, new Object[0]);
        if (StringUtils.hasText(candidate)) {
          expression = candidate;
        }
      }
    }
    return expression;
  }
  
  public AbstractAspectJAdvisorFactory.AspectJAnnotationType getAnnotationType()
  {
    return annotationType;
  }
  
  public A getAnnotation()
  {
    return annotation;
  }
  
  public String getPointcutExpression()
  {
    return pointcutExpression;
  }
  
  public String getArgumentNames()
  {
    return argumentNames;
  }
  
  public String toString()
  {
    return annotation.toString();
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.StringTokenizer;
import org.springframework.core.ParameterNameDiscoverer;

class AbstractAspectJAdvisorFactory$AspectJAnnotationParameterNameDiscoverer
  implements ParameterNameDiscoverer
{
  public String[] getParameterNames(Method method)
  {
    if (method.getParameterTypes().length == 0) {
      return new String[0];
    }
    AbstractAspectJAdvisorFactory.AspectJAnnotation annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
    if (annotation == null) {
      return null;
    }
    StringTokenizer strTok = new StringTokenizer(annotation.getArgumentNames(), ",");
    if (strTok.countTokens() > 0)
    {
      String[] names = new String[strTok.countTokens()];
      for (int i = 0; i < names.length; i++) {
        names[i] = strTok.nextToken();
      }
      return names;
    }
    return null;
  }
  
  public String[] getParameterNames(Constructor ctor)
  {
    throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotationParameterNameDiscoverer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

public enum AbstractAspectJAdvisorFactory$AspectJAnnotationType
{
  AtPointcut,  AtBefore,  AtAfter,  AtAfterReturning,  AtAfterThrowing,  AtAround;
  
  private AbstractAspectJAdvisorFactory$AspectJAnnotationType() {}
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.AspectJAnnotationType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.AjType;
import org.aspectj.lang.reflect.AjTypeSystem;
import org.aspectj.lang.reflect.PerClause;
import org.aspectj.lang.reflect.PerClauseKind;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.PrioritizedParameterNameDiscoverer;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.StringUtils;

public abstract class AbstractAspectJAdvisorFactory
  implements AspectJAdvisorFactory
{
  protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER = new AspectJAnnotationParameterNameDiscoverer(null);
  private static final String AJC_MAGIC = "ajc$";
  
  protected static AspectJAnnotation findAspectJAnnotationOnMethod(Method method)
  {
    Class<? extends Annotation>[] classesToLookFor = { Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class };
    for (Class<? extends Annotation> c : classesToLookFor)
    {
      AspectJAnnotation foundAnnotation = findAnnotation(method, c);
      if (foundAnnotation != null) {
        return foundAnnotation;
      }
    }
    return null;
  }
  
  private static <A extends Annotation> AspectJAnnotation<A> findAnnotation(Method method, Class<A> toLookFor)
  {
    A result = AnnotationUtils.findAnnotation(method, toLookFor);
    if (result != null) {
      return new AspectJAnnotation(result);
    }
    return null;
  }
  
  protected final Log logger = LogFactory.getLog(getClass());
  protected final ParameterNameDiscoverer parameterNameDiscoverer;
  
  protected AbstractAspectJAdvisorFactory()
  {
    PrioritizedParameterNameDiscoverer prioritizedParameterNameDiscoverer = new PrioritizedParameterNameDiscoverer();
    prioritizedParameterNameDiscoverer.addDiscoverer(ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER);
    parameterNameDiscoverer = prioritizedParameterNameDiscoverer;
  }
  
  public boolean isAspect(Class<?> clazz)
  {
    return (hasAspectAnnotation(clazz)) && (!compiledByAjc(clazz));
  }
  
  private boolean hasAspectAnnotation(Class<?> clazz)
  {
    return AnnotationUtils.findAnnotation(clazz, Aspect.class) != null;
  }
  
  private boolean compiledByAjc(Class<?> clazz)
  {
    for (Field field : clazz.getDeclaredFields()) {
      if (field.getName().startsWith("ajc$")) {
        return true;
      }
    }
    return false;
  }
  
  public void validate(Class<?> aspectClass)
    throws AopConfigException
  {
    if ((aspectClass.getSuperclass().getAnnotation(Aspect.class) != null) && (!Modifier.isAbstract(aspectClass.getSuperclass().getModifiers()))) {
      throw new AopConfigException("[" + aspectClass.getName() + "] cannot extend concrete aspect [" + aspectClass.getSuperclass().getName() + "]");
    }
    AjType<?> ajType = AjTypeSystem.getAjType(aspectClass);
    if (!ajType.isAspect()) {
      throw new NotAnAtAspectException(aspectClass);
    }
    if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOW) {
      throw new AopConfigException(aspectClass.getName() + " uses percflow instantiation model: " + "This is not supported in Spring AOP.");
    }
    if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) {
      throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + "This is not supported in Spring AOP.");
    }
  }
  
  protected AspectJExpressionPointcut createPointcutExpression(Method annotatedMethod, Class declarationScope, String[] pointcutParameterNames)
  {
    Class<?>[] pointcutParameterTypes = new Class[0];
    if (pointcutParameterNames != null) {
      pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames, annotatedMethod);
    }
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(declarationScope, pointcutParameterNames, pointcutParameterTypes);
    
    ajexp.setLocation(annotatedMethod.toString());
    return ajexp;
  }
  
  private Class<?>[] extractPointcutParameterTypes(String[] argNames, Method adviceMethod)
  {
    Class<?>[] ret = new Class[argNames.length];
    Class<?>[] paramTypes = adviceMethod.getParameterTypes();
    if (argNames.length > paramTypes.length) {
      throw new IllegalStateException("Expecting at least " + argNames.length + " arguments in the advice declaration, but only found " + paramTypes.length);
    }
    int typeOffset = paramTypes.length - argNames.length;
    for (int i = 0; i < ret.length; i++) {
      ret[i] = paramTypes[(i + typeOffset)];
    }
    return ret;
  }
  
  protected static enum AspectJAnnotationType
  {
    AtPointcut,  AtBefore,  AtAfter,  AtAfterReturning,  AtAfterThrowing,  AtAround;
    
    private AspectJAnnotationType() {}
  }
  
  protected static class AspectJAnnotation<A extends Annotation>
  {
    private static final String[] EXPRESSION_PROPERTIES = { "value", "pointcut" };
    private static Map<Class, AbstractAspectJAdvisorFactory.AspectJAnnotationType> annotationTypes = new HashMap();
    private final A annotation;
    private final AbstractAspectJAdvisorFactory.AspectJAnnotationType annotationType;
    private final String pointcutExpression;
    private final String argumentNames;
    
    static
    {
      annotationTypes.put(Pointcut.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtPointcut);
      annotationTypes.put(After.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfter);
      annotationTypes.put(AfterReturning.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfterReturning);
      annotationTypes.put(AfterThrowing.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAfterThrowing);
      annotationTypes.put(Around.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtAround);
      annotationTypes.put(Before.class, AbstractAspectJAdvisorFactory.AspectJAnnotationType.AtBefore);
    }
    
    public AspectJAnnotation(A annotation)
    {
      this.annotation = annotation;
      annotationType = determineAnnotationType(annotation);
      try
      {
        pointcutExpression = resolveExpression(annotation);
        argumentNames = ((String)annotation.getClass().getMethod("argNames", new Class[0]).invoke(annotation, new Object[0]));
      }
      catch (Exception ex)
      {
        throw new IllegalArgumentException(annotation + " cannot be an AspectJ annotation", ex);
      }
    }
    
    private AbstractAspectJAdvisorFactory.AspectJAnnotationType determineAnnotationType(A annotation)
    {
      for (Class type : annotationTypes.keySet()) {
        if (type.isInstance(annotation)) {
          return (AbstractAspectJAdvisorFactory.AspectJAnnotationType)annotationTypes.get(type);
        }
      }
      throw new IllegalStateException("Unknown annotation type: " + annotation.toString());
    }
    
    private String resolveExpression(A annotation)
      throws Exception
    {
      String expression = null;
      for (String methodName : EXPRESSION_PROPERTIES)
      {
        Method method;
        try
        {
          method = annotation.getClass().getDeclaredMethod(methodName, new Class[0]);
        }
        catch (NoSuchMethodException ex)
        {
          method = null;
        }
        if (method != null)
        {
          String candidate = (String)method.invoke(annotation, new Object[0]);
          if (StringUtils.hasText(candidate)) {
            expression = candidate;
          }
        }
      }
      return expression;
    }
    
    public AbstractAspectJAdvisorFactory.AspectJAnnotationType getAnnotationType()
    {
      return annotationType;
    }
    
    public A getAnnotation()
    {
      return annotation;
    }
    
    public String getPointcutExpression()
    {
      return pointcutExpression;
    }
    
    public String getArgumentNames()
    {
      return argumentNames;
    }
    
    public String toString()
    {
      return annotation.toString();
    }
  }
  
  private static class AspectJAnnotationParameterNameDiscoverer
    implements ParameterNameDiscoverer
  {
    public String[] getParameterNames(Method method)
    {
      if (method.getParameterTypes().length == 0) {
        return new String[0];
      }
      AbstractAspectJAdvisorFactory.AspectJAnnotation annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
      if (annotation == null) {
        return null;
      }
      StringTokenizer strTok = new StringTokenizer(annotation.getArgumentNames(), ",");
      if (strTok.countTokens() > 0)
      {
        String[] names = new String[strTok.countTokens()];
        for (int i = 0; i < names.length; i++) {
          names[i] = strTok.nextToken();
        }
        return names;
      }
      return null;
    }
    
    public String[] getParameterNames(Constructor ctor)
    {
      throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
    }
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import org.springframework.beans.factory.ListableBeanFactory;

class AnnotationAwareAspectJAutoProxyCreator$BeanFactoryAspectJAdvisorsBuilderAdapter
  extends BeanFactoryAspectJAdvisorsBuilder
{
  public AnnotationAwareAspectJAutoProxyCreator$BeanFactoryAspectJAdvisorsBuilderAdapter(AnnotationAwareAspectJAutoProxyCreator paramAnnotationAwareAspectJAutoProxyCreator, ListableBeanFactory beanFactory, AspectJAdvisorFactory advisorFactory)
  {
    super(beanFactory, advisorFactory);
  }
  
  protected boolean isEligibleBean(String beanName)
  {
    return this$0.isEligibleAspectBean(beanName);
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.BeanFactoryAspectJAdvisorsBuilderAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.util.Assert;

public class AnnotationAwareAspectJAutoProxyCreator
  extends AspectJAwareAdvisorAutoProxyCreator
{
  private List<Pattern> includePatterns;
  private AspectJAdvisorFactory aspectJAdvisorFactory;
  private BeanFactoryAspectJAdvisorsBuilder aspectJAdvisorsBuilder;
  
  public AnnotationAwareAspectJAutoProxyCreator()
  {
    aspectJAdvisorFactory = new ReflectiveAspectJAdvisorFactory();
  }
  
  public void setIncludePatterns(List<String> patterns)
  {
    includePatterns = new ArrayList(patterns.size());
    for (String patternText : patterns) {
      includePatterns.add(Pattern.compile(patternText));
    }
  }
  
  public void setAspectJAdvisorFactory(AspectJAdvisorFactory aspectJAdvisorFactory)
  {
    Assert.notNull(this.aspectJAdvisorFactory, "AspectJAdvisorFactory must not be null");
    this.aspectJAdvisorFactory = aspectJAdvisorFactory;
  }
  
  protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory)
  {
    super.initBeanFactory(beanFactory);
    aspectJAdvisorsBuilder = new BeanFactoryAspectJAdvisorsBuilderAdapter(beanFactory, aspectJAdvisorFactory);
  }
  
  protected List<Advisor> findCandidateAdvisors()
  {
    List<Advisor> advisors = super.findCandidateAdvisors();
    
    advisors.addAll(aspectJAdvisorsBuilder.buildAspectJAdvisors());
    return advisors;
  }
  
  protected boolean isInfrastructureClass(Class beanClass)
  {
    return (super.isInfrastructureClass(beanClass)) || (aspectJAdvisorFactory.isAspect(beanClass));
  }
  
  protected boolean isEligibleAspectBean(String beanName)
  {
    if (includePatterns == null) {
      return true;
    }
    for (Pattern pattern : includePatterns) {
      if (pattern.matcher(beanName).matches()) {
        return true;
      }
    }
    return false;
  }
  
  private class BeanFactoryAspectJAdvisorsBuilderAdapter
    extends BeanFactoryAspectJAdvisorsBuilder
  {
    public BeanFactoryAspectJAdvisorsBuilderAdapter(ListableBeanFactory beanFactory, AspectJAdvisorFactory advisorFactory)
    {
      super(advisorFactory);
    }
    
    protected boolean isEligibleBean(String beanName)
    {
      return isEligibleAspectBean(beanName);
    }
  }
}

/* Location:
 * Qualified Name:     org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.springframework.aop.aspectj.annotation;

import java.lang.reflect.Method;
import java.util.List;
import org.aopalliance.aop.Advice
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd