本文整理汇总了Java中org.springframework.core.BridgeMethodResolver.findBridgedMethod方法的典型用法代码示例。如果您正苦于以下问题:Java BridgeMethodResolver.findBridgedMethod方法的具体用法?Java BridgeMethodResolver.findBridgedMethod怎么用?Java BridgeMethodResolver.findBridgedMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.BridgeMethodResolver
的用法示例。
在下文中一共展示了BridgeMethodResolver.findBridgedMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpecificmethod
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的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;
}
示例2: HandlerMethod
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
/**
* Create an instance from a bean name, a method, and a {@code BeanFactory}.
* The method {@link #createWithResolvedBean()} may be used later to
* re-create the {@code HandlerMethod} with an initialized the bean.
*/
public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) {
Assert.hasText(beanName, "Bean name is required");
Assert.notNull(beanFactory, "BeanFactory is required");
Assert.notNull(method, "Method is required");
Assert.isTrue(beanFactory.containsBean(beanName),
"BeanFactory [" + beanFactory + "] does not contain bean [" + beanName + "]");
this.bean = beanName;
this.beanFactory = beanFactory;
this.method = method;
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
this.parameters = initMethodParameters();
}
示例3: findMethodsByAnnotation
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
/**
* Finds methods for the given annotation
*
* It first finds all public member methods of the class or interface represented by objClass,
* including those inherited from superclasses and superinterfaces.
*
* It then loops through these methods searching for a single Annotation of annotationType,
* traversing its super methods if no annotation can be found on the given method itself.
*
* @param objClass - the class
* @param annotationType - the annotation to find
* @return - the List of Method or an empty List
*/
@SuppressWarnings("rawtypes")
public static List<Method> findMethodsByAnnotation(Class objClass, Class<? extends Annotation> annotationType)
{
List<Method> annotatedMethods = new ArrayList<Method>();
Method[] methods = objClass.getMethods();
for (Method method : methods)
{
Annotation annot = AnnotationUtils.findAnnotation(method, annotationType);
if (annot != null) {
//Just to be sure, lets make sure its not a Bridged (Generic) Method
Method resolvedMethod = BridgeMethodResolver.findBridgedMethod(method);
annotatedMethods.add(resolvedMethod);
}
}
return annotatedMethods;
}
示例4: getSpecificmethod
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的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;
}
示例5: computeCacheOperation
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
private JCacheOperation<?> computeCacheOperation(Method method, Class<?> targetClass) {
// Don't allow no-public methods as required.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
// 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.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// If we are dealing with method with generic parameters, find the original method.
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
// First try is the method in the target class.
JCacheOperation<?> operation = findCacheOperation(specificMethod, targetClass);
if (operation != null) {
return operation;
}
if (specificMethod != method) {
// Fall back is to look at the original method.
operation = findCacheOperation(method, targetClass);
if (operation != null) {
return operation;
}
}
return null;
}
示例6: invoke
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
public Object invoke(final MethodInvocation invocation) throws Throwable {
Class<?> targetClass = invocation.getThis() != null ? invocation.getThis().getClass() : null;
Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
// If we are dealing with method with generic parameters, find the original
// method.
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
AlfrescoTransaction alfrescoTransaction = parseAnnotation(specificMethod);
if (alfrescoTransaction != null) {
RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
return invocation.proceed();
}
};
boolean readonly = alfrescoTransaction.readOnly();
Propagation propagation = alfrescoTransaction.propagation();
boolean requiresNew = Propagation.REQUIRES_NEW.equals(propagation);
return serviceRegistry.getRetryingTransactionHelper().doInTransaction(exampleWork, readonly, requiresNew);
} else {
return invocation.proceed();
}
}
示例7: computeSecurityAttribute
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
private SecurityAttribute computeSecurityAttribute(Method method, Class<?> targetClass)
{
// 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.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// If we are dealing with method with generic parameters, find the
// original method.
if( JdkVersion.isAtLeastJava15() )
{
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
}
// First try is the method in the target class.
SecurityAttribute txAtt = findSecurityAttribute(specificMethod, targetClass);
if( txAtt != null )
{
return txAtt;
}
if( !specificMethod.equals(method) )
{
// Fallback is to look at the original method.
txAtt = findSecurityAttribute(method, targetClass);
if( txAtt != null )
{
return txAtt;
}
}
return null;
}
示例8: initBinder
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
protected void initBinder(Object handler, String attrName, WebDataBinder binder, NativeWebRequest webRequest)
throws Exception {
if (this.bindingInitializer != null) {
this.bindingInitializer.initBinder(binder, webRequest);
}
if (handler != null) {
Set<Method> initBinderMethods = this.methodResolver.getInitBinderMethods();
if (!initBinderMethods.isEmpty()) {
boolean debug = logger.isDebugEnabled();
for (Method initBinderMethod : initBinderMethods) {
Method methodToInvoke = BridgeMethodResolver.findBridgedMethod(initBinderMethod);
String[] targetNames = AnnotationUtils.findAnnotation(initBinderMethod, InitBinder.class).value();
if (targetNames.length == 0 || Arrays.asList(targetNames).contains(attrName)) {
Object[] initBinderArgs =
resolveInitBinderArguments(handler, methodToInvoke, binder, webRequest);
if (debug) {
logger.debug("Invoking init-binder method: " + methodToInvoke);
}
ReflectionUtils.makeAccessible(methodToInvoke);
Object returnValue = methodToInvoke.invoke(handler, initBinderArgs);
if (returnValue != null) {
throw new IllegalStateException(
"InitBinder methods must not have a return value: " + methodToInvoke);
}
}
}
}
}
}
示例9: computeTransactionAttribute
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
/**
* Same signature as {@link #getTransactionAttribute}, but doesn't cache the result.
* {@link #getTransactionAttribute} is effectively a caching decorator for this method.
* @see #getTransactionAttribute
*/
private TransactionAttribute computeTransactionAttribute(Method method, Class<?> targetClass) {
// Don't allow no-public methods as required.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
// Ignore CGLIB subclasses - introspect the actual user class.
Class<?> userClass = ClassUtils.getUserClass(targetClass);
// 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.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, userClass);
// If we are dealing with method with generic parameters, find the original method.
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
// First try is the method in the target class.
TransactionAttribute txAtt = findTransactionAttribute(specificMethod);
if (txAtt != null) {
return txAtt;
}
// Second try is the transaction attribute on the target class.
txAtt = findTransactionAttribute(specificMethod.getDeclaringClass());
if (txAtt != null) {
return txAtt;
}
if (specificMethod != method) {
// Fallback is to look at the original method.
txAtt = findTransactionAttribute(method);
if (txAtt != null) {
return txAtt;
}
// Last fallback is the class of the original method.
return findTransactionAttribute(method.getDeclaringClass());
}
return null;
}
示例10: GenericTypeAwarePropertyDescriptor
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName,
Method readMethod, Method writeMethod, Class<?> propertyEditorClass)
throws IntrospectionException {
super(propertyName, null, null);
this.beanClass = beanClass;
this.propertyEditorClass = propertyEditorClass;
Method readMethodToUse = BridgeMethodResolver.findBridgedMethod(readMethod);
Method writeMethodToUse = BridgeMethodResolver.findBridgedMethod(writeMethod);
if (writeMethodToUse == null && readMethodToUse != null) {
// Fallback: Original JavaBeans introspection might not have found matching setter
// method due to lack of bridge method resolution, in case of the getter using a
// covariant return type whereas the setter is defined for the concrete property type.
Method candidate = ClassUtils.getMethodIfAvailable(
this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
if (candidate != null && candidate.getParameterTypes().length == 1) {
writeMethodToUse = candidate;
}
}
this.readMethod = readMethodToUse;
this.writeMethod = writeMethodToUse;
if (this.writeMethod != null && this.readMethod == null) {
// Write method not matched against read method: potentially ambiguous through
// several overloaded variants, in which case an arbitrary winner has been chosen
// by the JDK's JavaBeans Introspector...
Set<Method> ambiguousCandidates = new HashSet<Method>();
for (Method method : beanClass.getMethods()) {
if (method.getName().equals(writeMethodToUse.getName()) &&
!method.equals(writeMethodToUse) && !method.isBridge()) {
ambiguousCandidates.add(method);
}
}
if (!ambiguousCandidates.isEmpty()) {
this.ambiguousWriteMethods = ambiguousCandidates;
}
}
}
示例11: computeCacheOperations
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
private Collection<CacheOperation> computeCacheOperations(Method method, Class<?> targetClass) {
// Don't allow no-public methods as required.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
// 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.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// If we are dealing with method with generic parameters, find the original method.
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
// First try is the method in the target class.
Collection<CacheOperation> opDef = findCacheOperations(specificMethod);
if (opDef != null) {
return opDef;
}
// Second try is the caching operation on the target class.
opDef = findCacheOperations(specificMethod.getDeclaringClass());
if (opDef != null) {
return opDef;
}
if (specificMethod != method) {
// Fall back is to look at the original method.
opDef = findCacheOperations(method);
if (opDef != null) {
return opDef;
}
// Last fall back is the class of the original method.
return findCacheOperations(method.getDeclaringClass());
}
return null;
}
示例12: determineType
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
/**
* Determine the expected type as the returned type of the method.
* If the return type is a List it will return the generic element type instead of a List.
* @param resource - resource with methods
* @param method Method
* @return Class - type of class it needs.
*/
@SuppressWarnings("rawtypes")
protected static Class determineType(Class resource, Method method)
{
Method resolvedMethod = BridgeMethodResolver.findBridgedMethod(method);
/*
* The api is consistent that the object passed in must match the object passed out
* however, operations are different, if the param is supplied it doesn't have to match
* the return type.
* So we need special logic for operations
*/
Annotation annot = AnnotationUtils.findAnnotation(resolvedMethod, Operation.class);
if (annot != null)
{
return determineOperationType(resource, method);
}
else
{
Class returnType = GenericTypeResolver.resolveReturnType(resolvedMethod, resource);
if (List.class.isAssignableFrom(returnType))
{
return GenericCollectionTypeResolver.getCollectionReturnType(method);
}
return returnType;
}
}
示例13: HandlerMethod
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
/**
* Create an instance from a bean instance and a method.
*/
public HandlerMethod(Object bean, Method method) {
Assert.notNull(bean, "Bean is required");
Assert.notNull(method, "Method is required");
this.bean = bean;
this.beanFactory = null;
this.beanType = ClassUtils.getUserClass(bean);
this.method = method;
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
this.parameters = initMethodParameters();
}
示例14: UiEventListenerMethodAdapter
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
public UiEventListenerMethodAdapter(Object instance, Class<?> targetClass, Method method, Events events) {
this.instanceRef = new WeakReference<>(instance);
this.method = method;
this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
this.events = events;
Method targetMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
EventListener ann = AnnotatedElementUtils.findMergedAnnotation(targetMethod, EventListener.class);
this.declaredEventTypes = resolveDeclaredEventTypes(method, ann);
if (!ann.condition().isEmpty()) {
throw new UnsupportedOperationException("@EventListener condition is not supported for UiEvents");
}
this.order = resolveOrder(method);
}
示例15: computeCacheOperations
import org.springframework.core.BridgeMethodResolver; //导入方法依赖的package包/类
private Collection<CacheOperation> computeCacheOperations(Method method, Class<?> targetClass) {
// Don't allow no-public methods as required.
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
return null;
}
// 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.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// If we are dealing with method with generic parameters, find the original method.
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
// First try is the method in the target class.
Collection<CacheOperation> opDef = findCacheOperations(specificMethod);
if (opDef != null) {
return opDef;
}
// Second try is the caching operation on the target class.
opDef = findCacheOperations(specificMethod.getDeclaringClass());
if (opDef != null && ClassUtils.isUserLevelMethod(method)) {
return opDef;
}
if (specificMethod != method) {
// Fallback is to look at the original method.
opDef = findCacheOperations(method);
if (opDef != null) {
return opDef;
}
// Last fallback is the class of the original method.
opDef = findCacheOperations(method.getDeclaringClass());
if (opDef != null && ClassUtils.isUserLevelMethod(method)) {
return opDef;
}
}
return null;
}