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;
}
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;
}
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());
}
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);
}
}
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();
}
Aggregations