Search in sources :

Example 71 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class DefaultDataSourceBindingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(EAR, deploymentUnit)) {
        return;
    }
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final String defaultDataSource = moduleDescription.getDefaultResourceJndiNames().getDataSource();
    if (defaultDataSource == null) {
        return;
    }
    final LookupInjectionSource injectionSource = new LookupInjectionSource(defaultDataSource);
    if (DeploymentTypeMarker.isType(WAR, deploymentUnit)) {
        moduleDescription.getBindingConfigurations().add(new BindingConfiguration(MODULE_DEFAULT_DATASOURCE_JNDI_NAME, injectionSource));
    } else {
        if (DeploymentTypeMarker.isType(APPLICATION_CLIENT, deploymentUnit)) {
            moduleDescription.getBindingConfigurations().add(new BindingConfiguration(COMP_DEFAULT_DATASOURCE_JNDI_NAME, injectionSource));
        }
        for (ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
            if (componentDescription.getNamingMode() == ComponentNamingMode.CREATE) {
                componentDescription.getBindingConfigurations().add(new BindingConfiguration(COMP_DEFAULT_DATASOURCE_JNDI_NAME, injectionSource));
            }
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) LookupInjectionSource(org.jboss.as.ee.component.LookupInjectionSource) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration)

Example 72 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class PersistenceUnitServiceHandler method addPuService.

/**
     * Add one PU service per top level deployment that represents
     *
     *
     * @param phaseContext
     * @param puList
     * @param startEarly
     * @param platform
     * @throws DeploymentUnitProcessingException
     *
     */
private static void addPuService(final DeploymentPhaseContext phaseContext, final ArrayList<PersistenceUnitMetadataHolder> puList, final boolean startEarly, final Platform platform) throws DeploymentUnitProcessingException {
    if (puList.size() > 0) {
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final Collection<ComponentDescription> components = eeModuleDescription.getComponentDescriptions();
        if (module == null) {
            // Unresolved OSGi bundles would not have a module attached
            ROOT_LOGGER.failedToGetModuleAttachment(deploymentUnit);
            return;
        }
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        final ModuleClassLoader classLoader = module.getClassLoader();
        for (PersistenceUnitMetadataHolder holder : puList) {
            setAnnotationIndexes(holder, deploymentUnit);
            for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
                // only start the persistence unit if JPA_CONTAINER_MANAGED is true
                String jpaContainerManaged = pu.getProperties().getProperty(Configuration.JPA_CONTAINER_MANAGED);
                boolean deployPU = (jpaContainerManaged == null ? true : Boolean.parseBoolean(jpaContainerManaged));
                if (deployPU) {
                    final PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder = getPersistenceProviderDeploymentHolder(deploymentUnit);
                    final PersistenceProvider provider = lookupProvider(pu, persistenceProviderDeploymentHolder, deploymentUnit);
                    final PersistenceProviderAdaptor adaptor = getPersistenceProviderAdaptor(pu, persistenceProviderDeploymentHolder, deploymentUnit, provider, platform);
                    final boolean twoPhaseBootStrapCapable = (adaptor instanceof TwoPhaseBootstrapCapable) && Configuration.allowTwoPhaseBootstrap(pu);
                    if (startEarly) {
                        if (twoPhaseBootStrapCapable) {
                            deployPersistenceUnitPhaseOne(phaseContext, deploymentUnit, eeModuleDescription, components, serviceTarget, classLoader, pu, adaptor);
                        } else if (false == Configuration.needClassFileTransformer(pu)) {
                            // will start later when startEarly == false
                            ROOT_LOGGER.tracef("persistence unit %s in deployment %s is configured to not need class transformer to be set, no class rewriting will be allowed", pu.getPersistenceUnitName(), deploymentUnit.getName());
                        } else {
                            // we need class file transformer to work, don't allow cdi bean manager to be access since that
                            // could cause application classes to be loaded (workaround by setting jboss.as.jpa.classtransformer to false).  WFLY-1463
                            final boolean allowCdiBeanManagerAccess = false;
                            deployPersistenceUnit(phaseContext, deploymentUnit, eeModuleDescription, components, serviceTarget, classLoader, pu, startEarly, provider, adaptor, allowCdiBeanManagerAccess);
                        }
                    } else {
                        // !startEarly
                        if (twoPhaseBootStrapCapable) {
                            deployPersistenceUnitPhaseTwo(phaseContext, deploymentUnit, eeModuleDescription, components, serviceTarget, classLoader, pu, provider, adaptor);
                        } else if (false == Configuration.needClassFileTransformer(pu)) {
                            final boolean allowCdiBeanManagerAccess = true;
                            // PUs that have Configuration.JPA_CONTAINER_CLASS_TRANSFORMER = false will start during INSTALL phase
                            deployPersistenceUnit(phaseContext, deploymentUnit, eeModuleDescription, components, serviceTarget, classLoader, pu, startEarly, provider, adaptor, allowCdiBeanManagerAccess);
                        }
                    }
                } else {
                    ROOT_LOGGER.tracef("persistence unit %s in deployment %s is not container managed (%s is set to false)", pu.getPersistenceUnitName(), deploymentUnit.getName(), Configuration.JPA_CONTAINER_MANAGED);
                }
            }
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) ServiceTarget(org.jboss.msc.service.ServiceTarget) PersistenceProvider(javax.persistence.spi.PersistenceProvider) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata) Module(org.jboss.modules.Module) PersistenceProviderDeploymentHolder(org.jboss.as.jpa.config.PersistenceProviderDeploymentHolder) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) TwoPhaseBootstrapCapable(org.jipijapa.plugin.spi.TwoPhaseBootstrapCapable) PersistenceProviderAdaptor(org.jipijapa.plugin.spi.PersistenceProviderAdaptor)

