Author: dkulp
Date: Wed Jan 12 15:00:08 2011
New Revision: 1058163
URL: http://svn.apache.org/viewvc?rev=1058163&view=rev
Log:
[CXF-3092,CXF-3093] Make sure the Documentation annotaions are handled
at endpoint selection time, not when the server is created.
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/FactoryBeanListener.java
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java?rev=1058163&r1=1058162&r2=1058163&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
Wed Jan 12 15:00:08 2011
@@ -87,6 +87,7 @@ public class AnnotationsFactoryBeanListe
break;
}
case ENDPOINT_SELECTED: {
+ Class<?> implCls = args.length > 3 ? (Class<?>)args[3] : null;
Class<?> cls = (Class<?>)args[2];
Endpoint ep = (Endpoint)args[1];
Bus bus = factory.getBus();
@@ -103,6 +104,27 @@ public class AnnotationsFactoryBeanListe
if (props != null) {
addEndpointProperties(ep, bus, props.value());
}
+ // To avoid the NPE
+ if (implCls == null || implCls == cls) {
+ return;
+ }
+ WSDLDocumentation doc =
implCls.getAnnotation(WSDLDocumentation.class);
+ if (doc != null) {
+ addDocumentation(ep, WSDLDocumentation.Placement.SERVICE, doc);
+ }
+ WSDLDocumentationCollection col =
implCls.getAnnotation(WSDLDocumentationCollection.class);
+ if (col != null) {
+ addDocumentation(ep, WSDLDocumentation.Placement.SERVICE,
col.value());
+ }
+ InterfaceInfo i = ep.getEndpointInfo().getInterface();
+ List<WSDLDocumentation> docs =
CastUtils.cast((List<?>)i.removeProperty(EXTRA_DOCUMENTATION));
+ if (docs != null) {
+ addDocumentation(ep,
+ WSDLDocumentation.Placement.SERVICE,
+ docs.toArray(new
WSDLDocumentation[docs.size()]));
+ }
+ addBindingOperationDocs(ep);
+
break;
}
case SERVER_CREATED: {
@@ -116,27 +138,11 @@ public class AnnotationsFactoryBeanListe
addSchemaValidationSupport(server.getEndpoint(),
cls.getAnnotation(SchemaValidation.class));
addFastInfosetSupport(server.getEndpoint(),
cls.getAnnotation(FastInfoset.class));
addLoggingSupport(server.getEndpoint(), bus,
cls.getAnnotation(Logging.class));
- WSDLDocumentation doc = cls.getAnnotation(WSDLDocumentation.class);
- if (doc != null) {
- addDocumentation(server, WSDLDocumentation.Placement.SERVICE,
doc);
- }
- WSDLDocumentationCollection col =
cls.getAnnotation(WSDLDocumentationCollection.class);
- if (col != null) {
- addDocumentation(server, WSDLDocumentation.Placement.SERVICE,
col.value());
- }
- InterfaceInfo i =
server.getEndpoint().getEndpointInfo().getInterface();
- List<WSDLDocumentation> docs =
CastUtils.cast((List<?>)i.removeProperty(EXTRA_DOCUMENTATION));
- if (docs != null) {
- addDocumentation(server,
- WSDLDocumentation.Placement.SERVICE,
- docs.toArray(new
WSDLDocumentation[docs.size()]));
- }
addEndpointProperties(server.getEndpoint(), bus,
cls.getAnnotation(EndpointProperty.class));
EndpointProperties props =
cls.getAnnotation(EndpointProperties.class);
if (props != null) {
addEndpointProperties(server.getEndpoint(), bus,
props.value());
}
- addBindingOperationDocs(server);
setScope(factory, server, cls);
break;
}
@@ -272,8 +278,8 @@ public class AnnotationsFactoryBeanListe
}
}
- private void addBindingOperationDocs(Server server) {
- for (BindingOperationInfo binfo : server.getEndpoint().getBinding()
+ private void addBindingOperationDocs(Endpoint ep) {
+ for (BindingOperationInfo binfo : ep.getBinding()
.getBindingInfo().getOperations()) {
List<WSDLDocumentation> later =
CastUtils.cast((List<?>)binfo.getOperationInfo()
.getProperty(EXTRA_DOCUMENTATION));
@@ -390,7 +396,7 @@ public class AnnotationsFactoryBeanListe
}
}
}
- private void addDocumentation(Server server,
+ private void addDocumentation(Endpoint ep,
WSDLDocumentation.Placement defPlace,
WSDLDocumentation ... values) {
for (WSDLDocumentation doc : values) {
@@ -400,20 +406,20 @@ public class AnnotationsFactoryBeanListe
}
switch (p) {
case PORT_TYPE:
- server.getEndpoint().getEndpointInfo().getService()
+ ep.getEndpointInfo().getService()
.getInterface().setDocumentation(doc.value());
break;
case TOP:
-
server.getEndpoint().getEndpointInfo().getService().setTopLevelDoc(doc.value());
+ ep.getEndpointInfo().getService().setTopLevelDoc(doc.value());
break;
case SERVICE:
-
server.getEndpoint().getEndpointInfo().getService().setDocumentation(doc.value());
+
ep.getEndpointInfo().getService().setDocumentation(doc.value());
break;
case SERVICE_PORT:
-
server.getEndpoint().getEndpointInfo().setDocumentation(doc.value());
+ ep.getEndpointInfo().setDocumentation(doc.value());
break;
case BINDING:
-
server.getEndpoint().getEndpointInfo().getBinding().setDocumentation(doc.value());
+
ep.getEndpointInfo().getBinding().setDocumentation(doc.value());
break;
default:
//nothing?
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/FactoryBeanListener.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/FactoryBeanListener.java?rev=1058163&r1=1058162&r2=1058163&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/FactoryBeanListener.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/FactoryBeanListener.java
Wed Jan 12 15:00:08 2011
@@ -115,7 +115,7 @@ public interface FactoryBeanListener {
CLIENT_CREATED,
/**
- * EndpointInfo, Endpoint, Class
+ * EndpointInfo, Endpoint, SEI Class, Class
*/
ENDPOINT_SELECTED,
Modified:
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?rev=1058163&r1=1058162&r2=1058163&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
Wed Jan 12 15:00:08 2011
@@ -40,6 +40,7 @@ import org.apache.cxf.service.Service;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.wsdl.WSDLManager;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
import org.junit.Test;
@@ -154,6 +155,22 @@ public class CodeFirstWSDLTest extends A
d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My
binding doc",
d.getDocumentElement());
+
+
+ JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
+ builder.setServiceClass(CXF3093Impl.class);
+ ServiceInfo serviceInfo = builder.createService();
+ wsdlBuilder = new ServiceWSDLBuilder(bus, serviceInfo);
+
+ def = wsdlBuilder.build();
+ d =
bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
+ //org.apache.cxf.helpers.XMLUtils.printDOM(d);
+ assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top
level documentation",
+ d.getDocumentElement());
+
assertXPathEquals("//wsdl:definitions/wsdl:portType/wsdl:documentation", "My
portType documentation",
+ d.getDocumentElement());
+
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My
binding doc",
+ d.getDocumentElement());
}
@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt")
@@ -180,7 +197,7 @@ public class CodeFirstWSDLTest extends A
@Test
public void testDocumentationOnImpl() throws Exception {
- //CXF-3093
+ //CXF-3092
EndpointImpl ep = (EndpointImpl)Endpoint.publish("local://foo", new
CXF3092Impl());
ServiceWSDLBuilder wsdlBuilder =
new ServiceWSDLBuilder(bus,
ep.getService().getServiceInfos().get(0));
@@ -193,6 +210,21 @@ public class CodeFirstWSDLTest extends A
d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My
binding doc",
d.getDocumentElement());
+
+ JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
+ builder.setServiceClass(CXF3092Impl.class);
+ ServiceInfo serviceInfo = builder.createService();
+ wsdlBuilder = new ServiceWSDLBuilder(bus, serviceInfo);
+
+ def = wsdlBuilder.build();
+ d =
bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
+ //org.apache.cxf.helpers.XMLUtils.printDOM(d);
+ assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top
level documentation",
+ d.getDocumentElement());
+
assertXPathEquals("//wsdl:definitions/wsdl:service/wsdl:documentation", "My
Service documentation",
+ d.getDocumentElement());
+
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My
binding doc",
+ d.getDocumentElement());
}
@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt")
Modified:
cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java?rev=1058163&r1=1058162&r2=1058163&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
(original)
+++
cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractWSDLBasedEndpointFactory.java
Wed Jan 12 15:00:08 2011
@@ -191,7 +191,7 @@ public abstract class AbstractWSDLBasedE
ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED,
ei, ep,
- serviceFactory.getServiceClass());
+ serviceFactory.getServiceClass(),
getServiceClass());
return ep;
}
private void modifyTransportIdPerAddress(EndpointInfo ei) {