use of org.jboss.as.server.deployment.module.ModuleDependency in project teiid by teiid.
the class VDBDependencyDeployer method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
return;
}
final VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
ArrayList<ModuleDependency> localDependencies = new ArrayList<ModuleDependency>();
ArrayList<ModuleDependency> userDependencies = new ArrayList<ModuleDependency>();
// $NON-NLS-1$
String moduleNames = deployment.getPropertyValue("lib");
if (moduleNames != null) {
StringTokenizer modules = new StringTokenizer(moduleNames);
while (modules.hasMoreTokens()) {
String moduleName = modules.nextToken().trim();
ModuleIdentifier lib = ModuleIdentifier.create(moduleName);
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
try {
moduleLoader.loadModule(lib);
localDependencies.add(new ModuleDependency(moduleLoader, ModuleIdentifier.create(moduleName), false, false, false, false));
} catch (ModuleLoadException e) {
// this is to handle JAR based deployments which take on name like "deployment.<jar-name>"
moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
try {
moduleLoader.loadModule(lib);
userDependencies.add(new ModuleDependency(moduleLoader, ModuleIdentifier.create(moduleName), false, false, false, true));
} catch (ModuleLoadException e1) {
throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50088, moduleName, deployment.getName(), deployment.getVersion(), e1));
}
}
}
}
if (!TeiidAttachments.isVDBXMLDeployment(deploymentUnit)) {
try {
final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile deploymentRoot = deploymentResourceRoot.getRoot();
if (deploymentRoot == null) {
return;
}
final VirtualFile libDir = deploymentRoot.getChild(LIB);
if (libDir.exists()) {
final List<VirtualFile> archives = libDir.getChildren(DEFAULT_JAR_LIB_FILTER);
for (final VirtualFile archive : archives) {
try {
final Closeable closable = VFS.mountZip(archive, archive, TempFileProviderService.provider());
final ResourceRoot jarArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable));
ModuleRootMarker.mark(jarArchiveRoot);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, jarArchiveRoot);
} catch (IOException e) {
throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50018, archive), e);
}
}
}
} catch (IOException e) {
throw new DeploymentUnitProcessingException(e);
}
}
// add translators as dependent modules to this VDB.
try {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
// $NON-NLS-1$
final ModuleLoader moduleLoader = Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getModuleLoader();
// $NON-NLS-1$
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.api"), false, false, false, false));
// $NON-NLS-1$
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.common-core"), false, false, false, false));
// $NON-NLS-1$
moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("javax.api"), false, false, false, false));
if (!localDependencies.isEmpty()) {
moduleSpecification.addLocalDependencies(localDependencies);
}
if (!userDependencies.isEmpty()) {
moduleSpecification.addUserDependencies(userDependencies);
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(IntegrationPlugin.Event.TEIID50018.name(), e);
}
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class ClusteringDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API, true, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, MARSHALLING_API, true, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, SINGLETON_API, true, false, false, false));
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class BeanValidationDeploymentDependenciesProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
//
for (final ModuleIdentifier moduleIdentifier : DEPENDENCIES) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, false, true, false));
}
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class HibernateSearchProcessor method addSearchDependency.
private void addSearchDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
String searchModuleName = null;
PersistenceUnitsInApplication persistenceUnitsInApplication = DeploymentUtils.getTopDeploymentUnit(deploymentUnit).getAttachment(PersistenceUnitsInApplication.PERSISTENCE_UNITS_IN_APPLICATION);
for (PersistenceUnitMetadataHolder holder : persistenceUnitsInApplication.getPersistenceUnitHolders()) {
for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {
String providerModule = pu.getProperties().getProperty(Configuration.HIBERNATE_SEARCH_MODULE);
if (providerModule != null) {
// one persistence unit specifying the Hibernate search module is allowed
if (searchModuleName == null) {
searchModuleName = providerModule;
} else // more than one persistence unit specifying different Hibernate search module names is not allowed
if (!providerModule.equals(searchModuleName)) {
throw JpaLogger.ROOT_LOGGER.differentSearchModuleDependencies(deploymentUnit.getName(), searchModuleName, providerModule);
}
}
}
}
if (NONE.equals(searchModuleName)) {
// Hibernate Search module will not be added to deployment
ROOT_LOGGER.debugf("Not adding Hibernate Search dependency to deployment %s", deploymentUnit.getName());
return;
}
// use Search module name specified in persistence unit definition
if (searchModuleName != null && !IGNORE.equals(searchModuleName)) {
ModuleIdentifier moduleIdentifier = ModuleIdentifier.fromString(searchModuleName);
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, true, true, false));
ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
} else {
// add Hibernate Search module dependency if application is using the Hibernate Search Indexed annotation
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
List<AnnotationInstance> annotations = index.getAnnotations(SEARCH_INDEXED_ANNOTATION_NAME);
if (annotations != null && !annotations.isEmpty()) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, defaultSearchModule, false, true, true, false));
ROOT_LOGGER.debugf("deployment %s contains %s annotation, added %s dependency", deploymentUnit.getName(), SEARCH_INDEXED_ANNOTATION_NAME, defaultSearchModule);
}
}
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class JPADependencyProcessor method addOptionalDependency.
private void addOptionalDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, DeploymentUnit deploymentUnit, ModuleIdentifier... moduleIdentifiers) {
for (ModuleIdentifier moduleIdentifier : moduleIdentifiers) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, false, false, false));
ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
}
}
Aggregations