当前位置: 首页>>代码示例>>Java>>正文


Java AspectJProxyFactory类代码示例

本文整理汇总了Java中org.springframework.aop.aspectj.annotation.AspectJProxyFactory的典型用法代码示例。如果您正苦于以下问题:Java AspectJProxyFactory类的具体用法?Java AspectJProxyFactory怎么用?Java AspectJProxyFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AspectJProxyFactory类属于org.springframework.aop.aspectj.annotation包,在下文中一共展示了AspectJProxyFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProgrammaticProxyCreation

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
@Test
public void testProgrammaticProxyCreation() {
	ITestBean testBean = new TestBean();

	AspectJProxyFactory factory = new AspectJProxyFactory();
	factory.setTarget(testBean);

	CounterAspect myCounterAspect = new CounterAspect();
	factory.addAspect(myCounterAspect);

	ITestBean proxyTestBean = factory.getProxy();

	assertTrue("Expected a proxy", proxyTestBean instanceof Advised);
	proxyTestBean.setAge(20);
	assertEquals("Programmatically created proxy shouldn't match bean()", 0, myCounterAspect.count);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:BeanNamePointcutAtAspectTests.java

示例2: aopAspectJ

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
public static void aopAspectJ() {
	// 基于编程方式的AspectJ织入
	AspectJProxyFactory weaver = new AspectJProxyFactory();
	weaver.setProxyTargetClass(true);
	weaver.setTarget(new Foo());
	weaver.addAspect(PerformanceTraceAspect.class);
	Object proxy = weaver.getProxy();
	((Foo) proxy).method1();
	((Foo) proxy).method2();

	// 自动代理织入,参见spring-appfx-aop2.xml
	ApplicationContext app = iocInit("");
	proxy = app.getBean("fooTarget");
	((Foo) proxy).method1();
	((Foo) proxy).method2();

	// 基于XSD形式的自动代理,参见配置文件
}
 
开发者ID:bdceo,项目名称:bd-codes,代码行数:19,代码来源:FXmain.java

示例3: test

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
@Test
public void test() {
  Intf target = new Impl();
  AspectJProxyFactory factory = new AspectJProxyFactory(target);
  MyAspect aspect = new MyAspect();
  factory.addAspect(aspect);
  Intf proxy = factory.getProxy();

  Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
  Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:TestBeanUtils.java

示例4: setUp

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mockAbilitiesService = mock(AbilitiesService.class);
    RequestLogger requestLogger = new RequestLogger();
    AbilitiesController abilitiesController = new AbilitiesController(mockAbilitiesService);

    AspectJProxyFactory proxyFactory = new AspectJProxyFactory(abilitiesController);
    proxyFactory.addAspect(requestLogger);
    proxyController = proxyFactory.getProxy();

    LogSession.start();
}
 
开发者ID:HelfenKannJeder,项目名称:come2help,代码行数:13,代码来源:RequestLoggerTest.java

示例5: setUp

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
/**
 * SetUp.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Before
public void setUp() throws Exception {
    testHelper = new TestHelper();
    securityManager = new MockSecurityManager();
    storage = new MockDaoStorage();        
    contentDao = new MockContentDao(storage);
    userDao = new MockUserDao(storage);
    service = new StandardContentService();
    lockManager = new SingleVMLockManager();
    service.setContentDao(contentDao);
    service.setLockManager(lockManager);
    service.setTriageStatusQueryProcessor(new StandardTriageStatusQueryProcessor());
    service.init();
    
    // create a factory that can generate a proxy for the given target object
    AspectJProxyFactory factory = new AspectJProxyFactory(service); 
    
    sa.setSecurityManager(securityManager);
    sa.setContentDao(contentDao);
    sa.setUserDao(userDao);
    //this bean has request scope
    //sa.setSecuredMethod(Proxy) should be called by Spring
    sa.init();
    factory.addAspect(sa);

    // now get the proxy object...
    proxyService = factory.getProxy();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:33,代码来源:SecurityAdviceTest.java

示例6: createProxyServiceWithoutExpectedAdviceExecution

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
/**
 * Create service with the advice. It is not expected to create eventData for handers because they 
 * won't execute.
 */
private void createProxyServiceWithoutExpectedAdviceExecution() {
    eventOperationExtensionsAdvice = new ContextServiceExtensionsAdvice(){
    };
    // create a factory that can generate a proxy for the given target object
    AspectJProxyFactory factory = new AspectJProxyFactory(service); 

    factory.addAspect(eventOperationExtensionsAdvice);

    // now get the proxy object...
    proxyService = factory.getProxy();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:16,代码来源:ContextServiceExtensionsAdviceTest.java

示例7: createProxyServiceWithExpectedAdviceExecution

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
/**
 * Create service with the advice. The handlers wll execure with expected results.
 */
private void createProxyServiceWithExpectedAdviceExecution() {
    eventOperationExtensionsAdvice = new ContextServiceExtensionsAdvice();
    
    // create a factory that can generate a proxy for the given target object
    AspectJProxyFactory factory = new AspectJProxyFactory(service); 

    factory.addAspect(eventOperationExtensionsAdvice);

    // now get the proxy object...
    proxyService = factory.getProxy();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:15,代码来源:ContextServiceExtensionsAdviceTest.java

示例8: setUp

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
/**
 * SetUp.
 * @throws Exception - if something is wrong this exception is thrown.
 */
@Before
public void setUp() throws Exception {
    testHelper = new TestHelper();
    securityManager = new MockSecurityManager();
    storage = new MockDaoStorage();
    calendarDao = new MockCalendarDao(storage);
    contentDao = new MockContentDao(storage);
    eventLogDao = new MockEventLogDao();
    service = new StandardContentService();
    lockManager = new SingleVMLockManager();
    service.setContentDao(contentDao);
    service.setLockManager(lockManager);
    service.setTriageStatusQueryProcessor(new StandardTriageStatusQueryProcessor());
    service.init();
    
    // create a factory that can generate a proxy for the given target object
    AspectJProxyFactory factory = new AspectJProxyFactory(service); 

    // add aspect
    EventLogAdvice eva = new EventLogAdvice();
    eva.setEnabled(true);
    eva.setSecurityManager(securityManager);
    eva.setEventLogDao(eventLogDao);
    eva.init();
    factory.addAspect(eva);

    // now get the proxy object...
    proxyService = factory.getProxy();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:34,代码来源:EventLogAdviceTest.java

示例9: timeMethod

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
@Test
public void timeMethod() throws Exception {
    Timeable cprime = new TestClass();
    AspectJProxyFactory factory = new AspectJProxyFactory(cprime);
    factory.addAspect(MethodTimer.class);
    Timeable proxy = factory.getProxy();

    proxy.timeMe();

    final Double tot = CollectorRegistry.defaultRegistry.getSampleValue("test_class_sum");
    Assert.assertNotNull(tot);
    assertEquals(0.02, tot, 0.01);
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:14,代码来源:MethodTimerTest.java

示例10: getFactory

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
public AspectJProxyFactory getFactory() {
    return this.factory;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:4,代码来源:SdcctAopUtils.java

示例11: getProxy

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
<T> T getProxy(T source){
    AspectJProxyFactory factory = new AspectJProxyFactory(source);
    factory.addAspect(MethodTimer.class);
    return factory.getProxy();
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:6,代码来源:MethodTimerTest.java

示例12: main

import org.springframework.aop.aspectj.annotation.AspectJProxyFactory; //导入依赖的package包/类
public static void main( String[] args )
{
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    Student student = (Student) context.getBean("student");

    AspectJProxyFactory factory = new AspectJProxyFactory(student);

    factory.addAspect(Logging.class);

    Student studentProxy = factory.getProxy();

    studentProxy.getName();
}
 
开发者ID:garyhu1,项目名称:spring_mvc_demo,代码行数:14,代码来源:App.java


注:本文中的org.springframework.aop.aspectj.annotation.AspectJProxyFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。