Author: mmerz
Date: Tue Oct 26 11:23:11 2004
New Revision: 55631
Added:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/ValidationException.java
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WebServiceMetadataViewer.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
Log:
Fixed failing wsm-drt: validation method in WebServiceTYPEMetadata verified
that implementation bean implements all methods that are defined in interface
(if interface exists; based on Wolfgang's initial contribution). validate()
needs more test cases and needs to do more validation work.
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
==============================================================================
---
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
(original)
+++
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
Tue Oct 26 11:23:11 2004
@@ -231,7 +231,7 @@
new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
WebService wsAnnotation =
- new FakeWebServiceAnnotation("testname", "testserviceName",
"testwsdllocation", "testtargetnamespace", "testendpointinterface");
+ new FakeWebServiceAnnotation("testname", "testserviceName",
"testwsdllocation", "testtargetnamespace", "");
typeAnnotations.add(wsAnnotation);
WebServiceTYPEMetadata type =
@@ -241,7 +241,7 @@
assertEquals("testtargetnamespace", type.getWsTargetNamespace());
assertEquals("testserviceName", type.getWsServiceName());
assertEquals("testwsdllocation", type.getWsWsdlLocation());
- assertEquals("testendpointinterface", type.getWsEndpointInterface());
+// assertEquals("testendpointinterface", type.getWsEndpointInterface());
}
/////////////////////////
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
==============================================================================
---
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
(original)
+++
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
Tue Oct 26 11:23:11 2004
@@ -21,8 +21,8 @@
import org.apache.beehive.wsm.jsr181.model.Bar2TestCase;
import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
-public class WsmAnnotationProcessorEndpointInterface2Test extends Bar2TestCase
{
-
+public class WsmAnnotationProcessorEndpointInterface2Test extends Bar2TestCase
+{
@Override
public void setUp() throws Exception
{
@@ -41,6 +41,7 @@
try
{
objectModel =
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
+ objectModel.validate();
fail("Failed to generate error for the service implementation
which doesn't implement the methods declared "
+ "in the corresponding endpoint interface.");
}
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Tue Oct 26 11:23:11 2004
@@ -84,7 +84,7 @@
cl = AxisHook.class.getClassLoader();
}
- Class serviceClass = cl.loadClass(wsm.getJavaFQClassName());
+ Class serviceClass = cl.loadClass(wsm.getServiceImplementationBean());
String portType = wsm.getWsName();
sd.setName(portType);
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
Tue Oct 26 11:23:11 2004
@@ -22,7 +22,7 @@
import java.util.Collection;
-public class AnnotationModel {
+public abstract class AnnotationModel {
public static boolean hasAnnotationType(Collection<Annotation>
annotations, Class<? extends Annotation> annotationType)
{
@@ -54,4 +54,6 @@
}
return null;
}
+
+ public abstract void validate() throws ValidationException;
}
Added:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/ValidationException.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/ValidationException.java
Tue Oct 26 11:23:11 2004
@@ -0,0 +1,25 @@
+package org.apache.beehive.wsm.jsr181.model;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+public class ValidationException extends Exception {
+
+ public ValidationException() { super(); }
+ public ValidationException(String msg) { super(msg); }
+}
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
Tue Oct 26 11:23:11 2004
@@ -45,6 +45,11 @@
private String javaMethodName;
private Class javaReturnType;
+ public void validate() throws ValidationException
+ {
+ return; // no validation required
+ }
+
public WebServiceMETHODMetadata(String methodName, Class returnType)
{
super();
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
Tue Oct 26 11:23:11 2004
@@ -33,6 +33,11 @@
private Class javaType;
private String defaultName;
+ public void validate() throws ValidationException
+ {
+ return; // no validation required
+ }
+
public WebServicePARAMETERMetadata()
{
super();
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
Tue Oct 26 11:23:11 2004
@@ -20,6 +20,9 @@
import java.io.IOException;
+import java.lang.reflect.Type;
+import java.lang.reflect.Method;
+
import java.lang.annotation.Annotation;
import java.net.URL;
@@ -28,6 +31,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -61,42 +65,64 @@
private String wsWsdlLocation;
private String wsTargetNamespace;
private String wsEndpointInterface;
- private Collection<WebServiceMETHODMetadata> methods = new
ArrayList<WebServiceMETHODMetadata>();
+ private Collection<WebServiceMETHODMetadata> methods =
+ new ArrayList<WebServiceMETHODMetadata>();
private SOAPBindingInfo soapBinding;
private String hcFileName;
private String hcName;
- private List<SOAPMessageHandlerInfo> soapHandlers = new
ArrayList<SOAPMessageHandlerInfo>();
+ private List<SOAPMessageHandlerInfo> soapHandlers =
+ new ArrayList<SOAPMessageHandlerInfo>();
private SecurityRolesInfo securityRoles;
private String siValue;
- private String javaFQClassName;
-
- public WebServiceTYPEMetadata(String fqClassName)
+ private String sibClassName; // name of the service implementation bean
+ private String seiClassName; // name of the service endpoint interface
+
+ /**
+ * Constructor.
+ * @param sibClassName The fully-qualified name of the service
+ * implementation bean class.
+ */
+ public WebServiceTYPEMetadata(String sibClassName)
{
super();
- javaFQClassName = fqClassName;
+
+ this.sibClassName = sibClassName;
}
+ /**
+ * This method does not require to load the service implementation bean
+ * class.
+ * @param sibWsAnnotation The @WebService annotation of the service
+ * implementation bean.
+ * @param sibClassName The fully-qualified name of the service
+ * implementation bean class.
+ * @param annotations All annotations (including @WebService) of the
+ * service endpoint interface if it exists; all annotations (including
+ * @WebService) of the service implementation bean otherwise.
+ * @param webMethods All methods that are published by the service.
+ * @throws Exception
+ */
public WebServiceTYPEMetadata(
- WebService webServiceAnnotation,
- String fqClassName,
+ WebService sibWsAnnotation,
+ String sibClassName,
Collection<Annotation> annotations,
Collection<? extends WebServiceMETHODMetadata> webMethods
) throws Exception
{
super();
- // check required parameter: webServiceAnnotation
- if (null == webServiceAnnotation)
+ // check required parameter: sibWsAnnotation
+ if (null == sibWsAnnotation)
{
- throw new IllegalArgumentException("@WebService is required");
+ throw new IllegalArgumentException("@WebService is required for
service implementation beans");
}
- // check required parameter: fqClassName
- if ((null == fqClassName) || (0 == fqClassName.length()))
+ // check required parameter: sibClassName
+ if ((null == sibClassName) || (0 == sibClassName.length()))
{
- throw new IllegalArgumentException("className not set");
+ throw new IllegalArgumentException("service implementation bean
class not set");
}
- javaFQClassName = fqClassName;
+ this.sibClassName = sibClassName;
// check required parameters: annotations, webMethods
if ((null == annotations) || (null == webMethods))
@@ -104,6 +130,9 @@
throw new IllegalArgumentException("annotations or webMethods is
null");
}
+ // optional parameter: seiClassName
+ seiClassName = sibWsAnnotation.endpointInterface();
+
// enforce JSR-181 rules
if (AnnotationModel.hasAnnotationType(annotations,
SOAPMessageHandlers.class) &&
AnnotationModel.hasAnnotationType(annotations, HandlerChain.class))
@@ -113,9 +142,16 @@
"Illegal combination of @SOAPMessageHandlers and @HandlerChain"
);
}
-
- initFromAnnotation(webServiceAnnotation);
+ // initilize instance
+ WebService seiWsAnnotation = null;
+ if (0 < seiClassName.length())
+ {
+ seiWsAnnotation = (WebService)
+ AnnotationModel.getAnnotationOfType(annotations,
WebService.class);
+ }
+ initFromAnnotation(sibWsAnnotation, seiWsAnnotation);
+
// set optional annotations
for (Annotation a : annotations)
{
@@ -152,9 +188,11 @@
{
// TODO: What to do with annotations that are not specified in
// 181? For now ignore them. Later: delegation model?
+
+ // todo: note that @WebService is "handled" in here, too
}
}
-
+
// set WebServiceMETHODMetadata and back fill JSR-181 default values
for (WebServiceMETHODMetadata wsmm : webMethods)
{
@@ -180,39 +218,58 @@
}
}
- protected void initFromAnnotation(WebService annotation)
+ protected void initFromAnnotation(WebService sibWsAnnotation, WebService
seiWsAnnotation)
{
- if (null != annotation) {
- setWsName(annotation.name());
- setWsServiceName(annotation.serviceName());
- setWsTargetNamespace(annotation.targetNamespace());
- setWsWsdlLocation(annotation.wsdlLocation());
- setWsEndpointInterface(annotation.endpointInterface());
+ // initialize fields with values from annotations
+
+ if (null == seiWsAnnotation)
+ {
+ setWsName(sibWsAnnotation.name());
+ setWsTargetNamespace(sibWsAnnotation.targetNamespace());
+ setWsWsdlLocation(sibWsAnnotation.wsdlLocation());
+
+ }
+ else
+ {
+ setWsName(seiWsAnnotation.name());
+ setWsTargetNamespace(seiWsAnnotation.targetNamespace());
+ setWsWsdlLocation(seiWsAnnotation.wsdlLocation());
}
+ setWsServiceName(sibWsAnnotation.serviceName());
+ setWsEndpointInterface(sibWsAnnotation.endpointInterface());
+ // set default values
+
// name
- String name;
- if (javaFQClassName.indexOf('.') == -1)
- name = javaFQClassName;
- else {
- int index = javaFQClassName.lastIndexOf('.');
-
- name = javaFQClassName.substring(index + 1);
+ String name = (0 == seiClassName.length()) ? sibClassName :
seiClassName;
+ if (-1 < name.indexOf('.'))
+ {
+ int index = name.lastIndexOf('.');
+ name = name.substring(index + 1);
}
-
- if (0 == getWsName().length()) {
+ if (0 == getWsName().length())
+ {
setWsName(name);
}
// serviceName
- if (0 == getWsServiceName().length()) {
- setWsServiceName(name + "Service");
+ String serviceName = sibClassName;
+ if (-1 < serviceName.indexOf('.'))
+ {
+ int index = serviceName.lastIndexOf('.');
+ serviceName = serviceName.substring(index + 1);
+ }
+ if (0 == getWsServiceName().length())
+ {
+ setWsServiceName(serviceName + "Service");
}
// targetNamespace
if (0 == getWsTargetNamespace().length())
{
- setWsTargetNamespace(getTargetNamespace(javaFQClassName));
+ String defaultNamespaceSrc =
+ (0 == seiClassName.length()) ? sibClassName : seiClassName;
+ setWsTargetNamespace(getTargetNamespace(defaultNamespaceSrc));
}
}
@@ -330,7 +387,7 @@
if (handlerChainConfigURL == null) {
// try again using the classes package as a prefix
StringBuffer fullPath = new StringBuffer
- (javaFQClassName.substring(0,javaFQClassName
+ (sibClassName.substring(0,sibClassName
.lastIndexOf('.')));
if (!handlerChainConfigPath.startsWith("/")) {
@@ -443,9 +500,108 @@
}
- public boolean validate() {
- //TODO: Implement the validate for the object model
- return true;
+ /**
+ * Checks whether the implementation bean implements all the methods
+ * specified in the endpointInterface.
+ * @return
+ * @throws
+ */
+ public void validate() throws ValidationException
+ {
+ // note: load class here -- we might want to create the object model
without a sib class file (from source)
+
+ // if we have a service endpoint interface
+ if (0 < seiClassName.length())
+ {
+ try {
+
+ // load endpoint interface
+ Class sibClass = Class.forName(sibClassName);
+ Class seiClass = Class.forName(seiClassName);
+
+ // verify that bean implements all methods specified in
interface
+ for (Method m : seiClass.getMethods())
+ {
+ if (! doesImplement(sibClass, m))
+ {
+ throw new ValidationException(
+ "The implementation bean doesn't implement " +
+ m +
+ " as required by the interface: " +
+ getServiceImplementationBean()
+ );
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ValidationException(
+ "endpoint interface (" +
+ seiClassName +
+ ") or implementation bean (" +
+ sibClassName +
+ ") not on classpath"
+ );
+ }
+ }
+ }
+
+ /**
+ * Compares the signature of specified methods.
+ * @param m
+ * @return
+ */
+ private boolean doesImplement(Class sibClass, Method m)
+ {
+ if (null == m)
+ {
+ return false;
+ }
+
+ // search methods
+ boolean found = false;
+ for (Method _m : sibClass.getMethods())
+ {
+ // compare java method names; todo should this be the
action/operation name instead?
+ if (! m.getName().equals(_m.getName()))
+ {
+ continue;
+ }
+
+ // compare return types
+ if (! m.getReturnType().equals(_m.getReturnType()))
+ {
+ continue;
+ }
+
+ Type[] mTypes = m.getParameterTypes();
+ Type[] _mTypes = _m.getParameterTypes();
+
+ // compare number of arguments
+ if (mTypes.length != _mTypes.length)
+ {
+ continue;
+ }
+
+ // compare argument types
+ boolean isEqual = true;
+ for (int i = 0; i < mTypes.length; i++)
+ {
+ if (! mTypes[i].equals(_mTypes[i]))
+ {
+ isEqual = false;
+ break;
+ }
+ }
+
+ if (isEqual)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ return found;
}
public DefinitionsDocument getWSDLAsDocument()
@@ -611,7 +767,8 @@
return Collections.unmodifiableCollection(methods);
}
- public void addMethod(WebServiceMETHODMetadata method) {
+ public void addMethod(WebServiceMETHODMetadata method)
+ {
methods.add(method);
}
@@ -623,8 +780,14 @@
soapHandlers.add(soapHandler);
}
- public String getJavaFQClassName() {
- return javaFQClassName;
+ public String getServiceImplementationBean()
+ {
+ return sibClassName;
+ }
+
+ public String getServiceEndpointInterface()
+ {
+ return seiClassName;
}
private String getTargetNamespace(String fqClassName)
@@ -643,4 +806,4 @@
return "http://" + targetNamespace;
}
-}
+}
\ No newline at end of file
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WebServiceMetadataViewer.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WebServiceMetadataViewer.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WebServiceMetadataViewer.java
Tue Oct 26 11:23:11 2004
@@ -91,7 +91,7 @@
print( tab, "hcFileName" ,
webServiceTYPEMetadata.getHcFileName() );
print( tab, "hcName" , webServiceTYPEMetadata.getHcName()
);
//print( tab, "siRunAs" ,
webServiceTYPEMetadata.getSiRunAs() );
- print( tab, "javaFQClassName" ,
webServiceTYPEMetadata.getJavaFQClassName() );
+ print( tab, "serviceImplementationBean" ,
webServiceTYPEMetadata.getServiceImplementationBean() );
print("");
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
Tue Oct 26 11:23:11 2004
@@ -100,11 +100,17 @@
{
try {
Class seiClass = Class.forName(ws.endpointInterface());
- if (null ==
WsmReflectionAnnotationProcessor.getInstance().getObjectModelFromServiceEndpointInterface(seiClass))
+/*
+
+ // todo this code is currently not used; it will be needed for
the IDE milestone
+
+ // todo proper error checking -- e.g. check if all interface
methods are implemented in sib
+ if (null ==
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(null, seiClass))
{
throw new ProcessorException("Failed to create object
model for class: " + seiClass.getName());
// todo: proper error handling
}
+*/
}
catch (ClassNotFoundException e) {
e.printStackTrace(); // todo: proper error handling
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
Tue Oct 26 11:23:11 2004
@@ -60,91 +60,80 @@
* @param clazz Service implementation bean class.
* @return
*/
- public AnnotationModel getObjectModel(Class clazz)
+ public AnnotationModel getObjectModel(Class sibClass)
{
- WebService ws = (WebService) clazz.getAnnotation(WebService.class);
- if (null == ws)
+ return getWebServiceTYPEMetadata(sibClass);
+ }
+
+ /**
+ * @param sibClass
+ * @return
+ */
+ protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(Class sibClass)
+ {
+ if (null == sibClass)
{
return null;
}
- WebServiceTYPEMetadata wstm = null;
- if (0 == ws.endpointInterface().length())
+ // check WebService annotation
+ WebService wsAnnotation = (WebService)
sibClass.getAnnotation(WebService.class);
+ if (null == wsAnnotation)
{
- wstm = (WebServiceTYPEMetadata)
getObjectModelFromServiceImplementationBean(clazz);
+ return null;
}
- else
+
+ // check endpointInterface
+ boolean hasServiceEndpointInterface = false;
+ if ((null != wsAnnotation.endpointInterface()) && (0 <
wsAnnotation.endpointInterface().length()))
+ {
+ hasServiceEndpointInterface = true;
+ }
+
+ // webMethods
+ Collection<WebServiceMETHODMetadata> webMethods =
+ new ArrayList<WebServiceMETHODMetadata>();
+ String className;
+ Collection<Annotation> annotations;
+ if (hasServiceEndpointInterface)
{
try {
- Class seiClass = Class.forName(ws.endpointInterface());
- wstm = (WebServiceTYPEMetadata)
getObjectModelFromServiceEndpointInterface(seiClass);
-
- // todo: pass in parameters rather than adding serviceName and
endpointInterface afterwards
-
- wstm.setWsServiceName(ws.serviceName());
- wstm.setWsEndpointInterface(ws.endpointInterface());
-
- // todo: verify equivalence of SEI and SIB
+ Class seiClass =
Class.forName(wsAnnotation.endpointInterface());
+ Collection<Method> _methods =
Arrays.asList(sibClass.getMethods());
+ for (Method method : Arrays.asList(seiClass.getMethods()))
+ {
+ webMethods.add(getWebServiceMETHODMetadata(method));
+ }
+ annotations = (Collection<Annotation>)
Arrays.asList(seiClass.getAnnotations());
}
catch (ClassNotFoundException e)
{
- wstm = null;
+ return null;
}
}
-
- return wstm;
- }
-
- /**
- * Creates object model from service endpoint interface.
- * @param seiClass
- * @return
- */
- public AnnotationModel getObjectModelFromServiceEndpointInterface(Class
seiClass)
- {
- return getWebServiceTYPEMetadata(seiClass, false);
- }
-
- /**
- * Creates object model from service implementation bean.
- * @param sibClass
- * @return
- */
- public AnnotationModel getObjectModelFromServiceImplementationBean(Class
sibClass)
- {
- return getWebServiceTYPEMetadata(sibClass, true);
- }
-
- /**
- * @param clazz
- * @param isServiceImplementationBean
- * @return
- */
- protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(Class clazz,
boolean isServiceImplementationBean)
- {
- Collection<WebServiceMETHODMetadata> webMethods =
- new ArrayList<WebServiceMETHODMetadata>();
-
- // publish methods
- for (Method method : clazz.getMethods())
+ else
{
-
- if ((! isServiceImplementationBean) ||
- (isServiceImplementationBean &&
AnnotationModel.hasAnnotationType(Arrays.asList(method.getAnnotations()),
WebMethod.class)))
+ for (Method method: sibClass.getMethods())
{
- webMethods.add(getWebServiceMETHODMetadata(method));
+ // add only annotated methods
+ if
(AnnotationModel.hasAnnotationType(Arrays.asList(method.getAnnotations()),
WebMethod.class))
+ {
+ webMethods.add(getWebServiceMETHODMetadata(method));
+ }
}
+ annotations = (Collection<Annotation>)
Arrays.asList(sibClass.getAnnotations());
}
-
- // create & return webService
+
+ // create & return WebService
WebServiceTYPEMetadata wstm = null;
try {
wstm = new WebServiceTYPEMetadata(
- (WebService) clazz.getAnnotation(WebService.class),
- clazz.getName(),
- (Collection<Annotation>) Arrays.asList(clazz.getAnnotations()),
+ (WebService) sibClass.getAnnotation(WebService.class),
+ sibClass.getName(),
+ annotations,
webMethods
);
+ wstm.validate();
}
catch (Throwable t)
{
@@ -220,93 +209,5 @@
wspm = null;
}
return wspm;
- }
-
- /**
- * todo: needs to move into "object model"
- *
- * Checks whether the implementation bean implements all the methods
- * specified in the endpointInterface.
- * @param
- * @param
- * @return
- * @throws
- */
- private static void validate(WebServiceTYPEMetadata
implementationMetadata, WebServiceTYPEMetadata interfaceMetadata)
- throws ProcessorException
- {
- Collection<WebServiceMETHODMetadata> implementationMethods =
implementationMetadata.getMethods();
-
- Collection<WebServiceMETHODMetadata> interfaceMethods =
interfaceMetadata.getMethods();
-
- for( WebServiceMETHODMetadata interfaceMethod : interfaceMethods )
- {
- boolean exists = false;
- for( WebServiceMETHODMetadata implementationMethod :
implementationMethods )
- {
- exists = isSameMethodSignature( interfaceMethod,
implementationMethod );
- if( exists )
- {
- break;
- }
- }
-
- if(!exists)
- {
- throw new ProcessorException("The implementation bean ("+
implementationMetadata.getJavaFQClassName()
- + ") doesn't implement the " +
interfaceMethod.getWmOperationName()
- + " method in the endpoint
interface ("+ interfaceMetadata.getJavaFQClassName()
- + ")"
- );
- }
-
- }
-
- }
-
- /**
- * todo: needs to move into "object model"
- *
- * Compares the signature of specified methods.
- * @param
- * @param
- * @return
- */
- private static boolean isSameMethodSignature(WebServiceMETHODMetadata m1,
WebServiceMETHODMetadata m2)
- {
- // check java method names.
- if( ! m1.getJavaMethodName().equals(m2.getJavaMethodName()) )
- {
- return false;
- }
-
- // check java return types.
- if( ! m1.getJavaReturnType().equals(m2.getJavaReturnType()) )
- {
- return false;
- }
-
- List<WebServicePARAMETERMetadata> m1Params = m1.getParams();
- List<WebServicePARAMETERMetadata> m2Params = m2.getParams();
-
- // check the number of parameters.
- if( m1Params.size() != m2Params.size() )
- {
- return false;
- }
-
- // check each parameter's type.
- for( int i = 0 ; i < m1Params.size() ; i++ )
- {
- WebServicePARAMETERMetadata m1Param = m1Params.get(i);
- WebServicePARAMETERMetadata m2Param = m2Params.get(i);
-
- if( m1Param.getJavaType() != m2Param.getJavaType() )
- {
- return false;
- }
- }
-
- return true;
}
}