Author: asoldano
Date: 2015-04-15 11:05:30 -0400 (Wed, 15 Apr 2015)
New Revision: 19636
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
Log:
[JBWS-3899] Add check on service and port name being specified when a contract-first
endpoint is required
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-04-14
22:28:48 UTC (rev 19635)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Loggers.java 2015-04-15
15:05:30 UTC (rev 19636)
@@ -244,4 +244,8 @@
@LogMessage(level = WARN)
@Message(id = 24107, value = "JBossWS-CXF integration with Spring is deprecated
and will be dropped in a future release. See
https://issues.jboss.org/browse/JBWS-3884 for
details.")
void deprecatedSpringIntegration();
+
+ @LogMessage(level = WARN)
+ @Message(id = 24109, value = "Service or port names not specified for endpoint
%s; both have to be specified if the endpoint is really meant to be a contract-first
one.")
+ void contractFirstEndpointWithoutServiceOrPortName(String endpointImplementor);
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2015-04-14
22:28:48 UTC (rev 19635)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2015-04-15
15:05:30 UTC (rev 19636)
@@ -87,7 +87,8 @@
}
processWSDDContribution(ddep, (ArchiveDeployment)dep);
processAddressRewrite(ddep, (ArchiveDeployment)dep, sarm,
soapAddressWsdlParsers);
-
+ checkContractFirstEndpoint(ddep);
+
METADATA_LOGGER.addingServiceEndpointMetadata(METADATA_LOGGER.isDebugEnabled() ?
ddep.toStringExtended() : ddep.toString());
dd.addEndpoint(ddep);
serviceNameAddressMap.put(ddep.getServiceName(), ddep.getAddress());
@@ -96,6 +97,12 @@
return dd;
}
+ private void checkContractFirstEndpoint(DDEndpoint ddep) {
+ if (ddep.isContractFirstRequired() && (ddep.isDefaultPortName() ||
ddep.isDefaultServiceName())) {
+
METADATA_LOGGER.contractFirstEndpointWithoutServiceOrPortName(ddep.getImplementor());
+ }
+ }
+
protected boolean isMtomEnabled(Class<?> beanClass)
{
BindingType bindingType = (BindingType)beanClass.getAnnotation(BindingType.class);
@@ -128,11 +135,13 @@
if (portComp.getWsdlPort() != null) {
METADATA_LOGGER.overridePortName(id, endpoint.getPortName(),
portComp.getWsdlPort());
endpoint.setPortName(portComp.getWsdlPort());
+ endpoint.setDefaultPortName(false);
}
// ServiceQName overrides
if (portComp.getWsdlService() != null) {
METADATA_LOGGER.overrideServiceName(id, endpoint.getServiceName(),
portComp.getWsdlService());
endpoint.setServiceName(portComp.getWsdlService());
+ endpoint.setDefaultServiceName(false);
}
// HandlerChain contributions
@@ -165,6 +174,7 @@
if (wsdlFile != null) {
METADATA_LOGGER.overridingWsdlFileLocation(id, wsdlFile);
endpoint.setWsdlLocation(wsdlFile);
+ endpoint.setContractFirstRequired(true);
}
}
}
@@ -203,7 +213,8 @@
Class<?> seiClass = null;
String seiName;
- boolean missingServicePortAttr = false;
+ boolean missingServiceAttr = false;
+ boolean missingPortAttr = false;
String name = (anWebService != null) ? anWebService.name() : "";
if (name.length() == 0)
@@ -211,7 +222,7 @@
String serviceName = (anWebService != null) ? anWebService.serviceName() :
anWebServiceProvider.serviceName();
if (serviceName.length() == 0) {
- missingServicePortAttr = true;
+ missingServiceAttr = true;
serviceName = JavaUtils.getJustClassName(sepClass) + "Service";
}
@@ -221,7 +232,7 @@
String portName = (anWebService != null) ? anWebService.portName() :
anWebServiceProvider.portName();
if (portName.length() == 0) {
- missingServicePortAttr = true;
+ missingPortAttr = true;
portName = name + "Port";
}
@@ -273,8 +284,13 @@
}
}
result.setProperties(props);
- if (!missingServicePortAttr && annWsdlLocation.length() > 0) {
- result.setAnnotationWsdlLocation(annWsdlLocation);
+ result.setDefaultPortName(missingPortAttr);
+ result.setDefaultServiceName(missingServiceAttr);
+ if (annWsdlLocation.length() > 0) {
+ result.setContractFirstRequired(true);
+ if (!missingServiceAttr && !missingPortAttr) {
+ result.setAnnotationWsdlLocation(annWsdlLocation);
+ }
}
return result;
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2015-04-14
22:28:48 UTC (rev 19635)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2015-04-15
15:05:30 UTC (rev 19636)
@@ -76,6 +76,12 @@
private String annotationWsdlLocation;
+ private boolean defaultServiceName;
+
+ private boolean defaultPortName;
+
+ private boolean contractFirstRequired;
+
private int counter = 0;
public QName getPortName()
@@ -251,6 +257,36 @@
this.properties = properties;
}
+ public boolean isDefaultServiceName()
+ {
+ return defaultServiceName;
+ }
+
+ public void setDefaultServiceName(boolean defaultServiceName)
+ {
+ this.defaultServiceName = defaultServiceName;
+ }
+
+ public boolean isDefaultPortName()
+ {
+ return defaultPortName;
+ }
+
+ public void setDefaultPortName(boolean defaultPortName)
+ {
+ this.defaultPortName = defaultPortName;
+ }
+
+ public boolean isContractFirstRequired()
+ {
+ return contractFirstRequired;
+ }
+
+ public void setContractFirstRequired(boolean contractFirstRequired)
+ {
+ this.contractFirstRequired = contractFirstRequired;
+ }
+
public void writeTo(Writer writer) throws IOException
{
writer.write("<jaxws:endpoint id='" + this.id +
"'");