Search in sources :

Example 51 with DeploymentUnitProcessingException

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

the class SingletonComponentDescription method createConfiguration.

@Override
public ComponentConfiguration createConfiguration(final ClassReflectionIndex classIndex, final ClassLoader moduleClassLoader, final ModuleLoader moduleLoader) {
    ComponentConfiguration singletonComponentConfiguration = new ComponentConfiguration(this, classIndex, moduleClassLoader, moduleLoader);
    // setup the component create service
    singletonComponentConfiguration.setComponentCreateServiceFactory(new SingletonComponentCreateServiceFactory(this.isInitOnStartup(), dependsOn));
    if (isExplicitSecurityDomainConfigured()) {
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
                String contextID = deploymentUnit.getName();
                if (deploymentUnit.getParent() != null) {
                    contextID = deploymentUnit.getParent().getName() + "!" + contextID;
                }
                EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) description;
                if (isSecurityDomainKnown()) {
                    final HashMap<Integer, InterceptorFactory> elytronInterceptorFactories = getElytronInterceptorFactories(contextID, ejbComponentDescription.isEnableJacc());
                    elytronInterceptorFactories.forEach((priority, elytronInterceptorFactory) -> configuration.addPostConstructInterceptor(elytronInterceptorFactory, priority));
                } else {
                    configuration.addPostConstructInterceptor(new SecurityContextInterceptorFactory(isExplicitSecurityDomainConfigured(), false, contextID), InterceptorOrder.View.SECURITY_CONTEXT);
                }
            }
        });
    }
    getConfigurators().add(new ComponentConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
            if (isInitOnStartup()) {
                final StartupCountdown startupCountdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN);
                configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new StartupCountDownInterceptor(startupCountdown)), InterceptorOrder.ComponentPostConstruct.STARTUP_COUNTDOWN_INTERCEPTOR);
            }
        }
    });
    if (getTransactionManagementType().equals(TransactionManagementType.CONTAINER)) {
        //we need to add the transaction interceptor to the lifecycle methods
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                final EEApplicationClasses applicationClasses = context.getDeploymentUnit().getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
                InterceptorClassDescription interceptorConfig = ComponentDescription.mergeInterceptorConfig(configuration.getComponentClass(), applicationClasses.getClassByName(description.getComponentClassName()), description, MetadataCompleteMarker.isMetadataComplete(context.getDeploymentUnit()));
                if (interceptorConfig.getPostConstruct() != null) {
                    configuration.addPostConstructInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPostConstruct(), true), InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                }
                configuration.addPreDestroyInterceptor(new LifecycleCMTTxInterceptor.Factory(interceptorConfig.getPreDestroy(), true), InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                configuration.addTimeoutViewInterceptor(TimerCMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR);
            }
        });
    } else {
        // add the bmt interceptor
        getConfigurators().add(new ComponentConfigurator() {

            @Override
            public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
                configuration.addPostConstructInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPostConstruct.TRANSACTION_INTERCEPTOR);
                configuration.addPreDestroyInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.ComponentPreDestroy.TRANSACTION_INTERCEPTOR);
                // add the bmt interceptor factory
                configuration.addComponentInterceptor(EjbBMTInterceptor.FACTORY, InterceptorOrder.Component.BMT_TRANSACTION_INTERCEPTOR, false);
            }
        });
    }
    return singletonComponentConfiguration;
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ConcurrencyManagementType(javax.ejb.ConcurrencyManagementType) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) LifecycleCMTTxInterceptor(org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor) HashMap(java.util.HashMap) WriteReplaceInterface(org.jboss.as.ee.component.serialization.WriteReplaceInterface) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) StatelessWriteReplaceInterceptor(org.jboss.as.ejb3.component.session.StatelessWriteReplaceInterceptor) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InterceptorOrder(org.jboss.as.ee.component.interceptors.InterceptorOrder) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) Method(java.lang.reflect.Method) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ModuleLoader(org.jboss.modules.ModuleLoader) MetadataCompleteMarker(org.jboss.as.ee.metadata.MetadataCompleteMarker) ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ContainerManagedConcurrencyInterceptorFactory(org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptorFactory) StartupCountdown(org.jboss.as.ee.component.deployers.StartupCountdown) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) TimerCMTTxInterceptor(org.jboss.as.ejb3.tx.TimerCMTTxInterceptor) EjbBMTInterceptor(org.jboss.as.ejb3.tx.EjbBMTInterceptor) Attachments(org.jboss.as.ee.component.Attachments) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) List(java.util.List) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EjbLogger(org.jboss.as.ejb3.logging.EjbLogger) ServiceName(org.jboss.msc.service.ServiceName) ViewDescription(org.jboss.as.ee.component.ViewDescription) Collections(java.util.Collections) TransactionManagementType(javax.ejb.TransactionManagementType) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ComponentConfigurator(org.jboss.as.ee.component.ComponentConfigurator) HashMap(java.util.HashMap) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) ContainerManagedConcurrencyInterceptorFactory(org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptorFactory) StatelessRemoteViewInstanceFactory(org.jboss.as.ejb3.component.session.StatelessRemoteViewInstanceFactory) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) SecurityContextInterceptorFactory(org.jboss.as.ejb3.security.SecurityContextInterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) StartupCountdown(org.jboss.as.ee.component.deployers.StartupCountdown)

Example 52 with DeploymentUnitProcessingException

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

the class SingletonComponentDescription method addViewSerializationInterceptor.

