Refine search
@Override public void addInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType) { // these interfaces we want to scan for method and our proxies will implement them for (Class<?> c : proxiedBeanType.getInterfaces()) { addInterface(c); } // now we need to go deeper in hierarchy and scan those interfaces for additional interfaces with default impls for (Type type : typeClosure) { Class<?> c = Reflections.getRawType(type); if (c.isInterface()) { addInterfaceToInspect(c); } } }
@Override protected void addMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { // Add all class methods for interception addMethodsFromClass(proxyClassType, staticConstructor); // Add special proxy methods addSpecialMethods(proxyClassType, staticConstructor); }
private void createDelegateToSuper(ClassMethod classMethod, MethodInformation method) { createDelegateToSuper(classMethod, method, classMethod.getClassFile().getSuperclass()); }
Class<?> cls = getBeanType(); while (cls != null) { Set<BridgeMethod> declaredBridgeMethods = new HashSet<BridgeMethod>(); for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(cls))) { && !bridgeMethodsContainsMethod(processedBridgeMethods, methodSignature, method.getGenericReturnType(), Modifier.isAbstract(method.getModifiers()))) { try { final MethodInformation methodInfo = new RuntimeMethodInformation(method); createDelegateMethod(proxyClassType, method, methodInfo); ClassMethod classMethod = proxyClassType.addMethod(method); addConstructedGuardToMethodBody(classMethod); createForwardingMethodBody(classMethod, methodInfo, staticConstructor); BeanLogger.LOG.addingMethodToProxy(method); } else { if (!hasAbstractPackagePrivateSuperClassWithImplementation(cls, bridgeMethod)) { declaredBridgeMethods.add(bridgeMethod); Set<Class<?>> allInterfaces = new HashSet<>(getAdditionalInterfaces()); if (interfacesToInspect != null) { allInterfaces.addAll(interfacesToInspect); if (enhancedMethodSignatures.contains(signature) && !bridgeMethodsContainsMethod(processedBridgeMethods, signature, null, Modifier.isAbstract(method.getModifiers()))) { try { MethodInformation methodInfo = new RuntimeMethodInformation(method); if (interceptedMethodSignatures.contains(signature) && Reflections.isDefault(method)) { createDelegateMethod(proxyClassType, method, methodInfo);
@SuppressWarnings("unchecked") private void createDelegateMethod(ClassFile proxyClassType, Method method, MethodInformation methodInformation) { int modifiers = (method.getModifiers() | AccessFlag.SYNTHETIC | AccessFlag.PRIVATE) & ~AccessFlag.PUBLIC & ~AccessFlag.PROTECTED; ClassMethod delegatingMethod = proxyClassType.addMethod(modifiers, method.getName() + SUPER_DELEGATE_SUFFIX, DescriptorUtils.makeDescriptor(method.getReturnType()), DescriptorUtils.parameterDescriptors(method.getParameterTypes())); delegatingMethod.addCheckedExceptions((Class<? extends Exception>[]) method.getExceptionTypes()); createDelegateToSuper(delegatingMethod, methodInformation); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
Class<?> cls = getBeanType(); while (cls != null) { Set<BridgeMethod> declaredBridgeMethods = new HashSet<BridgeMethod>(); for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(cls))) { && !bridgeMethodsContainsMethod(processedBridgeMethods, methodSignature, method.getGenericReturnType(), Modifier.isAbstract(method.getModifiers()))) { try { final MethodInformation methodInfo = new RuntimeMethodInformation(method); createDelegateMethod(proxyClassType, method, methodInfo); ClassMethod classMethod = proxyClassType.addMethod(method); addConstructedGuardToMethodBody(classMethod); createForwardingMethodBody(classMethod, methodInfo, staticConstructor); BeanLogger.LOG.addingMethodToProxy(method); } else { if (!hasAbstractPackagePrivateSuperClassWithImplementation(cls, bridgeMethod)) { declaredBridgeMethods.add(bridgeMethod); Set<Class<?>> allInterfaces = new HashSet<>(getAdditionalInterfaces()); if (interfacesToInspect != null) { allInterfaces.addAll(interfacesToInspect); if (enhancedMethodSignatures.contains(signature) && !bridgeMethodsContainsMethod(processedBridgeMethods, signature, null, Modifier.isAbstract(method.getModifiers()))) { try { MethodInformation methodInfo = new RuntimeMethodInformation(method); if (interceptedMethodSignatures.contains(signature) && Reflections.isDefault(method)) { createDelegateMethod(proxyClassType, method, methodInfo);
@SuppressWarnings("unchecked") private void createDelegateMethod(ClassFile proxyClassType, Method method, MethodInformation methodInformation) { int modifiers = (method.getModifiers() | AccessFlag.SYNTHETIC | AccessFlag.PRIVATE) & ~AccessFlag.PUBLIC & ~AccessFlag.PROTECTED; ClassMethod delegatingMethod = proxyClassType.addMethod(modifiers, method.getName() + SUPER_DELEGATE_SUFFIX, DescriptorUtils.makeDescriptor(method.getReturnType()), DescriptorUtils.parameterDescriptors(method.getParameterTypes())); delegatingMethod.addCheckedExceptions((Class<? extends Exception>[]) method.getExceptionTypes()); createDelegateToSuper(delegatingMethod, methodInformation); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
Class<?> cls = getBeanType(); while (cls != null) { Set<BridgeMethod> declaredBridgeMethods = new HashSet<BridgeMethod>(); for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(cls))) { && !bridgeMethodsContainsMethod(processedBridgeMethods, methodSignature, method.getGenericReturnType(), Modifier.isAbstract(method.getModifiers()))) { try { final MethodInformation methodInfo = new RuntimeMethodInformation(method); createDelegateMethod(proxyClassType, method, methodInfo); ClassMethod classMethod = proxyClassType.addMethod(method); addConstructedGuardToMethodBody(classMethod); createForwardingMethodBody(classMethod, methodInfo, staticConstructor); BeanLogger.LOG.addingMethodToProxy(method); } else { if (!hasAbstractPackagePrivateSuperClassWithImplementation(cls, bridgeMethod)) { declaredBridgeMethods.add(bridgeMethod); Set<Class<?>> allInterfaces = new HashSet<>(getAdditionalInterfaces()); if (interfacesToInspect != null) { allInterfaces.addAll(interfacesToInspect); if (enhancedMethodSignatures.contains(signature) && !bridgeMethodsContainsMethod(processedBridgeMethods, signature, null, Modifier.isAbstract(method.getModifiers()))) { try { MethodInformation methodInfo = new RuntimeMethodInformation(method); if (interceptedMethodSignatures.contains(signature) && Reflections.isDefault(method)) { createDelegateMethod(proxyClassType, method, methodInfo);
@SuppressWarnings("unchecked") private void createDelegateMethod(ClassFile proxyClassType, Method method, MethodInformation methodInformation) { int modifiers = (method.getModifiers() | AccessFlag.SYNTHETIC | AccessFlag.PRIVATE) & ~AccessFlag.PUBLIC & ~AccessFlag.PROTECTED; ClassMethod delegatingMethod = proxyClassType.addMethod(modifiers, method.getName() + SUPER_DELEGATE_SUFFIX, DescriptorUtils.makeDescriptor(method.getReturnType()), DescriptorUtils.parameterDescriptors(method.getParameterTypes())); delegatingMethod.addCheckedExceptions((Class<? extends Exception>[]) method.getExceptionTypes()); createDelegateToSuper(delegatingMethod, methodInformation); }
private void createDelegateToSuper(ClassMethod classMethod, MethodInformation method) { createDelegateToSuper(classMethod, method, classMethod.getClassFile().getSuperclass()); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { // TODO we may need to really discover types here types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
@Override protected void addMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { // Add all class methods for interception addMethodsFromClass(proxyClassType, staticConstructor); // Add special proxy methods addSpecialMethods(proxyClassType, staticConstructor); }
@Override public void addInterfacesFromTypeClosure(Set<? extends Type> typeClosure, Class<?> proxiedBeanType) { // these interfaces we want to scan for method and our proxies will implement them for (Class<?> c : proxiedBeanType.getInterfaces()) { addInterface(c); } // now we need to go deeper in hierarchy and scan those interfaces for additional interfaces with default impls for (Type type : typeClosure) { Class<?> c = Reflections.getRawType(type); if (c.isInterface()) { addInterfaceToInspect(c); } } }
Class<?> cls = getBeanType(); while (cls != null) { Set<BridgeMethod> declaredBridgeMethods = new HashSet<BridgeMethod>(); for (Method method : AccessController.doPrivileged(new GetDeclaredMethodsAction(cls))) { && !bridgeMethodsContainsMethod(processedBridgeMethods, methodSignature, method.getGenericReturnType(), Modifier.isAbstract(method.getModifiers()))) { try { final MethodInformation methodInfo = new RuntimeMethodInformation(method); createDelegateMethod(proxyClassType, method, methodInfo); ClassMethod classMethod = proxyClassType.addMethod(method); addConstructedGuardToMethodBody(classMethod); createForwardingMethodBody(classMethod, methodInfo, staticConstructor); BeanLogger.LOG.addingMethodToProxy(method); } else { if (!hasAbstractPackagePrivateSuperClassWithImplementation(cls, bridgeMethod)) { declaredBridgeMethods.add(bridgeMethod); Set<Class<?>> allInterfaces = new HashSet<>(getAdditionalInterfaces()); if (interfacesToInspect != null) { allInterfaces.addAll(interfacesToInspect); if (enhancedMethodSignatures.contains(signature) && !bridgeMethodsContainsMethod(processedBridgeMethods, signature, null, Modifier.isAbstract(method.getModifiers()))) { try { MethodInformation methodInfo = new RuntimeMethodInformation(method); if (interceptedMethodSignatures.contains(signature) && Reflections.isDefault(method)) { createDelegateMethod(proxyClassType, method, methodInfo);
@SuppressWarnings("unchecked") private void createDelegateMethod(ClassFile proxyClassType, Method method, MethodInformation methodInformation) { int modifiers = (method.getModifiers() | AccessFlag.SYNTHETIC | AccessFlag.PRIVATE) & ~AccessFlag.PUBLIC & ~AccessFlag.PROTECTED; ClassMethod delegatingMethod = proxyClassType.addMethod(modifiers, method.getName() + SUPER_DELEGATE_SUFFIX, DescriptorUtils.makeDescriptor(method.getReturnType()), DescriptorUtils.parameterDescriptors(method.getParameterTypes())); delegatingMethod.addCheckedExceptions((Class<? extends Exception>[]) method.getExceptionTypes()); createDelegateToSuper(delegatingMethod, methodInformation); }
private void createDelegateToSuper(ClassMethod classMethod, MethodInformation method) { createDelegateToSuper(classMethod, method, classMethod.getClassFile().getSuperclass()); }
protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean); Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>(); Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>(); for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) { enhancedMethodSignatures.add(MethodSignatureImpl.of(method)); if (models != null) { for (InterceptionModel model : models) { if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) { interceptedMethodSignatures.add(MethodSignatureImpl.of(method)); break; } } } } Set<Type> types = null; if (bean == null) { types = Collections.<Type>singleton(type.getJavaClass()); } else { types = bean.getTypes(); } return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass(); }
@Override protected void addMethods(ClassFile proxyClassType, ClassMethod staticConstructor) { // Add all class methods for interception addMethodsFromClass(proxyClassType, staticConstructor); // Add special proxy methods addSpecialMethods(proxyClassType, staticConstructor); }