private PersistenceUnitsInApplication getPersistenceUnitsInApplication(DeploymentUnit topDeploymentUnit) { PersistenceUnitsInApplication persistenceUnitsInApplication = topDeploymentUnit.getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION); if (persistenceUnitsInApplication == null) { persistenceUnitsInApplication = new PersistenceUnitsInApplication(); topDeploymentUnit.putAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION, persistenceUnitsInApplication); } return persistenceUnitsInApplication; } }
private void addApplicationDependenciesOnProvider(DeploymentUnit topDeploymentUnit, PersistenceUnitMetadataHolder holder) { topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(topDeploymentUnit); synchronized (topDeploymentUnit) { // ensure that only one deployment thread sets this at a time PersistenceUnitsInApplication persistenceUnitsInApplication = getPersistenceUnitsInApplication(topDeploymentUnit); persistenceUnitsInApplication.addPersistenceUnitHolder(holder); } }
private void incrementPersistenceUnitCount(DeploymentUnit topDeploymentUnit, int persistenceUnitCount) { topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(topDeploymentUnit); // create persistence unit counter if not done already synchronized (topDeploymentUnit) { // ensure that only one deployment thread sets this at a time PersistenceUnitsInApplication persistenceUnitsInApplication = getPersistenceUnitsInApplication(topDeploymentUnit); persistenceUnitsInApplication.increment(persistenceUnitCount); } ROOT_LOGGER.tracef("incrementing PU count for %s by %d", topDeploymentUnit.getName(), persistenceUnitCount); }
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); } }
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); } }
/** * The sub-deployment phases run in parallel, ensure that no deployment/sub-deployment moves past * Phase.FIRST_MODULE_USE, until the applications persistence unit services are started. * * Note that some application persistence units will not be created until the Phase.INSTALL, in which case * NEXT_PHASE_DEPS is not needed. */ private static void nextPhaseDependsOnPersistenceUnit(final DeploymentPhaseContext phaseContext, final Platform platform) throws DeploymentUnitProcessingException { final DeploymentUnit topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(phaseContext.getDeploymentUnit()); final PersistenceUnitsInApplication persistenceUnitsInApplication = topDeploymentUnit.getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION); for(final PersistenceUnitMetadataHolder holder: persistenceUnitsInApplication.getPersistenceUnitHolders()) { for (final PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { String jpaContainerManaged = pu.getProperties().getProperty(Configuration.JPA_CONTAINER_MANAGED); boolean deployPU = (jpaContainerManaged == null? true : Boolean.parseBoolean(jpaContainerManaged)); if (deployPU) { final ServiceName puServiceName = PersistenceUnitServiceImpl.getPUServiceName(pu); final PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder = getPersistenceProviderDeploymentHolder(phaseContext.getDeploymentUnit()); final PersistenceProvider provider = lookupProvider(pu, persistenceProviderDeploymentHolder, phaseContext.getDeploymentUnit()); final PersistenceProviderAdaptor adaptor = getPersistenceProviderAdaptor(pu, persistenceProviderDeploymentHolder, phaseContext.getDeploymentUnit(), provider, platform); final boolean twoPhaseBootStrapCapable = (adaptor instanceof TwoPhaseBootstrapCapable) && Configuration.allowTwoPhaseBootstrap(pu); // only add the next phase dependency, if the persistence unit service is starting early. if( Configuration.needClassFileTransformer(pu)) { // wait until the persistence unit service is started before starting the next deployment phase phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, twoPhaseBootStrapCapable ? puServiceName.append(FIRST_PHASE) : puServiceName); } } } } }
private void addApplicationDependenciesOnProvider(DeploymentUnit topDeploymentUnit, PersistenceUnitMetadataHolder holder) { topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(topDeploymentUnit); synchronized (topDeploymentUnit) { // ensure that only one deployment thread sets this at a time PersistenceUnitsInApplication persistenceUnitsInApplication = getPersistenceUnitsInApplication(topDeploymentUnit); persistenceUnitsInApplication.addPersistenceUnitHolder(holder); } }
private PersistenceUnitsInApplication getPersistenceUnitsInApplication(DeploymentUnit topDeploymentUnit) { PersistenceUnitsInApplication persistenceUnitsInApplication = topDeploymentUnit.getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION); if (persistenceUnitsInApplication == null) { persistenceUnitsInApplication = new PersistenceUnitsInApplication(); topDeploymentUnit.putAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION, persistenceUnitsInApplication); } return persistenceUnitsInApplication; } }
private void incrementPersistenceUnitCount(DeploymentUnit topDeploymentUnit, int persistenceUnitCount) { topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(topDeploymentUnit); // create persistence unit counter if not done already synchronized (topDeploymentUnit) { // ensure that only one deployment thread sets this at a time PersistenceUnitsInApplication persistenceUnitsInApplication = getPersistenceUnitsInApplication(topDeploymentUnit); persistenceUnitsInApplication.increment(persistenceUnitCount); } ROOT_LOGGER.tracef("incrementing PU count for %s by %d", topDeploymentUnit.getName(), persistenceUnitCount); }
/** * The sub-deployment phases run in parallel, ensure that no deployment/sub-deployment moves past * Phase.FIRST_MODULE_USE, until the applications persistence unit services are started. * * Note that some application persistence units will not be created until the Phase.INSTALL, in which case * NEXT_PHASE_DEPS is not needed. */ private static void nextPhaseDependsOnPersistenceUnit(final DeploymentPhaseContext phaseContext, final Platform platform) throws DeploymentUnitProcessingException { final DeploymentUnit topDeploymentUnit = DeploymentUtils.getTopDeploymentUnit(phaseContext.getDeploymentUnit()); final PersistenceUnitsInApplication persistenceUnitsInApplication = topDeploymentUnit.getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION); for(final PersistenceUnitMetadataHolder holder: persistenceUnitsInApplication.getPersistenceUnitHolders()) { for (final PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { String jpaContainerManaged = pu.getProperties().getProperty(Configuration.JPA_CONTAINER_MANAGED); boolean deployPU = (jpaContainerManaged == null? true : Boolean.parseBoolean(jpaContainerManaged)); if (deployPU) { final ServiceName puServiceName = PersistenceUnitServiceImpl.getPUServiceName(pu); final PersistenceProviderDeploymentHolder persistenceProviderDeploymentHolder = getPersistenceProviderDeploymentHolder(phaseContext.getDeploymentUnit()); final PersistenceProvider provider = lookupProvider(pu, persistenceProviderDeploymentHolder, phaseContext.getDeploymentUnit()); final PersistenceProviderAdaptor adaptor = getPersistenceProviderAdaptor(pu, persistenceProviderDeploymentHolder, phaseContext.getDeploymentUnit(), provider, platform); final boolean twoPhaseBootStrapCapable = (adaptor instanceof TwoPhaseBootstrapCapable) && Configuration.allowTwoPhaseBootstrap(pu); // only add the next phase dependency, if the persistence unit service is starting early. if( Configuration.needClassFileTransformer(pu)) { // wait until the persistence unit service is started before starting the next deployment phase phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, twoPhaseBootStrapCapable ? puServiceName.append(FIRST_PHASE) : puServiceName); } } } } }
for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) { for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { String providerModule = pu.getProperties().getProperty(Configuration.HIBERNATE_SEARCH_MODULE);
for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) { for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { String providerModule = pu.getProperties().getProperty(Configuration.HIBERNATE_SEARCH_MODULE);