private void addViewSerializationInterceptor(final ViewDescription view) {
    view.setSerializable(true);
    view.setUseWriteReplace(true);
    view.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
            ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class);
            for (Method method : classIndex.getMethods()) {
                configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE);
            }
        }
    });
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) Method(java.lang.reflect.Method) WriteReplaceInterface(org.jboss.as.ee.component.serialization.WriteReplaceInterface) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 53 with DeploymentUnitProcessingException

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

the class StatefulComponentDescription method addViewSerializationInterceptor.

private void addViewSerializationInterceptor(final ViewDescription view) {
    view.setSerializable(true);
    view.setUseWriteReplace(true);
    view.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
            ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class);
            for (Method method : (Collection<Method>) classIndex.getMethods()) {
                configuration.addClientInterceptor(method, new StatefulWriteReplaceInterceptor.Factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE);
            }
        }
    });
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) ComponentTypeIdentityInterceptorFactory(org.jboss.as.ejb3.component.interceptors.ComponentTypeIdentityInterceptorFactory) InterceptorFactory(org.jboss.invocation.InterceptorFactory) ImmediateInterceptorFactory(org.jboss.invocation.ImmediateInterceptorFactory) ComponentInstanceInterceptorFactory(org.jboss.as.ee.component.ComponentInstanceInterceptorFactory) Method(java.lang.reflect.Method) WriteReplaceInterface(org.jboss.as.ee.component.serialization.WriteReplaceInterface) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 54 with DeploymentUnitProcessingException

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

the class WSIntegrationProcessorJAXWS_JMS method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
        return;
    }
    final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
    // TODO: how about @WebServiceProvider JMS based endpoints?
    //group @WebService annotations in the deployment by wsdl contract location
    Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
    for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
        final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
        final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
        final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
        //support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
        if (wsdlLocation != null && port != null && service != null) {
            String key = wsdlLocation.asString();
            List<AnnotationInstance> annotations = map.get(key);
            if (annotations == null) {
                annotations = new LinkedList<AnnotationInstance>();
                map.put(key, annotations);
            }
            annotations.add(webServiceAnnotation);
        }
    }
    //extract SOAP-over-JMS 1.0 bindings
    List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
    if (!map.isEmpty()) {
        for (String wsdlLocation : map.keySet()) {
            try {
                final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
                if (resourceRoot == null)
                    continue;
                final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
                final URL url = wsdlLocationFile.toURL();
                SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
                for (AnnotationInstance ai : map.get(wsdlLocation)) {
                    String port = ai.value(PORT_NAME).asString();
                    String service = ai.value(SERVICE_NAME).asString();
                    AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
                    String tns = targetNS != null ? targetNS.asString() : null;
                    QName serviceName = new QName(tns, service);
                    QName portName = new QName(tns, port);
                    String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
                    if (soapAddress != null) {
                        ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
                        String beanClassName = webServiceClassInfo.name().toString();
                        //service name ?
                        list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
                    }
                }
            } catch (Exception ignore) {
                WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
            }
        }
    }
    unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) JMSEndpointsMetaData(org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData) LinkedList(java.util.LinkedList) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) JMSEndpointMetaData(org.jboss.wsf.spi.metadata.jms.JMSEndpointMetaData) AnnotationValue(org.jboss.jandex.AnnotationValue) LinkedList(java.util.LinkedList) AttachmentList(org.jboss.as.server.deployment.AttachmentList) List(java.util.List) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SOAPAddressWSDLParser(org.jboss.ws.common.deployment.SOAPAddressWSDLParser) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 55 with DeploymentUnitProcessingException

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

the class MessagingXmlParsingDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Set<VirtualFile> files = messageDestinations(deploymentUnit);
    final XMLMapper mapper = XMLMapper.Factory.create();
    final MessagingDeploymentParser_1_0 messagingDeploymentParser_1_0 = new MessagingDeploymentParser_1_0(JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
    mapper.registerRootElement(ROOT_1_0, messagingDeploymentParser_1_0);
    mapper.registerRootElement(ROOT_NO_NAMESPACE, messagingDeploymentParser_1_0);
    for (final VirtualFile file : files) {
        InputStream xmlStream = null;
        try {
            final File f = file.getPhysicalFile();
            xmlStream = new FileInputStream(f);
            try {
                final XMLInputFactory inputFactory = INPUT_FACTORY;
                setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
                setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
                final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(xmlStream);
                final ParseResult result = new ParseResult();
                try {
                    mapper.parseDocument(result, streamReader);
                    deploymentUnit.addToAttachmentList(MessagingAttachments.PARSE_RESULT, result);
                } finally {
                    safeClose(streamReader, f.getAbsolutePath());
                }
            } catch (XMLStreamException e) {
                throw MessagingLogger.ROOT_LOGGER.couldNotParseDeployment(f.getPath(), e);
            }
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e.getMessage(), e);
        } finally {
            VFSUtils.safeClose(xmlStream);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLMapper(org.jboss.staxmapper.XMLMapper) XMLStreamException(javax.xml.stream.XMLStreamException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) File(java.io.File) VirtualFile(org.jboss.vfs.VirtualFile) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Aggregations

DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)95 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)45 Module (org.jboss.modules.Module)28 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)26 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)26 VirtualFile (org.jboss.vfs.VirtualFile)22 InputStream (java.io.InputStream)20 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)18 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)18 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)18 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)17 ViewDescription (org.jboss.as.ee.component.ViewDescription)16 Method (java.lang.reflect.Method)15 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)15 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)15 ServiceName (org.jboss.msc.service.ServiceName)15 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)14 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)12 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)12