Search in sources :

Example 31 with Module

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

the class UndertowJSRWebSocketDeploymentProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null) {
        return;
    }
    ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(module.getClassLoader());
        WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (metaData == null || metaData.getMergedJBossWebMetaData() == null) {
            return;
        }
        if (!metaData.getMergedJBossWebMetaData().isEnableWebSockets()) {
            return;
        }
        final Set<Class<?>> annotatedEndpoints = new HashSet<>();
        final Set<Class<? extends Endpoint>> endpoints = new HashSet<>();
        final Set<Class<? extends ServerApplicationConfig>> config = new HashSet<>();
        final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
        final List<AnnotationInstance> serverEndpoints = index.getAnnotations(SERVER_ENDPOINT);
        if (serverEndpoints != null) {
            for (AnnotationInstance endpoint : serverEndpoints) {
                if (endpoint.target() instanceof ClassInfo) {
                    ClassInfo clazz = (ClassInfo) endpoint.target();
                    try {
                        Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module);
                        if (!Modifier.isAbstract(moduleClass.getModifiers())) {
                            annotatedEndpoints.add(moduleClass);
                        }
                    } catch (ClassNotFoundException e) {
                        UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketEndpoint(clazz.name().toString(), e);
                    }
                }
            }
        }
        final List<AnnotationInstance> clientEndpoints = index.getAnnotations(CLIENT_ENDPOINT);
        if (clientEndpoints != null) {
            for (AnnotationInstance endpoint : clientEndpoints) {
                if (endpoint.target() instanceof ClassInfo) {
                    ClassInfo clazz = (ClassInfo) endpoint.target();
                    try {
                        Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module);
                        if (!Modifier.isAbstract(moduleClass.getModifiers())) {
                            annotatedEndpoints.add(moduleClass);
                        }
                    } catch (ClassNotFoundException e) {
                        UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketEndpoint(clazz.name().toString(), e);
                    }
                }
            }
        }
        final Set<ClassInfo> subclasses = index.getAllKnownImplementors(SERVER_APPLICATION_CONFIG);
        if (subclasses != null) {
            for (final ClassInfo clazz : subclasses) {
                try {
                    Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module);
                    if (!Modifier.isAbstract(moduleClass.getModifiers())) {
                        config.add((Class) moduleClass);
                    }
                } catch (ClassNotFoundException e) {
                    UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketConfig(clazz.name().toString(), e);
                }
            }
        }
        final Set<ClassInfo> epClasses = index.getAllKnownSubclasses(ENDPOINT);
        if (epClasses != null) {
            for (final ClassInfo clazz : epClasses) {
                try {
                    Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module);
                    if (!Modifier.isAbstract(moduleClass.getModifiers())) {
                        endpoints.add((Class) moduleClass);
                    }
                } catch (ClassNotFoundException e) {
                    UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketConfig(clazz.name().toString(), e);
                }
            }
        }
        WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
        doDeployment(deploymentUnit, webSocketDeploymentInfo, annotatedEndpoints, config, endpoints);
        installWebsockets(phaseContext, webSocketDeploymentInfo);
    } finally {
        Thread.currentThread().setContextClassLoader(oldCl);
    }
}
Also used : WarMetaData(org.jboss.as.web.common.WarMetaData) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) ServerApplicationConfig(javax.websocket.server.ServerApplicationConfig) WebSocketDeploymentInfo(io.undertow.websockets.jsr.WebSocketDeploymentInfo) Endpoint(javax.websocket.Endpoint) ServerEndpoint(javax.websocket.server.ServerEndpoint) ClientEndpoint(javax.websocket.ClientEndpoint) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet) ClassInfo(org.jboss.jandex.ClassInfo)

Example 32 with Module

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

the class WSClassVerificationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final JAXWSDeployment wsDeployment = unit.getAttachment(JAXWS_ENDPOINTS_KEY);
    if (wsDeployment != null) {
        final Module module = unit.getAttachment(Attachments.MODULE);
        final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
        final ClassLoader moduleClassLoader = module.getClassLoader();
        for (AbstractEndpoint pojoEndpoint : wsDeployment.getPojoEndpoints()) {
            verifyEndpoint(pojoEndpoint, moduleClassLoader, deploymentReflectionIndex);
        }
        for (AbstractEndpoint ejbEndpoint : wsDeployment.getEjbEndpoints()) {
            verifyEndpoint(ejbEndpoint, moduleClassLoader, deploymentReflectionIndex);
        }
        verifyApacheCXFModuleDependencyRequirement(unit);
    }
}
Also used : AbstractEndpoint(org.jboss.as.webservices.metadata.model.AbstractEndpoint) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 33 with Module

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

the class WSRefDDProcessor method processWSFeatures.

