private void handleJarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!isEarDeployment(deploymentUnit) && !isWarDeployment(deploymentUnit) && (!appClientContainerMode || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) ) { // handle META-INF/persistence.xml // ordered list of PUs List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); // handle META-INF/persistence.xml final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); // save the persistent unit definitions // deploymentUnit.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); markDU(holder, deploymentUnit); ROOT_LOGGER.tracef("parsed persistence unit definitions for jar %s", deploymentRoot.getRootName()); incrementPersistenceUnitCount(deploymentUnit, holder.getPersistenceUnits().size()); addApplicationDependenciesOnProvider( deploymentUnit, holder); } }
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); } }
public static String createBeanName(DeploymentUnit deploymentUnit, String persistenceUnitName) { // persistenceUnitName must be a simple name if (persistenceUnitName.indexOf('/') != -1) { throw JpaLogger.ROOT_LOGGER.invalidPersistenceUnitName(persistenceUnitName, '/'); } if (persistenceUnitName.indexOf('#') != -1) { throw JpaLogger.ROOT_LOGGER.invalidPersistenceUnitName(persistenceUnitName, '#'); } String unitName = getScopedDeploymentUnitPath(deploymentUnit) + "#" + persistenceUnitName; return unitName; }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { handleWarDeployment(phaseContext); handleEarDeployment(phaseContext); handleJarDeployment(phaseContext); phaseContext.addDeploymentDependency(TransactionManagerService.SERVICE_NAME, JpaAttachments.TRANSACTION_MANAGER); phaseContext.addDeploymentDependency(TransactionSynchronizationRegistryService.SERVICE_NAME, JpaAttachments.TRANSACTION_SYNCHRONIZATION_REGISTRY); }
if (pu.getJarFiles() != null) { for (String jar : pu.getJarFiles()) { jarfilesUrls.add(getRelativeURL(persistence_xml, jar)); URL url = getPersistenceUnitURL(persistence_xml); pu.setPersistenceUnitRootUrl(url); String scopedPersistenceUnitName; scopedPersistenceUnitName = createBeanName(deploymentUnit, pu.getPersistenceUnitName()); } else { ROOT_LOGGER.tracef("persistence unit '%s' specified a custom scoped persistence unit name hint " +
processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PERSISTENCE_UNIT, new PersistenceUnitParseProcessor(appclient));
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { handleWarDeployment(phaseContext); handleEarDeployment(phaseContext); handleJarDeployment(phaseContext); CapabilityServiceSupport capabilitySupport = phaseContext.getDeploymentUnit().getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); phaseContext.addDeploymentDependency(capabilitySupport.getCapabilityServiceName(JPAServiceNames.LOCAL_TRANSACTION_PROVIDER_CAPABILITY), JpaAttachments.LOCAL_TRANSACTION_PROVIDER); phaseContext.addDeploymentDependency(capabilitySupport.getCapabilityServiceName(JPAServiceNames.TRANSACTION_SYNCHRONIZATION_REGISTRY_CAPABILITY), JpaAttachments.TRANSACTION_SYNCHRONIZATION_REGISTRY); }
if (pu.getJarFiles() != null) { for (String jar : pu.getJarFiles()) { jarfilesUrls.add(getRelativeURL(persistence_xml, jar)); URL url = getPersistenceUnitURL(persistence_xml); pu.setPersistenceUnitRootUrl(url); String scopedPersistenceUnitName; scopedPersistenceUnitName = createBeanName(deploymentUnit, pu.getPersistenceUnitName()); } else { ROOT_LOGGER.tracef("persistence unit '%s' specified a custom scoped persistence unit name hint " +
processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PERSISTENCE_UNIT, new PersistenceUnitParseProcessor(appclient));
private void handleJarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!isEarDeployment(deploymentUnit) && !isWarDeployment(deploymentUnit) && (!appClientContainerMode || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) ) { // handle META-INF/persistence.xml // ordered list of PUs List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); // handle META-INF/persistence.xml final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); // save the persistent unit definitions // deploymentUnit.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); markDU(holder, deploymentUnit); ROOT_LOGGER.tracef("parsed persistence unit definitions for jar %s", deploymentRoot.getRootName()); incrementPersistenceUnitCount(deploymentUnit, holder.getPersistenceUnits().size()); addApplicationDependenciesOnProvider( deploymentUnit, holder); } }
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); } }
public static String createBeanName(DeploymentUnit deploymentUnit, String persistenceUnitName) { // persistenceUnitName must be a simple name if (persistenceUnitName.indexOf('/') != -1) { throw JpaLogger.ROOT_LOGGER.invalidPersistenceUnitName(persistenceUnitName, '/'); } if (persistenceUnitName.indexOf('#') != -1) { throw JpaLogger.ROOT_LOGGER.invalidPersistenceUnitName(persistenceUnitName, '#'); } String unitName = getScopedDeploymentUnitPath(deploymentUnit) + "#" + persistenceUnitName; return unitName; }
private void handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!appClientContainerMode && isWarDeployment(deploymentUnit)) { parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount = holder.getPersistenceUnits().size(); listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); holder = normalize(listPUHolders); resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount += holder.getPersistenceUnits().size(); incrementPersistenceUnitCount(deploymentUnit, puCount);
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 handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!appClientContainerMode && isWarDeployment(deploymentUnit)) { parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount = holder.getPersistenceUnits().size(); listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); holder = normalize(listPUHolders); resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount += holder.getPersistenceUnits().size(); incrementPersistenceUnitCount(deploymentUnit, puCount);
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 handleEarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (isEarDeployment(deploymentUnit)) { parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount = holder.getPersistenceUnits().size(); listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); holder = normalize(listPUHolders); resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount += holder.getPersistenceUnits().size(); incrementPersistenceUnitCount(deploymentUnit, puCount);
private void handleEarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (isEarDeployment(deploymentUnit)) { parse(persistence_xml, listPUHolders, deploymentUnit); PersistenceUnitMetadataHolder holder = normalize(listPUHolders); deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount = holder.getPersistenceUnits().size(); listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1); persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML); parse(persistence_xml, listPUHolders, deploymentUnit); holder = normalize(listPUHolders); resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder); addApplicationDependenciesOnProvider( deploymentUnit, holder); markDU(holder, deploymentUnit); puCount += holder.getPersistenceUnits().size(); incrementPersistenceUnitCount(deploymentUnit, puCount);