亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? abstractaspectjadvisorfactory.java

?? struts+spring 源碼 希望能給大家帶來幫助
?? JAVA
字號:
/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aop.aspectj.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.InvocationTargetException;
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.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;

/**
 * Abstract base class for factories that can create Spring AOP Advisors
 * given AspectJ classes from classes honoring the AspectJ 5 annotation syntax.
 *
 * <p>This class handles annotation parsing and validation functionality.
 * It does not actually generate Spring AOP Advisors, which is deferred to subclasses.
 *
 * @author Rod Johnson
 * @author Adrian Colyer
 * @since 2.0
 */
public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory {
	
	private static final String AJC_MAGIC = "ajc$";
	
	protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER =
			new AspectJAnnotationParameterNameDiscoverer();


	/**
	 * Find and return the first AspectJ annotation on the given method
	 * (there <i>should</i> only be one anyway...)
	 */
	protected static AspectJAnnotation findAspectJAnnotationOnMethod(Method aMethod) {
		Class<? extends Annotation>[] classesToLookFor = (Class<? extends Annotation>[]) new Class[] {
					Before.class, 
					Around.class, 
					After.class, 
					AfterReturning.class, 
					AfterThrowing.class, 
					Pointcut.class
				};
		for (Class<? extends Annotation> c : classesToLookFor) {
			AspectJAnnotation foundAnnotation = findAnnotation(aMethod, 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<A>(result);
		}
		else {
			return null;
		}
	}


	/** Logger available to subclasses */
	protected final Log logger = LogFactory.getLog(getClass());
	
	protected final ParameterNameDiscoverer parameterNameDiscoverer;
	
	
	protected AbstractAspectJAdvisorFactory() {
		PrioritizedParameterNameDiscoverer prioritizedParameterNameDiscoverer = new PrioritizedParameterNameDiscoverer();
		prioritizedParameterNameDiscoverer.addDiscoverer(ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER);
		this.parameterNameDiscoverer = prioritizedParameterNameDiscoverer;
	}

	public boolean isAspect(Class<?> clazz) {
		boolean couldBeAtAspectJAspect = AjTypeSystem.getAjType(clazz).isAspect();
		if (!couldBeAtAspectJAspect) {
			return false;
		} 
		else {
			// we know it's an aspect, but we don't know whether it is an 
			// @AspectJ aspect or a code style aspect.
			// This is an *unclean* test whilst waiting for AspectJ to provide
			// us with something better
			Method[] methods = clazz.getDeclaredMethods();
			for(Method m : methods) {
				if (m.getName().startsWith(AJC_MAGIC)) {
					// must be a code style aspect
					return false;
				}
			}
			return true;
		}
	}

	public void validate(Class<?> aspectClass) throws AopConfigException {
		// If the parent has the annotation and isn't abstract it's an error
		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");
		}	
	}

	/**
	 * The pointcut and advice annotations both have an "argNames" member which contains a 
	 * comma-separated list of the argument names. We use this (if non-empty) to build the
	 * formal parameters for the pointcut.
	 */
	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;
	}
	
	/**
	 * Create the pointcut parameters needed by aspectj based on the given argument names
	 * and the argument types that are available from the adviceMethod. Needs to take into
	 * account (ignore) any JoinPoint based arguments as these are not pointcut context but
	 * rather part of the advice execution context (thisJoinPoint, thisJoinPointStaticPart)
	 */
	private Class<?>[] extractPointcutParameterTypes(String[] argNames, Method adviceMethod) {
		Class<?>[] ret = new Class<?>[argNames.length];
		Class<?>[] paramTypes = adviceMethod.getParameterTypes();
		if (argNames.length > paramTypes.length) {
			// TODO Spring logging here??
			throw new IllegalStateException("Expecting at least " + argNames.length + 
					     " arguments in the advice declaration, but only found " +
					     paramTypes.length);
		}
		// make the simplifying assumption for now that all of the JoinPoint based arguments
		// come first in the advice declaration
		int typeOffset = paramTypes.length - argNames.length;
		for (int i = 0; i < ret.length; i++) {
			ret[i] = paramTypes[i+typeOffset];			
		}
		return ret;
	}


	protected enum AspectJAnnotationType {
		AtPointcut,
		AtBefore,
		AtAfter,
		AtAfterReturning,
		AtAfterThrowing,
		AtAround
	};


	/**
	 * Class modelling an AspectJ annotation, exposing its type enumeration and
	 * pointcut String.
	 */
	protected static class AspectJAnnotation<A extends Annotation> {

		private static Map<Class,AspectJAnnotationType> annotationTypes = new HashMap<Class,AspectJAnnotationType>();

		private static final String[] EXPRESSION_PROPERTIES = new String[]{"value", "pointcut"};

		static {
			annotationTypes.put(Pointcut.class,AspectJAnnotationType.AtPointcut);
			annotationTypes.put(After.class,AspectJAnnotationType.AtAfter);
			annotationTypes.put(AfterReturning.class,AspectJAnnotationType.AtAfterReturning);
			annotationTypes.put(AfterThrowing.class,AspectJAnnotationType.AtAfterThrowing);
			annotationTypes.put(Around.class,AspectJAnnotationType.AtAround);
			annotationTypes.put(Before.class,AspectJAnnotationType.AtBefore);
		}

		private final A annotation;
		private AspectJAnnotationType annotationType;
		private final String expression;
		private final String argNames;

		public AspectJAnnotation(A aspectjAnnotation) {
			this.annotation = aspectjAnnotation;
			for(Class c : annotationTypes.keySet()) {
				if (c.isInstance(this.annotation)) {
					this.annotationType = annotationTypes.get(c);
					break;
				}
			}
			if (this.annotationType == null) {
				throw new IllegalStateException("unknown annotation type: " + this.annotation.toString());
			}

			// We know these methods exist with the same name on each object,
			// but need to invoke them reflectively as there isn't a common interfaces
			try {
				this.expression = resolveExpression();
				this.argNames = (String) annotation.getClass().getMethod("argNames", (Class[]) null).
					invoke(this.annotation);
			}
			catch (Exception ex) {
				throw new IllegalArgumentException(aspectjAnnotation + " cannot be an AspectJ annotation", ex);
			}
		}

		private String resolveExpression() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
			String expression = null;
			for (int i = 0; i < EXPRESSION_PROPERTIES.length; i++) {
				String methodName = EXPRESSION_PROPERTIES[i];
				Method method;
				try {
					method = annotation.getClass().getDeclaredMethod(methodName);
				}
				catch (NoSuchMethodException ex) {
					method = null;
				}

				if (method != null) {
					String candidate = (String) method.invoke(this.annotation);

					if (StringUtils.hasText(candidate)) {
						expression = candidate;
					}
				}
			}
			return expression;
		}

		public AspectJAnnotationType getAnnotationType() {
			return this.annotationType;
		}

		public A getAnnotation() {
			return this.annotation;
		}

		public String getPointcutExpression() {
			return this.expression;
		}

		public String getArgNames() {
			return this.argNames;
		}

		public String toString() {
			return this.annotation.toString();
		}
	}


	private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {

		public String[] getParameterNames(Method m) {
			if (m.getParameterTypes().length == 0) {
				return new String[0];
			}
			
			AspectJAnnotation annotation = findAspectJAnnotationOnMethod(m);
			if (annotation == null) {
				return null;
			}
			
			StringTokenizer strTok = new StringTokenizer(annotation.getArgNames(),",");
			if (strTok.countTokens() > 0) {
				String[] ret = new String[strTok.countTokens()];
				for (int i = 0; i < ret.length; i++) {
					ret[i] = strTok.nextToken();
				}
				
				return ret;
			} else { 
				return null; 				
			}
		}
		
		public String[] getParameterNames(Constructor ctor) {
			throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女bb生活片| 七七婷婷婷婷精品国产| 欧美成人精品高清在线播放| 欧美亚洲高清一区| 欧美性受xxxx| 欧美日韩mp4| 日韩视频在线观看一区二区| 欧美va亚洲va国产综合| 26uuu亚洲| 国产精品午夜在线| 国产精品第13页| 亚洲专区一二三| 免费高清视频精品| 国产综合久久久久影院| av在线不卡电影| 一本久久综合亚洲鲁鲁五月天| 91黄色免费观看| 欧美日韩和欧美的一区二区| 日韩欧美国产三级电影视频| 欧美一区二区三级| 久久久国产午夜精品| 亚洲视频你懂的| 日韩精品一二三| 国产精品亚洲午夜一区二区三区| 9久草视频在线视频精品| www.欧美日韩国产在线| 99精品黄色片免费大全| 欧美日韩高清影院| 国产色爱av资源综合区| 亚洲制服丝袜在线| 国产精品18久久久久久久久| 91视频www| 日韩三级精品电影久久久| 国产片一区二区| 亚洲国产色一区| 国产在线不卡一区| 欧美日韩激情一区二区| 中文字幕精品综合| 美女视频免费一区| 91麻豆免费看片| 久久伊99综合婷婷久久伊| 亚洲精品高清视频在线观看| 国内欧美视频一区二区| 精品视频在线免费| 自拍av一区二区三区| 久久99久久99| 欧美日韩国产高清一区二区三区| 日本一区二区在线不卡| 日韩不卡一区二区| 99re成人在线| 国产人久久人人人人爽| 日韩av电影一区| 在线观看视频一区二区| 国产精品国产三级国产| 国产综合久久久久久鬼色 | 久久国产人妖系列| 在线观看区一区二| 中文字幕二三区不卡| 老司机免费视频一区二区| 欧美影视一区在线| 日韩美女久久久| 9久草视频在线视频精品| 国产亚洲欧美日韩在线一区| 美女性感视频久久| 91精品免费在线观看| 亚洲黄色小视频| 色偷偷88欧美精品久久久| 国产精品久久久久一区二区三区共| 精品制服美女久久| 日韩欧美亚洲另类制服综合在线| 亚洲6080在线| 欧美高清www午色夜在线视频| 亚洲精品国产无天堂网2021| a4yy欧美一区二区三区| 亚洲男同性视频| 色婷婷亚洲一区二区三区| 亚洲老妇xxxxxx| 色婷婷av久久久久久久| 亚洲尤物在线视频观看| 欧美最猛性xxxxx直播| 午夜欧美在线一二页| 欧美日韩一区二区三区在线看| 亚洲小说欧美激情另类| 欧美色图天堂网| 日韩国产欧美在线视频| 日韩久久免费av| 国产精品资源网| 亚洲男同1069视频| 欧美日韩高清在线| 久久激情五月婷婷| 中文字幕欧美区| 91亚洲精品一区二区乱码| 一区二区三区在线免费视频| 欧美日本一区二区在线观看| 美国精品在线观看| 国产精品网站导航| 欧美在线观看视频在线| 美女看a上一区| 国产欧美视频一区二区三区| 色婷婷久久一区二区三区麻豆| 日韩激情一二三区| 久久久精品免费观看| 91麻豆高清视频| 蜜桃视频一区二区三区| 国产精品视频麻豆| 欧美巨大另类极品videosbest| 麻豆一区二区在线| 亚洲色欲色欲www在线观看| 欧美日韩你懂得| 国产精品18久久久久久久久| 亚洲乱码中文字幕综合| 日韩精品一区在线观看| av亚洲精华国产精华精华| 日韩激情中文字幕| 中文字幕日本不卡| 5858s免费视频成人| 粉嫩一区二区三区性色av| 亚洲国产va精品久久久不卡综合| 久久久久久久久久久久久久久99 | 成人av资源在线| 日韩黄色片在线观看| 国产精品色在线| 欧美电影精品一区二区| 91免费观看视频| 国产成人av福利| 麻豆视频一区二区| 亚洲精选视频在线| 国产欧美精品一区二区色综合朱莉| 欧美日韩三级一区二区| 色噜噜夜夜夜综合网| 成人精品视频一区二区三区| 日本午夜一区二区| 亚洲大片在线观看| 亚洲桃色在线一区| 国产精品日韩精品欧美在线 | 不卡高清视频专区| 久草这里只有精品视频| 亚洲电影一级片| 亚洲精品免费播放| 国产欧美日韩久久| 久久精品一区八戒影视| 精品国产91洋老外米糕| 日韩一二三四区| 91精品国产全国免费观看 | 欧美a一区二区| 午夜精品久久久| 亚洲电影一级黄| 亚洲一区二区三区在线播放| 一区二区三区中文在线| 中文字幕制服丝袜成人av| 国产亲近乱来精品视频| 中文av一区特黄| 国产精品对白交换视频| 成人欧美一区二区三区1314| 中文字幕亚洲精品在线观看| 亚洲天堂精品视频| 亚洲欧美在线高清| 亚洲自拍偷拍九九九| 亚洲已满18点击进入久久| 亚洲精品日产精品乱码不卡| 亚洲靠逼com| 天堂在线亚洲视频| 日本亚洲三级在线| 激情综合网最新| 成人精品视频一区二区三区| 一本大道久久a久久精品综合| 色8久久精品久久久久久蜜| 欧美日免费三级在线| 91麻豆精品国产91久久久久久久久| 在线电影国产精品| 久久一区二区三区国产精品| 国产欧美精品一区| 亚洲精品中文在线观看| 日欧美一区二区| 国产精品一区二区在线观看不卡| 成人精品在线视频观看| 欧美视频一区二区三区在线观看| 91精品国产色综合久久不卡蜜臀 | 亚洲欧美一区二区三区国产精品| 亚洲精品欧美二区三区中文字幕| 亚洲成人av免费| 国产乱子伦视频一区二区三区| 国产激情91久久精品导航| 色婷婷av一区二区| 久久蜜桃av一区精品变态类天堂 | 欧美精选一区二区| 久久久国产一区二区三区四区小说| 国产精品乱码妇女bbbb| 图片区小说区区亚洲影院| 国产福利电影一区二区三区| 欧美色精品在线视频| 亚洲精品在线观看网站| 亚洲男同1069视频| 国产成人在线免费| 欧美高清视频一二三区| 亚洲人成网站在线| 国产一区二区三区综合| 欧美日韩精品欧美日韩精品一综合| 国产欧美va欧美不卡在线| 肉丝袜脚交视频一区二区|