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


Java AopProxyUtils类代码示例

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


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

示例1: getSpecificmethod

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
private Method getSpecificmethod(ProceedingJoinPoint pjp) {
	MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
	Method method = methodSignature.getMethod();
	// The method may be on an interface, but we need attributes from the
	// target class. If the target class is null, the method will be
	// unchanged.
	Class<?> targetClass = AopProxyUtils.ultimateTargetClass(pjp.getTarget());
	if (targetClass == null && pjp.getTarget() != null) {
		targetClass = pjp.getTarget().getClass();
	}
	Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
	// If we are dealing with method with generic parameters, find the
	// original method.
	specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
	return specificMethod;
}
 
开发者ID:ziwenxie,项目名称:leafer,代码行数:17,代码来源:CachingAnnotationsAspect.java

示例2: buildScheduledRunnable

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
/**
 * 封装ScheduledMethodRunnable对象
 */
private static ScheduledMethodRunnable buildScheduledRunnable(Object bean, String targetMethod, String params, String extKeySuffix, boolean onlyOne) throws Exception {

    Assert.notNull(bean, "target object must not be null");
    Assert.hasLength(targetMethod, "Method name must not be empty");

    Method method;
    ScheduledMethodRunnable scheduledMethodRunnable;
    Class<?> clazz;
    if (AopUtils.isAopProxy(bean)) {
        clazz = AopProxyUtils.ultimateTargetClass(bean);
    } else {
        clazz = bean.getClass();
    }
    if (params != null) {
        method = ReflectionUtils.findMethod(clazz, targetMethod, String.class);
    } else {
        method = ReflectionUtils.findMethod(clazz, targetMethod);
    }
    Assert.notNull(method, "can not find method named " + targetMethod);
    scheduledMethodRunnable = new ScheduledMethodRunnable(bean, method, params, extKeySuffix, onlyOne);
    return scheduledMethodRunnable;
}
 
开发者ID:liuht777,项目名称:uncode-scheduler,代码行数:26,代码来源:DynamicTaskManager.java

示例3: _buildScheduledRunnable

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
private static ScheduledMethodRunnable _buildScheduledRunnable(Object bean, String targetMethod, String params) throws Exception {

		Assert.notNull(bean, "target object must not be null");
		Assert.hasLength(targetMethod, "Method name must not be empty");

		Method method;
		ScheduledMethodRunnable scheduledMethodRunnable;

		Class<?> clazz;
		if (AopUtils.isAopProxy(bean)) {
			clazz = AopProxyUtils.ultimateTargetClass(bean);
		} else {
			clazz = bean.getClass();
		}
		if (params != null) {
			method = ReflectionUtils.findMethod(clazz, targetMethod, String.class);
		} else {
			method = ReflectionUtils.findMethod(clazz, targetMethod);
		}

		Assert.notNull(method, "can not find method named " + targetMethod);
		scheduledMethodRunnable = new ScheduledMethodRunnable(bean, method, params);
		return scheduledMethodRunnable;
	}
 
开发者ID:rabbitgyk,项目名称:uncode-schedule,代码行数:25,代码来源:DynamicTaskManager.java

示例4: getSpecificmethod

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
/**
 * Finds out the most specific method when the execution reference is an
 * interface or a method with generic parameters
 * 
 * @param pjp
 * @return
 */
private Method getSpecificmethod(ProceedingJoinPoint pjp) {
	MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
	Method method = methodSignature.getMethod();
	// The method may be on an interface, but we need attributes from the
	// target class. If the target class is null, the method will be
	// unchanged.
	Class<?> targetClass = AopProxyUtils.ultimateTargetClass(pjp.getTarget());
	if (targetClass == null && pjp.getTarget() != null) {
		targetClass = pjp.getTarget().getClass();
	}
	Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
	// If we are dealing with method with generic parameters, find the
	// original method.
	specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
	return specificMethod;
}
 
开发者ID:yantrashala,项目名称:spring-cache-self-refresh,代码行数:24,代码来源:CachingAnnotationsAspect.java

示例5: postProcessAfterInitialization

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
  // need the target class, not the Spring proxied one
  Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean);
  // for each method in the bean
  for(Method method : targetClass.getMethods()) {
    if(method.isAnnotationPresent(Subscribe.class)) {
      log.debug("Register bean {} ({}) containing method {} to EventBus", beanName, bean.getClass().getName(),
          method.getName());
      // register it with the event bus
      eventBus.register(bean);
      return bean; // we only need to register once
    }
  }
  return bean;
}
 
开发者ID:obiba,项目名称:agate,代码行数:17,代码来源:EventBusConfiguration.java

