Search in sources :

Example 6 with ModuleIdentifier

use of org.jboss.modules.ModuleIdentifier in project wildfly by wildfly.

the class JSFDependencyProcessor method addJSFInjection.

private void addJSFInjection(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
    if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL))
        return;
    ModuleIdentifier jsfInjectionModule = moduleIdFactory.getInjectionModId(jsfVersion);
    ModuleDependency jsfInjectionDependency = new ModuleDependency(moduleLoader, jsfInjectionModule, false, true, true, false);
    jsfInjectionDependency.addImportFilter(PathFilters.getMetaInfFilter(), true);
    moduleSpecification.addSystemDependency(jsfInjectionDependency);
}
Also used : ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleIdentifier(org.jboss.modules.ModuleIdentifier)

Example 7 with ModuleIdentifier

use of org.jboss.modules.ModuleIdentifier in project wildfly by wildfly.

the class JMSBridgeAdd method createJMSBridge.

private JMSBridge createJMSBridge(OperationContext context, ModelNode model) throws OperationFailedException {
    final Properties sourceContextProperties = resolveContextProperties(JMSBridgeDefinition.SOURCE_CONTEXT, context, model);
    final String sourceConnectionFactoryName = JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY.resolveModelAttribute(context, model).asString();
    final ConnectionFactoryFactory sourceCff = new JNDIConnectionFactoryFactory(sourceContextProperties, sourceConnectionFactoryName);
    final String sourceDestinationName = JMSBridgeDefinition.SOURCE_DESTINATION.resolveModelAttribute(context, model).asString();
    final DestinationFactory sourceDestinationFactory = new JNDIDestinationFactory(sourceContextProperties, sourceDestinationName);
    final Properties targetContextProperties = resolveContextProperties(JMSBridgeDefinition.TARGET_CONTEXT, context, model);
    final String targetConnectionFactoryName = JMSBridgeDefinition.TARGET_CONNECTION_FACTORY.resolveModelAttribute(context, model).asString();
    final ConnectionFactoryFactory targetCff = new JNDIConnectionFactoryFactory(targetContextProperties, targetConnectionFactoryName);
    final String targetDestinationName = JMSBridgeDefinition.TARGET_DESTINATION.resolveModelAttribute(context, model).asString();
    final DestinationFactory targetDestinationFactory = new JNDIDestinationFactory(targetContextProperties, targetDestinationName);
    final String sourceUsername = resolveAttribute(JMSBridgeDefinition.SOURCE_USER, context, model);
    final String sourcePassword = resolveAttribute(JMSBridgeDefinition.SOURCE_PASSWORD, context, model);
    final String targetUsername = resolveAttribute(JMSBridgeDefinition.TARGET_USER, context, model);
    final String targetPassword = resolveAttribute(JMSBridgeDefinition.TARGET_PASSWORD, context, model);
    final String selector = resolveAttribute(CommonAttributes.SELECTOR, context, model);
    final long failureRetryInterval = JMSBridgeDefinition.FAILURE_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong();
    final int maxRetries = JMSBridgeDefinition.MAX_RETRIES.resolveModelAttribute(context, model).asInt();
    final QualityOfServiceMode qosMode = QualityOfServiceMode.valueOf(JMSBridgeDefinition.QUALITY_OF_SERVICE.resolveModelAttribute(context, model).asString());
    final int maxBatchSize = JMSBridgeDefinition.MAX_BATCH_SIZE.resolveModelAttribute(context, model).asInt();
    final long maxBatchTime = JMSBridgeDefinition.MAX_BATCH_TIME.resolveModelAttribute(context, model).asLong();
    final String subName = resolveAttribute(JMSBridgeDefinition.SUBSCRIPTION_NAME, context, model);
    final String clientID = resolveAttribute(JMSBridgeDefinition.CLIENT_ID, context, model);
    final boolean addMessageIDInHeader = JMSBridgeDefinition.ADD_MESSAGE_ID_IN_HEADER.resolveModelAttribute(context, model).asBoolean();
    final String moduleName = resolveAttribute(JMSBridgeDefinition.MODULE, context, model);
    final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        // will use the correct class loader to execute its threads
        if (moduleName != null) {
            ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
            Module module = Module.getCallerModuleLoader().loadModule(moduleID);
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
        }
        return new JMSBridgeImpl(sourceCff, targetCff, sourceDestinationFactory, targetDestinationFactory, sourceUsername, sourcePassword, targetUsername, targetPassword, selector, failureRetryInterval, maxRetries, qosMode, maxBatchSize, maxBatchTime, subName, clientID, addMessageIDInHeader);
    } catch (ModuleLoadException e) {
        throw MessagingLogger.ROOT_LOGGER.unableToLoadModule(moduleName, e);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) JNDIDestinationFactory(org.apache.activemq.artemis.jms.bridge.impl.JNDIDestinationFactory) DestinationFactory(org.apache.activemq.artemis.jms.bridge.DestinationFactory) JNDIConnectionFactoryFactory(org.apache.activemq.artemis.jms.bridge.impl.JNDIConnectionFactoryFactory) JMSBridgeImpl(org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl) QualityOfServiceMode(org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode) Properties(java.util.Properties) JNDIDestinationFactory(org.apache.activemq.artemis.jms.bridge.impl.JNDIDestinationFactory) JNDIConnectionFactoryFactory(org.apache.activemq.artemis.jms.bridge.impl.JNDIConnectionFactoryFactory) ConnectionFactoryFactory(org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module)

Example 8 with ModuleIdentifier

use of org.jboss.modules.ModuleIdentifier in project wildfly by wildfly.

the class JMSBridgeService method startBridge.

public void startBridge() throws Exception {
    final Module module;
    if (moduleName != null) {
        ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
        module = Module.getContextModuleLoader().loadModule(moduleID);
    } else {
        module = Module.forClass(JMSBridgeService.class);
    }
    ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
        setJMSBridgePasswordsFromCredentialSource();
        bridge.start();
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
    }
    MessagingLogger.ROOT_LOGGER.startedService("JMS Bridge", bridgeName);
}
Also used : ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module)

Example 9 with ModuleIdentifier

use of org.jboss.modules.ModuleIdentifier in project wildfly by wildfly.

the class ModuleConfig method visit.

@Override
public void visit(ConfigVisitor visitor) {
    if (moduleName != null) {
        ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleName);
        if (moduleName.startsWith(ServiceModuleLoader.MODULE_PREFIX)) {
            ServiceName serviceName = ServiceModuleLoader.moduleServiceName(identifier);
            visitor.addDependency(serviceName, getInjectedModule());
        } else {
            Module dm = visitor.loadModule(identifier);
            getInjectedModule().setValue(new ImmediateValue<Module>(dm));
        }
    } else {
        getInjectedModule().setValue(new ImmediateValue<Module>(visitor.getModule()));
    }
// no children, no need to visit
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module)

Example 10 with ModuleIdentifier

use of org.jboss.modules.ModuleIdentifier in project wildfly by wildfly.

the class WarAnnotationDeploymentProcessor method deploy.

/**
     * Process web annotations.
     */
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    assert warMetaData != null;
    Map<String, WebMetaData> annotationsMetaData = warMetaData.getAnnotationsMetaData();
    if (annotationsMetaData == null) {
        annotationsMetaData = new HashMap<String, WebMetaData>();
        warMetaData.setAnnotationsMetaData(annotationsMetaData);
    }
    Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
    // Process lib/*.jar
    for (final Entry<ResourceRoot, Index> entry : indexes.entrySet()) {
        final Index jarIndex = entry.getValue();
        annotationsMetaData.put(entry.getKey().getRootName(), processAnnotations(jarIndex));
    }
    Map<ModuleIdentifier, CompositeIndex> additionalModelAnnotations = deploymentUnit.getAttachment(Attachments.ADDITIONAL_ANNOTATION_INDEXES_BY_MODULE);
    if (additionalModelAnnotations != null) {
        final List<WebMetaData> additional = new ArrayList<WebMetaData>();
        for (Entry<ModuleIdentifier, CompositeIndex> entry : additionalModelAnnotations.entrySet()) {
            for (Index index : entry.getValue().getIndexes()) {
                additional.add(processAnnotations(index));
            }
        }
        warMetaData.setAdditionalModuleAnnotationsMetadata(additional);
    }
}
Also used : WarMetaData(org.jboss.as.web.common.WarMetaData) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) ArrayList(java.util.ArrayList) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) Index(org.jboss.jandex.Index) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) WebMetaData(org.jboss.metadata.web.spec.WebMetaData)

Aggregations

ModuleIdentifier (org.jboss.modules.ModuleIdentifier)22 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)12 Module (org.jboss.modules.Module)10 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)8 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)6 ModuleLoadException (org.jboss.modules.ModuleLoadException)6 ArrayList (java.util.ArrayList)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)4 ModuleLoader (org.jboss.modules.ModuleLoader)4 ServiceTarget (org.jboss.msc.service.ServiceTarget)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)3 WarMetaData (org.jboss.as.web.common.WarMetaData)3 ServiceName (org.jboss.msc.service.ServiceName)3 IOException (java.io.IOException)2 Driver (java.sql.Driver)2 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)2 Index (org.jboss.jandex.Index)2 Closeable (java.io.Closeable)1