Search in sources :

Example 51 with DeploymentUnit

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

the class SingletonDeploymentDependencyProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
    DeploymentUnit unit = context.getDeploymentUnit();
    DeploymentUnit parent = unit.getParent();
    // If this is a sub-deployment, any configuration will be attached to the parent deployment unit
    SingletonDeploymentConfiguration config = ((parent != null) ? parent : unit).getAttachment(CONFIGURATION_KEY);
    if (config != null) {
        CapabilityServiceSupport support = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        context.addDependency(SingletonServiceNameFactory.SINGLETON_POLICY.getServiceName(support, config.getPolicy()), SingletonDeploymentProcessor.POLICY_KEY);
    }
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 52 with DeploymentUnit

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

the class SingletonDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
    SingletonPolicy policy = context.getAttachment(POLICY_KEY);
    if (policy != null) {
        DeploymentUnit parent = context.getDeploymentUnit().getParent();
        DeploymentUnitPhaseBuilder builder = (parent == null) ? new SingletonDeploymentUnitPhaseBuilder(policy) : new SingletonSubDeploymentUnitPhaseBuilder(parent, context.getPhase().next());
        context.putAttachment(Attachments.DEPLOYMENT_UNIT_PHASE_BUILDER, builder);
    }
}
Also used : SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) DeploymentUnitPhaseBuilder(org.jboss.as.server.deployment.DeploymentUnitPhaseBuilder) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 53 with DeploymentUnit

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

the class ComponentTypeInjectionSource method getResourceValue.

public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION);
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    final Set<ViewDescription> componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot());
    final Iterator<ViewDescription> iterator = componentsForViewName.iterator();
    if (!iterator.hasNext()) {
        throw EeLogger.ROOT_LOGGER.componentNotFound(typeName);
    }
    final ViewDescription description = iterator.next();
    if (iterator.hasNext()) {
        throw EeLogger.ROOT_LOGGER.multipleComponentsFound(typeName);
    }
    //TODO: should ComponentView also be a managed reference factory?
    serviceBuilder.addDependency(description.getServiceName(), ComponentView.class, new ViewManagedReferenceFactory.Injector(injector));
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 54 with DeploymentUnit

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

the class DefaultComponentViewConfigurator method configure.

public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final ProxyMetadataSource proxyReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.PROXY_REFLECTION_INDEX);
    //views
    for (ViewDescription view : description.getViews()) {
        Class<?> viewClass;
        try {
            viewClass = module.getClassLoader().loadClass(view.getViewClassName());
        } catch (ClassNotFoundException e) {
            throw EeLogger.ROOT_LOGGER.cannotLoadViewClass(e, view.getViewClassName(), configuration);
        }
        final ViewConfiguration viewConfiguration;
        final ProxyConfiguration proxyConfiguration = new ProxyConfiguration();
        if (viewClass.getName().startsWith("java.")) {
            proxyConfiguration.setProxyName("org.jboss.proxy.java.lang." + viewClass.getSimpleName() + "$$$view" + PROXY_ID.incrementAndGet());
        } else {
            proxyConfiguration.setProxyName(viewClass.getName() + "$$$view" + PROXY_ID.incrementAndGet());
        }
        proxyConfiguration.setClassLoader(module.getClassLoader());
        proxyConfiguration.setProtectionDomain(viewClass.getProtectionDomain());
        proxyConfiguration.setMetadataSource(proxyReflectionIndex);
        if (view.isSerializable()) {
            proxyConfiguration.addAdditionalInterface(Serializable.class);
            if (view.isUseWriteReplace()) {
                proxyConfiguration.addAdditionalInterface(WriteReplaceInterface.class);
            }
        }
        //we define it in the modules class loader to prevent permgen leaks
        if (viewClass.isInterface()) {
            proxyConfiguration.setSuperClass(Object.class);
            proxyConfiguration.addAdditionalInterface(viewClass);
            viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
        } else {
            proxyConfiguration.setSuperClass(viewClass);
            viewConfiguration = view.createViewConfiguration(viewClass, configuration, new ProxyFactory(proxyConfiguration));
        }
        for (final ViewConfigurator configurator : view.getConfigurators()) {
            configurator.configure(context, configuration, view, viewConfiguration);
        }
        configuration.getViews().add(viewConfiguration);
    }
    configuration.getStartDependencies().add(new DependencyConfigurator<ComponentStartService>() {

        @Override
        public void configureDependency(final ServiceBuilder<?> serviceBuilder, ComponentStartService service) throws DeploymentUnitProcessingException {
            for (final Map.Entry<ServiceName, ServiceBuilder.DependencyType> entry : description.getDependencies().entrySet()) {
                serviceBuilder.addDependency(entry.getValue(), entry.getKey());
            }
        }
    });
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ProxyFactory(org.jboss.invocation.proxy.ProxyFactory) ProxyMetadataSource(org.jboss.as.server.deployment.reflect.ProxyMetadataSource) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ProxyConfiguration(org.jboss.invocation.proxy.ProxyConfiguration) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 55 with DeploymentUnit

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

the class EJBComponentCreateService method getEJBUtilities.

/**
     * @return
     * @deprecated {@link EJBUtilities} is deprecated post 7.2.0.Final version.
     */
@Deprecated
protected EJBUtilities getEJBUtilities() {
    // constructs
    final DeploymentUnit deploymentUnit = getDeploymentUnitInjector().getValue();
    final ServiceController<EJBUtilities> serviceController = (ServiceController<EJBUtilities>) deploymentUnit.getServiceRegistry().getRequiredService(EJBUtilities.SERVICE_NAME);
    return serviceController.getValue();
}
Also used : ServiceController(org.jboss.msc.service.ServiceController) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)271 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)77 Module (org.jboss.modules.Module)58 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)49 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)44 ServiceName (org.jboss.msc.service.ServiceName)44 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)43 ArrayList (java.util.ArrayList)33 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)32 VirtualFile (org.jboss.vfs.VirtualFile)30 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)29 WarMetaData (org.jboss.as.web.common.WarMetaData)25 ServiceTarget (org.jboss.msc.service.ServiceTarget)25 HashMap (java.util.HashMap)24 HashSet (java.util.HashSet)24 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)24 ModuleLoader (org.jboss.modules.ModuleLoader)24 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)20 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)19 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)17