Search in sources :

Example 41 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit 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));
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 42 with DeploymentUnit

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

the class DataSourceDefinitionInjectionSource method getResourceValue.

public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final String poolName = uniqueName(context, jndiName);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName);
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    try {
        final Class<?> clazz = module.getClassLoader().loadClass(className);
        clearUnknownProperties(reflectionIndex, clazz, properties);
        populateProperties(reflectionIndex, clazz, properties);
        DsSecurityImpl dsSecurity = new DsSecurityImpl(user, password, null, false, null, null);
        if (XADataSource.class.isAssignableFrom(clazz) && transactional) {
            final DsXaPoolImpl xaPool = new DsXaPoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : Integer.valueOf(minPoolSize), initialPoolSize < 0 ? Defaults.INITIAL_POOL_SIZE : Integer.valueOf(initialPoolSize), maxPoolSize < 1 ? Defaults.MAX_POOL_SIZE : Integer.valueOf(maxPoolSize), Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL, Boolean.FALSE, null, Defaults.FAIR, null);
            final ModifiableXaDataSource dataSource = new ModifiableXaDataSource(transactionIsolation(), null, dsSecurity, null, null, null, null, null, null, poolName, true, jndiName, false, false, Defaults.CONNECTABLE, Defaults.TRACKING, Defaults.MCP, Defaults.ENLISTMENT_TRACE, properties, className, null, null, xaPool, null);
            final XaDataSourceService xds = new XaDataSourceService(bindInfo.getBinderServiceName().getCanonicalName(), bindInfo, module.getClassLoader());
            xds.getDataSourceConfigInjector().inject(dataSource);
            startDataSource(xds, bindInfo, eeModuleDescription, context, phaseContext.getServiceTarget(), serviceBuilder, injector, support);
        } else {
            final DsPoolImpl commonPool = new DsPoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : Integer.valueOf(minPoolSize), initialPoolSize < 0 ? Defaults.INITIAL_POOL_SIZE : Integer.valueOf(initialPoolSize), maxPoolSize < 1 ? Defaults.MAX_POOL_SIZE : Integer.valueOf(maxPoolSize), Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, Boolean.FALSE, null, Defaults.FAIR, null);
            final ModifiableDataSource dataSource = new ModifiableDataSource(url, null, className, null, transactionIsolation(), properties, null, dsSecurity, null, null, null, null, null, false, poolName, true, jndiName, Defaults.SPY, Defaults.USE_CCM, transactional, Defaults.CONNECTABLE, Defaults.TRACKING, Defaults.MCP, Defaults.ENLISTMENT_TRACE, commonPool);
            final LocalDataSourceService ds = new LocalDataSourceService(bindInfo.getBinderServiceName().getCanonicalName(), bindInfo, module.getClassLoader());
            ds.getDataSourceConfigInjector().inject(dataSource);
            startDataSource(ds, bindInfo, eeModuleDescription, context, phaseContext.getServiceTarget(), serviceBuilder, injector, support);
        }
    } catch (Exception e) {
        throw new DeploymentUnitProcessingException(e);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XADataSource(javax.sql.XADataSource) ModifiableXaDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableXaDataSource) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) XaDataSourceService(org.jboss.as.connector.subsystems.datasources.XaDataSourceService) LocalDataSourceService(org.jboss.as.connector.subsystems.datasources.LocalDataSourceService) ModifiableDataSource(org.jboss.as.connector.subsystems.datasources.ModifiableDataSource) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DsSecurityImpl(org.jboss.as.connector.metadata.ds.DsSecurityImpl) DsPoolImpl(org.jboss.jca.common.metadata.ds.DsPoolImpl) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) DsXaPoolImpl(org.jboss.jca.common.metadata.ds.DsXaPoolImpl) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 43 with DeploymentUnit

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

the class DriverProcessor method deploy.

