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()); } } }
private MethodIdentifier getMethodIdentifier(Type[] args, MethodInfo methodInfo){ if (args.length == 0) { return MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name()); } else { return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), InvocationContext.class.getName()); } } }
/** * 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()); } }
private MethodIdentifier getMethodIdentifier(final AnnotationTarget target) { final MethodInfo methodInfo = MethodInfo.class.cast(target); final String[] args = new String[methodInfo.args().length]; for (int i = 0; i < methodInfo.args().length; i++) { args[i] = methodInfo.args()[i].name().toString(); } return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), args); }
final MethodIdentifier ejbRemoveIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbRemove"); final MethodIdentifier ejbActivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbActivate"); final MethodIdentifier ejbPassivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbPassivate");
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
final List<Method> viewMethods = viewConfiguration.getProxyFactory().getCachedMethods(); for (final Method method : viewMethods) { final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(method.getReturnType(), method.getName(), method.getParameterTypes()); final List<InterceptorFactory> aroundInvokesApplicableForMethod = new ArrayList<InterceptorFactory>(); final List<InterceptorFactory> aroundTimeoutsApplicableForMethod = new ArrayList<InterceptorFactory>();
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) { if (!(target instanceof MethodInfo)) { throw EjbLogger.ROOT_LOGGER.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString()); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPostConstruct(methodIdentifier); eeModuleDescription.addInterceptorMethodOverride(className, builder.build()); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPreDestroy(methodIdentifier); eeModuleDescription.addInterceptorMethodOverride(className, builder.build());
final MethodIdentifier identifier = MethodIdentifier.getIdentifier(method.getReturnType(), method.getName(), method.getParameterTypes());
methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name()); } else { methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class);
configuration.addComponentInterceptor(method, new ImmediateInterceptorFactory(new ManagedReferenceMethodInterceptor(BasicComponentInstance.INSTANCE_KEY, method)), InterceptorOrder.Component.TERMINAL_INTERCEPTOR); final MethodIdentifier identifier = MethodIdentifier.getIdentifier(method.getReturnType(), method.getName(), method.getParameterTypes());
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 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 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 InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); final String methodName = prePassivate.getMethodName(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPrePassivate(methodIdentifier); if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); final String methodName = postActivate.getMethodName(); final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName); builder.setPostActivate(methodIdentifier); if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) {
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 InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = aroundTimeout.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class); builder.setAroundTimeout(methodIdentifier); if (aroundTimeout.getClassName() == null || aroundTimeout.getClassName().isEmpty()) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = postConstruct.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class); builder.setPostConstruct(methodIdentifier); if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = preDestroy.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class); builder.setPreDestroy(methodIdentifier); if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); String methodName = prePassivate.getMethodName(); MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class); builder.setPrePassivate(methodIdentifier); if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
private MethodIdentifier getMethodIdentifier(Type[] args, MethodInfo methodInfo){ if (args.length == 0) { return MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name()); } else { return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), InvocationContext.class.getName()); } } }
private MethodIdentifier getMethodIdentifier(Type[] args, MethodInfo methodInfo){ if (args.length == 0) { return MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name()); } else { return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), InvocationContext.class.getName()); } } }
private MethodIdentifier getMethodIdentifier(final AnnotationTarget target) { final MethodInfo methodInfo = MethodInfo.class.cast(target); final String[] args = new String[methodInfo.args().length]; for (int i = 0; i < methodInfo.args().length; i++) { args[i] = methodInfo.args()[i].name().toString(); } return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), args); }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw MESSAGES.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) { if (!(target instanceof MethodInfo)) { throw MESSAGES.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString()); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }