public String toString() { return getClass().getName() + "[name=" + componentDescription.getComponentName() + " class=" + componentDescription.getComponentClassName() + "]"; }
private void processComponentConfig(final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final ComponentDescription description, DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final Class<?> componentClass; try { componentClass = ClassLoadingUtils.loadClass(description.getComponentClassName(), deploymentUnit); } catch (Throwable e) { //just ignore the class for now. //if it is an optional component this is ok, if it is not an optional component //it will fail at configure time anyway return; } handleAnnotations(applicationClasses, deploymentReflectionIndex, componentClass, description); }
private Set<String> getImplicitBeanClasses(Index index, ResourceRoot resourceRoot) { Set<String> implicitBeanClasses = new HashSet<String>(); for (AnnotationType beanDefiningAnnotation : beanDefiningAnnotations) { List<AnnotationInstance> annotationInstances = index.getAnnotations(beanDefiningAnnotation.getName()); for (ClassInfo classInfo : Indices.getAnnotatedClasses(annotationInstances)) { implicitBeanClasses.add(Indices.CLASS_INFO_TO_FQCN.apply(classInfo)); } } // Make all explicit components into implicit beans so they will support injection for(ComponentDescription description : components.componentDescriptions.get(resourceRoot)) { if(!components.implicitComponentDescriptions.contains(description)) { implicitBeanClasses.add(description.getComponentClassName()); } } return implicitBeanClasses; }
/** * Add a component to this module. * * @param description the component description */ public void addComponent(ComponentDescription description) { final String componentName = description.getComponentName(); final String componentClassName = description.getComponentClassName(); if (componentName == null) { throw EeLogger.ROOT_LOGGER.nullVar("componentName", "module", moduleName); } if (componentClassName == null) { throw EeLogger.ROOT_LOGGER.nullVar("componentClassName","module", moduleName); } if (componentsByName.containsKey(componentName)) { throw EeLogger.ROOT_LOGGER.componentAlreadyDefined(componentName); } componentsByName.put(componentName, description); List<ComponentDescription> list = componentsByClassName.get(componentClassName); if (list == null) { componentsByClassName.put(componentClassName, list = new ArrayList<ComponentDescription>(1)); } list.add(description); }
@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()); } }
public Components(DeploymentUnit deploymentUnit, Map<ResourceRoot, Index> indexes) { componentDescriptionProcessors = ServiceLoader.load(ComponentDescriptionProcessor.class, WildFlySecurityManager.getClassLoaderPrivileged(BeanArchiveProcessor.class)); for (ComponentDescription component : deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION).getComponentDescriptions()) { ResourceRoot resourceRoot = null; DotName componentClassName = DotName.createSimple(component.getComponentClassName()); for (Entry<ResourceRoot, Index> entry : indexes.entrySet()) { final Index index = entry.getValue(); if (index != null) { if (index.getClassByName(componentClassName) != null) { resourceRoot = entry.getKey(); break; } } } if (resourceRoot == null) { implicitComponentDescriptions.add(component); } if (resourceRoot == null || isClassesRoot(resourceRoot)) { // special handling resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); } componentDescriptions.put(resourceRoot, component); // Process component descriptions for (ComponentDescriptionProcessor processor : componentDescriptionProcessors) { processor.processComponentDescription(resourceRoot, component); } } }
for (ComponentSupport support : supportServices) { if (!support.isDiscoveredExternalType(component)) { componentClassNames.add(component.getComponentClassName()); break;
componentByClass.put(component.getComponentClassName(), component);
componentClass = module.getClassLoader().loadClass(componentDescription.getComponentClassName()); } catch (ClassNotFoundException e) { throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, componentDescription.getComponentClassName());
continue; final Class<?> ejbClass = this.getEjbClass(componentDescription.getComponentClassName(), moduleClassLoader); try { this.processViewAnnotations(deploymentUnit, ejbClass, (SessionBeanComponentDescription) componentDescription); continue; final Class<?> ejbClass = this.getEjbClass(componentDescription.getComponentClassName(), moduleClassLoader); try { this.processViewAnnotations(deploymentUnit, ejbClass, (SessionBeanComponentDescription) componentDescription);
while (iterator.hasNext()) { final ComponentDescription componentDescription = iterator.next(); ROOT_LOGGER.debugf("Configuring component class: %s named %s", componentDescription.getComponentClassName(), componentDescription.getComponentName()); final ComponentConfiguration componentConfiguration; try { componentConfiguration = componentDescription.createConfiguration(reflectionIndex.getClassIndex(ClassLoadingUtils.loadClass(componentDescription.getComponentClassName(), module)), module.getClassLoader(), module.getModuleLoader()); for (final ComponentConfigurator componentConfigurator : componentDescription.getConfigurators()) { componentConfigurator.configure(phaseContext, componentDescription, componentConfiguration);
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy() ,true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { if (TransactionManagementType.CONTAINER.equals(getTransactionManagementType())) { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } configuration.addTimeoutViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), false), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), false), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); if (description.isPassivationApplicable()) { configuration.addPrePassivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPrePassivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR); configuration.addPostActivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostActivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR); } } });
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit); final String paClassName = processApplicationComponent.getComponentClassName(); String[] deploymentDescriptorResourceNames = null; Module module = deploymentUnit.getAttachment(MODULE); Class<?> paClass = null; try { paClass = (Class<?>) module.getClassLoader().loadClass(paClassName); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'."); } ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class); if(annotation == null) { deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML }; } else { deploymentDescriptorResourceNames = annotation.deploymentDescriptors(); } return deploymentDescriptorResourceNames; }
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit); final String paClassName = processApplicationComponent.getComponentClassName(); String[] deploymentDescriptorResourceNames = null; Module module = deploymentUnit.getAttachment(MODULE); Class<?> paClass = null; try { paClass = (Class<?>) module.getClassLoader().loadClass(paClassName); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'."); } ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class); if(annotation == null) { deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML }; } else { deploymentDescriptorResourceNames = annotation.deploymentDescriptors(); } return deploymentDescriptorResourceNames; }
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit); final String paClassName = processApplicationComponent.getComponentClassName(); String[] deploymentDescriptorResourceNames = null; Module module = deploymentUnit.getAttachment(MODULE); Class<?> paClass = null; try { paClass = (Class<?>) module.getClassLoader().loadClass(paClassName); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'."); } ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class); if(annotation == null) { deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML }; } else { deploymentDescriptorResourceNames = annotation.deploymentDescriptors(); } return deploymentDescriptorResourceNames; }
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION); InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit())); configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), false), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR); configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), false), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR); if (description.isPassivationApplicable()) { configuration.addPrePassivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPrePassivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR); configuration.addPostActivateInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostActivate(), false), InterceptorOrder.ComponentPassivation.TRANSACTION_INTERCEPTOR); } } });