private static void processWSFeatures(final DeploymentUnit unit, final Set<ResourceInjectionTargetMetaData> injectionTargets, final UnifiedServiceRefMetaData serviceRefUMDM) throws DeploymentUnitProcessingException {
    if (injectionTargets == null || injectionTargets.size() == 0)
        return;
    if (injectionTargets.size() > 1) {
    // TODO: We should validate all the injection targets whether they're compatible.
    // This means all the injection targets must be assignable or equivalent.
    // If there are @Addressing, @RespectBinding or @MTOM annotations present on injection targets,
    // these annotations must be equivalent for all the injection targets.
    }
    final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
    final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
    final String injectionTargetName = injectionTarget.getInjectionTargetName();
    final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
    processAnnotatedElement(fieldOrMethod, serviceRefUMDM);
}
Also used : ResourceInjectionTargetMetaData(org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData) AccessibleObject(java.lang.reflect.AccessibleObject) Module(org.jboss.modules.Module) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 34 with Module

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

the class WSRefDDProcessor method processDescriptorEntries.

@Override
protected List<BindingConfiguration> processDescriptorEntries(final DeploymentUnit unit, final DeploymentDescriptorEnvironment environment, final ResourceInjectionTarget resourceInjectionTarget, final ComponentDescription componentDescription, final ClassLoader classLoader, final DeploymentReflectionIndex deploymentReflectionIndex, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
    final ServiceReferencesMetaData serviceRefsMD = environment.getEnvironment().getServiceReferences();
    if (serviceRefsMD == null) {
        return Collections.<BindingConfiguration>emptyList();
    }
    final List<BindingConfiguration> bindingDescriptions = new LinkedList<BindingConfiguration>();
    for (final ServiceReferenceMetaData serviceRefMD : serviceRefsMD) {
        final UnifiedServiceRefMetaData serviceRefUMDM = getServiceRef(unit, componentDescription, serviceRefMD);
        final Module module = unit.getAttachment(Attachments.MODULE);
        WebServiceManagedReferenceFactory factory = new WebServiceManagedReferenceFactory(serviceRefUMDM, module.getClassLoader());
        final FixedInjectionSource valueSource = new FixedInjectionSource(factory, factory);
        final BindingConfiguration bindingConfiguration = new BindingConfiguration(serviceRefUMDM.getServiceRefName(), valueSource);
        bindingDescriptions.add(bindingConfiguration);
        final String serviceRefTypeName = serviceRefUMDM.getServiceRefType();
        final Class<?> serviceRefType = getClass(classLoader, serviceRefTypeName);
        processInjectionTargets(resourceInjectionTarget, valueSource, classLoader, deploymentReflectionIndex, serviceRefMD, serviceRefType);
    }
    return bindingDescriptions;
}
Also used : FixedInjectionSource(org.jboss.as.ee.component.FixedInjectionSource) ServiceReferencesMetaData(org.jboss.metadata.javaee.spec.ServiceReferencesMetaData) UnifiedServiceRefMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData) Module(org.jboss.modules.Module) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) LinkedList(java.util.LinkedList) ServiceReferenceMetaData(org.jboss.metadata.javaee.spec.ServiceReferenceMetaData)

Example 35 with Module

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

the class WebServiceReferences method initServiceRef.

private static UnifiedServiceRefMetaData initServiceRef(final DeploymentUnit unit, final UnifiedServiceRefMetaData serviceRefUMDM, final String type, final WSRefAnnotationWrapper annotation) throws DeploymentUnitProcessingException {
    // wsdl location
    if (!isEmpty(annotation.wsdlLocation())) {
        serviceRefUMDM.setWsdlFile(annotation.wsdlLocation());
    }
    // ref class type
    final Module module = unit.getAttachment(Attachments.MODULE);
    final Class<?> typeClass = getClass(module, type);
    serviceRefUMDM.setServiceRefType(typeClass.getName());
    // ref service interface
    if (!isEmpty(annotation.value())) {
        serviceRefUMDM.setServiceInterface(annotation.value());
    } else if (Service.class.isAssignableFrom(typeClass)) {
        serviceRefUMDM.setServiceInterface(typeClass.getName());
    } else {
        serviceRefUMDM.setServiceInterface(Service.class.getName());
    }
    return serviceRefUMDM;
}
Also used : Service(javax.xml.ws.Service) Module(org.jboss.modules.Module)

Aggregations

Module (org.jboss.modules.Module)100 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)58 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)28 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)27 ServiceName (org.jboss.msc.service.ServiceName)21 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)19 HashMap (java.util.HashMap)17 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)17 ServiceTarget (org.jboss.msc.service.ServiceTarget)17 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)13 ModuleLoadException (org.jboss.modules.ModuleLoadException)11 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)10 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)9 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)8 Method (java.lang.reflect.Method)7 Map (java.util.Map)7 IOException (java.io.IOException)6 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)6 ContextNames (org.jboss.as.naming.deployment.ContextNames)6