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

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

?? abstractaspectjadvisorfactorytests.java

?? struts+spring 源碼 希望能給大家?guī)韼椭?
?? JAVA
?? 第 1 頁 / 共 2 頁
字號(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.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());

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲人一二三区| 欧美日韩国产免费一区二区| 国产高清无密码一区二区三区| eeuss鲁一区二区三区| 欧美中文一区二区三区| 精品久久久久久久久久久久久久久久久| 久久亚洲影视婷婷| 亚洲亚洲精品在线观看| 国产一区二区三区免费在线观看| 色综合色综合色综合| 欧美一区二区三区视频免费| 亚洲欧美在线视频观看| 韩国精品免费视频| 欧美日韩国产欧美日美国产精品| 日韩精品电影在线| 91美女在线看| 国产精品女上位| 久久精品国产一区二区三| 日本高清不卡aⅴ免费网站| 日本一区二区视频在线| 久久精品国产一区二区三区免费看| 国产亚洲欧洲一区高清在线观看| 日韩精品乱码av一区二区| wwwwww.欧美系列| 91在线无精精品入口| 国产蜜臀97一区二区三区| 色综合久久88色综合天天| 日本午夜精品一区二区三区电影| 日本高清视频一区二区| 日韩国产精品久久久| 国产精品久久久久久久久晋中 | 91麻豆.com| 天天操天天综合网| 欧美日韩国产大片| 丁香婷婷综合色啪| 国产精品丝袜久久久久久app| 欧美色精品在线视频| 亚洲丝袜美腿综合| 日韩欧美www| 国模冰冰炮一区二区| 一区二区三区四区在线播放| 色综合久久中文综合久久牛| 裸体一区二区三区| 精品久久久久一区二区国产| 91美女片黄在线观看91美女| 九九精品一区二区| 国产欧美一区二区精品仙草咪| 欧美视频自拍偷拍| 麻豆精品精品国产自在97香蕉| 亚洲视频电影在线| 欧美色视频一区| 精品一区二区在线视频| 2欧美一区二区三区在线观看视频| 91免费看`日韩一区二区| 国内精品伊人久久久久av一坑| 亚洲精品成人天堂一二三| 欧美电影一区二区| 在线播放中文字幕一区| 91极品视觉盛宴| 欧美日韩五月天| 欧美一区二区免费| 26uuu色噜噜精品一区二区| 国产亲近乱来精品视频 | 国产欧美一二三区| 日韩理论片网站| 亚洲国产精品一区二区尤物区| 日韩在线a电影| 国产一区二区免费看| 成人三级在线视频| 久久精品国产久精国产| 国产另类ts人妖一区二区| 免费人成精品欧美精品| 亚洲成av人**亚洲成av**| 一区二区在线观看免费| 美女看a上一区| 成人福利视频在线| 不卡一区二区三区四区| 欧美色视频在线| 久久久久久99久久久精品网站| 日韩精品在线看片z| 国产精品毛片久久久久久| 亚洲成人av在线电影| 精品影院一区二区久久久| 92国产精品观看| 日韩欧美一级片| 亚洲黄色性网站| 狠狠色伊人亚洲综合成人| 91在线播放网址| 欧美日韩高清一区二区三区| 中文字幕 久热精品 视频在线| 久久网站最新地址| 亚洲一区二区三区视频在线播放 | 一区二区三区色| 美女爽到高潮91| 99精品欧美一区| 久久一区二区三区四区| 最新中文字幕一区二区三区 | 久久99最新地址| 视频一区欧美日韩| 国产美女一区二区| 97久久超碰精品国产| 欧美久久一区二区| 久久久久久久久久久久久久久99| 中文字幕在线不卡视频| 青青草国产成人av片免费| 国产成人在线看| 欧美日韩视频在线第一区| 久久亚洲精品小早川怜子| 亚洲裸体xxx| 1区2区3区国产精品| 精品在线免费视频| 欧美一卡二卡三卡| 91在线国产观看| 亚洲精品一区二区在线观看| 欧美日韩精品一区视频| 中文字幕一区免费在线观看| 韩国一区二区在线观看| 4438x亚洲最大成人网| 日韩欧美国产电影| 五月婷婷久久丁香| 欧美日韩一区二区在线观看| 亚洲欧洲一区二区在线播放| 国产成人啪午夜精品网站男同| 日韩欧美卡一卡二| 日韩成人免费电影| 欧美日韩精品综合在线| 亚洲一区电影777| 在线观看欧美精品| 亚洲激情图片qvod| 色婷婷精品久久二区二区蜜臂av| 国产精品二区一区二区aⅴ污介绍| 国产一区二区h| 26uuu国产一区二区三区| 久久 天天综合| 精品久久久久久久人人人人传媒| 久久精品国内一区二区三区| 欧美电影免费观看高清完整版在线 | 日韩精品一区二区三区视频播放 | 成人久久久精品乱码一区二区三区 | 日本aⅴ亚洲精品中文乱码| 色狠狠av一区二区三区| 综合激情网...| 粉嫩久久99精品久久久久久夜| 久久久亚洲高清| 麻豆精品在线视频| 日韩欧美一区在线观看| 日本一区二区三区在线观看| 岛国av在线一区| 亚洲色图第一区| 欧美日韩在线电影| 日韩国产一区二| 久久影院午夜片一区| 波多野结衣亚洲| 亚洲综合色视频| 日韩欧美在线123| 国产大陆精品国产| 自拍偷拍亚洲综合| 欧美丝袜自拍制服另类| 琪琪久久久久日韩精品| 久久亚洲二区三区| www.爱久久.com| 亚洲一卡二卡三卡四卡无卡久久 | 青青草一区二区三区| 久久久久97国产精华液好用吗| 国产激情一区二区三区| 亚洲人成精品久久久久| 4438x亚洲最大成人网| 国产高清在线精品| 亚洲综合一区二区| 欧美精品一区二区三区高清aⅴ| 不卡免费追剧大全电视剧网站| 一区二区三区国产豹纹内裤在线| 69堂国产成人免费视频| 国产成人综合网| 性久久久久久久久久久久| 精品国内二区三区| 99久久久无码国产精品| 日韩成人伦理电影在线观看| 中文字幕欧美区| 欧美精品乱码久久久久久按摩| 国产一区亚洲一区| 亚洲综合一二区| 国产丝袜欧美中文另类| 欧美日韩综合一区| 国产精品一品二品| 午夜精品久久久久久久99樱桃| 久久精品人人爽人人爽| 欧美另类z0zxhd电影| 成人免费视频视频在线观看免费| 日韩电影免费一区| 亚洲日本丝袜连裤袜办公室| 日韩一区和二区| 色综合视频一区二区三区高清| 老色鬼精品视频在线观看播放| 亚洲色图第一区| 精品国产乱码久久久久久牛牛 | 精品婷婷伊人一区三区三| 国产精品综合二区| 天天操天天干天天综合网| 国产精品丝袜一区|