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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? reflectiveaspectjadvisorfactory.java

?? struts+spring 源碼 希望能給大家?guī)韼椭?
?? JAVA
字號(hào):
/*
 * 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.reflect.Field;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;

import org.aopalliance.aop.Advice;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.Pointcut;

import org.springframework.aop.Advisor;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.PointcutAdvisor;
import org.springframework.aop.aspectj.AbstractAspectJAdvice;
import org.springframework.aop.aspectj.AspectJAfterAdvice;
import org.springframework.aop.aspectj.AspectJAfterReturningAdvice;
import org.springframework.aop.aspectj.AspectJAfterThrowingAdvice;
import org.springframework.aop.aspectj.AspectJAroundAdvice;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.DeclareParentsAdvisor;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;

/**
 * Factory that can create Spring AOP Advisors given AspectJ classes from classes honouring
 * the AspectJ 5 annotation syntax, using reflection to invoke advice methods.
 *
 * @author Rod Johnson
 * @author Adrian Colyer
 * @since 2.0
 */
public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFactory {

	/**
	 * Create Spring Advisors for all At AspectJ methods on the given aspect instance.
	 * @return a list of advisors for this class
	 */
	public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
		final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
		final String aspectName = maaif.getAspectMetadata().getAspectName();
		validate(aspectClass);

		// We need to wrap the MetadataAwareAspectInstanceFactory with a decorator
		// so that it will only instantiate once.
		final MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
				new LazySingletonMetadataAwareAspectInstanceFactoryDecorator(maaif);

		final List<Advisor> advisors = new LinkedList<Advisor>();
		//final AspectInstanceFactory aif = new AspectInstanceFactory.SingletonAspectInstanceFactory(aspectInstance);
		ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
			public void doWith(Method m) throws IllegalArgumentException {
				// Exclude pointcuts
				if (AnnotationUtils.getAnnotation(m, Pointcut.class) == null) {
					PointcutAdvisor pa = getAdvisor(m, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
					if (pa != null) {
						advisors.add(pa);
					}
				}
			}
		});

		// If it's a per target aspect, emit the dummy instantiating aspect
		if (!advisors.isEmpty() && lazySingletonAspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
			Advisor instantiationAdvisor = new SyntheticInstantiationAdvisor(lazySingletonAspectInstanceFactory);
			advisors.add(0, instantiationAdvisor);
		}

		//	Find introduction fields
		for (Field f : aspectClass.getDeclaredFields()) {
			// AMC: not sure why this test is here? AspectJ doesn't enforce this...
			//if (Modifier.isStatic(f.getModifiers()) && Modifier.isPublic(f.getModifiers())) {
				Advisor a = getDeclareParentsAdvisor(f);
				if (a != null) {
					advisors.add(a);
				}
			//}
		}

		return advisors;
	}

	/**
	 * Resulting advisors will need to be evaluated for targets.
	 * @return <code>null</code> if not an advisor
	 */
	private Advisor getDeclareParentsAdvisor(Field introductionField) {
		DeclareParents declareParents = (DeclareParents) introductionField.getAnnotation(DeclareParents.class);
		if (declareParents == null) {
			// Not an introduction field
			return null;
		}

		if (declareParents.defaultImpl() == DeclareParents.class) {
			// This is what comes back if it wasn't set. This seems bizarre...
			// TODO this restriction possibly should be relaxed
			throw new IllegalStateException("defaultImpl must be set on DeclareParents");
		}

		return new DeclareParentsAdvisor(
				introductionField.getType(), declareParents.value(), declareParents.defaultImpl());
	}


	public InstantiationModelAwarePointcutAdvisorImpl getAdvisor(
			Method candidateAspectJAdviceMethod, MetadataAwareAspectInstanceFactory aif,
			int declarationOrderInAspect, String aspectName) {

		validate(aif.getAspectMetadata().getAspectClass());

		AspectJExpressionPointcut ajexp =
				getPointcut(candidateAspectJAdviceMethod, aif.getAspectMetadata().getAspectClass());
		if (ajexp == null) {
			return null;
		}
		return new InstantiationModelAwarePointcutAdvisorImpl(
				this, ajexp, aif, candidateAspectJAdviceMethod, declarationOrderInAspect, aspectName);
	}

	/**
	 * Return <code>null</code> if the method is not an AspectJ advice method or if it is a pointcut
	 * that will be used by other advice but will not create a Springt advice in its own right.
	 */
	public Advice getAdvice(Method candidateAspectJAdviceMethod,
			AspectJExpressionPointcut ajexp,
			MetadataAwareAspectInstanceFactory aif,
			int declarationOrderInAspect,
			String aspectName) {

		Class<?> candidateAspectClass = aif.getAspectMetadata().getAspectClass();
		validate(candidateAspectClass);

		AspectJAnnotation<?> aspectJAnnotation =
				AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAspectJAdviceMethod);
		if (aspectJAnnotation == null) {
			//throw new IllegalStateException("Class " + aif.getAspectMetadata().getAspectClass() + " must be an aspect");
			return null;
		}

		// If we get here, we know we have an AspectJ method. 
		// Check that it's an AspectJ-annotated class
		if (!isAspect(candidateAspectClass)) {
			throw new AopConfigException("Advice must be declared inside an aspect type: " +
					"Offending method '" + candidateAspectJAdviceMethod + "' in class " + candidateAspectClass.getName());
		}

		logger.debug("Found AspectJ method " + candidateAspectJAdviceMethod);

		AbstractAspectJAdvice springAdvice;

		switch (aspectJAnnotation.getAnnotationType()) {
			case AtBefore:
				springAdvice = new AspectJMethodBeforeAdvice(candidateAspectJAdviceMethod, ajexp, aif);
				break;
			case AtAfter:
				springAdvice = new AspectJAfterAdvice(candidateAspectJAdviceMethod, ajexp, aif);
				break;
			case AtAfterReturning:
				springAdvice = new AspectJAfterReturningAdvice(candidateAspectJAdviceMethod, ajexp, aif);
				AfterReturning afterReturningAnnotation = (AfterReturning) aspectJAnnotation.getAnnotation();
				if (StringUtils.hasText(afterReturningAnnotation.returning())) {
					springAdvice.setReturningName(afterReturningAnnotation.returning());
				}
				break;
			case AtAfterThrowing:
				springAdvice = new AspectJAfterThrowingAdvice(candidateAspectJAdviceMethod, ajexp, aif);
				AfterThrowing afterThrowingAnnotation = (AfterThrowing) aspectJAnnotation.getAnnotation();
				if (StringUtils.hasText(afterThrowingAnnotation.throwing())) {
					springAdvice.setThrowingName(afterThrowingAnnotation.throwing());
				}
				break;
			case AtAround:
				springAdvice = new AspectJAroundAdvice(candidateAspectJAdviceMethod, ajexp, aif, parameterNameDiscoverer);
				break;
			case AtPointcut:
				if (logger.isDebugEnabled()) {
					logger.debug("Processing pointcut '" + candidateAspectJAdviceMethod.getName() + "'");
				}
				return null;
			default:
				throw new UnsupportedOperationException("Unsupported advice type on method " + candidateAspectJAdviceMethod);
		}

		// Now to configure the advice...
		springAdvice.setAspectName(aspectName);
		springAdvice.setDeclarationOrder(declarationOrderInAspect);
		String[] argNames = getArgumentNames(candidateAspectJAdviceMethod);
		if (argNames != null) {
			springAdvice.setArgumentNamesFromStringArray(argNames);
		}
		try {
			springAdvice.afterPropertiesSet();
		}
		catch (Exception ex) {
			throw new IllegalArgumentException("Advice configuration failed", ex);
		}
		return (Advice) springAdvice;
	}

	private String[] getArgumentNames(Method forMethod) {
		String[] argNames = this.parameterNameDiscoverer.getParameterNames(forMethod);
		if (argNames != null) {
			if (forMethod.getParameterTypes().length == (argNames.length + 1)) {
				// may need to add implicit join point arg name
				Class firstArgType = forMethod.getParameterTypes()[0];
				if (firstArgType == JoinPoint.class ||
						firstArgType == ProceedingJoinPoint.class ||
						firstArgType == JoinPoint.StaticPart.class) {
					String[] oldNames = argNames;
					argNames = new String[oldNames.length + 1];
					argNames[0] = "THIS_JOIN_POINT";
					System.arraycopy(oldNames, 0, argNames, 1, oldNames.length);
				}
			}
		}
		return argNames;
	}

	private AspectJExpressionPointcut getPointcut(Method candidateAspectJAdviceMethod, Class<?> candidateAspectClass) {
		AspectJAnnotation<?> aspectJAnnotation =
				AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(candidateAspectJAdviceMethod);
		if (aspectJAnnotation == null) {
			return null;
		}
		AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class[0]);
		ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
		return ajexp;
	}


	/**
	 * Synthetic advisor that instantiates the aspect.
	 * Triggered by per-clause pointcut on non-singleton aspect.
	 * The advice has no effect.
	 */
	protected static class SyntheticInstantiationAdvisor extends DefaultPointcutAdvisor {

		private static final long serialVersionUID = -7789221134469113954L;

		public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
			super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
				public void before(Method method, Object[] args, Object target) {
					// Simply instantiate the aspect
					aif.getAspectInstance();
				}
			});
		}
	}

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91福利小视频| 蜜桃av噜噜一区| 成人97人人超碰人人99| 国产日产欧美一区二区视频| 精品无人码麻豆乱码1区2区| 久久综合色综合88| 国产a区久久久| 亚洲视频一区在线| 欧美日韩三级视频| 日产欧产美韩系列久久99| 91精品福利在线一区二区三区 | 精品一区二区三区免费播放| 欧美一级生活片| 国产老肥熟一区二区三区| 国产精品久久99| 在线看不卡av| 麻豆国产精品官网| 中文成人av在线| 在线免费精品视频| 蜜臀av一区二区在线观看| 亚洲精品一线二线三线| 99免费精品在线观看| 五月天视频一区| 久久久久综合网| 色综合天天综合网国产成人综合天| 一区二区三区加勒比av| 6080亚洲精品一区二区| 国产精品一区二区不卡| 一区二区三区中文在线| 日韩精品专区在线影院重磅| 成人h精品动漫一区二区三区| 亚洲午夜久久久久久久久久久| 欧美r级在线观看| 99久久夜色精品国产网站| 秋霞成人午夜伦在线观看| 国产欧美日本一区视频| 欧美人狂配大交3d怪物一区| 国产suv精品一区二区6| 亚洲国产综合色| 国产日韩欧美一区二区三区乱码| 欧美中文字幕一区二区三区| 国产乱码精品一区二区三区忘忧草| 亚洲欧美欧美一区二区三区| 日韩精品一区国产麻豆| 色偷偷久久一区二区三区| 国产在线不卡一区| 亚洲永久免费av| 欧美韩国日本一区| 精品国产一区二区三区四区四 | 国产精品久久久久毛片软件| 在线不卡a资源高清| 成人av在线影院| 精品一区二区三区在线播放视频| 亚洲国产婷婷综合在线精品| 欧美激情在线免费观看| 精品噜噜噜噜久久久久久久久试看 | 视频一区视频二区在线观看| 国产欧美精品一区二区色综合 | 日本在线不卡视频| 亚洲精品国产第一综合99久久 | 天天色天天操综合| 亚洲视频一区在线| 国产亚洲1区2区3区| 日韩一级视频免费观看在线| 在线一区二区三区做爰视频网站| 成人一区二区三区视频在线观看| 美女尤物国产一区| 午夜久久久久久| 亚洲一区在线视频| 最新国产の精品合集bt伙计| 国产欧美日韩在线| 久久综合狠狠综合久久综合88 | 欧美mv日韩mv亚洲| 9191国产精品| 欧美美女视频在线观看| 欧美日韩一卡二卡三卡| 色94色欧美sute亚洲线路二 | 夜夜爽夜夜爽精品视频| 亚洲欧洲99久久| 亚洲日本va在线观看| 国产精品乱码一区二三区小蝌蚪| 国产免费久久精品| 久久精品视频免费| 国产欧美日本一区二区三区| 国产欧美日韩在线| 亚洲丝袜精品丝袜在线| 亚洲免费伊人电影| 亚洲综合在线五月| 亚洲一区在线视频观看| 亚洲高清免费视频| 日韩中文字幕91| 免费欧美高清视频| 国产原创一区二区| 国产不卡高清在线观看视频| 国产成人一级电影| 高清不卡在线观看av| 成人99免费视频| 91黄色激情网站| 欧美区在线观看| 精品999久久久| 国产欧美综合在线| 亚洲视频网在线直播| 亚洲风情在线资源站| 开心九九激情九九欧美日韩精美视频电影 | 国产风韵犹存在线视精品| 国产99精品视频| www.爱久久.com| 欧美日韩精品欧美日韩精品一综合| 欧美人动与zoxxxx乱| 欧美mv日韩mv国产网站| 国产精品久久久久久亚洲毛片 | 亚洲成人免费av| 久久99精品久久久久婷婷| 国产乱子轮精品视频| 波多野结衣在线一区| 在线免费观看日韩欧美| 日韩美女视频一区二区在线观看| 欧美激情综合网| 亚洲国产aⅴ天堂久久| 激情综合色播激情啊| 99re这里只有精品6| 欧美一级二级三级乱码| 中文字幕巨乱亚洲| 日韩电影在线看| 91在线观看美女| 欧美成人a∨高清免费观看| 国产精品丝袜91| 日韩vs国产vs欧美| 色综合久久综合网97色综合| 日韩视频一区二区三区在线播放 | 国产精品短视频| 麻豆国产精品777777在线| 色综合久久久久久久久久久| 欧美一区二区三区四区高清| 国产精品不卡在线| 国产中文字幕精品| 欧美日韩夫妻久久| 亚洲欧美中日韩| 国产在线视频不卡二| 欧美日韩精品一区二区在线播放| 国产日韩欧美精品电影三级在线 | 日韩欧美国产小视频| 亚洲欧美日韩一区二区三区在线观看| 久久精品国产久精国产| 欧美综合亚洲图片综合区| 久久综合九色欧美综合狠狠 | 日韩国产欧美在线视频| 91视视频在线直接观看在线看网页在线看| 91精品久久久久久蜜臀| 一区二区三区欧美日韩| 成人开心网精品视频| 精品国产露脸精彩对白| 亚洲国产一区二区视频| 91麻豆免费在线观看| 久久先锋影音av| 精品一区二区三区香蕉蜜桃| 91 com成人网| 五月婷婷久久丁香| 欧美日韩成人综合在线一区二区| 亚洲天堂成人在线观看| 国产成都精品91一区二区三 | 亚洲国产精品成人综合| 国产在线精品免费| 日韩欧美精品三级| 免费在线观看精品| 欧美久久久久久久久中文字幕| 亚洲韩国一区二区三区| 欧美在线观看一二区| 一区二区三区在线视频播放 | 亚洲女人小视频在线观看| 成人永久看片免费视频天堂| 欧美极品xxx| 丁香婷婷综合五月| 国产精品免费久久久久| 成人av网址在线观看| 国产精品女同一区二区三区| 成人午夜精品一区二区三区| 国产精品网友自拍| av成人动漫在线观看| 成人免费在线视频| 91久久免费观看| 亚洲综合激情网| 欧美一区二区三区视频在线| 美女视频网站久久| www精品美女久久久tv| 国产在线麻豆精品观看| 国产精品欧美一区二区三区| 99精品视频一区二区| 亚洲人成网站色在线观看| 欧洲av一区二区嗯嗯嗯啊| 亚洲成av人片在线观看无码| 欧美电影一区二区| 经典三级在线一区| 国产精品女上位| 欧美性生活一区| 久久国产综合精品| 久久九九99视频| 一本到高清视频免费精品| 香蕉成人啪国产精品视频综合网| 精品日韩在线一区|