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); } } } }
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()); } } }
@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); } } } } } });
/** * Handles setting up the ejbCreate and ejbRemove methods for stateless session beans and MDB's * * @param component The component * @param module The module * @param reflectionIndex The reflection index */ private void handleStatelessSessionBean(final EJBComponentDescription component, final Module module, final DeploymentReflectionIndex reflectionIndex) throws ClassNotFoundException, DeploymentUnitProcessingException { final Class<?> componentClass = ClassLoadingUtils.loadClass(component.getComponentClassName(), module); final MethodIdentifier ejbCreateId = MethodIdentifier.getIdentifier(void.class, "ejbCreate"); final Method ejbCreate = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentClass, ejbCreateId); if (ejbCreate != null) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); builder.setPostConstruct(ejbCreateId); component.addInterceptorMethodOverride(ejbCreate.getDeclaringClass().getName(), builder.build()); } final MethodIdentifier ejbRemoveId = MethodIdentifier.getIdentifier(void.class, "ejbRemove"); final Method ejbRemove = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentClass, ejbRemoveId); if (ejbRemove != null) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); builder.setPreDestroy(ejbRemoveId); component.addInterceptorMethodOverride(ejbRemove.getDeclaringClass().getName(), builder.build()); } }
final Method componentMethod = ClassReflectionIndexUtil.findMethod(index, componentConfiguration.getComponentClass(), MethodIdentifier.getIdentifierForMethod(method));
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Create method indexes final DeploymentReflectionIndex reflectionIndex = context.getDeploymentUnit().getAttachment(REFLECTION_INDEX); final List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (final Method method : methods) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); Method componentMethod = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentConfiguration.getComponentClass(), methodIdentifier); if (componentMethod == null && method.getDeclaringClass().isInterface() && (method.getModifiers() & (ABSTRACT | PUBLIC | STATIC)) == PUBLIC) { // no component method and the interface method is defaulted, so we really do want to invoke on the interface method componentMethod = method; } if (componentMethod != null) { if ((BRIDGE & componentMethod.getModifiers()) != 0) { Method other = findRealMethodForBridgeMethod(componentMethod, componentConfiguration, reflectionIndex, methodIdentifier); //try and find the non-bridge method to delegate to if(other != null) { componentMethod = other; } } configuration.addViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor(method, CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); configuration.getViewToComponentMethodMap().put(method, componentMethod); } } configuration.addClientPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }
final Method classMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentConfiguration.getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) {
final Method classMethod = ClassReflectionIndexUtil.findMethod(index, ejbViewConfiguration.getComponentConfiguration().getComponentClass(), viewMethod); if (ejbMethodSecurityMetaData == null) { if (classMethod != null) {
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) return; if (value instanceof String && "".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(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType); final Method setterMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, dataSourceClass, methodIdentifier); if (setterMethod != null) { properties.put(name, value.toString()); } }
/** * 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 ServerMessages.MESSAGES.noMethodFound(methodIdentifier, clazz); } return method; }
/** * 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; }
/** * 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 ServerMessages.MESSAGES.noMethodFound(methodIdentifier, clazz); } return method; }
/** * 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; }
private void clearUnkownProperties(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); } } } }
/** * 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/> * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return */ public static Method findMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) { Assert.checkNotNullParam("method", method); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
/** * 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/> * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return */ public static Method findMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) { Assert.checkNotNullParam("method", method); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
/** * 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/> * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return */ public static Method findMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) { if (method == null) { throw ServerMessages.MESSAGES.nullMethod(); } MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
/** * 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/> * * @param deploymentReflectionIndex The deployment reflection index * @param clazz The class * @param method The method being searched for * @return */ public static Method findMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> clazz, final Method method) { if (method == null) { throw ServerMessages.MESSAGES.nullMethod(); } MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); return findMethod(deploymentReflectionIndex, clazz, methodIdentifier); }
@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); configuration.addAsyncMethod(method); } else { MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method); if (componentDescription.getAsynchronousMethods().contains(id)) { addAsyncInterceptor(configuration, method); configuration.addAsyncMethod(method); } } } } } });
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Create method indexes final DeploymentReflectionIndex reflectionIndex = context.getDeploymentUnit().getAttachment(REFLECTION_INDEX); final List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (final Method method : methods) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); Method componentMethod = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentConfiguration.getComponentClass(), methodIdentifier); if (componentMethod != null) { if ((BRIDGE & componentMethod.getModifiers()) != 0) { Method other = findRealMethodForBridgeMethod(componentMethod, componentConfiguration, reflectionIndex, methodIdentifier); //try and find the non-bridge method to delegate to if(other != null) { componentMethod = other; } } configuration.addViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor(method, CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } } configuration.addClientPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }