Search in sources :

Example 61 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class EEJndiViewExtension method handleModule.

private void handleModule(final JndiViewExtensionContext context, final DeploymentUnit deploymentUnit, final ModelNode modulesNode, final ServiceRegistry serviceRegistry) throws OperationFailedException {
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    // If it isn't an EE module, just return
    if (moduleDescription == null) {
        return;
    }
    final String appName = moduleDescription.getApplicationName();
    final String moduleName = moduleDescription.getModuleName();
    final ModelNode moduleNode = modulesNode.get(moduleDescription.getModuleName());
    final ServiceName moduleContextName = ContextNames.contextServiceNameOfModule(appName, moduleName);
    final ServiceController<?> moduleContextController = serviceRegistry.getService(moduleContextName);
    if (moduleContextController != null) {
        final NamingStore moduleStore = NamingStore.class.cast(moduleContextController.getValue());
        try {
            context.addEntries(moduleNode.get("java:module"), new NamingContext(moduleStore, null));
        } catch (NamingException e) {
            throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:module", appName, moduleName)));
        }
        final Collection<ComponentDescription> componentDescriptions = moduleDescription.getComponentDescriptions();
        for (ComponentDescription componentDescription : componentDescriptions) {
            final String componentName = componentDescription.getComponentName();
            final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(appName, moduleName, componentName);
            final ServiceController<?> compContextController = serviceRegistry.getService(compContextServiceName);
            if (compContextController != null) {
                final ModelNode componentNode = moduleNode.get("components").get(componentName);
                final NamingStore compStore = NamingStore.class.cast(compContextController.getValue());
                try {
                    context.addEntries(componentNode.get("java:comp"), new NamingContext(compStore, null));
                } catch (NamingException e) {
                    throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:comp", appName, moduleName, componentName)));
                }
            }
        }
    }
}
Also used : NamingStore(org.jboss.as.naming.NamingStore) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) OperationFailedException(org.jboss.as.controller.OperationFailedException) NamingException(javax.naming.NamingException) ModelNode(org.jboss.dmr.ModelNode) NamingContext(org.jboss.as.naming.NamingContext)

Example 62 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class AbstractEEAnnotationProcessor method deploy.

public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    if (index == null || eeModuleDescription == null) {
        return;
    }
    final List<ClassAnnotationInformationFactory> factories = annotationInformationFactories();
    for (final ClassAnnotationInformationFactory factory : factories) {
        final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, propertyReplacer);
        for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
            EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey());
            clazz.addAnnotationInformation(entry.getValue());
        }
    }
    afterAnnotationsProcessed(phaseContext, deploymentUnit);
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map)

Example 63 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class ApplicationContextProcessor method deploy.

/**
     * Add a ContextService for this module.
     *
     * @param phaseContext the deployment unit context
     * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
     */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null) {
        return;
    }
    EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final ServiceName applicationContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
    final NamingStoreService contextService = new NamingStoreService(true);
    serviceTarget.addService(applicationContextServiceName, contextService).install();
    final BinderService applicationNameBinder = new BinderService("AppName");
    final ServiceName appNameServiceName = applicationContextServiceName.append("AppName");
    serviceTarget.addService(appNameServiceName, applicationNameBinder).addDependency(applicationContextServiceName, ServiceBasedNamingStore.class, applicationNameBinder.getNamingStoreInjector()).addInjection(applicationNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getApplicationName()))).install();
    deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, appNameServiceName);
    deploymentUnit.putAttachment(Attachments.APPLICATION_CONTEXT_CONFIG, applicationContextServiceName);
}
Also used : NamingStoreService(org.jboss.as.naming.service.NamingStoreService) BinderService(org.jboss.as.naming.service.BinderService) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 64 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class InApplicationClientBindingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    //if this is a war we need to bind to the modules comp namespace
    if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
        final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
        bindServices(deploymentUnit, serviceTarget, moduleContextServiceName);
    }
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        if (component.getNamingMode() == ComponentNamingMode.CREATE) {
            final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
            bindServices(deploymentUnit, serviceTarget, compContextServiceName);
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 65 with EEModuleDescription

use of org.jboss.as.ee.component.EEModuleDescription in project wildfly by wildfly.

the class ModuleContextProcessor method deploy.

/**
     * Add a ContextService for this module.
     *
     * @param phaseContext the deployment unit context
     * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
     */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    EEModuleDescription moduleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final ServiceName appContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
    final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
    final NamingStoreService contextService = new NamingStoreService(true);
    serviceTarget.addService(moduleContextServiceName, contextService).install();
    final BinderService moduleNameBinder = new BinderService("ModuleName");
    final ServiceName moduleNameServiceName = moduleContextServiceName.append("ModuleName");
    serviceTarget.addService(moduleNameServiceName, moduleNameBinder).addInjection(moduleNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getModuleName()))).addDependency(moduleContextServiceName, ServiceBasedNamingStore.class, moduleNameBinder.getNamingStoreInjector()).install();
    deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, moduleNameServiceName);
    deploymentUnit.putAttachment(MODULE_CONTEXT_CONFIG, moduleContextServiceName);
    final InjectedEENamespaceContextSelector selector = new InjectedEENamespaceContextSelector();
    phaseContext.addDependency(appContextServiceName, NamingStore.class, selector.getAppContextInjector());
    phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getModuleContextInjector());
    phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getCompContextInjector());
    phaseContext.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getJbossContextInjector());
    phaseContext.addDependency(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getExportedContextInjector());
    phaseContext.addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getGlobalContextInjector());
    moduleDescription.setNamespaceContextSelector(selector);
    final Set<ServiceName> serviceNames = new HashSet<ServiceName>();
    serviceNames.add(appContextServiceName);
    serviceNames.add(moduleContextServiceName);
    serviceNames.add(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
    serviceNames.add(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
    // add the arquillian setup action, so the module namespace is available in arquillian tests
    final JavaNamespaceSetup setupAction = new JavaNamespaceSetup(selector, deploymentUnit.getServiceName());
    deploymentUnit.addToAttachmentList(SETUP_ACTIONS, setupAction);
    deploymentUnit.addToAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS, setupAction);
    deploymentUnit.putAttachment(Attachments.JAVA_NAMESPACE_SETUP_ACTION, setupAction);
}
Also used : NamingStoreService(org.jboss.as.naming.service.NamingStoreService) BinderService(org.jboss.as.naming.service.BinderService) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) HashSet(java.util.HashSet)

Aggregations

EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)90 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)77 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)44 Module (org.jboss.modules.Module)27 ServiceName (org.jboss.msc.service.ServiceName)21 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)18 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)17 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)16 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)11 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)11 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)10 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 AnnotationInstance (org.jboss.jandex.AnnotationInstance)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)8 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)8 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)7 Map (java.util.Map)6