JBossWS SVN: r18859 - in container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices: metadata/model and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: rsearls
Date: 2014-08-23 11:15:44 -0400 (Sat, 23 Aug 2014)
New Revision: 18859
Added:
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInfo.java
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInformationFactory.java
Modified:
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_POJO.java
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebServiceAnnotationProcessor.java
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/metadata/model/AbstractDeployment.java
container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java
Log:
[JBWS-3809] integration of fix from wfly9
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_POJO.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_POJO.java 2014-08-22 09:48:45 UTC (rev 18858)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WSIntegrationProcessorJAXWS_POJO.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -26,8 +26,10 @@
import static org.jboss.as.webservices.util.ASHelper.getEndpointName;
import static org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData;
import static org.jboss.as.webservices.util.ASHelper.getJaxwsDeployment;
+import static org.jboss.as.webservices.util.ASHelper.getJBossWebserviceMetaDataPortComponent;
import static org.jboss.as.webservices.util.ASHelper.getRequiredAttachment;
import static org.jboss.as.webservices.util.ASHelper.isJaxwsEndpoint;
+import static org.jboss.as.webservices.util.ASHelper.getWebserviceMetadataEJBEndpoint;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JMS_ENDPOINT_METADATA_KEY;
import static org.jboss.as.webservices.util.WebMetaDataHelper.getServlets;
@@ -49,6 +51,7 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
+import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.as.webservices.metadata.model.JAXWSDeployment;
import org.jboss.as.webservices.metadata.model.POJOEndpoint;
import org.jboss.jandex.ClassInfo;
@@ -56,8 +59,10 @@
import org.jboss.metadata.web.spec.ServletMappingMetaData;
import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.msc.service.ServiceName;
+import org.jboss.ws.api.annotation.WebContext;
import org.jboss.wsf.spi.metadata.jms.JMSEndpointMetaData;
import org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData;
+import org.jboss.ws.common.utils.UrlPatternUtils;
/**
* @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
@@ -119,28 +124,62 @@
for (EEModuleClassDescription classDescription : classDescriptionMap.values()) {
ClassInfo classInfo = null;
String serviceName = null;
- final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription
+ String urlPattern = null;
+
+ // #1 Override serviceName with the explicit urlPattern from port-component/port-component-uri in jboss-webservices.xml
+ EJBEndpoint ejbEndpoint = getWebserviceMetadataEJBEndpoint(jaxwsDeployment, classDescription.getClassName());
+ if (ejbEndpoint != null) {
+ urlPattern = UrlPatternUtils.getUrlPatternByPortComponentURI(
+ getJBossWebserviceMetaDataPortComponent(unit, ejbEndpoint.getName()));
+ }
+
+ // #2 Override serviceName with @WebContext.urlPattern
+ if (urlPattern == null) {
+ final ClassAnnotationInformation<WebContext, WebContextAnnotationInfo> annotationWebContext =
+ classDescription.getAnnotationInformation(WebContext.class);
+ if (annotationWebContext != null) {
+ WebContextAnnotationInfo wsInfo = annotationWebContext.getClassLevelAnnotations().get(0);
+ if (wsInfo != null && wsInfo.getUrlPattern().length() > 0) {
+ urlPattern = wsInfo.getUrlPattern();
+ }
+ }
+ }
+
+ // #3 use serviceName declared in a class annotation
+ if (urlPattern == null) {
+ final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription
.getAnnotationInformation(WebService.class);
- if (annotationInfo != null) {
- WebServiceAnnotationInfo wsInfo = annotationInfo.getClassLevelAnnotations().get(0);
- serviceName = wsInfo.getServiceName();
- classInfo = (ClassInfo)wsInfo.getTarget();
+ if (annotationInfo != null) {
+ WebServiceAnnotationInfo wsInfo = annotationInfo.getClassLevelAnnotations().get(0);
+ serviceName = wsInfo.getServiceName();
+ classInfo = (ClassInfo)wsInfo.getTarget();
+
+ urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
+ if (jaxwsDeployment.contains(urlPattern)){
+ urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName, wsInfo.getName());
+ }
+ }
+
+ final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> annotationProviderInfo = classDescription
+ .getAnnotationInformation(WebServiceProvider.class);
+ if (annotationProviderInfo != null) {
+ WebServiceProviderAnnotationInfo wsInfo = annotationProviderInfo.getClassLevelAnnotations().get(0);
+ serviceName = wsInfo.getServiceName();
+ classInfo = (ClassInfo)wsInfo.getTarget();
+ }
}
- final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> annotationProviderInfo = classDescription
- .getAnnotationInformation(WebServiceProvider.class);
- if (annotationProviderInfo != null) {
- WebServiceProviderAnnotationInfo wsInfo = annotationProviderInfo.getClassLevelAnnotations().get(0);
- serviceName = wsInfo.getServiceName();
- classInfo = (ClassInfo)wsInfo.getTarget();
- }
+
if (classInfo != null) {
final String endpointClassName = classDescription.getClassName();
final ComponentDescription pojoComponent = createComponentDescription(unit, endpointClassName,
endpointClassName, endpointClassName);
final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
+ if (urlPattern == null) {
+ urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
+ }
// register POJO endpoint
- final String urlPattern = getUrlPattern(classInfo, serviceName);
- jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointClassName, pojoViewName, urlPattern));
+ jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointClassName,
+ pojoViewName, UrlPatternUtils.getUrlPattern(urlPattern)));
}
}
@@ -165,10 +204,6 @@
return false;
}
- private static String getUrlPattern(ClassInfo clazz, String serviceName) {
- return "/" + (!serviceName.equals("") ? serviceName : clazz.name().local());
- }
-
private static String getUrlPattern(final String servletName, final DeploymentUnit unit) {
final JBossWebMetaData jbossWebMD = getJBossWebMetaData(unit);
for (final ServletMappingMetaData servletMappingMD : jbossWebMD.getServletMappings()) {
Added: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInfo.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInfo.java (rev 0)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInfo.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.webservices.deployers;
+
+/**
+ * User: rsearls
+ * Date: 7/17/14
+ */
+public class WebContextAnnotationInfo {
+ private final String authMethod;
+ private final String contextRoot;
+ private final boolean secureWSDLAccess;
+ private final String transportGuarantee;
+ private final String urlPattern;
+ private final String virtualHost;
+
+ public WebContextAnnotationInfo(final String authMethod, final String contextRoot, final boolean secureWSDLAccess, final String transportGuarantee, final String urlPattern, final String virtualHost) {
+
+ this.authMethod = authMethod;
+ this.contextRoot = contextRoot;
+ this.secureWSDLAccess = secureWSDLAccess;
+ this.transportGuarantee = transportGuarantee;
+ this.urlPattern = urlPattern;
+ this.virtualHost = virtualHost;
+
+ }
+
+ public String getAuthMethod() {
+ return authMethod;
+ }
+
+ public String getContextRoot() {
+ return contextRoot;
+ }
+
+ public boolean isSecureWSDLAccess() {
+ return secureWSDLAccess;
+ }
+
+ public String getTransportGuarantee() {
+ return transportGuarantee;
+ }
+
+ public String getUrlPattern() {
+ return urlPattern;
+ }
+
+ public String getVirtualHost() {
+ return virtualHost;
+ }
+
+}
Added: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInformationFactory.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInformationFactory.java (rev 0)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebContextAnnotationInformationFactory.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2014, Red Hat Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.webservices.deployers;
+
+import org.jboss.ws.api.annotation.WebContext;
+
+import org.jboss.as.ee.metadata.ClassAnnotationInformationFactory;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationValue;
+import org.jboss.metadata.property.PropertyReplacer;
+
+/**
+ * User: rsearls
+ * Date: 7/17/14
+ */
+public class WebContextAnnotationInformationFactory extends
+ ClassAnnotationInformationFactory<WebContext, WebContextAnnotationInfo> {
+
+ protected WebContextAnnotationInformationFactory() {
+ super(org.jboss.ws.api.annotation.WebContext.class, null);
+ }
+
+ @Override
+ protected WebContextAnnotationInfo fromAnnotation(final AnnotationInstance annotationInstance, final boolean replacement) {
+ String authMethodValue = asString(annotationInstance, "authMethod");
+ String contextRootValue = asString(annotationInstance, "contextRoot");
+ boolean secureWSDLAccessValue = asBoolean(annotationInstance, "secureWSDLAccessValue");
+ String transportGuaranteeValue = asString(annotationInstance, "transportGuarantee");
+ String urlPatternValue = asString(annotationInstance, "urlPattern");
+ String virtualHostValue = asString(annotationInstance, "virtualHost");
+ return new WebContextAnnotationInfo(authMethodValue, contextRootValue,
+ secureWSDLAccessValue, transportGuaranteeValue, urlPatternValue, virtualHostValue);
+ }
+
+ private String asString(final AnnotationInstance annotation, String property) {
+ AnnotationValue value = annotation.value(property);
+ return value == null ? "" : value.asString();
+ }
+
+ private boolean asBoolean(final AnnotationInstance annotation, String property) {
+ AnnotationValue value = annotation.value(property);
+ return value == null ? false : Boolean.getBoolean(value.asString());
+ }
+}
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebServiceAnnotationProcessor.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebServiceAnnotationProcessor.java 2014-08-22 09:48:45 UTC (rev 18858)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/deployers/WebServiceAnnotationProcessor.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -36,6 +36,8 @@
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.metadata.property.PropertyReplacers;
+
/**
* @author <a href="mailto:ema@redhat.com">Jim Ma</a>
*/
@@ -48,6 +50,7 @@
List<ClassAnnotationInformationFactory> factories = new ArrayList<ClassAnnotationInformationFactory>();
factories.add(new WebServiceAnnotationInformationFactory());
factories.add(new WebServiceProviderAnnotationInformationFactory());
+ factories.add(new WebContextAnnotationInformationFactory());
this.factories = Collections.unmodifiableList(factories);
}
@@ -56,12 +59,13 @@
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
+ final Boolean replacement = deploymentUnit.getAttachment(org.jboss.as.ee.structure.Attachments.ANNOTATION_PROPERTY_REPLACEMENT);
if (index == null || eeModuleDescription == null) {
return;
}
for (final ClassAnnotationInformationFactory factory : factories) {
- final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, false);
+ final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, replacement);
for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey());
clazz.addAnnotationInformation(entry.getValue());
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/metadata/model/AbstractDeployment.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/metadata/model/AbstractDeployment.java 2014-08-22 09:48:45 UTC (rev 18858)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/metadata/model/AbstractDeployment.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -64,4 +64,7 @@
}
}
+ public boolean contains(String urlPattern) {
+ return urlPatternToClassMapping.keySet().contains((urlPattern));
+ }
}
Modified: container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java
===================================================================
--- container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java 2014-08-22 09:48:45 UTC (rev 18858)
+++ container/wildfly81/branches/jbossws-wildfly810/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java 2014-08-23 15:15:44 UTC (rev 18859)
@@ -28,6 +28,7 @@
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 static org.jboss.as.webservices.util.WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY;
import java.lang.reflect.Modifier;
import java.util.Collections;
@@ -68,6 +69,8 @@
import org.jboss.msc.service.ServiceName;
import org.jboss.ws.common.integration.WSHelper;
import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.webservices.JBossPortComponentMetaData;
+import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
/**
* JBoss AS integration helper class.
@@ -297,6 +300,51 @@
}
/**
+ * Return a named port-component from the jboss-webservices.xml
+ * @param unit
+ * @param name
+ * @return
+ */
+ public static JBossPortComponentMetaData getJBossWebserviceMetaDataPortComponent(
+ final DeploymentUnit unit, final String name) {
+
+ if (name != null) {
+ final JBossWebservicesMetaData jbossWebserviceMetaData = unit.getAttachment(JBOSS_WEBSERVICES_METADATA_KEY);
+
+ if (jbossWebserviceMetaData != null) {
+ JBossPortComponentMetaData[] portComponent = jbossWebserviceMetaData.getPortComponents();
+
+ if (portComponent != null) {
+ for (JBossPortComponentMetaData component : portComponent) {
+ if (name.equals(component.getEjbName())) {
+ return component;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns an EJBEndpoint based upon fully qualified classname.
+ * @param jaxwsDeployment
+ * @param className
+ * @return
+ */
+ public static EJBEndpoint getWebserviceMetadataEJBEndpoint(final JAXWSDeployment jaxwsDeployment,
+ final String className) {
+
+ java.util.List<EJBEndpoint> ejbEndpointList = jaxwsDeployment.getEjbEndpoints();
+ for (EJBEndpoint ejbEndpoint : ejbEndpointList) {
+ if (className.equals(ejbEndpoint.getClassName())) {
+ return ejbEndpoint;
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns context root associated with webservice deployment.
*
* If there's application.xml descriptor provided defining nested web module, then context root defined there will be