Author: asoldano
Date: 2014-09-29 05:37:28 -0400 (Mon, 29 Sep 2014)
New Revision: 18954
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/WSLogger.java
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSClassVerificationProcessor.java
Log:
Backport [WFLY-3535] check
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/WSLogger.java
===================================================================
---
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/WSLogger.java 2014-09-29
09:37:03 UTC (rev 18953)
+++
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/WSLogger.java 2014-09-29
09:37:28 UTC (rev 18954)
@@ -300,4 +300,7 @@
+ WS_SPEC_REF_5_3_2_4_2)
void finalizeMethodNotAllowed(Class<?> seiClass);
+ @LogMessage(level = WARN)
+ @Message(id = 15617, value = "Annotation '@%s' found on class
'%s'. Perhaps you forgot to add a '%s' module dependency to your
deployment?")
+ void missingModuleDependency(String annotation, String clazz, String module);
}
Modified:
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSClassVerificationProcessor.java
===================================================================
---
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSClassVerificationProcessor.java 2014-09-29
09:37:03 UTC (rev 18953)
+++
container/wildfly80/branches/jbossws-wildfly800/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSClassVerificationProcessor.java 2014-09-29
09:37:28 UTC (rev 18954)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2013, Red Hat, Inc., and individual contributors
+ * Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -24,6 +24,8 @@
import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
import static org.jboss.as.webservices.WSMessages.MESSAGES;
+import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_ANNOTATION;
+import static org.jboss.as.webservices.util.DotNames.WEB_SERVICE_PROVIDER_ANNOTATION;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JAXWS_ENDPOINTS_KEY;
import javax.jws.WebService;
@@ -33,14 +35,23 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.as.server.deployment.annotation.CompositeIndex;
+import org.jboss.as.server.deployment.module.ModuleDependency;
+import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex;
+import org.jboss.as.webservices.WSLogger;
import org.jboss.as.webservices.metadata.model.AbstractEndpoint;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.as.webservices.verification.JwsWebServiceEndpointVerifier;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationTarget;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
import org.jboss.modules.Module;
/**
* @author sfcoy
+ * @autor <a href="mailto:alessio.soldano@jboss.com">Alessio
Soldano</a>
*
*/
public class WSClassVerificationProcessor implements DeploymentUnitProcessor {
@@ -60,6 +71,7 @@
for (AbstractEndpoint ejbEndpoint : wsDeployment.getEjbEndpoints()) {
verifyEndpoint(ejbEndpoint, moduleClassLoader,
deploymentReflectionIndex);
}
+ verifyApacheCXFModuleDependencyRequirement(unit);
}
}
@@ -94,7 +106,44 @@
throw
MESSAGES.declaredEndpointInterfaceClassNotFound(endpointInterfaceClassName,
endpointClass);
}
}
+
+ private void verifyApacheCXFModuleDependencyRequirement(DeploymentUnit unit) {
+ if (!hasCxfModuleDependency(unit)) {
+ // notify user if he clearly forgot the CXF module dependency
+ final CompositeIndex index = unit
+ .getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
+ final DotName[] dotNames = { WEB_SERVICE_ANNOTATION,
+ WEB_SERVICE_PROVIDER_ANNOTATION };
+ for (final DotName dotName : dotNames) {
+ for (AnnotationInstance ai : index.getAnnotations(dotName)) {
+ AnnotationTarget at = ai.target();
+ if (at instanceof ClassInfo) {
+ final ClassInfo clazz = (ClassInfo) ai.target();
+ for (DotName dn : clazz.annotations().keySet()) {
+ if (dn.toString().startsWith("org.apache.cxf")) {
+ WSLogger.ROOT_LOGGER.missingModuleDependency(
+ dn.toString(), clazz.name().toString(),
+ "org.apache.cxf");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ private static boolean hasCxfModuleDependency(DeploymentUnit unit) {
+ final ModuleSpecification moduleSpec = unit
+ .getAttachment(Attachments.MODULE_SPECIFICATION);
+ for (ModuleDependency dep : moduleSpec.getUserDependencies()) {
+ final String id = dep.getIdentifier().getName();
+ if ("org.apache.cxf".equals(id) ||
"org.apache.cxf.impl".equals(id)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public void undeploy(DeploymentUnit context) {
}
Show replies by date