public Constructor<T> lookup(ClassReflectionIndex index) { final Constructor ctor = index.getConstructor(parameterTypes); if (ctor == null) throw PojoLogger.ROOT_LOGGER.ctorNotFound(Arrays.toString(parameterTypes), beanClass.getName()); return ctor; } }, 0, 1);
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final ClassReflectionIndex classIndex = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX).getClassIndex(configuration.getComponentClass()); final Constructor<?> ctor = classIndex.getConstructor(new String[0]); boolean noInterface = false; for(ViewDescription view : description.getViews()) { if(view.getViewClassName().equals(description.getComponentClassName())) { noInterface = true; } } EjbValidationsUtil.getBusinessMethods(configuration.getComponentClass()); EjbValidationsUtil.verifyEjbClassAndDefaultConstructor(ctor, configuration.getComponentClass().getEnclosingClass(), noInterface, description.getComponentName(), description.getComponentClassName(), configuration.getComponentClass().getModifiers()); EjbValidationsUtil.verifyEjbPublicMethodAreNotFinalNorStatic(configuration.getComponentClass().getDeclaredMethods(),description.getComponentClassName()); for ( Class<?> interfaceClass : configuration.getComponentClass().getInterfaces()) EjbValidationsUtil.verifyEjbPublicMethodAreNotFinalNorStatic(interfaceClass.getDeclaredMethods(), interfaceClass.getCanonicalName()); } }
@Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { final InterceptorClassDescription interceptorConfig; if (classDescription != null) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName())); } // get the container-interceptor class' constructor final ClassReflectionIndex interceptorClassReflectionIndex = deploymentReflectionIndex.getClassIndex(interceptorClass); final Constructor<?> interceptorClassConstructor = interceptorClassReflectionIndex.getConstructor(EMPTY_CLASS_ARRAY); if (interceptorClassConstructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(interceptorClass); } final MethodIdentifier aroundInvokeMethodIdentifier = interceptorConfig.getAroundInvoke(); final InterceptorFactory aroundInvokeInterceptorFactory = createInterceptorFactory(clazz, aroundInvokeMethodIdentifier, interceptorClassConstructor); if (aroundInvokeInterceptorFactory != null) { this.aroundInvokeInterceptorFactories.add(aroundInvokeInterceptorFactory); } if (ejbComponentDescription.isTimerServiceRequired()) { final MethodIdentifier aroundTimeoutMethodIdentifier = interceptorConfig.getAroundTimeout(); final InterceptorFactory aroundTimeoutInterceptorFactory = createInterceptorFactory(clazz, aroundTimeoutMethodIdentifier, interceptorClassConstructor); if (aroundTimeoutInterceptorFactory != null) { this.aroundTimeoutInterceptorFactories.add(aroundTimeoutInterceptorFactory); } } }
final ClassReflectionIndex componentClassIndex = deploymentReflectionIndex.getClassIndex(configuration.getComponentClass()); final Constructor<?> constructor = componentClassIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(configuration.getComponentClass()); final Constructor<?> constructor = interceptorIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFoundOnComponent(interceptorClassName, configuration.getComponentClass());
private static Object newInstance(final JBossServiceConfig serviceConfig, final List<ClassReflectionIndex> mBeanClassHierarchy, final ClassLoader deploymentClassLoader) throws DeploymentUnitProcessingException { // set TCCL so that the MBean instantiation happens in the deployment's classloader final ClassLoader oldTCCL = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(deploymentClassLoader); try { final JBossServiceConstructorConfig constructorConfig = serviceConfig.getConstructorConfig(); final int paramCount = constructorConfig != null ? constructorConfig.getArguments().length : 0; final Class<?>[] types = new Class<?>[paramCount]; final Object[] params = new Object[paramCount]; if (constructorConfig != null) { final Argument[] arguments = constructorConfig.getArguments(); for (int i = 0; i < paramCount; i++) { final Argument argument = arguments[i]; types[i] = ReflectionUtils.getClass(argument.getType(), deploymentClassLoader); params[i] = newValue(ReflectionUtils.getClass(argument.getType(), deploymentClassLoader), argument.getValue()); } } final Constructor<?> constructor = mBeanClassHierarchy.get(0).getConstructor(types); if(constructor == null){ throw SarLogger.ROOT_LOGGER.defaultConstructorNotFound(mBeanClassHierarchy.get(0).getIndexedClass()); } final Object mBeanInstance = ReflectionUtils.newInstance(constructor, params); return mBeanInstance; } finally { // switch back the TCCL WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTCCL); } }
public Constructor<T> lookup(ClassReflectionIndex index) { final Constructor ctor = index.getConstructor(parameterTypes); if (ctor == null) throw PojoMessages.MESSAGES.ctorNotFound(Arrays.toString(parameterTypes), beanClass.getName()); return ctor; } }, 0, 1);
public Constructor<T> lookup(ClassReflectionIndex index) { final Constructor ctor = index.getConstructor(parameterTypes); if (ctor == null) throw PojoLogger.ROOT_LOGGER.ctorNotFound(Arrays.toString(parameterTypes), beanClass.getName()); return ctor; } }, 0, 1);
@SuppressWarnings("unchecked") private Extension loadExtension(String serviceClassName, final DeploymentReflectionIndex index, final ClassLoader loader) throws DeploymentUnitProcessingException { Class<?> clazz; Class<Extension> serviceClass; try { clazz = loader.loadClass(serviceClassName); serviceClass = (Class<Extension>) clazz; final Constructor<Extension> ctor = index.getClassIndex(serviceClass).getConstructor(EMPTY_STRING_ARRAY); return ctor.newInstance(); } catch (ClassCastException e) { throw WeldMessages.MESSAGES.extensionDoesNotImplementExtension(serviceClassName, e); } catch (Exception e) { WeldLogger.DEPLOYMENT_LOGGER.couldNotLoadPortableExceptionClass(serviceClassName, e); } return null; }
@Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { final InterceptorClassDescription interceptorConfig; if (classDescription != null) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName())); } // get the container-interceptor class' constructor final ClassReflectionIndex<?> interceptorClassReflectionIndex = deploymentReflectionIndex.getClassIndex(interceptorClass); final Constructor<?> interceptorClassConstructor = interceptorClassReflectionIndex.getConstructor(EMPTY_CLASS_ARRAY); if (interceptorClassConstructor == null) { throw MESSAGES.defaultConstructorNotFound(interceptorClass); } final MethodIdentifier aroundInvokeMethodIdentifier = interceptorConfig.getAroundInvoke(); final InterceptorFactory aroundInvokeInterceptorFactory = createInterceptorFactory(clazz, aroundInvokeMethodIdentifier, interceptorClassConstructor); if (aroundInvokeInterceptorFactory != null) { this.aroundInvokeInterceptorFactories.add(aroundInvokeInterceptorFactory); } if (ejbComponentDescription.isTimerServiceApplicable()) { final MethodIdentifier aroundTimeoutMethodIdentifier = interceptorConfig.getAroundTimeout(); final InterceptorFactory aroundTimeoutInterceptorFactory = createInterceptorFactory(clazz, aroundTimeoutMethodIdentifier, interceptorClassConstructor); if (aroundTimeoutInterceptorFactory != null) { this.aroundTimeoutInterceptorFactories.add(aroundTimeoutInterceptorFactory); } } }
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex deploymentReflectionIndex = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX); final ClassReflectionIndex<?> classIndex = deploymentReflectionIndex.getClassIndex(configuration.getComponentClass()); final Constructor<?> ctor = classIndex.getConstructor(new String[0]); if(ctor == null) { throw EjbMessages.MESSAGES.ejbMustHavePublicDefaultConstructor(description.getComponentName(), description.getComponentClassName()); } if(!Modifier.isPublic(ctor.getModifiers())) { throw EjbMessages.MESSAGES.ejbMustHavePublicDefaultConstructor(description.getComponentName(), description.getComponentClassName()); } if(configuration.getComponentClass().getEnclosingClass() != null) { throw EjbMessages.MESSAGES.ejbMustNotBeInnerClass(description.getComponentName(), description.getComponentClassName()); } if(!Modifier.isPublic(configuration.getComponentClass().getModifiers())) { throw EjbMessages.MESSAGES.ejbMustBePublicClass(description.getComponentName(), description.getComponentClassName()); } if(Modifier.isFinal(configuration.getComponentClass().getModifiers())) { throw EjbMessages.MESSAGES.ejbMustNotBeFinalClass(description.getComponentName(), description.getComponentClassName()); } } }
final ClassReflectionIndex componentClassIndex = deploymentReflectionIndex.getClassIndex(configuration.getComponentClass()); final Constructor<?> constructor = componentClassIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(configuration.getComponentClass()); final Constructor<?> constructor = interceptorIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFoundOnComponent(interceptorClassName, configuration.getComponentClass());
final ClassReflectionIndex componentClassIndex = deploymentReflectionIndex.getClassIndex(configuration.getComponentClass()); final Constructor<?> constructor = componentClassIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(configuration.getComponentClass()); final Constructor<?> constructor = interceptorIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFoundOnComponent(interceptorClassName, configuration.getComponentClass());
} else { final Constructor<Object> constructor = (Constructor<Object>) componentClassIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw MESSAGES.defaultConstructorNotFound(configuration.getComponentClass()); final Constructor<?> constructor = interceptorIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { throw MESSAGES.defaultConstructorNotFoundOnComponent(interceptorClassName, configuration.getComponentClass());