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();
}
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;
}
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;
}
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();
}
}
}
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));
}
}
Aggregations