Search in sources :

Example 1 with DeploymentAspect

use of org.jboss.wsf.spi.deployment.DeploymentAspect in project wildfly by wildfly.

the class WSDeploymentAspectParser method parseDeploymentAspect.

private static DeploymentAspect parseDeploymentAspect(XMLStreamReader reader, ClassLoader loader) throws XMLStreamException {
    String deploymentAspectClass = reader.getAttributeValue(null, CLASS);
    if (deploymentAspectClass == null) {
        throw WSLogger.ROOT_LOGGER.missingDeploymentAspectClassAttribute();
    }
    DeploymentAspect deploymentAspect = null;
    try {
        @SuppressWarnings("unchecked") Class<? extends DeploymentAspect> clazz = (Class<? extends DeploymentAspect>) Class.forName(deploymentAspectClass, true, loader);
        ClassLoader orig = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
        try {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(loader);
            deploymentAspect = clazz.newInstance();
        } finally {
            WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(orig);
        }
    } catch (Exception e) {
        throw WSLogger.ROOT_LOGGER.cannotInstantiateDeploymentAspect(e, deploymentAspectClass);
    }
    String priority = reader.getAttributeValue(null, PRIORITY);
    if (priority != null) {
        deploymentAspect.setRelativeOrder(Integer.parseInt(priority.trim()));
    }
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (match(reader, NS, DEPLOYMENT_ASPECT)) {
                        return deploymentAspect;
                    } else {
                        throw WSLogger.ROOT_LOGGER.unexpectedEndTag(reader.getLocalName());
                    }
                }
            case XMLStreamConstants.START_ELEMENT:
                {
                    if (match(reader, NS, PROPERTY)) {
                        parseProperty(reader, deploymentAspect, loader);
                    } else {
                        throw WSLogger.ROOT_LOGGER.unexpectedElement(reader.getLocalName());
                    }
                }
        }
    }
    throw WSLogger.ROOT_LOGGER.unexpectedEndOfDocument();
}
Also used : DeploymentAspect(org.jboss.wsf.spi.deployment.DeploymentAspect) WebServiceException(javax.xml.ws.WebServiceException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 2 with DeploymentAspect

use of org.jboss.wsf.spi.deployment.DeploymentAspect in project wildfly by wildfly.

the class DeploymentAspectsProvider method getSortedDeploymentAspects.

public static synchronized List<DeploymentAspect> getSortedDeploymentAspects() {
    if (aspects == null) {
        final List<DeploymentAspect> deploymentAspects = new LinkedList<DeploymentAspect>();
        final ClassLoaderProvider provider = ClassLoaderProvider.getDefaultProvider();
        final ClassLoader cl = provider.getServerIntegrationClassLoader();
        deploymentAspects.addAll(getDeploymentAspects(cl, "/META-INF/stack-agnostic-deployment-aspects.xml"));
        deploymentAspects.addAll(getDeploymentAspects(cl, "/META-INF/stack-specific-deployment-aspects.xml"));
        aspects = DeploymentAspectSorter.getInstance().sort(deploymentAspects);
    }
    return aspects;
}
Also used : DeploymentAspect(org.jboss.wsf.spi.deployment.DeploymentAspect) ClassLoaderProvider(org.jboss.wsf.spi.classloading.ClassLoaderProvider) LinkedList(java.util.LinkedList)

Example 3 with DeploymentAspect

use of org.jboss.wsf.spi.deployment.DeploymentAspect in project wildfly by wildfly.

the class EndpointPublisherImpl method getReplacedDeploymentAspects.

private static synchronized List<DeploymentAspect> getReplacedDeploymentAspects() {
    if (depAspects == null) {
        depAspects = new LinkedList<DeploymentAspect>();
        List<DeploymentAspect> serverAspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
        for (DeploymentAspect aspect : serverAspects) {
            if (aspect instanceof EndpointHandlerDeploymentAspect) {
                depAspects.add(aspect);
                //add another aspect to set InvocationHandlerJAXWS to each endpoint
                ForceJAXWSInvocationHandlerDeploymentAspect handlerAspect = new ForceJAXWSInvocationHandlerDeploymentAspect();
                depAspects.add(handlerAspect);
            } else {
                depAspects.add(aspect);
            }
        }
    }
    return depAspects;
}
Also used : EndpointHandlerDeploymentAspect(org.jboss.ws.common.deployment.EndpointHandlerDeploymentAspect) AbstractDeploymentAspect(org.jboss.ws.common.integration.AbstractDeploymentAspect) EndpointServiceDeploymentAspect(org.jboss.as.webservices.deployers.EndpointServiceDeploymentAspect) DeploymentAspect(org.jboss.wsf.spi.deployment.DeploymentAspect) EndpointHandlerDeploymentAspect(org.jboss.ws.common.deployment.EndpointHandlerDeploymentAspect)

Example 4 with DeploymentAspect

use of org.jboss.wsf.spi.deployment.DeploymentAspect in project wildfly by wildfly.

the class WSDeploymentAspectParserTestCase method test.

@Test
public void test() throws Exception {
    InputStream is = getXmlUrl("jbossws-deployment-aspects-example.xml").openStream();
    try {
        List<DeploymentAspect> das = WSDeploymentAspectParser.parse(is, this.getClass().getClassLoader());
        assertEquals(4, das.size());
        boolean da1Found = false;
        boolean da2Found = false;
        boolean da3Found = false;
        boolean da4Found = false;
        for (DeploymentAspect da : das) {
            if (da instanceof TestDA2) {
                da2Found = true;
                TestDA2 da2 = (TestDA2) da;
                assertEquals("myString", da2.getTwo());
            } else if (da instanceof TestDA3) {
                da3Found = true;
                TestDA3 da3 = (TestDA3) da;
                assertNotNull(da3.getList());
                assertTrue(da3.getList().contains("One"));
                assertTrue(da3.getList().contains("Two"));
            } else if (da instanceof TestDA4) {
                da4Found = true;
                TestDA4 da4 = (TestDA4) da;
                assertEquals(true, da4.isBool());
                assertNotNull(da4.getMap());
                assertEquals(1, (int) da4.getMap().get("One"));
                assertEquals(3, (int) da4.getMap().get("Three"));
            } else if (da instanceof TestDA1) {
                da1Found = true;
            }
        }
        assertTrue(da1Found);
        assertTrue(da2Found);
        assertTrue(da3Found);
        assertTrue(da4Found);
    } finally {
        if (is != null) {
            is.close();
        }
    }
}
Also used : InputStream(java.io.InputStream) DeploymentAspect(org.jboss.wsf.spi.deployment.DeploymentAspect) Test(org.junit.Test)

Example 5 with DeploymentAspect

use of org.jboss.wsf.spi.deployment.DeploymentAspect in project wildfly by wildfly.

the class WSDeploymentActivator method addDeploymentProcessors.

private static void addDeploymentProcessors(final DeploymentProcessorTarget processorTarget, final Phase phase, final int priority) {
    int index = 1;
    List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects();
    for (final DeploymentAspect da : aspects) {
        if (WSLogger.ROOT_LOGGER.isTraceEnabled()) {
            WSLogger.ROOT_LOGGER.tracef("Installing aspect %s", da.getClass().getName());
        }
        processorTarget.addDeploymentProcessor(WSExtension.SUBSYSTEM_NAME, phase, priority + index++, new AspectDeploymentProcessor(da));
    }
}
Also used : DeploymentAspect(org.jboss.wsf.spi.deployment.DeploymentAspect) AspectDeploymentProcessor(org.jboss.as.webservices.deployers.AspectDeploymentProcessor)

Aggregations

DeploymentAspect (org.jboss.wsf.spi.deployment.DeploymentAspect)8 EndpointServiceDeploymentAspect (org.jboss.as.webservices.deployers.EndpointServiceDeploymentAspect)4 EndpointHandlerDeploymentAspect (org.jboss.ws.common.deployment.EndpointHandlerDeploymentAspect)4 AbstractDeploymentAspect (org.jboss.ws.common.integration.AbstractDeploymentAspect)4 DeploymentAspectManagerImpl (org.jboss.ws.common.deployment.DeploymentAspectManagerImpl)2 DeploymentAspectManager (org.jboss.wsf.spi.deployment.DeploymentAspectManager)2 InputStream (java.io.InputStream)1 LinkedList (java.util.LinkedList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 WebServiceException (javax.xml.ws.WebServiceException)1 AspectDeploymentProcessor (org.jboss.as.webservices.deployers.AspectDeploymentProcessor)1 ClassLoaderProvider (org.jboss.wsf.spi.classloading.ClassLoaderProvider)1 Deployment (org.jboss.wsf.spi.deployment.Deployment)1 Test (org.junit.Test)1