Example 73 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class JPAInterceptorProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        if (component instanceof SessionBeanComponentDescription) {
            ROOT_LOGGER.tracef("registering session bean interceptors for component '%s' in '%s'", component.getComponentName(), deploymentUnit.getName());
            registerSessionBeanInterceptors((SessionBeanComponentDescription) component, deploymentUnit);
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Example 74 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class JPADependencyProcessor method addPersistenceProviderModuleDependencies.

private void addPersistenceProviderModuleDependencies(DeploymentPhaseContext phaseContext, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    int defaultProviderCount = 0;
    Set<String> moduleDependencies = new HashSet<String>();
    // get the number of persistence units that use the default persistence provider module.
    // Dependencies for other persistence provider will be added to the passed
    // 'moduleDependencies' collection.  Each persistence provider module that is found, will be injected into the
    // passed moduleSpecification (for the current deployment unit).
    PersistenceUnitsInApplication persistenceUnitsInApplication = DeploymentUtils.getTopDeploymentUnit(deploymentUnit).getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION);
    for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) {
        defaultProviderCount += loadPersistenceUnits(moduleSpecification, moduleLoader, deploymentUnit, moduleDependencies, holder);
    }
    // add dependencies for the default persistence provider module
    if (defaultProviderCount > 0) {
        moduleDependencies.add(Configuration.getDefaultProviderModuleName());
        ROOT_LOGGER.debugf("added (default provider) %s dependency to %s (since %d PU(s) didn't specify %s", Configuration.getDefaultProviderModuleName(), deploymentUnit.getName(), defaultProviderCount, Configuration.PROVIDER_MODULE + ")");
    }
    // add persistence provider dependency
    for (String dependency : moduleDependencies) {
        addDependency(moduleSpecification, moduleLoader, deploymentUnit, ModuleIdentifier.fromString(dependency));
    }
    // add the PU service as a dependency to all EE components in this scope
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> components = eeModuleDescription.getComponentDescriptions();
    for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) {
        addPUServiceDependencyToComponents(components, holder);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) PersistenceUnitsInApplication(org.jboss.as.jpa.config.PersistenceUnitsInApplication) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HashSet(java.util.HashSet)

Example 75 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class JSFManagedBeanProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (index == null) {
        return;
    }
    if (module == null) {
        return;
    }
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        return;
    }
    final Set<String> managedBeanClasses = new HashSet<String>();
    handleAnnotations(index, managedBeanClasses);
    processXmlManagedBeans(deploymentUnit, managedBeanClasses);
    for (String managedBean : managedBeanClasses) {
        //fail due to missing managed beans
        try {
            final Class<?> componentClass = module.getClassLoader().loadClass(managedBean);
            componentClass.getConstructor();
        } catch (ClassNotFoundException e) {
            JSFLogger.ROOT_LOGGER.managedBeanLoadFail(managedBean);
            continue;
        } catch (NoSuchMethodException e) {
            JSFLogger.ROOT_LOGGER.managedBeanNoDefaultConstructor(managedBean);
            continue;
        }
        installManagedBeanComponent(managedBean, moduleDescription, deploymentUnit, applicationClassesDescription);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HashSet(java.util.HashSet)

Aggregations

EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)90 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)77 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)44 Module (org.jboss.modules.Module)27 ServiceName (org.jboss.msc.service.ServiceName)21 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)18 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)17 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)16 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)11 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)10 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 AnnotationInstance (org.jboss.jandex.AnnotationInstance)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)8 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)8 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)7 Map (java.util.Map)6