Refine search
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { //we need the component method to get the correct declaring class final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method); if (componentMethod != null) { if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) { addAsyncInterceptor(configuration, method, isSecurityDomainKnown); configuration.addAsyncMethod(method); } else { MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method); if (componentDescription.getAsynchronousMethods().contains(id)) { addAsyncInterceptor(configuration, method, isSecurityDomainKnown); configuration.addAsyncMethod(method); } } } } } });
protected boolean isNotOverriden(final Class<?> clazz, final Method method, final Class<?> actualClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException { return Modifier.isPrivate(method.getModifiers()) || ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, actualClass, method).getDeclaringClass() == clazz; } }
public Method getMethod(final DeploymentReflectionIndex reflectionIndex, final Class<?> clazz) throws DeploymentUnitProcessingException { final ClassReflectionIndex classIndex = reflectionIndex.getClassIndex(clazz); Collection<Method> methods = null; final String paramType = getDeclaredValueClassName(); final String name = getName(); final String className = getClassName(); if (paramType != null) { // find the methods with the specific name and the param types methods = ClassReflectionIndexUtil.findMethods(reflectionIndex, classIndex, name, paramType); } // either paramType is not set, or we may need to find autoboxing methods // e.g. setMyBoolean(boolean) for a Boolean if (methods == null || methods.isEmpty()) { // find all the methods with the specific name and which accept just 1 parameter. methods = ClassReflectionIndexUtil.findAllMethods(reflectionIndex, classIndex, name, 1); } Iterator<Method> iterator = methods.iterator(); if (!iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.methodNotFound(name, paramType, className); } Method method = iterator.next(); if (iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.multipleMethodsFound(name, paramType, className); } return method; } }
private void setProperty(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> dataSourceClass, final Map<String, String> properties, final String name, final Object value) { // Ignore defaulted values if (value == null || "".equals(value)) return; if (value instanceof Integer && ((Integer) value).intValue() == -1) return; StringBuilder builder = new StringBuilder("set").append(name); builder.setCharAt(3, Character.toUpperCase(name.charAt(0))); final String methodName = builder.toString(); final Class<?> paramType = value.getClass(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType); Method setterMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } else if (paramType == Integer.class) { //if this is an Integer also look for int setters (WFLY-1364) methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, int.class); setterMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } } else if (paramType == Boolean.class) { methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, boolean.class); setterMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } } }
protected boolean createPermissions(final EjbJaccConfig ejbJaccConfig, final EJBComponentDescription description, final EJBViewConfiguration ejbViewConfiguration, final Method viewMethod, final DeploymentReflectionIndex index, final ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(viewMethod); EJBMethodSecurityAttribute ejbMethodSecurityMetaData = permissions.getViewAttribute(ejbViewConfiguration.getMethodIntf(), viewMethod); final Method classMethod = ClassReflectionIndexUtil.findMethod(index, ejbViewConfiguration.getComponentConfiguration().getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) { if (classMethod != null) { methodIdentifier = MethodIdentifier.getIdentifierForMethod(classMethod); final EJBMethodPermission permission = new EJBMethodPermission(description.getEJBName(), methodIdentifier.getName(), interfaceType.name(), methodIdentifier.getParameterTypes());
private boolean handlePermissions(String contextID, ComponentConfiguration componentConfiguration, ViewConfiguration viewConfiguration, DeploymentReflectionIndex deploymentReflectionIndex, String viewClassName, EJBViewDescription ejbViewDescription, Method viewMethod, ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions, boolean annotations) { EJBMethodSecurityAttribute ejbMethodSecurityMetaData = permissions.getViewAttribute(ejbViewDescription.getMethodIntf(), viewMethod.getName(), MethodIdentifier.getIdentifierForMethod(viewMethod).getParameterTypes()); final List<EJBMethodSecurityAttribute> allAttributes = new ArrayList<EJBMethodSecurityAttribute>(); allAttributes.addAll(permissions.getAllAttributes(ejbViewDescription.getMethodIntf(), viewMethod.getDeclaringClass().getName(), viewMethod.getName(), MethodIdentifier.getIdentifierForMethod(viewMethod).getParameterTypes())); allAttributes.addAll(permissions.getAllAttributes(MethodIntf.BEAN, viewMethod.getDeclaringClass().getName(), viewMethod.getName(), MethodIdentifier.getIdentifierForMethod(viewMethod).getParameterTypes())); final Method classMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentConfiguration.getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) {
/** * Finds and returns a method corresponding to the passed <code>method</code>, which may be declared in the super class * of the passed <code>classReflectionIndex</code>. * <p/> * <p/> * Throws {@link org.jboss.as.server.deployment.DeploymentUnitProcessingException} if no such method is found. * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException * If no such method is found */ public static Method findRequiredMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) throws DeploymentUnitProcessingException { Assert.checkNotNullParam("method", method); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
final Method classMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentConfiguration.getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = aroundInvoke.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class); builder.setAroundInvoke(methodIdentifier); if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = postConstruct.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPostConstruct(methodIdentifier); if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); final String methodName = preDestroy.getMethodName(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPreDestroy(methodIdentifier); if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPrePassivate(methodIdentifier); if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
/** * Finds and returns methods corresponding to the passed method <code>name</code> and method <code>paramTypes</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @param paramTypes The param types accepted by the method * @return */ public static Collection<Method> findMethods(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName, final String... paramTypes) { final Collection<Method> methods = classReflectionIndex.getMethods(methodName, paramTypes); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex<?> superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findMethods(deploymentReflectionIndex, superClassIndex, methodName, paramTypes); } } return methods; }
/** * Finds and returns all methods corresponding to the passed method <code>name</code> and method <code>paramCount</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @param paramCount The number of params accepted by the method * @return */ public static Collection<Method> findAllMethods(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName, int paramCount) { Collection<Method> methods = classReflectionIndex.getAllMethods(methodName, paramCount); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex<?> superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findAllMethods(deploymentReflectionIndex, superClassIndex, methodName, paramCount); } } return methods; }
/** * Finds and returns all methods corresponding to the passed method <code>name</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @return */ public static Collection<Method> findAllMethodsByName(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName) { Collection<Method> methods = classReflectionIndex.getAllMethods(methodName); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex<?> superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findAllMethodsByName(deploymentReflectionIndex, superClassIndex, methodName); } } return methods; } }
private void clearUnknownProperties(final DeploymentReflectionIndex reflectionIndex, final Class<?> dataSourceClass, final Map<String, String> props) { final Iterator<Map.Entry<String, String>> it = props.entrySet().iterator(); while (it.hasNext()) { final Map.Entry<String, String> entry = it.next(); String value = entry.getKey(); if (value == null || "".equals(value)) { it.remove(); } else { StringBuilder builder = new StringBuilder("set").append(entry.getKey()); builder.setCharAt(3, Character.toUpperCase(entry.getKey().charAt(0))); final String methodName = builder.toString(); final Class<?> paramType = value.getClass(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType); final Method setterMethod = ClassReflectionIndexUtil.findMethod(reflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod == null) { it.remove(); ConnectorLogger.DS_DEPLOYER_LOGGER.methodNotFoundOnDataSource(methodName, dataSourceClass); } } } }
protected boolean createPermissions(final EjbJaccConfig ejbJaccConfig, final EJBComponentDescription description, final EJBViewConfiguration ejbViewConfiguration, final Method viewMethod, final DeploymentReflectionIndex index, final ApplicableMethodInformation<EJBMethodSecurityAttribute> permissions) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(viewMethod); EJBMethodSecurityAttribute ejbMethodSecurityMetaData = permissions.getViewAttribute(ejbViewConfiguration.getMethodIntf(), viewMethod.getName(), methodIdentifier.getParameterTypes()); ejbMethodSecurityMetaData = permissions.getViewAttribute(MethodIntf.BEAN, viewMethod.getName(), methodIdentifier.getParameterTypes()); final Method classMethod = ClassReflectionIndexUtil.findMethod(index, ejbViewConfiguration.getComponentConfiguration().getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) { if (classMethod != null) {
/** * Finds and returns a method corresponding to the passed <code>method</code>, which may be declared in the super class * of the passed <code>classReflectionIndex</code>. * <p/> * <p/> * Throws {@link org.jboss.as.server.deployment.DeploymentUnitProcessingException} if no such method is found. * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException * If no such method is found */ public static Method findRequiredMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) throws DeploymentUnitProcessingException { if (method == null) { throw ServerMessages.MESSAGES.nullMethod(); } final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
/** * Finds and returns a method corresponding to the passed <code>methodIdentifier</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Throws {@link org.jboss.as.server.deployment.DeploymentUnitProcessingException} if no such method is found. * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class to search * @param methodIdentifier The method identifier of the method being searched for * @return * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException * If no such method is found */ public static Method findRequiredMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final MethodIdentifier methodIdentifier) throws DeploymentUnitProcessingException { Method method = findMethod(deploymentReflectionIndex, clazz, methodIdentifier); if (method == null) { throw ServerLogger.ROOT_LOGGER.noMethodFound(methodIdentifier, clazz); } return method; }
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = aroundInvoke.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class); builder.setAroundInvoke(methodIdentifier); if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = postConstruct.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPostConstruct(methodIdentifier); if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); final String methodName = preDestroy.getMethodName(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPreDestroy(methodIdentifier); if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPrePassivate(methodIdentifier); if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
/** * Finds and returns methods corresponding to the passed method <code>name</code> and method <code>paramTypes</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @param paramTypes The param types accepted by the method * @return */ public static Collection<Method> findMethods(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName, final String... paramTypes) { final Collection<Method> methods = classReflectionIndex.getMethods(methodName, paramTypes); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex<?> superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findMethods(deploymentReflectionIndex, superClassIndex, methodName, paramTypes); } } return methods; }
/** * Finds and returns all methods corresponding to the passed method <code>name</code> and method <code>paramCount</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @param paramCount The number of params accepted by the method * @return */ public static Collection<Method> findAllMethods(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName, int paramCount) { Collection<Method> methods = classReflectionIndex.getAllMethods(methodName, paramCount); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findAllMethods(deploymentReflectionIndex, superClassIndex, methodName, paramCount); } } return methods; }
/** * Finds and returns all methods corresponding to the passed method <code>name</code>. * The passed <code>classReflectionIndex</code> will be used to traverse the class hierarchy while finding the method. * <p/> * Returns empty collection if no such method is found * * @param deploymentReflectionIndex The deployment reflection index * @param classReflectionIndex The class reflection index which will be used to traverse the class hierarchy to find the method * @param methodName The name of the method * @return */ public static Collection<Method> findAllMethodsByName(final DeploymentReflectionIndex deploymentReflectionIndex, final ClassReflectionIndex classReflectionIndex, final String methodName) { Collection<Method> methods = classReflectionIndex.getAllMethods(methodName); if (!methods.isEmpty()) { return methods; } // find on super class Class<?> superClass = classReflectionIndex.getIndexedClass().getSuperclass(); if (superClass != null) { ClassReflectionIndex superClassIndex = deploymentReflectionIndex.getClassIndex(superClass); if (superClassIndex != null) { return findAllMethodsByName(deploymentReflectionIndex, superClassIndex, methodName); } } return methods; } }