private void setClassLoaderTransformer(DeploymentUnit deploymentUnit) { // (AS7-2233) each persistence unit can use a persistence provider, that might need // to use ClassTransformers. Providers that need class transformers will add them // during the call to CreateContainerEntityManagerFactory. DelegatingClassFileTransformer transformer = deploymentUnit.getAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY); boolean appContainsPersistenceProviderJars = false; // remove when we revert WFLY-10520 if ( transformer != null) { for (ResourceRoot resourceRoot : DeploymentUtils.allResourceRoots(deploymentUnit)) { PersistenceUnitMetadataHolder holder = resourceRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS); if (holder != null) { for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { if (Configuration.needClassFileTransformer(pu)) { transformer.addTransformer(new JPADelegatingClassFileTransformer(pu)); } // remove this check when we revert WFLY-10520 String provider = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE); if (provider != null) { if (provider.equals(Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED)) { appContainsPersistenceProviderJars = true; } } } } } // WFLY-10520 Add Hibernate ORM 5.3 compatibility transformer if(!appContainsPersistenceProviderJars && hibernate51CompatibilityTransformer) { transformer.addTransformer(Hibernate51CompatibilityTransformer.getInstance()); } } }
private void setClassLoaderTransformer(DeploymentUnit deploymentUnit) { // (AS7-2233) each persistence unit can use a persistence provider, that might need // to use ClassTransformers. Providers that need class transformers will add them // during the call to CreateContainerEntityManagerFactory. DelegatingClassFileTransformer transformer = deploymentUnit.getAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY); boolean appContainsPersistenceProviderJars = false; // remove when we revert WFLY-10520 if ( transformer != null) { for (ResourceRoot resourceRoot : DeploymentUtils.allResourceRoots(deploymentUnit)) { PersistenceUnitMetadataHolder holder = resourceRoot.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS); if (holder != null) { for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) { if (Configuration.needClassFileTransformer(pu)) { transformer.addTransformer(new JPADelegatingClassFileTransformer(pu)); } // remove this check when we revert WFLY-10520 String provider = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE); if (provider != null) { if (provider.equals(Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED)) { appContainsPersistenceProviderJars = true; } } } } } // WFLY-10520 Add Hibernate ORM 5.3 compatibility transformer if(!appContainsPersistenceProviderJars && hibernate51CompatibilityTransformer) { transformer.addTransformer(Hibernate51CompatibilityTransformer.getInstance()); } } }
/** * 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); } } } } }
/** * 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); } } } } }
deployPersistenceUnitPhaseOne(deploymentUnit, eeModuleDescription, serviceTarget, classLoader, pu, adaptor); else if (false == Configuration.needClassFileTransformer(pu)) { if (twoPhaseBootStrapCapable) { deployPersistenceUnitPhaseTwo(deploymentUnit, eeModuleDescription, serviceTarget, classLoader, pu, provider, adaptor); } else if (false == Configuration.needClassFileTransformer(pu)) { final boolean allowCdiBeanManagerAccess = true;
deployPersistenceUnitPhaseOne(deploymentUnit, eeModuleDescription, serviceTarget, classLoader, pu, adaptor); else if (false == Configuration.needClassFileTransformer(pu)) { if (twoPhaseBootStrapCapable) { deployPersistenceUnitPhaseTwo(deploymentUnit, eeModuleDescription, serviceTarget, classLoader, pu, provider, adaptor); } else if (false == Configuration.needClassFileTransformer(pu)) { final boolean allowCdiBeanManagerAccess = true;