示例6: getTargetClass

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
private Class<?> getTargetClass(Object target) {
	Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
	if (targetClass == null && target != null) {
		targetClass = target.getClass();
	}
	return targetClass;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:CacheAspectSupport.java

示例7: getTargetClass

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
private Class<?> getTargetClass(Object target) {
  Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
  if (targetClass == null && target != null) {
    targetClass = target.getClass();
  }
  return targetClass;
}
 
开发者ID:nickevin,项目名称:Qihua,代码行数:8,代码来源:CacheAspectSupport.java

示例8: testRootVars

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
public void testRootVars(CacheableService<?> service) {
	Object key = new Object();
	Object r1 = service.rootVars(key);
	assertSame(r1, service.rootVars(key));
	Cache cache = cm.getCache("testCache");
	// assert the method name is used
	String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service;
	assertNotNull(cache.get(expectedKey));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AbstractCacheAnnotationTests.java

示例9: getMostSpecificMethod

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
public Method getMostSpecificMethod() {
	if (this.mostSpecificMethod != null) {
		return this.mostSpecificMethod;
	}
	else if (AopUtils.isAopProxy(this.bean)) {
		Class<?> target = AopProxyUtils.ultimateTargetClass(this.bean);
		return AopUtils.getMostSpecificMethod(getMethod(), target);
	}
	else {
		return getMethod();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:MethodJmsListenerEndpoint.java

示例10: getTargetClass

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
private Class<?> getTargetClass(Object target) {
    Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
    if (targetClass == null && target != null) {
        targetClass = target.getClass();
    }
    return targetClass;
}
 
开发者ID:blackshadowwalker,项目名称:spring-distributelock,代码行数:8,代码来源:LockAspectSupport.java

示例11: getMethodAnnotation

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private <T extends Annotation> MethodAnnotation<T> getMethodAnnotation(MethodInvocation invocation,
        Class<T> annotationClass) {
    Method method = invocation.getMethod();
    T annotation = method.getAnnotation(annotationClass);
    //Try to read the class level annotation if the interface is not found
    if (annotation != null) {
        return new MethodAnnotation(method, annotation);
    }
    Class<?> targetClass = AopProxyUtils.ultimateTargetClass(
            ((ReflectiveMethodInvocation) invocation).getProxy());
    Method specificMethod = AopUtils.getMostSpecificMethod(method, targetClass);
    annotation = specificMethod.getAnnotation(annotationClass);
    return new MethodAnnotation(specificMethod, annotation);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:16,代码来源:AsyncAdvice.java

示例12: synchronizeInvocation

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
@Around("synchronizePointcut()")
public Object synchronizeInvocation(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
    Method method = methodSignature.getMethod();
    Object target = proceedingJoinPoint.getTarget();
    Object[] args = proceedingJoinPoint.getArgs();
    Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
    Synchronized annotation = getAnnotation(targetClass, method);
    Validate.notNull(annotation, "Could not find @Synchronized annotation!");

    Lock lock = getLock(targetClass, method, args, annotation);
    if (lock == null) {
        logger.debug("No lock obtained for call [{}] on targetClass [{}] - proceeding without synchronization on " +
                "thread {}", new Object[]{method.getName(), targetClass.getName(), Thread.currentThread().getId()});
        return proceedingJoinPoint.proceed();
    } else {
        try {
            logger.debug("Lock obtained for call [{}] on targetClass [{}] - proceeding with synchronization on thread {}",
                    new Object[]{method.getName(), targetClass.getName(), Thread.currentThread().getId()});
            lock.lock();
            return proceedingJoinPoint.proceed();
        } finally {
            lock.unlock();
            lockService.returnLock(lock);
        }
    }
}
 
开发者ID:apache,项目名称:rave,代码行数:28,代码来源:SynchronizingAspect.java

示例13: testRootVars

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
public void testRootVars(CacheableService<?> service) {
	Object key = new Object();
	Object r1 = service.rootVars(key);
	assertSame(r1, service.rootVars(key));
	Cache cache = cm.getCache("default");
	// assert the method name is used
	String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service;
	assertNotNull(cache.get(expectedKey));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AbstractAnnotationTests.java

示例14: testFooService

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
@Test
public void testFooService() {

  assertNotEquals(fooService.getClass(), FooServiceImpl.class);

  assertTrue(AopUtils.isAopProxy(fooService));
  assertTrue(AopUtils.isCglibProxy(fooService));

  assertEquals(AopProxyUtils.ultimateTargetClass(fooService), FooServiceImpl.class);

  assertEquals(AopTestUtils.getTargetObject(fooService).getClass(), FooServiceImpl.class);
  assertEquals(AopTestUtils.getUltimateTargetObject(fooService).getClass(), FooServiceImpl.class);

  assertEquals(fooService.incrementAndGet(), 0);
  assertEquals(fooService.incrementAndGet(), 0);

}
 
开发者ID:chanjarster,项目名称:spring-test-examples,代码行数:18,代码来源:SpringAop_1_Test.java

示例15: testFooService

import org.springframework.aop.framework.AopProxyUtils; //导入依赖的package包/类
@Test
public void testFooService() {

  assertNotEquals(fooService.getClass(), FooServiceImpl.class);

  assertTrue(AopUtils.isAopProxy(fooService));
  assertTrue(AopUtils.isCglibProxy(fooService));

  assertEquals(AopProxyUtils.ultimateTargetClass(fooService), FooServiceImpl.class);

  assertEquals(AopTestUtils.getTargetObject(fooService).getClass(), FooServiceImpl.class);
  assertEquals(AopTestUtils.getUltimateTargetObject(fooService).getClass(), FooServiceImpl.class);

  assertEquals(fooService.incrementAndGet(), 0);
  assertEquals(fooService.incrementAndGet(), 0);

  verify(fooAspect, times(2)).changeIncrementAndGet(any());

}
 
开发者ID:chanjarster,项目名称:spring-test-examples,代码行数:20,代码来源:SpringBootAopTest.java


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