Search in sources :

Example 1 with EEApplicationClasses

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

the class JPAAnnotationProcessor method deploy.

@Override
public void deploy(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);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    // @PersistenceContext
    List<AnnotationInstance> persistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXT_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceContext annotations
    this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceContexts, applicationClasses);
    // @PersistenceContexts
    List<AnnotationInstance> collectionPersistenceContexts = index.getAnnotations(PERSISTENCE_CONTEXTS_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceContext annotations
    processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceContexts, applicationClasses);
    // @PersistenceUnits
    List<AnnotationInstance> collectionPersistenceunits = index.getAnnotations(PERSISTENCE_UNITS_ANNOTATION_NAME);
    processPersistenceAnnotations(deploymentUnit, eeModuleDescription, collectionPersistenceunits, applicationClasses);
    // @PersistenceUnit
    List<AnnotationInstance> persistenceUnits = index.getAnnotations(PERSISTENCE_UNIT_ANNOTATION_NAME);
    // create binding and injection configurations out of the @PersistenceUnit annotations
    this.processPersistenceAnnotations(deploymentUnit, eeModuleDescription, persistenceUnits, applicationClasses);
    // if we found any @PersistenceContext or @PersistenceUnit annotations then mark this as a JPA deployment
    if (!persistenceContexts.isEmpty() || !persistenceUnits.isEmpty() || !collectionPersistenceContexts.isEmpty() || !collectionPersistenceunits.isEmpty()) {
        JPADeploymentMarker.mark(deploymentUnit);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 2 with EEApplicationClasses

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

the class WebComponentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        return;
    }
    final Map<String, ComponentDescription> componentByClass = new HashMap<String, ComponentDescription>();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (moduleDescription == null) {
        //not an EE deployment
        return;
    }
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        componentByClass.put(component.getComponentClassName(), component);
    }
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    final TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
    final Set<String> classes = getAllComponentClasses(deploymentUnit, compositeIndex, warMetaData, tldsMetaData);
    for (String clazz : classes) {
        if (clazz == null || clazz.trim().isEmpty()) {
            continue;
        }
        ComponentDescription description = componentByClass.get(clazz);
        if (description != null) {
            //TODO: make sure the component is a managed bean
            if (!(description.getViews().size() == 1)) {
                throw UndertowLogger.ROOT_LOGGER.wrongComponentType(clazz);
            }
        } else {
            //we do not make the standard tags into components, as there is no need
            if (compositeIndex.getClassByName(DotName.createSimple(clazz)) == null) {
                boolean found = false;
                for (String pack : BUILTIN_TAGLIBS) {
                    if (clazz.startsWith(pack)) {
                        found = true;
                        break;
                    }
                }
                if (found) {
                    continue;
                }
            }
            description = new WebComponentDescription(clazz, clazz, moduleDescription, deploymentUnit.getServiceName(), applicationClassesDescription);
            moduleDescription.addComponent(description);
            deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, description.getStartServiceName());
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) WebComponentDescription(org.jboss.as.web.common.WebComponentDescription) HashMap(java.util.HashMap) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) WarMetaData(org.jboss.as.web.common.WarMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) WebComponentDescription(org.jboss.as.web.common.WebComponentDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 3 with EEApplicationClasses

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

the class WebIntegrationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription module = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData == null) {
        WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no war metadata found");
        return;
    }
    JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
    if (webMetaData == null) {
        WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no merged web metadata found");
        return;
    }
    if (!WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
        if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
            createDependency(deploymentUnit, warMetaData);
        }
        return;
    }
    createDependency(deploymentUnit, warMetaData);
    List<ListenerMetaData> listeners = webMetaData.getListeners();
    if (listeners == null) {
        listeners = new ArrayList<ListenerMetaData>();
        webMetaData.setListeners(listeners);
    } else {
        //if the weld servlet listener is present remove it
        //this should allow wars to be portable between AS7 and servlet containers
        final ListIterator<ListenerMetaData> iterator = listeners.listIterator();
        while (iterator.hasNext()) {
            final ListenerMetaData listener = iterator.next();
            if (listener.getListenerClass().trim().equals(WELD_SERVLET_LISTENER)) {
                WeldLogger.DEPLOYMENT_LOGGER.debugf("Removing weld servlet listener %s from web config, as it is not needed in EE6 environments", WELD_SERVLET_LISTENER);
                iterator.remove();
                break;
            }
        }
    }
    listeners.add(0, INITIAL_LISTENER_METADATA);
    listeners.add(TERMINAL_LISTENER_MEDATADA);
    //These listeners use resource injection, so they need to be components
    registerAsComponent(WELD_INITIAL_LISTENER, deploymentUnit);
    registerAsComponent(WELD_TERMINAL_LISTENER, deploymentUnit);
    deploymentUnit.addToAttachmentList(ExpressionFactoryWrapper.ATTACHMENT_KEY, WeldJspExpressionFactoryWrapper.INSTANCE);
    if (webMetaData.getContextParams() == null) {
        webMetaData.setContextParams(new ArrayList<ParamValueMetaData>());
    }
    final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
    setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_FORWARD);
    setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_INCLUDE);
    if (webMetaData.getFilterMappings() != null) {
        // register ConversationFilter
        boolean filterMappingFound = false;
        for (FilterMappingMetaData mapping : webMetaData.getFilterMappings()) {
            if (CONVERSATION_FILTER_NAME.equals(mapping.getFilterName())) {
                filterMappingFound = true;
                break;
            }
        }
        if (filterMappingFound) {
            // otherwise WeldListener will take care of conversation context activation
            boolean filterFound = false;
            // register ConversationFilter
            if (webMetaData.getFilters() == null) {
                webMetaData.setFilters(new FiltersMetaData());
            }
            for (FilterMetaData filter : webMetaData.getFilters()) {
                if (CONVERSATION_FILTER_CLASS.equals(filter.getFilterClass())) {
                    filterFound = true;
                    break;
                }
            }
            if (!filterFound) {
                webMetaData.getFilters().add(conversationFilterMetadata);
                registerAsComponent(CONVERSATION_FILTER_CLASS, deploymentUnit);
                webMetaData.getContextParams().add(CONVERSATION_FILTER_INITIALIZED);
            }
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) FilterMetaData(org.jboss.metadata.web.spec.FilterMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) FiltersMetaData(org.jboss.metadata.web.spec.FiltersMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ListenerMetaData(org.jboss.metadata.web.spec.ListenerMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) FilterMappingMetaData(org.jboss.metadata.web.spec.FilterMappingMetaData)

Example 4 with EEApplicationClasses

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

the class ApplicationClientManifestProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
        return;
    }
    final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Manifest manifest = root.getAttachment(Attachments.MANIFEST);
    if (manifest != null) {
        Attributes main = manifest.getMainAttributes();
        if (main != null) {
            String mainClass = main.getValue("Main-Class");
            if (mainClass != null && !mainClass.isEmpty()) {
                try {
                    final Class<?> clazz = module.getClassLoader().loadClass(mainClass);
                    deploymentUnit.putAttachment(AppClientAttachments.MAIN_CLASS, clazz);
                    final ApplicationClientComponentDescription description = new ApplicationClientComponentDescription(clazz.getName(), moduleDescription, deploymentUnit.getServiceName(), applicationClasses);
                    moduleDescription.addComponent(description);
                    deploymentUnit.putAttachment(AppClientAttachments.APPLICATION_CLIENT_COMPONENT, description);
                    final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
                    if (environment != null) {
                        DescriptorEnvironmentLifecycleMethodProcessor.handleMethods(environment, moduleDescription, mainClass);
                    }
                } catch (ClassNotFoundException e) {
                    throw AppClientLogger.ROOT_LOGGER.cannotLoadAppClientMainClass(e);
                }
            }
        }
    }
}
Also used : ApplicationClientComponentDescription(org.jboss.as.appclient.component.ApplicationClientComponentDescription) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) Attributes(java.util.jar.Attributes) Module(org.jboss.modules.Module) Manifest(java.util.jar.Manifest) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 5 with EEApplicationClasses

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

the class InterceptorAnnotationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final Collection<ComponentDescription> componentConfigurations = eeModuleDescription.getComponentDescriptions();
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    if (MetadataCompleteMarker.isMetadataComplete(deploymentUnit)) {
        return;
    }
    if (componentConfigurations == null || componentConfigurations.isEmpty()) {
        return;
    }
    for (final ComponentDescription description : componentConfigurations) {
        processComponentConfig(applicationClasses, deploymentReflectionIndex, description, deploymentUnit);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Aggregations

EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)24 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)19 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)18 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 Module (org.jboss.modules.Module)9 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)7 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)6 HashMap (java.util.HashMap)5 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)5 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)5 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)4 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)4 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)4 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)3 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)3 ComponentTypeIdentityInterceptorFactory (org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory)3 AnnotationInstance (org.jboss.jandex.AnnotationInstance)3