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

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

?? abstractaspectjadvisorfactorytests.java

?? struts+spring 源碼 希望能給大家帶來幫助
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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.UndeclaredThrowableException;
import java.rmi.RemoteException;
import java.util.LinkedList;
import java.util.List;

import javax.servlet.ServletException;

import junit.framework.TestCase;
import org.aspectj.lang.ProceedingJoinPoint;
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.DeclarePrecedence;
import org.aspectj.lang.annotation.Pointcut;

import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.framework.Lockable;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.core.Ordered;

/**
 * Abstract tests for AspectJAdvisorFactory. See subclasses
 * for tests of concrete factories.
 * 
 * @author Rod Johnson
 * @since 2.0
 */
public abstract class AbstractAspectJAdvisorFactoryTests extends TestCase {
	
	/**
	 * To be overridden by concrete test subclasses
	 * @return the fixture
	 */
	protected abstract AspectJAdvisorFactory getFixture();
	
	@Aspect("percflow(execution(* *(..)))")
	public static class PerCflowAspect {	
	}
	
	@Aspect("percflowbelow(execution(* *(..)))")
	public static class PerCflowBelowAspect {	
	}
	
	public void testRejectsPerCflowAspect() {
		try {
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerCflowAspect(),"someBean"));
			fail("Cannot accept cflow");
		}
		catch (AopConfigException ex) {
			assertTrue(ex.getMessage().indexOf("PERCFLOW") != -1);
		}
	}
	
	public void testRejectsPerCflowBelowAspect() {
		try {
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerCflowBelowAspect(),"someBean"));
			fail("Cannot accept cflowbelow");
		}
		catch (AopConfigException ex) {
			assertTrue(ex.getMessage().indexOf("PERCFLOWBELOW") != -1);
		}
	}
	
	@Aspect("pertarget(execution(* *.getSpouse()))")
	public static class PerTargetAspect implements Ordered {
		public int count;
		private int order = Ordered.LOWEST_PRECEDENCE;
		
		@Around("execution(int *.getAge())")
		public int returnCountAsAge() {
			return count++;
		}
		
		@Before("execution(void *.set*(int))")
		public void countSetter() {
			++count;
		}

		/* (non-Javadoc)
		 * @see org.springframework.core.Ordered#getOrder()
		 */
		public int getOrder() {
			return this.order;
		}
		
		public void setOrder(int order) {
			this.order = order;
		}
	}

	public void testPerTargetAspect() throws SecurityException, NoSuchMethodException {
		TestBean target = new TestBean();
		int realAge = 65;
		target.setAge(realAge);
		TestBean itb = (TestBean) createProxy(target, 
				getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean")), 
				TestBean.class);
		assertEquals("Around advice must NOT apply", realAge, itb.getAge());
		
		Advised advised = (Advised) itb;
		SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
		assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[3];
		MetadataAwareAspectInstanceFactory maaif = imapa.getAspectInstanceFactory();
		assertEquals(0, maaif.getInstantiationCount());
		
		// Check that the perclause pointcut is valid
		assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
		
		// Hit the method in the per clause to instantiate the aspect
		itb.getSpouse();
		
		assertEquals(1, maaif.getInstantiationCount());
		
		assertEquals("Around advice must apply", 0, itb.getAge());
		assertEquals("Around advice must apply", 1, itb.getAge());
	}

	@Aspect("perthis(execution(* *.getSpouse()))")
	public static class PerThisAspect {
		public int count;

		/**
		 * Just to check that this doesn't cause problems with introduction processing
		 */
		private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();

		@Around("execution(int *.getAge())")
		public int returnCountAsAge() {
			return count++;
		}

		@Before("execution(void *.set*(int))")
		public void countSetter() {
			++count;
		}
	}

	public void testPerThisAspect() throws SecurityException, NoSuchMethodException {
		TestBean target = new TestBean();
		int realAge = 65;
		target.setAge(realAge);
		TestBean itb = (TestBean) createProxy(target, 
				getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerThisAspect(),"someBean")), 
				TestBean.class);
		assertEquals("Around advice must NOT apply", realAge, itb.getAge());
		
		Advised advised = (Advised) itb;
		// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
		assertEquals(4, advised.getAdvisors().length);
		SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
		assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[2];
		MetadataAwareAspectInstanceFactory maaif = imapa.getAspectInstanceFactory();
		assertEquals(0, maaif.getInstantiationCount());
		
		// Check that the perclause pointcut is valid
		assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
		
		// Hit the method in the per clause to instantiate the aspect
		itb.getSpouse();
		
		assertEquals(1, maaif.getInstantiationCount());
		
		assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
	
		assertEquals("Around advice must apply", 0, itb.getAge());
		assertEquals("Around advice must apply", 1, itb.getAge());
	}
	
	@Aspect("pertypewithin(org.springframework.beans.IOther+)")
	public static class PerTypeWithinAspect {
		public int count;
		
		@Around("execution(int *.getAge())")
		public int returnCountAsAge() {
			return count++;
		}
		
		@Before("execution(void *.*(..))")
		public void countAnythingVoid() {
			++count;
		}
	}
	
	private class PerTypeWithinAspectInstanceFactory implements MetadataAwareAspectInstanceFactory {
		private int count;
		public Object getAspectInstance() {
			++count;
			return new PerTypeWithinAspect();
		}
		
		public int getInstantiationCount() {
			return count;
		}
		public AspectMetadata getAspectMetadata() {
			return new AspectMetadata(PerTypeWithinAspect.class,"perTypeWithin");
		}
	}
	
	public void testPerTypeWithinAspect() throws SecurityException, NoSuchMethodException {
		TestBean target = new TestBean();
		int realAge = 65;
		target.setAge(realAge);
		PerTypeWithinAspectInstanceFactory aif = new PerTypeWithinAspectInstanceFactory();
		TestBean itb = (TestBean) createProxy(target, 
				getFixture().getAdvisors(aif), 
				TestBean.class);
		assertEquals("No method calls", 0, aif.getInstantiationCount());
		assertEquals("Around advice must now apply", 0, itb.getAge());
		
		Advised advised = (Advised) itb;
		// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
		assertEquals(4, advised.getAdvisors().length);
		SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
		assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		InstantiationModelAwarePointcutAdvisorImpl imapa = (InstantiationModelAwarePointcutAdvisorImpl) advised.getAdvisors()[2];
		MetadataAwareAspectInstanceFactory maaif = imapa.getAspectInstanceFactory();
		assertEquals(1, maaif.getInstantiationCount());
		
		// Check that the perclause pointcut is valid
		assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
		assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
		
		// Hit the method in the per clause to instantiate the aspect
		itb.getSpouse();
		
		assertEquals(1, maaif.getInstantiationCount());
		
		assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
	
		assertEquals("Around advice must still apply", 1, itb.getAge());
		assertEquals("Around advice must still apply", 2, itb.getAge());
		
		TestBean itb2 = (TestBean) createProxy(target, 
				getFixture().getAdvisors(aif), 
				TestBean.class);
		assertEquals(1, aif.getInstantiationCount());
		assertEquals("Around advice be independent for second instance", 0, itb2.getAge());
		assertEquals(2, aif.getInstantiationCount());
	}
	
	
	@Aspect
	public static class NamedPointcutAspectWithFQN {
		
		@SuppressWarnings("unused")
		private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean();
		
		@Pointcut("execution(* getAge())")
		public void getAge() {			
		}
		
		@Around("org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.NamedPointcutAspectWithFQN.getAge()")
		public int changeReturnValue(ProceedingJoinPoint pjp) {
			return -1;
		}
	}
	
	public void testNamedPointcutAspectWithFQN() {
		testNamedPointcuts(new NamedPointcutAspectWithFQN());
	}
	
	@Aspect
	public static class NamedPointcutAspectWithoutFQN {
		@Pointcut("execution(* getAge())")
		public void getAge() {			
		}
		
		@Around("getAge()")
		public int changeReturnValue(ProceedingJoinPoint pjp) {
			return -1;
		}
	}
	
	public void testNamedPointcutAspectWithoutFQN() {
		testNamedPointcuts(new NamedPointcutAspectWithoutFQN());
	}
	
	@Aspect
	public static class NamedPointcutAspectFromLibrary {

		@Around("org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.propertyAccess()")
		public int changeReturnType(ProceedingJoinPoint pjp) {
			return -1;
		}
		
		@Around(value="org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.integerArgOperation(x)", argNames="x")
		public void doubleArg(ProceedingJoinPoint pjp, int x) throws Throwable {
			pjp.proceed(new Object[]{x*2});
		}
	}

	@Aspect
	public static class Library {
		
		@Pointcut("execution(!void get*())")
		public void propertyAccess() {}
		
		@Pointcut("execution(* *(..)) && args(i)")
		public void integerArgOperation(int i) {}
		
	}
	
	public void testNamedPointcutFromAspectLibrary() {
		testNamedPointcuts(new NamedPointcutAspectFromLibrary());
	}
	
	
	@Aspect
	public static class NamedPointcutAspectFromLibraryWithBinding {
		
		@Around(value="org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.integerArgOperation(x)", argNames="x")
		public void doubleArg(ProceedingJoinPoint pjp, int x) throws Throwable {
			pjp.proceed(new Object[]{x*2});
		}
	}
	
	public void testNamedPointcutFromAspectLibraryWithBinding() {
		TestBean target = new TestBean();
		ITestBean itb = (ITestBean) createProxy(target, 
				getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new NamedPointcutAspectFromLibraryWithBinding(),"someBean")), 
				ITestBean.class);
		itb.setAge(10);
		assertEquals("Around advice must apply", 20, itb.getAge());
		assertEquals(20,target.getAge());
	}
	
	private void testNamedPointcuts(Object aspectInstance) {
		TestBean target = new TestBean();
		int realAge = 65;
		target.setAge(realAge);
		ITestBean itb = (ITestBean) createProxy(target, 
				getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspectInstance,"someBean")), 
				ITestBean.class);
		assertEquals("Around advice must apply", -1, itb.getAge());
		assertEquals(realAge, target.getAge());
	}
	
	@Aspect
	public static class BindingAspectWithSingleArg {
		
		@Pointcut(value="args(a)", argNames="a")
		public void setAge(int a) {}
		
		@Around(value="setAge(age)",argNames="age")
//		@ArgNames({"age"})   // AMC needs more work here? ignoring pjp arg... ok??
//		                       // argNames should be suported in Around as it is in Pointcut
		public void changeReturnType(ProceedingJoinPoint pjp, int age) throws Throwable {
			pjp.proceed(new Object[]{age*2});
		}
	}

	public void testBindingWithSingleArg() {
		TestBean target = new TestBean();
		ITestBean itb = (ITestBean) createProxy(target, 
				getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new BindingAspectWithSingleArg(),"someBean")), 
				ITestBean.class);
		itb.setAge(10);
		assertEquals("Around advice must apply", 20, itb.getAge());
		assertEquals(20,target.getAge());

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区在线观看| 中文字幕中文字幕一区| 久久精品一区四区| 偷拍与自拍一区| www.亚洲国产| 精品久久久久av影院| 亚洲成人动漫在线免费观看| 99r国产精品| 久久久夜色精品亚洲| 亚洲一区二区偷拍精品| 成人免费毛片app| 精品国产精品网麻豆系列| 亚洲一区二区三区影院| 一本到一区二区三区| 久久精品人人爽人人爽| 蜜桃久久精品一区二区| 欧美日韩国产影片| 夜夜亚洲天天久久| 91成人国产精品| 亚洲欧美日韩国产一区二区三区 | 亚洲女同ⅹxx女同tv| 国产精品一区二区三区四区| 日韩欧美精品三级| 日韩国产精品久久久久久亚洲| 97se亚洲国产综合自在线观| 中文字幕中文字幕在线一区| 成人性视频免费网站| 欧美国产欧美亚州国产日韩mv天天看完整| 日韩 欧美一区二区三区| 欧美乱妇15p| 日本在线不卡一区| 日韩欧美亚洲国产另类| 亚洲一区二区在线免费观看视频| 在线亚洲一区二区| 亚洲综合视频在线| 中文字幕第一页久久| 日韩精品1区2区3区| 欧美精品黑人性xxxx| 亚洲成人免费在线| 欧美亚洲免费在线一区| 夜夜爽夜夜爽精品视频| 欧美午夜免费电影| 天天综合天天做天天综合| 欧美高清激情brazzers| 视频在线观看一区| 欧美xxxx在线观看| 国产主播一区二区三区| 国产日韩精品一区二区三区| 国内精品视频一区二区三区八戒| 欧美电影免费提供在线观看| 久久国产精品99久久人人澡| 久久精品人人做人人爽97| 成人综合日日夜夜| 国产精品传媒视频| 欧美日韩中文国产| 久久91精品久久久久久秒播| 国产亚洲精品资源在线26u| 99久久婷婷国产精品综合| 亚洲一区二区av电影| 日韩欧美一区中文| 国产精品中文字幕欧美| 国产欧美一区二区在线| 成人综合在线视频| 亚洲主播在线观看| 日韩久久精品一区| 成人激情综合网站| 午夜欧美电影在线观看| 久久色.com| 99国产精品99久久久久久| 日韩精品一二区| 国产精品色眯眯| 欧美日韩免费观看一区二区三区| 开心九九激情九九欧美日韩精美视频电影| 精品福利在线导航| 91婷婷韩国欧美一区二区| 日韩激情在线观看| 国产精品美女一区二区三区 | 国产精品麻豆欧美日韩ww| 欧美亚洲一区二区在线观看| 麻豆一区二区三区| 国产三级三级三级精品8ⅰ区| 91视频一区二区三区| 国内外精品视频| 精品国产自在久精品国产| 久久综合久久久久88| 欧美无砖专区一中文字| 懂色av噜噜一区二区三区av | 国产亚洲精品久| 欧美日韩午夜影院| 9久草视频在线视频精品| 麻豆精品一区二区av白丝在线| 亚洲欧洲日产国产综合网| 精品国产污污免费网站入口 | 成a人片国产精品| 裸体在线国模精品偷拍| 一区二区三区小说| 国产日韩欧美精品综合| 日韩欧美一区二区三区在线| 一本色道久久综合亚洲aⅴ蜜桃| 奇米综合一区二区三区精品视频 | 2021久久国产精品不只是精品| 91丨porny丨国产| 99综合电影在线视频| 国产自产高清不卡| 日日骚欧美日韩| 亚洲一本大道在线| 亚洲一区二区三区视频在线| 亚洲欧美视频在线观看| 国产精品福利一区| 国产精品久久久久久亚洲伦 | 欧美男男青年gay1069videost| 91婷婷韩国欧美一区二区| 99久久99久久免费精品蜜臀| 9i看片成人免费高清| 91免费视频大全| 色综合久久综合| 在线观看亚洲一区| 欧美色手机在线观看| 欧美乱熟臀69xxxxxx| 6080亚洲精品一区二区| 4438x成人网最大色成网站| 欧美私人免费视频| 欧美日韩中文国产| 日韩一区二区三区观看| 精品久久久久一区二区国产| 日韩你懂的电影在线观看| 精品福利av导航| 国产人成一区二区三区影院| 国产精品久久久久久久岛一牛影视| 中文字幕在线视频一区| 亚洲日穴在线视频| 亚洲国产精品久久久久婷婷884| 视频在线观看一区| 国产一区二区中文字幕| 成人午夜视频在线观看| 91久久精品午夜一区二区| 欧美麻豆精品久久久久久| 久久色在线视频| 最好看的中文字幕久久| 日韩和的一区二区| 国产精品综合一区二区三区| 91美女在线观看| 91精品国产一区二区三区蜜臀| www久久精品| 尤物视频一区二区| 韩国视频一区二区| 色94色欧美sute亚洲线路一ni| 欧美精品1区2区| 欧美国产亚洲另类动漫| 亚洲成a人片在线不卡一二三区| 九一久久久久久| 日本高清无吗v一区| 日韩一级片网站| 亚洲人亚洲人成电影网站色| 日韩av成人高清| 91色.com| 精品1区2区在线观看| 一区二区免费在线| 国内精品写真在线观看| 欧美日韩一区 二区 三区 久久精品| 精品国产91洋老外米糕| 亚洲超碰精品一区二区| 国产成人av电影在线| 91精品国产一区二区| 亚洲区小说区图片区qvod| 韩日av一区二区| 欧美伦理电影网| 亚洲欧美偷拍三级| 国产不卡一区视频| 日韩你懂的在线观看| 亚洲第一综合色| 国产成人精品亚洲日本在线桃色 | 91美女福利视频| 国产日韩亚洲欧美综合| 麻豆国产欧美一区二区三区| 91国产免费看| 国产精品黄色在线观看| 国产高清不卡一区二区| 欧美一级理论片| 亚洲成人一区二区在线观看| 色综合夜色一区| 国产精品国产三级国产aⅴ入口 | 日本一区二区成人在线| 日本亚洲三级在线| 欧美日韩精品一区二区三区| 亚洲天堂成人网| www.性欧美| 欧美激情中文字幕一区二区| 国产一区二区三区免费| 日韩欧美成人激情| 秋霞成人午夜伦在线观看| 欧美猛男gaygay网站| 偷偷要91色婷婷| 欧美精品日韩综合在线| 亚洲成人动漫在线观看| 欧美年轻男男videosbes| 日本欧美大码aⅴ在线播放| 欧美日韩亚洲综合在线| 午夜欧美大尺度福利影院在线看| 欧美欧美欧美欧美首页|