Search in sources :

Example 41 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class PersistenceUnitSearch method findWithinDeployment.

/*
     * When finding the default persistence unit, the first persistence unit encountered is returned.
     */
private static PersistenceUnitMetadata findWithinDeployment(DeploymentUnit unit, String persistenceUnitName) {
    if (traceEnabled) {
        ROOT_LOGGER.tracef("pu findWithinDeployment searching for %s", persistenceUnitName);
    }
    for (ResourceRoot root : DeploymentUtils.allResourceRoots(unit)) {
        PersistenceUnitMetadataHolder holder = root.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS);
        if (holder == null || holder.getPersistenceUnits() == null) {
            if (traceEnabled) {
                ROOT_LOGGER.tracef("pu findWithinDeployment skipping empty pu holder for %s", persistenceUnitName);
            }
            continue;
        }
        ambiguousPUError(unit, persistenceUnitName, holder);
        persistenceUnitName = defaultPersistenceUnitName(persistenceUnitName, holder);
        for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
            if (traceEnabled) {
                ROOT_LOGGER.tracef("findWithinDeployment check '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
            }
            if (persistenceUnitName == null || persistenceUnitName.length() == 0 || persistenceUnit.getPersistenceUnitName().equals(persistenceUnitName)) {
                if (traceEnabled) {
                    ROOT_LOGGER.tracef("findWithinDeployment matched '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
                }
                return persistenceUnit;
            }
        }
    }
    return null;
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata)

Example 42 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class PersistenceUnitSearch method findWithinApplication.

private static PersistenceUnitMetadata findWithinApplication(DeploymentUnit unit, String persistenceUnitName) {
    if (traceEnabled) {
        ROOT_LOGGER.tracef("pu findWithinApplication for %s", persistenceUnitName);
    }
    PersistenceUnitMetadata name = findWithinDeployment(unit, persistenceUnitName);
    if (name != null) {
        if (traceEnabled) {
            ROOT_LOGGER.tracef("pu findWithinApplication matched for %s", persistenceUnitName);
        }
        return name;
    }
    List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot resourceRoot : resourceRoots) {
        if (!SubDeploymentMarker.isSubDeployment(resourceRoot)) {
            name = findWithinLibraryJar(unit, resourceRoot, persistenceUnitName);
            if (name != null) {
                return name;
            }
        }
    }
    return null;
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadata(org.jipijapa.plugin.spi.PersistenceUnitMetadata)

Example 43 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class KernelDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for jboss-beans.xml files.
     * Will parse the xml file and attach a configuration discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (unit.hasAttachment(Attachments.OSGI_MANIFEST))
        return;
    final VirtualFile deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    parseDescriptors(unit, deploymentRoot);
    final List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot root : resourceRoots) parseDescriptors(unit, root.getRoot());
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 44 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class PersistenceUnitParseProcessor method handleJarDeployment.

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);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 45 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class PersistenceUnitParseProcessor method getScopedDeploymentUnitPath.

private static String getScopedDeploymentUnitPath(DeploymentUnit deploymentUnit) {
    // order of deployment elements will start with parent
    ArrayList<String> parts = new ArrayList<String>();
    do {
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        DeploymentUnit parentdeploymentUnit = deploymentUnit.getParent();
        if (parentdeploymentUnit != null) {
            ResourceRoot parentDeploymentRoot = parentdeploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
            parts.add(0, deploymentRoot.getRoot().getPathNameRelativeTo(parentDeploymentRoot.getRoot()));
        } else {
            parts.add(0, deploymentRoot.getRoot().getName());
        }
    } while ((deploymentUnit = deploymentUnit.getParent()) != null);
    StringBuilder result = new StringBuilder();
    boolean needSeparator = false;
    for (String part : parts) {
        if (needSeparator) {
            result.append('/');
        }
        result.append(part);
        needSeparator = true;
    }
    return result.toString();
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)71 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)49 VirtualFile (org.jboss.vfs.VirtualFile)37 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)12 HashMap (java.util.HashMap)10 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)10 WarMetaData (org.jboss.as.web.common.WarMetaData)10 MountHandle (org.jboss.as.server.deployment.module.MountHandle)9 Index (org.jboss.jandex.Index)8 Closeable (java.io.Closeable)7 URL (java.net.URL)7 HashSet (java.util.HashSet)7 Module (org.jboss.modules.Module)7 InputStream (java.io.InputStream)6 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)6 ServiceName (org.jboss.msc.service.ServiceName)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 EEApplicationDescription (org.jboss.as.ee.component.EEApplicationDescription)5