/**
 * {@inheritDoc}
 */
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
    if (module != null && servicesAttachment != null) {
        final ModuleClassLoader classLoader = module.getClassLoader();
        final List<String> driverNames = servicesAttachment.getServiceImplementations(Driver.class.getName());
        int idx = 0;
        for (String driverClassName : driverNames) {
            try {
                final Class<? extends Driver> driverClass = classLoader.loadClass(driverClassName).asSubclass(Driver.class);
                final Constructor<? extends Driver> constructor = driverClass.getConstructor();
                final Driver driver = constructor.newInstance();
                final int majorVersion = driver.getMajorVersion();
                final int minorVersion = driver.getMinorVersion();
                final boolean compliant = driver.jdbcCompliant();
                if (compliant) {
                    DEPLOYER_JDBC_LOGGER.deployingCompliantJdbcDriver(driverClass, majorVersion, minorVersion);
                } else {
                    DEPLOYER_JDBC_LOGGER.deployingNonCompliantJdbcDriver(driverClass, majorVersion, minorVersion);
                }
                String driverName = deploymentUnit.getName();
                if ((driverName.contains(".") && !driverName.endsWith(".jar")) || driverNames.size() != 1) {
                    driverName += "_" + driverClassName + "_" + majorVersion + "_" + minorVersion;
                }
                InstalledDriver driverMetadata = new InstalledDriver(driverName, driverClass.getName(), null, null, majorVersion, minorVersion, compliant);
                DriverService driverService = new DriverService(driverMetadata, driver);
                phaseContext.getServiceTarget().addService(ServiceName.JBOSS.append("jdbc-driver", driverName.replaceAll("\\.", "_")), driverService).addDependency(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, DriverRegistry.class, driverService.getDriverRegistryServiceInjector()).setInitialMode(Mode.ACTIVE).install();
                if (idx == 0 && driverNames.size() != 1) {
                    // create short name driver service
                    // reset driverName to the deployment unit name
                    driverName = deploymentUnit.getName();
                    driverMetadata = new InstalledDriver(driverName, driverClass.getName(), null, null, majorVersion, minorVersion, compliant);
                    driverService = new DriverService(driverMetadata, driver);
                    phaseContext.getServiceTarget().addService(ServiceName.JBOSS.append("jdbc-driver", driverName.replaceAll("\\.", "_")), driverService).addDependency(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, DriverRegistry.class, driverService.getDriverRegistryServiceInjector()).setInitialMode(Mode.ACTIVE).install();
                }
                idx++;
            } catch (Throwable e) {
                DEPLOYER_JDBC_LOGGER.cannotInstantiateDriverClass(driverClassName, e);
            }
        }
    }
}
Also used : InstalledDriver(org.jboss.as.connector.services.driver.InstalledDriver) ServicesAttachment(org.jboss.as.server.deployment.ServicesAttachment) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) InstalledDriver(org.jboss.as.connector.services.driver.InstalledDriver) Driver(java.sql.Driver) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DriverService(org.jboss.as.connector.services.driver.DriverService)

Example 44 with DeploymentUnit

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

the class StructureDriverProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (ResourceRoot resourceRoot : resourceRoots) {
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) {
            DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName());
            break;
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 45 with DeploymentUnit

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

the class RaDeploymentParsingProcessor method deploy.

/**
 * Process a deployment for standard ra deployment 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 {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final boolean resolveProperties = Util.shouldResolveSpec(deploymentUnit);
    final VirtualFile file = deploymentRoot.getRoot();
    if (file == null || !file.exists())
        return;
    final String deploymentRootName = file.getName().toLowerCase(Locale.ENGLISH);
    if (!deploymentRootName.endsWith(".rar")) {
        return;
    }
    final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CONNECTOR_DEPLOYMENT_DESCRIPTOR);
    String prefix = "";
    if (deploymentUnit.getParent() != null) {
        prefix = deploymentUnit.getParent().getName() + "#";
    }
    String deploymentName = prefix + file.getName();
    ConnectorXmlDescriptor xmlDescriptor = process(resolveProperties, file, alternateDescriptor, deploymentName);
    phaseContext.getDeploymentUnit().putAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ConnectorXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)359 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)84 Module (org.jboss.modules.Module)70 ServiceName (org.jboss.msc.service.ServiceName)62 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)56 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)56 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)47 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)45 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)40 VirtualFile (org.jboss.vfs.VirtualFile)39 ArrayList (java.util.ArrayList)37 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)37 ModuleLoader (org.jboss.modules.ModuleLoader)35 ServiceTarget (org.jboss.msc.service.ServiceTarget)34 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)33 WarMetaData (org.jboss.as.web.common.WarMetaData)31 HashMap (java.util.HashMap)30 HashSet (java.util.HashSet)30 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)20 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)20