You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/09/03 18:12:01 UTC
svn commit: rev 37491 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm drt/tests/org/apache/beehive/wsm/jsr181 drt/tests/org/apache/beehive/wsm/jsr181/model drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations drt/tests/org/apache/beehive/wsm/jsr181/processor drt/tests/org/apache/beehive/wsm/jsr181/processor/apt drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection drt/tests/org/apache/beehive/wsm/jsr181/wsdl drt/tests/org/apache/beehive/wsm/wsdl src/api/javax/jws src/runtime/org/apache/beehive/wsm src/runtime/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/jsr181 src/runtime/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/jsr181/processor src/runtime/org/apache/beehive/wsm/jsr181/processor/apt src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection src/runtime/org/apache/beehive/wsm/jsr181/wsdl src/runtime/org/apache/beehive/wsm/processor src/runtime/org/apache/beehive/wsm/wsdl
Author: mmerz
Date: Fri Sep 3 09:12:01 2004
New Revision: 37491
Added:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/MetaDataTest.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/MetaDataTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/
- copied from rev 37438, incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/wsdl/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/
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/InitParamInfo.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InitParamInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/InvalidFileType.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InvalidFileType.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/QNameInfo.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/QNameInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SoapBindingInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SecurityRolesInfo.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SecurityRolesInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceMETHODMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServicePARAMETERMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java
- copied, changed from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceTYPEMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/
- copied from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/
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/wsdl/
- copied from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/
Removed:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/MetaDataTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/wsdl/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InitParamInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InvalidFileType.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/QNameInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SOAPMessageHandlersInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SecurityRolesInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SoapBindingInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WSMProcessorException.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceMETHODMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServicePARAMETERMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceTYPEMetadata.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessorTest.java
incubator/beehive/trunk/wsm/src/api/javax/jws/HandlerChain.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/ProcessorException.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TwoPhaseAnnotationProcessor.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/apt/WsmAnnotationProcessorFactory.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java
Log:
1) Modified javax.jws.HandlerChain.java to reflect JSR-181 document: add file(), commented out location()
2) Modified the object model to reflect the relationships between annotations as specified in JSR-181 more closely; the Beehive Wiki page will be updated accordingly.
3) Moved all
- jsr181-functionality into .../wsm/jsr181/
- classes related to the object model into .../wsm/jsr181/model
- functionality related to parsing byte-code files into .../wsm/jsr181/processor/reflection
- functionality related to parsing source-code files into .../wsm/jsr181/processor/apt
- classes related to the object model into .../wsm/jsr181/wsdl
Created .../wsm/axis directory parallel to .../wsm/jsr181 for Axis-specific code (e.g. plug-ins).
Directory structure:
.../trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/
+-- axis
+-+ jsr181
+-- model
+-+ processor
+-- apt
+-- reflection
+-- wsdl
4) Aligned the drt directory's contents accordingly.
Contributors: Jonathan Colwell, Daryoush Mehrtash, Anil Sharma, Michael Merz
Copied: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/MetaDataTest.java (from rev 37438, incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/MetaDataTest.java)
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/MetaDataTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/MetaDataTest.java Fri Sep 3 09:12:01 2004
@@ -1,30 +1,75 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeSOAPBindingAnnotation;
+import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeWebServiceAnnotation;
import junit.framework.TestCase;
-/*
- * Created on Aug 23, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-
-/**
- * @author dmehrtas
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
+
public class MetaDataTest extends TestCase {
- public void setUp( ) {
+ Collection<Annotation> typeAnnotations;
+ Collection<Annotation> methodAnnotations;
+ Collection<Annotation> paramAnnotations;
+ public void setUp( ) {
+ typeAnnotations = new ArrayList<Annotation>();
+ methodAnnotations = new ArrayList<Annotation>();
+ paramAnnotations = new ArrayList<Annotation>();
}
public void tearDown( ) {
-
- }
- public void testMetaDataFromCompiledClass() throws Exception {
- WebServiceTYPEMetadata model= WebServiceTYPEMetadata.buildWSMetadata(Class.forName("Foo"));
- assertTrue("Unexpected Webservice name", model.getWsName().compareTo("Abacus") == 0);
+ typeAnnotations.clear();
+ methodAnnotations.clear();
+ paramAnnotations.clear();
}
+
+ // test TYPE level annotations
+
+ public void testTYPEWebSerivceRequired() throws Exception {
+ // test to make sure the Type throws an exception if there are no WebMethod annotation defined.
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ typeAnnotations.add(new FakeSOAPBindingAnnotation(SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED, SOAPBinding.ParameterStyle.DEFAULT));
+ try {
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(typeAnnotations, "testclass", methodMetadata);
+ assertTrue( "Error, the TYPE annotation should fail without WebMethod", false);
+ }
+ catch (IllegalArgumentException e) {
+ // good case
+ }
+
+
+ }
+ public void testTYPEWebServiceAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ typeAnnotations.add(new FakeWebServiceAnnotation("testname", "testserviceName", "testwsdllocation", "testtargetnamespace", "testendpointinterface") );
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(typeAnnotations, "testclass", methodMetadata);
+ assertTrue(type.getWsName().compareTo("testname") == 0);
+ // TODO more assert
+
+ }
+ public void testTYPESOAPBindingAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ typeAnnotations.add(new FakeWebServiceAnnotation("testname", "testserviceName", "testwsdllocation", "testtargetnamespace", "testendpointinterface") );
+ typeAnnotations.add(new FakeSOAPBindingAnnotation(SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED, SOAPBinding.ParameterStyle.DEFAULT));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(typeAnnotations, "testclass", methodMetadata);
+
+ assertTrue(type.getSoapBinding().getStyle()==SOAPBinding.Style.RPC);
+ // TODO more asserts
+ }
+
+
+ //TODO: test METHOD level
+
+
+ //TODO: test PARAMETER level annotation
+
+
+ // TODO: test combination of type, method, annotation
}
+
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeSOAPBindingAnnotation.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,58 @@
+package org.apache.beehive.wsm.jsr181.model.fakeAnnotations;
+
+import java.lang.annotation.Annotation;
+
+import javax.jws.soap.SOAPBinding;
+
+/*
+ * 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:$
+ */
+
+//org.apache.beehive.wsm.model.TestSOAPBindingAnnotation.java
+public class FakeSOAPBindingAnnotation implements SOAPBinding, Annotation{
+
+ SOAPBinding.Style style;
+ SOAPBinding.Use use;
+ SOAPBinding.ParameterStyle parameterStyle;
+
+ /**
+ *
+ */
+ public FakeSOAPBindingAnnotation(SOAPBinding.Style style, SOAPBinding.Use use, SOAPBinding.ParameterStyle parameterStyle) {
+ this.style=style;
+ this.use=use;
+ this.parameterStyle=parameterStyle;
+ }
+
+
+ public Style style() {
+ return style;
+ }
+
+
+ public Use use() {
+ return use;
+ }
+
+ public ParameterStyle parameterStyle() {
+ return parameterStyle;
+ }
+ public Class annotationType() {
+ return SOAPBinding.class;
+ }
+
+}
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/FakeWebServiceAnnotation.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,103 @@
+package org.apache.beehive.wsm.jsr181.model.fakeAnnotations;
+
+import java.lang.annotation.Annotation;
+
+import javax.jws.WebService;
+
+/*
+ * 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:$
+ */
+
+//org.apache.beehive.wsm.model.testWebServiceAnnotation.java
+public class FakeWebServiceAnnotation implements WebService, Annotation {
+
+ private String name;
+
+ private String endpointInterface;
+
+ private String serviceName;
+
+ private String wsdlLocation;
+
+ private String targetNamespace;
+
+ public FakeWebServiceAnnotation(String name, String serviceName,
+ String wsdlLocation, String targetNamespace,
+ String endpointInterface) {
+ this.name = name;
+ this.serviceName = serviceName;
+ this.wsdlLocation = wsdlLocation;
+ this.targetNamespace = targetNamespace;
+ this.endpointInterface = endpointInterface;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jws.WebService#name()
+ */
+ public String name() {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jws.WebService#serviceName()
+ */
+ public String serviceName() {
+ return serviceName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jws.WebService#wsdlLocation()
+ */
+ public String wsdlLocation() {
+ return wsdlLocation;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jws.WebService#targetNamespace()
+ */
+ public String targetNamespace() {
+ return targetNamespace;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.jws.WebService#endpointInterface()
+ */
+ public String endpointInterface() {
+ return endpointInterface;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.annotation.Annotation#annotationType()
+ */
+ public Class annotationType() {
+ return WebService.class;
+ }
+
+}
+
Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/ReflectionProcessingTest.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,24 @@
+package org.apache.beehive.wsm.jsr181.processor.reflection;
+
+import junit.framework.TestCase;
+
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+import org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+
+
+public class ReflectionProcessingTest extends TestCase {
+
+ public void setUp( ) {
+ }
+
+ public void tearDown( ) {
+
+ }
+ public void testMetaDataFromCompiledClass() throws Exception {
+ WebServiceTYPEMetadata model= WsmReflectionAnnotationProcessor.getObjectModel(Class.forName("Foo"));
+ assertTrue("Unexpected Webservice name", model.getWsName().compareTo("Abacus") == 0);
+ }
+
+
+
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessorTest.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/wsdl/WSDLProcessorTest.java (original)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessorTest.java Fri Sep 3 09:12:01 2004
@@ -15,9 +15,11 @@
*
* $Header:$
*/
-package org.apache.beehive.wsm.wsdl;
+package org.apache.beehive.wsm.jsr181.wsdl;
import java.io.File;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
import org.xmlsoap.schemas.wsdl.TBinding;
import org.xmlsoap.schemas.wsdl.TBindingOperation;
import org.xmlsoap.schemas.wsdl.TBindingOperationMessage;
@@ -149,5 +151,24 @@
}
}
}
- }
+ }
+
+ public void testWSMConversion() throws Exception
+ {
+ File wsdlOut = new File( BEEHIVE_HOME, "wsm/drt/logs/WSM_WSDL.xml" );
+ assertNotNull(doc);
+ if (doc != null) {
+ org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata wsm = WSDLProcessor.toWebServiceMetadata(doc);
+ assertEquals("Cheetorama", wsm.getWsServiceName());
+ assertEquals("Abacus", wsm.getWsName());
+ assertEquals("http://www.superflaco.com/AnnotationTest",
+ wsm.getWsTargetNamespace());
+ assertEquals(2, wsm.getMethods().size());
+
+ WSDLProcessor.fromWebServiceMetadata(wsm)
+ .save(wsdlOut, new XmlOptions()
+ .setSavePrettyPrint()
+ .setSavePrettyPrintIndent(4));
+ }
+ }
}
Modified: incubator/beehive/trunk/wsm/src/api/javax/jws/HandlerChain.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/api/javax/jws/HandlerChain.java (original)
+++ incubator/beehive/trunk/wsm/src/api/javax/jws/HandlerChain.java Fri Sep 3 09:12:01 2004
@@ -27,7 +27,8 @@
* may be relative or absolute. Relative URLs are relative to
* the location of the Java WS file at the time of processing.
*/
- String location();
+// String location(); // this does not comply to the JSR-181 spec;
+ String file(); // added in compliance to the JSR-181 spec;
/**
* The name of the handler chain within the file
Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,51 @@
+package org.apache.beehive.wsm.jsr181.model;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+/*
+ * 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:$
+ */
+
+//org.apache.beehive.wsm.AnnotationModel.java
+
+public class AnnotationModel {
+
+ /**
+ *
+ */
+ public AnnotationModel() {
+ super();
+ }
+
+ protected boolean hasAnnotationType(Collection<Annotation> annotations, Class<? extends Annotation> annotationType)
+ {
+ if ((null != annotations) && (null != annotationType) && (0 < annotations.size()))
+ {
+ for ( Annotation a : annotations )
+ {
+ if (a.annotationType() == annotationType)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/InitParamInfo.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InitParamInfo.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InitParamInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/InitParamInfo.java Fri Sep 3 09:12:01 2004
@@ -1,8 +1,5 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
-import org.apache.beehive.wsm.WSMProcessorException;
-
-import javax.jws.InitParam;
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -26,6 +23,14 @@
String name;
String value;
+
+
+ /**
+ *
+ */
+ public InitParamInfo() {
+ super();
+ }
/**
* @return Returns the name.
*/
@@ -50,8 +55,6 @@
public void setValue(String value) {
this.value = value;
}
- public InitParamInfo() {
- }
-
+
}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/InvalidFileType.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InvalidFileType.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/InvalidFileType.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/InvalidFileType.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
/*
* Copyright 2004 The Apache Software Foundation
*
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/QNameInfo.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/QNameInfo.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/QNameInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/QNameInfo.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
import javax.jws.QName;
/*
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SoapBindingInfo.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SoapBindingInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPBindingInfo.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
import javax.jws.soap.SOAPBinding;
@@ -20,12 +20,21 @@
* $Header:$
*/
-public class SoapBindingInfo {
+public class SOAPBindingInfo {
SOAPBinding.Style style;
SOAPBinding.Use use;
SOAPBinding.ParameterStyle parameterStyle;
-
+ /**
+ *
+ */
+ public SOAPBindingInfo() {
+ super();
+ }
+
+ public SOAPBindingInfo (SOAPBinding annotation) {
+ initFromAnnotation(annotation);
+ }
/**
* @return Returns the parameterStyle.
*/
@@ -62,4 +71,13 @@
public void setUse(SOAPBinding.Use use) {
this.use = use;
}
+ /**
+ * @param annotation
+ * @return
+ */
+ private void initFromAnnotation(SOAPBinding annotation) {
+ setStyle(annotation.style());
+ setUse(annotation.use());
+ setParameterStyle(annotation.parameterStyle());
+ }
}
Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,126 @@
+package org.apache.beehive.wsm.jsr181.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.jws.InitParam;
+import javax.jws.QName;
+import javax.jws.soap.SOAPMessageHandler;
+
+
+/*
+ * 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 SOAPMessageHandlerInfo {
+ String name;
+ String className;
+ Collection<InitParam> params = new ArrayList<InitParam>();
+ Collection<String> roles = new ArrayList<String>();
+ Collection<QName> headers = new ArrayList<QName>();
+ /**
+ *
+ */
+ public SOAPMessageHandlerInfo() {
+ super();
+ }
+ /**
+ * @return Returns the className.
+ */
+ public String getClassName() {
+ return className;
+ }
+ /**
+ * @param className The className to set.
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the headers.
+ */
+ public Collection<QName> getHeaders() {
+ return Collections.unmodifiableCollection(headers);
+ }
+
+ public void addHeader(QName header) {
+ headers.add(header);
+ }
+ /**
+ * @param collection
+ */
+ private void addHeaders(Collection<QName> headers) {
+ this.headers.addAll(headers);
+ }
+
+ /**
+ * @return Returns the params.
+ */
+ public Collection<InitParam> getParams() {
+ return Collections.unmodifiableCollection(params);
+ }
+
+ public void addInitParam(InitParam param) {
+ params.add(param);
+ }
+
+ public void addInitParam(Collection<InitParam> params) {
+ params.addAll(params);
+ }
+ /**
+ * @return Returns the roles.
+ */
+ public Collection<String> getRoles() {
+ return Collections.unmodifiableCollection(roles);
+ }
+
+ public void addRole(String role) {
+ roles.add(role);
+ }
+
+ public void addRoles(Collection<String> roles) {
+ roles.addAll(roles);
+ }
+ /**
+ * @param handler
+ * @return
+ */
+ public SOAPMessageHandlerInfo initFromAnnotation(SOAPMessageHandler annotation) {
+ setName(annotation.name());
+ setClassName(annotation.className());
+ addInitParam(Arrays.asList(annotation.initParams()));
+ addRoles(Arrays.asList(annotation.roles()));
+ addHeaders(Arrays.asList(annotation.headers()));
+
+ return null;
+ }
+
+}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SecurityRolesInfo.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SecurityRolesInfo.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/SecurityRolesInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SecurityRolesInfo.java Fri Sep 3 09:12:01 2004
@@ -1,9 +1,11 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
+
+import javax.jws.SecurityRoles;
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -27,6 +29,19 @@
Collection<String> rolesAllowed = new ArrayList<String>();
Collection<String> rolesReferenced = new ArrayList<String>();
+
+ /**
+ *
+ */
+ public SecurityRolesInfo() {
+ super();
+ }
+
+
+ public SecurityRolesInfo (SecurityRoles annotation) {
+ initFromAnnotation(annotation);
+ }
+
/**
* @return Returns the wrRolesAllowed.
*/
@@ -54,6 +69,18 @@
public void addRolesReferenced(Collection<String> roles) {
rolesReferenced.addAll(roles);
+ }
+
+ /**
+ * @param annotation
+ * @return
+ */
+ private SecurityRolesInfo initFromAnnotation(SecurityRoles annotation) {
+ addRolesAllowed(Arrays.asList(annotation.rolesAllowed()));
+ addRolesReferenced(Arrays.asList(annotation.rolesReferenced()));
+ return null;
}
+
+
}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceMETHODMetadata.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceMETHODMetadata.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceMETHODMetadata.java Fri Sep 3 09:12:01 2004
@@ -1,9 +1,24 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.jws.Oneway;
+import javax.jws.SecurityIdentity;
+import javax.jws.SecurityRoles;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.soap.DocumentWrapper;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPMessageHandlers;
+
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -22,135 +37,320 @@
* $Header:$
*/
-public class WebServiceMETHODMetadata {
+public class WebServiceMETHODMetadata extends AnnotationModel {
String wmOperationName;
+
String wmAction;
-
- boolean oneWay; // should be called oOneWay, but that looks strange!
-
+
+ boolean oneWay = false; // should be called oOneWay, but that looks strange!
+
List<WebServicePARAMETERMetadata> params = new ArrayList<WebServicePARAMETERMetadata>();
- String wrName; // webresults
-
- SoapBindingInfo soapBinding;
+ String wrName; // webresults
+
+ SOAPBindingInfo soapBinding;
+
+ QNameInfo dwRequestElement;
+
+ QNameInfo dwResponseElement;
- String dwRequestElement;
- String dwResponseElement;
-
SecurityRolesInfo securityRoles;
+
private String javaMethodName;
- private String javaReturnType;
- public WebServiceMETHODMetadata(String javaMethodName, String javaReturnType) {
- this.javaMethodName = javaMethodName;
- this.javaReturnType = javaReturnType;
+ private Class javaReturnType;
+
+
+
+ /**
+ *
+ */
+ public WebServiceMETHODMetadata() {
+ super();
}
+ public WebServiceMETHODMetadata(Collection<Annotation> annotations,
+ String javaMethodName, Class javaReturnType,
+ List<WebServicePARAMETERMetadata> webParams) {
+ // check parameters
+ if ((null == javaMethodName) || (null == javaReturnType)) {
+ throw new IllegalArgumentException(
+ "javaMethodName or javaReturnType not set");
+ }
+ this.javaMethodName = javaMethodName;
+ this.javaReturnType = javaReturnType;
+
+ // check required parameters
+ if (!hasAnnotationType(annotations, javax.jws.WebMethod.class)) {
+ throw new IllegalArgumentException("@WebMethod is required");
+ }
+
+ // extract information from annotations
+ for (Annotation a : annotations) {
+
+ // add defaults
+ if (a.annotationType() == javax.jws.Oneway.class) {
+ initFromAnnotation((javax.jws.Oneway) a);
+ enforceAnnotationRules((javax.jws.Oneway) a);
+
+ } else if (a.annotationType() == javax.jws.SecurityRoles.class) {
+ initFromAnnotation((javax.jws.SecurityRoles) a);
+ enforceAnnotationRules((javax.jws.SecurityRoles) a);
+
+ } else if (a.annotationType() == javax.jws.WebMethod.class) {
+ initFromAnnotation((javax.jws.WebMethod) a);
+ enforceAnnotationRules((javax.jws.WebMethod) a);
+
+ } else if (a.annotationType() == javax.jws.WebResult.class) {
+ initFromAnnotation((javax.jws.WebResult) a);
+ enforceAnnotationRules((javax.jws.WebResult) a);
+
+ } else if (a.annotationType() == javax.jws.soap.DocumentWrapper.class) {
+ initFromAnnotation((javax.jws.soap.DocumentWrapper) a);
+ enforceAnnotationRules((javax.jws.soap.DocumentWrapper) a);
+
+ } else if (a.annotationType() == javax.jws.soap.SOAPBinding.class) {
+ initFromAnnotation((javax.jws.soap.SOAPBinding) a);
+ enforceAnnotationRules((javax.jws.soap.SOAPBinding) a);
+
+ } else {
+ // todo: warning -- unknown annotation
+ }
+ }
+
+ // set WebServicePARAMETERMetadata
+ int i = 0;
+ for (WebServicePARAMETERMetadata wspm : webParams) {
+ i++;
+ // todo check defaults for wspm
+ if (0 == wspm.getWpName().length()) {
+ if (wspm.getSourceName() == null
+ || wspm.getSourceName().length() == 0)
+ wspm.setWpName("param_" + i);
+ else
+ wspm.setWpName(wspm.getSourceName());
+ }
+
+ addParam(wspm);
+ }
+ }
+
+
+ private void enforceAnnotationRules(javax.jws.Oneway ow) {
+ // no defaults to handle
+ }
+
+ private void enforceAnnotationRules(javax.jws.SecurityRoles sr) {
+ // no defaults to handle
+ }
+
+ private void enforceAnnotationRules(javax.jws.WebMethod wm) {
+ // deferred --> requires TYPE information: targetNamespace
+ }
+
+ private void enforceAnnotationRules(javax.jws.WebResult wr) {
+ if (0 == getWrName().length()) {
+ setWrName("result");
+ }
+ }
+
+ private void enforceAnnotationRules(javax.jws.soap.DocumentWrapper dw) {
+ // deferred --> requires TYPE information: targetNamespace
+ }
+
+ private void enforceAnnotationRules(javax.jws.soap.SOAPBinding sb) {
+ // deferred --> requires TYPE information: SOAPBinding
+ }
+
+ /**
+ * @param annotation
+ */
+ private void initFromAnnotation(SecurityRoles annotation) {
+ if (null == annotation)
+ return;
+ setSecurityRoles(new SecurityRolesInfo(annotation));
+ return;
+ }
+
+ /**
+ * @param annotation
+ */
+ private void initFromAnnotation(SOAPBinding annotation) {
+ if (null == annotation)
+ return;
+ setSoapBinding(new SOAPBindingInfo(annotation));
+
+ }
+
+ /**
+ * @param annotation
+ */
+ private void initFromAnnotation(DocumentWrapper annotation) {
+ if (null == annotation)
+ return;
+ setDwRequestElement(new QNameInfo(annotation.requestElement()));
+ setDwResponseElement(new QNameInfo(annotation.responseElement()));
+ }
+
+ /**
+ * @param annotation
+ */
+ private void initFromAnnotation(WebResult annotation) {
+ if (null == annotation)
+ return;
+ setWrName(annotation.name());
+ }
+
+ /**
+ * @param annotation
+ */
+ private void initFromAnnotation(Oneway annotation) {
+ if (null == annotation)
+ setOneWay(false);
+ else
+ setOneWay(true);
+
+ }
+
+ /**
+ * @param webMethodAnnotation
+ */
+ private void initFromAnnotation(WebMethod annotation) {
+ if (null == annotation)
+ return;
+ setWmAction(annotation.action());
+ setWmOperationName(annotation.operationName());
+ }
+
/**
* @return Returns the dwRequestElement.
*/
- public String getDwRequestElement() {
+ public QNameInfo getDwRequestElement() {
return dwRequestElement;
}
+
/**
- * @param dwRequestElement The dwRequestElement to set.
+ * @param dwRequestElement
+ * The dwRequestElement to set.
*/
- public void setDwRequestElement(String dwRequestElement) {
+ public void setDwRequestElement(QNameInfo dwRequestElement) {
this.dwRequestElement = dwRequestElement;
}
+
/**
* @return Returns the dwResponseElement.
*/
- public String getDwResponseElement() {
+ public QNameInfo getDwResponseElement() {
return dwResponseElement;
}
+
/**
- * @param dwResponseElement The dwResponseElement to set.
+ * @param dwResponseElement
+ * The dwResponseElement to set.
*/
- public void setDwResponseElement(String dwResponseElement) {
+ public void setDwResponseElement(QNameInfo dwResponseElement) {
this.dwResponseElement = dwResponseElement;
}
+
/**
* @return Returns the oneWay.
*/
public boolean isOneWay() {
return oneWay;
}
+
/**
- * @param oneWay The oneWay to set.
+ * @param oneWay
+ * The oneWay to set.
*/
public void setOneWay(boolean oneWay) {
this.oneWay = oneWay;
}
+
/**
* @return Returns the securityRoles.
*/
public SecurityRolesInfo getSecurityRoles() {
return securityRoles;
}
+
/**
- * @param securityRoles The securityRoles to set.
+ * @param securityRoles
+ * The securityRoles to set.
*/
public void setSecurityRoles(SecurityRolesInfo securityRoles) {
this.securityRoles = securityRoles;
}
+
/**
* @return Returns the soapBinding.
*/
- public SoapBindingInfo getSoapBinding() {
+ public SOAPBindingInfo getSoapBinding() {
return soapBinding;
}
+
/**
- * @param soapBinding The soapBinding to set.
+ * @param soapBinding
+ * The soapBinding to set.
*/
- public void setSoapBinding(SoapBindingInfo soapBinding) {
+ public void setSoapBinding(SOAPBindingInfo soapBinding) {
this.soapBinding = soapBinding;
}
+
/**
* @return Returns the wmAction.
*/
public String getWmAction() {
return wmAction;
}
+
/**
- * @param wmAction The wmAction to set.
+ * @param wmAction
+ * The wmAction to set.
*/
public void setWmAction(String wmAction) {
this.wmAction = wmAction;
}
+
/**
* @return Returns the wmOperationName.
*/
public String getWmOperationName() {
return wmOperationName;
}
+
/**
- * @param wmOperationName The wmOperationName to set.
+ * @param wmOperationName
+ * The wmOperationName to set.
*/
public void setWmOperationName(String wmOperationName) {
this.wmOperationName = wmOperationName;
}
+
/**
* @return Returns the wrName.
*/
public String getWrName() {
return wrName;
}
+
/**
- * @param wrName The wrName to set.
+ * @param wrName
+ * The wrName to set.
*/
public void setWrName(String wrName) {
this.wrName = wrName;
}
+
/**
* @return Returns the params.
*/
public List<WebServicePARAMETERMetadata> getParams() {
return Collections.unmodifiableList(params);
}
-
- public void addParams(WebServicePARAMETERMetadata param) {
+
+ public void addParam(WebServicePARAMETERMetadata param) {
params.add(param);
}
@@ -158,7 +358,8 @@
return javaMethodName;
}
- public String getJavaReturnType() {
+ public Class getJavaReturnType() {
return javaReturnType;
}
-}
+
+}
\ No newline at end of file
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServicePARAMETERMetadata.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServicePARAMETERMetadata.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServicePARAMETERMetadata.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,5 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
+
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -17,67 +18,148 @@
* $Header:$
*/
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collection;
+
import javax.jws.WebParam;
-public class WebServicePARAMETERMetadata {
+public class WebServicePARAMETERMetadata extends AnnotationModel {
String wpName;
- WebParam.Mode wpMode;
+
+ WebParam.Mode wpMode;
+
boolean wpHeader;
- private String javaType;
+
+ private Class javaType;
+
+ private String sourceName;
+
+
+
+ /**
+ *
+ */
+ public WebServicePARAMETERMetadata() {
+ super();
+ }
- public WebServicePARAMETERMetadata(String javaType) {
+ private void setDefaults(javax.jws.WebParam wp) {
+ // deferred --> requires METHOD information: position
+ }
+
+ // sourceName is argument name in the source file. It can be null if the
+ // name is not known.
+ public WebServicePARAMETERMetadata(Collection<Annotation> annotations,
+ Class javaType, String sourceName) {
+ // check parameters
+ if (null == javaType) {
+ throw new IllegalArgumentException("javaType not set");
+ }
+
this.javaType = javaType;
+ this.sourceName = sourceName;
+
+ // check required parameters
+ if (!hasAnnotationType(annotations, javax.jws.WebParam.class)) {
+ throw new IllegalArgumentException("@WebParam is required");
+ }
+ // extract information from annotations
+ for (Annotation a : annotations) {
+
+ // add defaults
+ if (a.annotationType() == javax.jws.WebParam.class) {
+ initFromAnnotation((javax.jws.WebParam) a);
+ enforceAnnotationRules((javax.jws.WebParam) a);
+
+ }
+ }
+
}
+
/**
* @return Returns the wpHeader.
*/
public boolean isWpHeader() {
return wpHeader;
}
+
/**
- * @param wpHeader The wpHeader to set.
+ * @param wpHeader
+ * The wpHeader to set.
*/
public void setWpHeader(boolean wpHeader) {
this.wpHeader = wpHeader;
}
+
/**
* @return Returns the wpMode.
*/
public WebParam.Mode getWpMode() {
return wpMode;
}
+
/**
- * @param wpMode The wpMode to set.
+ * @param wpMode
+ * The wpMode to set.
*/
public void setWpMode(WebParam.Mode wpMode) {
this.wpMode = wpMode;
}
+
/**
* @return Returns the wpName.
*/
public String getWpName() {
return wpName;
}
+
/**
- * @param wpName The wpName to set.
+ * @param wpName
+ * The wpName to set.
*/
public void setWpName(String wpName) {
this.wpName = wpName;
}
+
+
/**
- *
+ * @return Returns the javaType.
*/
- public WebServicePARAMETERMetadata() {
- super();
- // TODO Auto-generated constructor stub
+ public Class getJavaType() {
+ return javaType;
+ }
+
+ public void setJavaType(Class javaType) {
+ this.javaType = javaType;
+ }
+ /**
+ * @param webParam
+ */
+ private void initFromAnnotation(WebParam annotation) {
+ setWpName(annotation.name());
+ setWpMode(annotation.mode());
+ setWpHeader(annotation.header());
+ }
+
+ private void enforceAnnotationRules(javax.jws.WebParam wp) {
+ // deferred --> requires METHOD information: position
}
/**
- * @return Returns the javaType.
+ * @return Returns the sourceName.
*/
- public String getJavaType() {
- return javaType;
+ public String getSourceName() {
+ return sourceName;
+ }
+
+ /**
+ * @param sourceName
+ * The sourceName to set.
+ */
+ public void setSourceName(String sourceName) {
+ this.sourceName = sourceName;
}
-}
+}
\ No newline at end of file
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java (from rev 37438, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceTYPEMetadata.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/WebServiceTYPEMetadata.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/WebServiceTYPEMetadata.java Fri Sep 3 09:12:01 2004
@@ -1,17 +1,21 @@
-package org.apache.beehive.wsm;
+package org.apache.beehive.wsm.jsr181.model;
import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.jws.*;
import javax.jws.soap.*;
-import org.apache.beehive.wsm.wsdl.WSDLProcessor;
+import org.apache.beehive.wsm.jsr181.wsdl.WSDLProcessor;
import org.apache.xmlbeans.XmlException;
import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
+
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -30,7 +34,7 @@
* $Header:$
*/
-public class WebServiceTYPEMetadata {
+public class WebServiceTYPEMetadata extends AnnotationModel {
String wsName;
@@ -42,13 +46,13 @@
Collection<WebServiceMETHODMetadata> methods = new ArrayList<WebServiceMETHODMetadata>();
- SoapBindingInfo soapBinding;
+ SOAPBindingInfo soapBinding;
String hcFileName;
String hcName;
- Map<String, SOAPMessageHandlersInfo> soapHandlers = new HashMap<String, SOAPMessageHandlersInfo>();
+ List<SOAPMessageHandlerInfo> soapHandlers = new ArrayList<SOAPMessageHandlerInfo>();
SecurityRolesInfo securityRoles;
@@ -59,51 +63,18 @@
- static public WebServiceTYPEMetadata buildWSMetadata(Class clazz) {
- WebServiceTYPEMetadata model = new WebServiceTYPEMetadata(clazz.getName());
- //set the webservice annotation
- WebService webServiceAnnotation = (WebService)clazz.getAnnotation(WebService.class);
- model.setFromAnnotation(webServiceAnnotation);
- SOAPBinding soapBindingAnnotation = (SOAPBinding)clazz.getAnnotation(SOAPBinding.class);
- model.setFromAnnotation(soapBindingAnnotation);
- //TODO: Add the rest from Anil code here.
-
- return model;
- }
-
- private void setFromAnnotation(WebService annotation) {
- setWsName( annotation.name());
- setWsServiceName(annotation.serviceName());
- setWsTargetNamespace(annotation.targetNamespace());
- setWsWsdlLocation(annotation.wsdlLocation());
-
- }
-
- private void setFromAnnotation(SOAPBinding annotation) {
- //TODO: From Anil code
+ /**
+ *
+ */
+ public WebServiceTYPEMetadata() {
+ super();
}
- private void setFromAnnotation(HandlerChain annotation) {
- //TODO: From Anil code
-
- }
- private void setFromAnnotation(SOAPMessageHandler annotation) {
- //TODO: From Anil code
-
- }
- private void setFromAnnotation(SecurityRoles annotation) {
- //TODO: From Anil code
-
- }
- private void setFromAnnotation(SecurityIdentity annotation) {
- //TODO: From Anil code
-
- }
static public WebServiceTYPEMetadata buildWSMetadata(String filename)
throws InvalidFileType {
if (filename.endsWith(".java") || filename.endsWith(".jws")) {
- //TODO: get the object model from 2 phase processor
+ //TODO: get the object model from 2 phase processor
return null;
} else {
throw new InvalidFileType(
@@ -113,10 +84,180 @@
}
}
-
- // Constructor
- public WebServiceTYPEMetadata(String javaFQClassName) {
- this.javaFQClassName = javaFQClassName;
+ public WebServiceTYPEMetadata( Collection<Annotation> annotations,
+ String fqClassName,
+ Collection<WebServiceMETHODMetadata> webMethods) {
+ super();
+ // check parameters
+ if ((null == fqClassName) || (0 == fqClassName.length())) {
+ throw new IllegalArgumentException("className not set");
+ }
+ this.javaFQClassName = fqClassName;
+
+ // check required parameters
+ if (!hasAnnotationType(annotations, javax.jws.WebService.class)) {
+ throw new IllegalArgumentException("@WebService is required");
+ }
+
+ // extract information from annotations
+ for (Annotation a : annotations) {
+ if (a.annotationType() == javax.jws.WebService.class) {
+ initFromAnnotation((javax.jws.WebService)a);
+ enforceAnnotationRules((javax.jws.WebService)a);
+ }
+ // @HandlerChain
+ else if (a.annotationType() == javax.jws.HandlerChain.class) {
+ initFromAnnotation((javax.jws.HandlerChain)a);
+ enforceAnnotationRules((javax.jws.HandlerChain)a);
+ }
+
+ // @SecurityIdentity
+ else if (a.annotationType() == javax.jws.SecurityIdentity.class) {
+ initFromAnnotation((javax.jws.SecurityIdentity)a);
+ enforceAnnotationRules((javax.jws.SecurityIdentity)a);
+ }
+
+ // @SecurityRoles
+ else if (a.annotationType() == javax.jws.SecurityRoles.class) {
+ initFromAnnotation((javax.jws.SecurityRoles)a);
+ enforceAnnotationRules((javax.jws.SecurityRoles)a);
+ }
+
+ // @SOAPBinding (TYPE-level)
+ else if (a.annotationType() == javax.jws.soap.SOAPBinding.class) {
+ initFromAnnotation((javax.jws.soap.SOAPBinding)a);
+ enforceAnnotationRules((javax.jws.soap.SOAPBinding)a);
+ }
+
+ // @SOAPMessageHandlers
+ else if (a.annotationType() == javax.jws.soap.SOAPMessageHandlers.class) {
+ initFromAnnotation((javax.jws.soap.SOAPMessageHandlers)a);
+ enforceAnnotationRules((javax.jws.soap.SOAPMessageHandlers)a);
+ }
+ else {
+ //TODO: What to do with annotations that are not specified in 181, for now ignore them.
+ }
+
+ }
+
+ // set WebServiceMETHODMetadata
+ for (WebServiceMETHODMetadata wsmm : webMethods) {
+ // todo: check defaults for wsmm -- override with TYPE data if
+ // necessary
+ addMethod(wsmm);
+ }
+ }
+
+ // todo: check if SOAPMessageHandlers() is used anywhere -> throw error!
+ private void enforceAnnotationRules(javax.jws.HandlerChain hc) {
+ // no defaults to handle
+ }
+
+ private void enforceAnnotationRules(javax.jws.SecurityIdentity si) {
+ // no defaults to handle
+ }
+
+ private void enforceAnnotationRules(javax.jws.SecurityRoles sr) {
+ // no defaults to handle
+ }
+
+ private void enforceAnnotationRules(javax.jws.WebService ws) {
+ String className = "";
+ String packageName = "";
+
+ // name
+ if (0 == getWsName().length()) {
+ setWsName(className);
+ }
+
+ // serviceName
+ if (0 == getWsServiceName().length()) {
+ setWsServiceName(className + "Service");
+ }
+
+ // targetNamespace
+ if (0 == getWsTargetNamespace().length()) {
+ setWsTargetNamespace(packageName);
+ }
+ }
+
+ private void enforceAnnotationRules(javax.jws.soap.SOAPBinding sb) {
+ SOAPBindingInfo sbi = getSoapBinding();
+ if (null == sbi) {
+ throw new IllegalArgumentException(
+ "illegal SOAPBinding annotation on WebService class:\n\t"
+ + sb);
+ }
+
+ // style
+ if (javax.jws.soap.SOAPBinding.Style.DEFAULT == sbi.getStyle()) {
+ sbi.setStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);
+ }
+
+ // use
+ if (javax.jws.soap.SOAPBinding.Use.DEFAULT == sbi.getUse()) {
+ sbi.setUse(javax.jws.soap.SOAPBinding.Use.LITERAL);
+ }
+
+ // default
+ if (javax.jws.soap.SOAPBinding.ParameterStyle.DEFAULT == sbi
+ .getParameterStyle()) {
+ sbi
+ .setParameterStyle(javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED);
+ }
+ }
+
+ // todo: check if SOAPMessageHandlers() is used anywhere -> throw error!
+ private void enforceAnnotationRules(javax.jws.soap.SOAPMessageHandlers smh) {
+ // no defaults to handle
+ }
+
+ protected void initFromAnnotation(WebService annotation) {
+ if (null == annotation)
+ return;
+ setWsName(annotation.name());
+ setWsServiceName(annotation.serviceName());
+ setWsTargetNamespace(annotation.targetNamespace());
+ setWsWsdlLocation(annotation.wsdlLocation());
+
+ }
+
+ private void initFromAnnotation(SOAPBinding annotation) {
+ if (null == annotation)
+ return;
+ setSoapBinding(new SOAPBindingInfo(annotation));
+ }
+
+ private void initFromAnnotation(HandlerChain annotation) {
+ if (null == annotation)
+ return;
+ setHcFileName(annotation.file());
+ setHcName(annotation.name());
+
+ }
+
+ private void initFromAnnotation(SOAPMessageHandlers annotation) {
+ if (null == annotation)
+ return;
+ SOAPMessageHandler[] soapMsgHandlerArray = annotation.value();
+
+ for (int i = 0; i < soapMsgHandlerArray.length; i++) {
+ addSOAPHandler(new SOAPMessageHandlerInfo()
+ .initFromAnnotation(soapMsgHandlerArray[i]));
+ }
+ }
+
+ private void initFromAnnotation(SecurityRoles annotation) {
+ if (null == annotation)
+ return;
+ setSecurityRoles(new SecurityRolesInfo(annotation));
+
+ }
+
+ private void initFromAnnotation(SecurityIdentity annotation) {
+ if (null == annotation)
+ return;
+ setSiRunAs(annotation.runAs());
}
public boolean validate() {
@@ -129,8 +270,7 @@
return WSDLProcessor.parseWSDL(getWsWsdlLocation());
}
-
- /**
+ /**
* @return Returns the hcFileName.
*/
public String getHcFileName() {
@@ -193,7 +333,7 @@
/**
* @return Returns the soapBinding.
*/
- public SoapBindingInfo getSoapBinding() {
+ public SOAPBindingInfo getSoapBinding() {
return soapBinding;
}
@@ -201,7 +341,7 @@
* @param soapBinding
* The soapBinding to set.
*/
- public void setSoapBinding(SoapBindingInfo soapBinding) {
+ public void setSoapBinding(SOAPBindingInfo soapBinding) {
this.soapBinding = soapBinding;
}
@@ -279,8 +419,12 @@
/**
* @return Returns the soapHandlers.
*/
- public Map<String, SOAPMessageHandlersInfo> getSoapHandlers() {
- return soapHandlers;
+ public List<SOAPMessageHandlerInfo> getSoapHandlers() {
+ return Collections.unmodifiableList(soapHandlers);
+ }
+
+ public void addSOAPHandler(SOAPMessageHandlerInfo soapHandler) {
+ soapHandlers.add(soapHandler);
}
/**
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/ProcessorException.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/ProcessorException.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/ProcessorException.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm.runtime.processor;
+package org.apache.beehive.wsm.jsr181.processor;
/*
* Copyright 2004 The Apache Software Foundation
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TwoPhaseAnnotationProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/TwoPhaseAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TwoPhaseAnnotationProcessor.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm.runtime.processor.apt;
+package org.apache.beehive.wsm.jsr181.processor.apt;
/*
* Copyright 2004 The Apache Software Foundation
@@ -32,7 +32,7 @@
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.Declaration;
-import org.apache.beehive.wsm.runtime.processor.ProcessorException;
+import org.apache.beehive.wsm.jsr181.processor.ProcessorException;
/**
* The TwoPhaseAnnotationProcessor class is an abstract class that implements the APT
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/processor/apt/WsmAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm.runtime.processor.apt;
+package org.apache.beehive.wsm.jsr181.processor.apt;
/*
* Copyright 2004 The Apache Software Foundation
@@ -18,322 +18,127 @@
* $Header:$
*/
-import java.io.IOException;
-import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import java.lang.annotation.Annotation;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationMirror;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.Declaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.ParameterDeclaration;
-import org.apache.beehive.wsm.runtime.processor.ProcessorException;
-
-import org.apache.beehive.wsm.*;
+import org.apache.beehive.wsm.jsr181.model.*;
-
-/**
- * FIXME Should this also generate a new source file and/or class file that
- * contains default values as specified in JSR-181?
- */
public class WsmAnnotationProcessor extends TwoPhaseAnnotationProcessor
{
/**
* Constructor.
- * @param atds
- * @param env
+ * @param _atds
+ * @param _env
* @return
*/
- public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env)
+ public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> _atds,
+ AnnotationProcessorEnvironment _env)
{
- super(atds, env);
+ super(_atds, _env);
}
-
- public WebServiceTYPEMetadata getObjectModel()
- {
- return this.wstm;
- }
-
+
@Override
public void check(Declaration decl)
{
- // we're only interested in class declarations
- if (! (decl instanceof ClassDeclaration))
+ // check type of declaration
+ if ((null == decl) || (! (decl instanceof ClassDeclaration)))
{
- return; // todo Handle error properly / throw exception
+ // todo: error --> @WebService is @Target(TYPE)
}
-
- // get & store object model
- if (null != (decl.getAnnotation(javax.jws.WebService.class)))
+
+ if (null == decl.getAnnotation(javax.jws.WebService.class))
{
- this.wstm = getWebServiceTYPEMetadata((ClassDeclaration) decl);
+ return;
+ // todo: log warning/error "@WebService" not defined (should never happen)
}
- }
+ // create & store object model
+ objectModels.put(
+ ((ClassDeclaration) decl).getQualifiedName(),
+ getWebServiceTYPEMetadata((ClassDeclaration) decl));
+ }
+
@Override
public void generate(Declaration decl)
{
// todo: on demand code generation
- // todo: do something useful with this.wstm, the object model
- printObjectModel();
-
- // todo: these print statement are for demonstration purposes only
+ // todo: do something useful with the object model
}
- /**
- * Builds the metadata structure that describes the Web service defined
- * in the source file.
- * Encapsulates JSR-181 data and procedures.
- * @param decl
- * @return
- */
- private WebServiceTYPEMetadata getWebServiceTYPEMetadata(ClassDeclaration decl)
+ public static AnnotationModel getObjectModel(String fqClassName)
{
- // @WebService
- javax.jws.WebService ws = decl.getAnnotation(javax.jws.WebService.class);
- if (null == ws)
- {
- throw new IllegalArgumentException();
- }
- WebServiceTYPEMetadata wstm =
- new WebServiceTYPEMetadata(decl.getQualifiedName());
-
- // name: JSR-181 default value
- if ((null == ws.name ()) || (0 == ws.name().length()))
- {
- wstm.setWsName(decl.getSimpleName());
- }
- else
- {
- wstm.setWsName(ws.name());
- }
-
- // serviceName: JSR-181 default value
- if ((null == ws.serviceName()) || (0 == ws.serviceName().length()))
- {
- wstm.setWsServiceName(decl.getSimpleName() + "Service");
- }
- else
- {
- wstm.setWsServiceName(ws.serviceName());
- }
-
- // wsdlLocation: set JSR-181 default value
- wstm.setWsWsdlLocation(ws.wsdlLocation());
-
- // targetNamespace: set JSR-181 default value
- if ((null == ws.targetNamespace()) || (0 == ws.targetNamespace().length()))
- {
- wstm.setWsTargetNamespace(decl.getPackage().getQualifiedName());
- // todo: check if namespace is correct
- }
- else
- {
- wstm.setWsTargetNamespace(ws.targetNamespace());
- }
-
- // @SOAPBinding
- javax.jws.soap.SOAPBinding sb;
- if (null != (sb = decl.getAnnotation(javax.jws.soap.SOAPBinding.class)))
- {
- // todo
- }
-
- // @HandlerChain
- javax.jws.HandlerChain hc;
- if (null != (hc = decl.getAnnotation(javax.jws.HandlerChain.class)))
- {
- // todo
- }
-
- // @SecurityIdentity
- javax.jws.SecurityIdentity si;
- if (null != (si = decl.getAnnotation(javax.jws.SecurityIdentity.class)))
- {
- // todo
- }
-
- // @SecurityRoles
- javax.jws.SecurityRoles sr;
- if (null != (sr = decl.getAnnotation(javax.jws.SecurityRoles.class)))
- {
- // todo
- }
-
- this.wstm = wstm;
-
- // delegate handling of annotated methods
- for ( MethodDeclaration md : decl.getMethods() )
- {
- if (null != (md.getAnnotation(javax.jws.WebMethod.class)))
- {
- wstm.addMethod(getWebServiceMETHODMetadata(md));
- }
- }
-
- // todo semantic checking for annotated web service
-
- return wstm;
+ return objectModels.get(fqClassName);
}
- private WebServiceMETHODMetadata getWebServiceMETHODMetadata(MethodDeclaration decl)
+ private WebServiceTYPEMetadata getWebServiceTYPEMetadata(
+ ClassDeclaration decl)
{
- // @WebMethod
- javax.jws.WebMethod wm = decl.getAnnotation(javax.jws.WebMethod.class);
- if (null == wm)
+ // get webService's webMethods
+ Collection<WebServiceMETHODMetadata> webMethods =
+ new ArrayList<WebServiceMETHODMetadata>();
+ for ( MethodDeclaration methodDecl : decl.getMethods() )
{
- throw new IllegalArgumentException();
- }
- WebServiceMETHODMetadata wsmm = new WebServiceMETHODMetadata(
- decl.getSimpleName(),
- decl.getReturnType().getClass().getName()
- );
-
- // operationName: set JSR-181 default value
- if ((null == wm.operationName()) || (0 == wm.operationName().length()))
- {
- wsmm.setWmOperationName(decl.getSimpleName());
- }
- else
- {
- wsmm.setWmOperationName(wm.operationName());
- }
-
- // action: set JSR-181 default value
- if ((null == wm.action()) || (0 == wm.action().length()))
- {
- wsmm.setWmAction(wstm.getWsTargetNamespace() + "/" + decl.getSimpleName());
- }
- else
- {
- wsmm.setWmAction(wm.action());
- }
-
- // @WebResult
- javax.jws.WebResult wr;
- if (null != (wr = decl.getAnnotation(javax.jws.WebResult.class)))
- {
- // todo
- }
-
- // @Oneway
- javax.jws.Oneway ow;
- if (null != (ow = decl.getAnnotation(javax.jws.Oneway.class)))
- {
- // todo
- }
-
- // @DocumentWrapper
- javax.jws.soap.DocumentWrapper dw;
- if (null != (dw = decl.getAnnotation(javax.jws.soap.DocumentWrapper.class)))
- {
- // todo
- }
-
- // @SOAPMessageHandlers
- javax.jws.soap.SOAPMessageHandlers smh;
- if (null != (smh = decl.getAnnotation(javax.jws.soap.SOAPMessageHandlers.class)))
- {
- // todo
- }
-
- // delegate handling of annotated parameters
- for ( ParameterDeclaration pd : decl.getParameters() )
- {
- if (null != (pd.getAnnotation(javax.jws.WebParam.class)))
+ if (null != methodDecl.getAnnotation(javax.jws.WebMethod.class))
{
- wsmm.addParams(getWebServicePARAMETERMetadata(pd));
+ webMethods.add(getWebServiceMETHODMetadata(methodDecl));
}
}
- // todo semantic checking for annotated method
-
- return wsmm;
- }
-
- private WebServicePARAMETERMetadata getWebServicePARAMETERMetadata(ParameterDeclaration decl)
- {
- // @WebParam
- javax.jws.WebParam wp = decl.getAnnotation(javax.jws.WebParam.class);
- if (null == wp)
- {
- throw new IllegalArgumentException();
- }
- WebServicePARAMETERMetadata wspm = new WebServicePARAMETERMetadata();
-
- // name: set JSR-181 default value
- if ((null == wp.name()) || (0 == wp.name().length()))
- {
- wspm.setWpName(decl.getSimpleName());
- }
- else
- {
- wspm.setWpName(wp.name());
- }
-
- // mode: set JSR-181 default value
- wspm.setWpMode(wp.mode());
-
- // header: set JSR-181 default value
- wspm.setWpHeader(wp.header());
-
- // todo semantic checking for annotated parameter
-
- return wspm;
+ // create & return webService
+ return new WebServiceTYPEMetadata(
+ java.util.Arrays.asList(decl.getClass().getAnnotations()),
+ ((ClassDeclaration)decl).getClass().getName(),
+ webMethods
+ );
}
-
- private WebServiceTYPEMetadata wstm;
-
- // private and temporary test methods
- private void printObjectModel()
- {
- System.out.println(wsToString());
- }
-
- private String wsToString()
+ private WebServiceMETHODMetadata getWebServiceMETHODMetadata(
+ MethodDeclaration decl)
{
- StringBuffer sb = new StringBuffer();
-
- sb.append("@WebService(\n");
- sb.append("\tname=\"" + wstm.getWsName() + "\"\n");
- sb.append("\tserviceName=\"" + wstm.getWsServiceName() + "\"\n");
- sb.append("\ttargetNamespace=\"" + wstm.getWsTargetNamespace() + "\"\n");
- sb.append("\twsdlLocation=\"" + wstm.getWsWsdlLocation() + "\"\n");
- sb.append(")\n");
-
- for ( WebServiceMETHODMetadata wsmm : wstm.getMethods() )
+ // get webMethod's webParams
+ List<WebServicePARAMETERMetadata> webParams =
+ new ArrayList<WebServicePARAMETERMetadata>();
+ for ( ParameterDeclaration paramDecl : decl.getParameters() )
{
- sb.append(wmToString(wsmm) + "\n");
+ if (null != paramDecl.getAnnotation(javax.jws.WebParam.class))
+ {
+ webParams.add(getWebServicePARAMETERMetadata(paramDecl));
+ }
}
- return sb.toString();
+ // create & return webMethod
+ return new WebServiceMETHODMetadata(
+ java.util.Arrays.asList(decl.getClass().getAnnotations()),
+ decl.getSimpleName(),
+ ((MethodDeclaration)decl).getReturnType().getClass(),
+ webParams
+ );
}
-
- private String wmToString(WebServiceMETHODMetadata wsmm)
+
+ private WebServicePARAMETERMetadata getWebServicePARAMETERMetadata(
+ ParameterDeclaration decl)
{
- StringBuffer sb = new StringBuffer();
-
- sb.append("@WebMethod(\n");
- sb.append("\toperationName=\"" + wsmm.getWmOperationName() + "\"\n");
- sb.append("\taction=\"" + wsmm.getWmAction() + "\"\n");
- sb.append(")\n");
-
- return sb.toString();
+ // create & return webParam
+ return new WebServicePARAMETERMetadata(
+ java.util.Arrays.asList(decl.getClass().getAnnotations()),
+ decl.getClass(),
+ decl.getSimpleName()
+ );
}
+
+ private static Map<String, AnnotationModel> objectModels =
+ new HashMap<String, AnnotationModel>();
}
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessorFactory.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java Fri Sep 3 09:12:01 2004
@@ -1,4 +1,4 @@
-package org.apache.beehive.wsm.runtime.processor.apt;
+package org.apache.beehive.wsm.jsr181.processor.apt;
/*
* Copyright 2004 The Apache Software Foundation
Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java Fri Sep 3 09:12:01 2004
@@ -0,0 +1,88 @@
+package org.apache.beehive.wsm.jsr181.processor.reflection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+
+/*
+ * 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:$
+ */
+
+//org.apache.beehive.wsm.processor.reflection.WsmReflectionAnnotationProcessor.java
+public class WsmReflectionAnnotationProcessor {
+
+ /**
+ *
+ */
+ public WsmReflectionAnnotationProcessor() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public static WebServiceTYPEMetadata getObjectModel(Class clazz) {
+ if(null == clazz.getAnnotation(WebService.class)) // no @WebService
+ return null;
+
+ Method[] methods = clazz.getMethods();
+ Collection<WebServiceMETHODMetadata> webMethods = new ArrayList<WebServiceMETHODMetadata>();
+ for (Method method : methods) {
+ WebMethod webMethodAnnotation = method
+ .getAnnotation(WebMethod.class);
+ //method is a webmethod
+ if (webMethodAnnotation != null) {
+ // get all parameters
+ List<WebServicePARAMETERMetadata> params = new ArrayList<WebServicePARAMETERMetadata>();
+ int offset = 0;
+ Class< ? >[] methodParamTypes = method.getParameterTypes();
+ Annotation[][] allAnnotations = method
+ .getParameterAnnotations();
+
+ for (Class paramType : methodParamTypes) {
+ WebParam webParam = null;
+ WebServicePARAMETERMetadata paramMetaData = new WebServicePARAMETERMetadata(
+ Arrays.asList(allAnnotations[offset]),
+ paramType, null); // class reflection
+ // doesn't keep the
+ // name of
+ // the parameter
+ params.add(paramMetaData);
+ offset++;
+ }
+ WebServiceMETHODMetadata methodMetaData = new WebServiceMETHODMetadata(
+ Arrays.asList(method.getAnnotations()), method
+ .getName(), method.getReturnType(), params);
+ webMethods.add(methodMetaData);
+ }
+
+ }
+ return new WebServiceTYPEMetadata( Arrays.asList(clazz.getAnnotations()), clazz.getName(), webMethods);
+
+ }
+
+
+}
\ No newline at end of file
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/wsdl/WSDLProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java Fri Sep 3 09:12:01 2004
@@ -16,13 +16,22 @@
* $Header:$
*/
-package org.apache.beehive.wsm.wsdl;
+package org.apache.beehive.wsm.jsr181.wsdl;
import java.lang.reflect.Array;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.xml.namespace.QName;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.WebParam;
import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
import org.xmlsoap.schemas.wsdl.TDefinitions;
@@ -30,20 +39,404 @@
import org.xmlsoap.schemas.wsdl.TBindingOperationMessage;
import org.xmlsoap.schemas.wsdl.TBinding;
import org.xmlsoap.schemas.wsdl.TDefinitions;
+import org.xmlsoap.schemas.wsdl.TMessage;
+import org.xmlsoap.schemas.wsdl.TOperation;
+import org.xmlsoap.schemas.wsdl.TParam;
+import org.xmlsoap.schemas.wsdl.TPart;
import org.xmlsoap.schemas.wsdl.TPort;
+import org.xmlsoap.schemas.wsdl.TPortType;
+import org.xmlsoap.schemas.wsdl.TService;
+
+import org.xmlsoap.schemas.wsdl.soap.UseChoice;
+import org.xmlsoap.schemas.wsdl.soap.TStyleChoice;
import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.beehive.wsm.jsr181.model.SOAPBindingInfo;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
/*******************************************************************************
*
*
*/
public class WSDLProcessor {
-
- private DefinitionsDocument mDefDoc;
+
+ public static final String TRANSPORT =
+ "http://schemas.xmlsoap.org/soap/http";
+
+ public static final String SOAPENCODING =
+ "http://schemas.xmlsoap.org/soap/encoding/";
+
+ public static final String WSDLNS = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+ public static final String WSDLSOAPNS =
+ "http://schemas.xmlsoap.org/wsdl/soap/";
+
+
+ public static WebServiceTYPEMetadata toWebServiceMetadata
+ (DefinitionsDocument defDoc)
+ throws IllegalAccessException, NoSuchFieldException
+ {
+
+ WebServiceTYPEMetadata wsm = new WebServiceTYPEMetadata();
+ Map<String, WebServiceMETHODMetadata> methodMap =
+ new HashMap<String, WebServiceMETHODMetadata>();
+ TDefinitions defs = defDoc.getDefinitions();
+
+ Map<String, TPart[]> messageMap = new HashMap<String, TPart[]>();
+ if (defs.sizeOfMessageArray() > 0) {
+ TMessage[] messages = defs.getMessageArray();
+ for (TMessage msg : messages) {
+ messageMap.put(msg.getName(), msg.getPartArray());
+ }
+ }
+
+ if (defs.sizeOfPortTypeArray() > 0) {
+ TPortType tP = defs.getPortTypeArray(0);
+ wsm.setWsName(tP.getName());
+ TOperation[] operations = tP.getOperationArray();
+ for (TOperation op : operations) {
+ processTOperation(op, wsm, methodMap, messageMap);
+ }
+ }
+
+ if (defs.sizeOfBindingArray() > 0) {
+ TBinding tBind = defs.getBindingArray(0);
+ processTBinding(tBind, wsm, methodMap);
+
+ }
+
+ if (defs.sizeOfServiceArray() > 0) {
+ wsm.setWsServiceName(defs.getServiceArray(0).getName());
+ }
+ return wsm;
+ }
+
+ public static DefinitionsDocument fromWebServiceMetadata
+ (WebServiceTYPEMetadata wsm)
+ throws Exception
+ {
+ String ns = wsm.getWsTargetNamespace();
+
+ DefinitionsDocument defDoc = DefinitionsDocument.Factory.newInstance();
+ TDefinitions tDefs = defDoc.addNewDefinitions();
+
+ TPortType tPT = tDefs.addNewPortType();
+ tPT.setName(wsm.getWsName());
+
+ TBinding tBind = tDefs.addNewBinding();
+ tBind.setName(tPT.getName() + "Binding");
+ tBind.setType(new QName(ns, tPT.getName()));
+ org.xmlsoap.schemas.wsdl.soap.BindingDocument bindDoc =
+ org.xmlsoap.schemas.wsdl.soap.BindingDocument.Factory.newInstance();
+ org.xmlsoap.schemas.wsdl.soap.TBinding tSoapBind = bindDoc
+ .addNewBinding();
+
+ if (SOAPBinding.Style.DOCUMENT.equals(wsm.getSoapBinding().getStyle())) {
+ tSoapBind.setStyle(TStyleChoice.DOCUMENT);
+ }
+ else {
+ tSoapBind.setStyle(TStyleChoice.RPC);
+ }
+ tSoapBind.setTransport(TRANSPORT);
+ insertChild(tBind, bindDoc);
+
+ processMethodMetadata(wsm.getMethods(), tDefs, tPT, tBind, ns);
+
+ TService tServ = tDefs.addNewService();
+ tServ.setName(wsm.getWsServiceName());
+ TPort tPort = tServ.addNewPort();
+ tPort.setName(wsm.getWsName());
+ tPort.setBinding(new QName(ns, tBind.getName()));
+
+ org.xmlsoap.schemas.wsdl.soap.AddressDocument addrDoc =
+ org.xmlsoap.schemas.wsdl.soap.AddressDocument.Factory.newInstance();
+ org.xmlsoap.schemas.wsdl.soap.TAddress tAddr = addrDoc.addNewAddress();
+ tAddr.setLocation("fake://FAKEURL");
+ insertChild(tPort, tAddr);
+
+ return defDoc;
+ }
+
+ private static void processTOperation(TOperation op,
+ WebServiceTYPEMetadata wsm,
+ Map<String,
+ WebServiceMETHODMetadata> methodMap,
+ Map<String, TPart[]> messageMap)
+ {
+ WebServiceMETHODMetadata wmm = new WebServiceMETHODMetadata();
+ String opName = op.getName();
+ //wmm.setJavaMethodName(opName);
+ wmm.setWmOperationName(opName);
+ methodMap.put(opName, wmm);
+ TParam outputParam = op.getOutput();
+ if (outputParam != null) {
+ TPart[] returnTypes = messageMap
+ .get(outputParam.getMessage().getLocalPart());
+
+ if (returnTypes.length > 0) {
+
+ String returnName = returnTypes[0].getName();
+ QName qReturnType = returnTypes[0].getType();
+ /*
+ wmm.setJavaReturnType(qReturnType
+ .getNamespaceURI()
+ + '.' + qReturnType
+ .getLocalPart());
+ */
+ }
+ else {
+ //wmm.setJavaReturnType("void");
+ }
+ }
+ else {
+ //wmm.setJavaReturnType("void");
+ }
+
+ List paramOrder = op.getParameterOrder();
+ if (paramOrder != null) {
+
+ TParam inputParam = op.getInput();
+ TPart[] parameters = messageMap
+ .get(inputParam.getMessage().getLocalPart());
+ for (Object ord : paramOrder) {
+ /*
+ * NOTE jcolwell@bea.com 2004-Aug-31 -- assuming just a
+ * few params so a quick skim through the array
+ * should be okay
+ */
+ for (TPart currentParam : parameters) {
+ if (ord.equals(currentParam.getName())) {
+ QName qParamType = currentParam.getType();
+ WebServicePARAMETERMetadata wpm =
+ new WebServicePARAMETERMetadata();
+ /* wpm.setJavaType(qParamType.getNamespaceURI() +
+ '.' + qParamType.getLocalPart());*/
+ wpm.setWpName((String)ord);
+ wpm.setWpMode(WebParam.Mode.IN);
+ wmm.addParam(wpm);
+ break;
+ }
+ }
+ }
+ }
+ wsm.addMethod(wmm);
+ }
+
+ private static void processTBinding(TBinding tBind,
+ WebServiceTYPEMetadata wsm,
+ Map<String,
+ WebServiceMETHODMetadata> methodMap)
+ throws IllegalAccessException, NoSuchFieldException
+ {
+
+ org.xmlsoap.schemas.wsdl.soap.TBinding[] soapBinding =
+ getSOAPBinding(tBind);
+
+ SOAPBindingInfo soapInfo = new SOAPBindingInfo();
+ if (TStyleChoice.DOCUMENT.equals(soapBinding[0].getStyle())) {
+ soapInfo.setStyle(SOAPBinding.Style.DOCUMENT);
+ }
+ else {
+ soapInfo.setStyle(SOAPBinding.Style.RPC);
+ }
+ wsm.setSoapBinding(soapInfo);
+ TBindingOperation[] tBops = tBind.getOperationArray();
+ for (TBindingOperation tBop : tBops) {
+
+ WebServiceMETHODMetadata wmm = methodMap.get(tBop.getName());
+
+ org.xmlsoap.schemas.wsdl.soap.TOperation[] soapOperations =
+ getSOAPOperations(tBop);
+
+ if (soapOperations.length > 0) {
+ wmm.setWmAction(soapOperations[0].getSoapAction());
+
+
+ if(TStyleChoice.DOCUMENT.equals(soapOperations[0]
+ .getStyle())) {
+ soapInfo = new SOAPBindingInfo();
+ soapInfo.setStyle(SOAPBinding.Style.DOCUMENT);
+ }
+ else if (TStyleChoice.RPC.equals(soapOperations[0]
+ .getStyle())) {
+ soapInfo = new SOAPBindingInfo();
+ soapInfo.setStyle(SOAPBinding.Style.RPC);
+ }
+ }
+
+ TBindingOperationMessage tbMsg = tBop.getInput();
+ if (tbMsg == null) {
+ tbMsg = tBop.getOutput();
+ }
+
+ if (tbMsg != null) {
+ org.xmlsoap.schemas.wsdl.soap.TBody[] bodies =
+ getSOAPBody(tbMsg);
+ if (bodies.length > 0) {
+ if (wsm.getWsTargetNamespace() == null) {
+ wsm.setWsTargetNamespace(bodies[0].getNamespace());
+ }
+ if (UseChoice.LITERAL.equals(bodies[0].getUse())) {
+ soapInfo.setUse(SOAPBinding.Use.LITERAL);
+ }
+ else {
+ soapInfo.setUse(SOAPBinding.Use.ENCODED);
+ }
+ }
+ }
+ }
+ }
+
+ private static void processMethodMetadata
+ (Collection<WebServiceMETHODMetadata> methods,
+ TDefinitions defs,
+ TPortType portType,
+ TBinding bind,
+ String namespace)
+ {
+
+ for (WebServiceMETHODMetadata op : methods) {
+
+ String operationName = op.getWmOperationName();
+ String request = operationName + "Request";
+ String response = operationName + "Response";
+
+ TMessage tMsg = defs.addNewMessage();
+ tMsg.setName(request);
+
+ List<String> paramOrder = new ArrayList<String>();
+ processParameterMetadata(op.getParams(), paramOrder, tMsg);
+
+ if (!op.isOneWay()) {
+ tMsg = defs.addNewMessage();
+ tMsg.setName(response);
+ TPart tPart = tMsg.addNewPart();
+ tPart.setName(op.getWrName());
+ tPart.setType(class2QName(op.getJavaReturnType()));
+ //tPart.setElement(new QName("some", "element");
+ }
+
+ TOperation tOp = portType.addNewOperation();
+ tOp.setName(operationName);
+ tOp.setParameterOrder(paramOrder);
+ TParam input = tOp.addNewInput();
+ TParam output = tOp.addNewOutput();
+ input.setName(request);
+ input.setMessage(new QName(namespace, request));
+ if (!op.isOneWay()) {
+ output.setName(response);
+ output.setMessage(new QName(namespace, response));
+ }
+ processBindingOperationMetadata(bind.addNewOperation(),
+ op,
+ namespace,
+ operationName,
+ request,
+ response);
+ }
+ }
+
+ private static void processParameterMetadata
+ (Collection<WebServicePARAMETERMetadata> params,
+ List<String> paramOrder,
+ TMessage msg)
+ {
+ for (WebServicePARAMETERMetadata param : params) {
+ TPart tPart = msg.addNewPart();
+ tPart.setName(param.getWpName());
+ tPart.setType(class2QName(param.getJavaType()));
+ paramOrder.add(param.getWpName());
+ }
+ }
+
+ private static void processBindingOperationMetadata(TBindingOperation tBop,
+ WebServiceMETHODMetadata op,
+ String namespace,
+ String operationName,
+ String request,
+ String response)
+ {
+
+ tBop.setName(operationName);
+ org.xmlsoap.schemas.wsdl.soap.OperationDocument opDoc =
+ org.xmlsoap.schemas.wsdl.soap.OperationDocument.Factory
+ .newInstance();
+ org.xmlsoap.schemas.wsdl.soap.TOperation tSoapOperation =
+ opDoc.addNewOperation();
+
+ tSoapOperation.setSoapAction(op.getWmAction());
+ SOAPBindingInfo sb = op.getSoapBinding();
+ if (sb != null && SOAPBinding.Style.DOCUMENT.equals(sb.getStyle())) {
+ tSoapOperation.setStyle(TStyleChoice.DOCUMENT);
+ }
+ else {
+ tSoapOperation.setStyle(TStyleChoice.RPC);
+ }
+ insertChild(tBop, opDoc);
+
+
+ TBindingOperationMessage inBom = tBop.addNewInput();
+ TBindingOperationMessage outBom = tBop.addNewOutput();
+ inBom.setName(request);
+ outBom.setName(response);
+
+ /*
+ * NOTE jcolwell@bea.com 2004-Aug-31 -- Using the same body
+ * for both the input and output, this may need to be changed.
+ */
+ org.xmlsoap.schemas.wsdl.soap.BodyDocument bodDoc =
+ org.xmlsoap.schemas.wsdl.soap.BodyDocument.Factory.newInstance();
+ org.xmlsoap.schemas.wsdl.soap.TBody tBod = bodDoc.addNewBody();
+
+ if (sb != null && SOAPBinding.Use.LITERAL.equals(sb.getUse())) {
+ tBod.setUse(UseChoice.LITERAL);
+ }
+ else {
+ tBod.setUse(UseChoice.ENCODED);
+ }
+
+ /*
+ * NOTE jcolwell@bea.com 2004-Aug-31 -- not sure what parts
+ * get set here.
+ */
+ // tBod.setParts(?);
+
+ tBod.setNamespace(namespace);
+ List<String> encodingStyles = new ArrayList<String>();
+ encodingStyles.add(SOAPENCODING);
+ tBod.setEncodingStyle(encodingStyles);
+
+ insertChild(inBom, bodDoc);
+ insertChild(outBom, bodDoc);
+ }
+
+
+ public static boolean insertChild(XmlObject parent, XmlObject child)
+ {
+ // might need to use copyXmlContents() instead if copyXml copies too much
+ XmlCursor kidCursor = child.newCursor();
+ XmlCursor parentCursor = parent.newCursor();
+ parentCursor.toFirstContentToken();
+ //parentCursor.toNextToken();
+ kidCursor.toNextToken();
+ return kidCursor.copyXml(parentCursor);
+ }
+
+ public static WebServiceTYPEMetadata loadWebServiceMetadataFromWSDL
+ (String wsdlLocation)
+ throws IOException,
+ XmlException,
+ IllegalAccessException,
+ NoSuchFieldException
+ {
+ return toWebServiceMetadata(parseWSDL(wsdlLocation));
+ }
public static DefinitionsDocument parseWSDL(String wsdlLocation)
throws IOException, MalformedURLException, XmlException
@@ -112,5 +505,38 @@
castKids[j] = childClass.cast(kids[j]);
}
return castKids;
+ }
+
+ public static QName class2QName(String typeName)
+ {
+ if (typeName == null) {
+ return new QName("java", "UnknownType");
+ }
+ else {
+ // this cheesy impl won't work for inner classes,
+ // see more details below
+ int lastDot = typeName.lastIndexOf('.');
+ return new QName(typeName.substring(0, lastDot),
+ typeName.substring(lastDot + 1));
+ }
+ }
+
+ public static QName class2QName(Class type)
+ {
+ /*
+ * FIXME jcolwell@bea.com 2004-Aug-30 -- this method should be replaced
+ * by a fully functional mechanism for mapping Java types to XML.
+ * Just taking the easy way out to get this working, but pretty much
+ * unusable for the moment.
+ */
+ if (type == null) {
+ return new QName("java", "UnknownType");
+ }
+ else {
+ String packageName = type.getPackage().getName();
+ String className = type.getName();
+ className = className.substring(packageName.length());
+ return new QName(packageName, className);
+ }
}
}