Author: mmerz
Date: Wed Sep 22 13:40:20 2004
New Revision: 47072
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
incubator/beehive/trunk/wsm/samples/dropInDeployment/AddressBook/server/build.xml
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/WsmAnnotationProcessor.java
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/WSDLProcessor.java
Log:
- Added copyright notices.
- Added JSR-181 rules for:
@Oneway w/ non-void return type
@Oneway w/ exceptions
@Oneway w/ @WebResult
@Oneway w/ IN/OUT WebParam
@SOAPHandler w/ @HanderChain
- Added test cases to Jsr181ModelTest
testTYPESOAPHandlerWithHandlerChain
testMETHODOnewayWithWebResult
testMETHODOnewayWithReturnType
testMETHODOnewayWithExceptions
testMETHODOnewayOUTParam
- Removed test cases from Jsr181ModelTest
testMETHODSoapBindingDefaults
testMETHODSoapBinding
- Fixed build file for AddressBook/server
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
==============================================================================
---
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
(original)
+++
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
Wed Sep 22 13:40:20 2004
@@ -72,7 +72,7 @@
assertNotNull("Cannot find WebMethod goHome();", method);
assertEquals("Invalid wmAction;", "", method.getWmAction());
assertTrue("Cannot find @Oneway;", method.isOneWay());
- assertTrue("Unexpected @WebResult;",
method.getWrName().compareTo("result") == 0);
+ assertEquals("Unexpected @WebResult;", "result", method.getWrName());
assertEquals("Unexpected return type;",
void.class,
method.getJavaReturnType()
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
Wed Sep 22 13:40:20 2004
@@ -1,6 +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:$
+ */
+
import java.lang.annotation.Annotation;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -14,7 +33,6 @@
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPMessageHandler;
-import org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeDocumentWrapper;
import
org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeHandlerChainAnnotation;
import
org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeInitParamAnnotation;
import
org.apache.beehive.wsm.jsr181.model.fakeAnnotations.FakeOneWayAnnotation;
@@ -31,58 +49,78 @@
import junit.framework.TestCase;
-public class Jsr181ModelTest extends TestCase {
+ // TODO: test combination of type, method, annotation
- public void setUp() {
+public class Jsr181ModelTest extends TestCase
+{
+ @Override
+ public void setUp()
+ {
+ // empty
}
- public void tearDown() {
+ @Override
+ public void tearDown()
+ {
+ // empty
}
+ //
// test TYPE level annotations
-
- public void testTYPERequiredAnnotations() throws Exception {
+ //
+ public void testTYPERequiredAnnotations() throws Exception
+ {
// test to make sure the Type throws an exception if there are no
// WebMethod annotation defined.
- try {
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- null, "a.b.c.testclass", null,null);
+ try {
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(null, "a.b.c.testclass",
null,null);
assertTrue(
- "Error, the TYPE annotation should fail without
@WebService",
- false);
- } catch (IllegalArgumentException e) {
+ "Error, the TYPE annotation should fail without @WebService",
+ false
+ );
+ }
+ catch (IllegalArgumentException e)
+ {
// good case
}
- Collection<WebServiceMETHODMetadata> methodMetadata = new
ArrayList<WebServiceMETHODMetadata>();
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.DEFAULT));
+ SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
+ SOAPBinding.ParameterStyle.DEFAULT)
+ );
try {
WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- null, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ null, "a.b.c.testclass", typeAnnotations, methodMetadata);
assertTrue(
- "Error, the TYPE annotation should fail without
@WebService",
- false);
- } catch (IllegalArgumentException e) {
+ "Error, the TYPE annotation should fail without @WebService",
+ false
+ );
+ }
+ catch (IllegalArgumentException e)
+ {
// good case
}
}
public void testTYPEWebServiceDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new
ArrayList<WebServiceMETHODMetadata>();
+ Collection<WebServiceMETHODMetadata> methodMetadata =
+ new ArrayList<WebServiceMETHODMetadata>();
Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
"");
+ WebService wsAnnotation =
+ new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
- wsAnnotation, "a.b.c.testclass", typeAnnotations,
methodMetadata);
- assertTrue("Invalid WebService Name, got: " + type.getWsName(), type
- .getWsName().compareTo("testclass") == 0);
- assertTrue(type.getWsServiceName().compareTo("testclassService") == 0);
- assertTrue(type.getWsWsdlLocation().length() == 0);
- assertTrue("Invalid target name space: " + type.getWsTargetNamespace(),
- type.getWsTargetNamespace().compareTo("http://c.b.a") == 0);
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertEquals("Invalid WebService name", "testclass", type.getWsName());
+ assertEquals("Invalid WebService service name", "testclassService",
+ type.getWsServiceName());
+ assertTrue("Invalid WSDL location", type.getWsWsdlLocation().length()
== 0);
+ assertEquals("Invalid target name space", "http://c.b.a",
+ type.getWsTargetNamespace());
}
public void testTYPEWebServiceAnnotation() throws Exception {
@@ -293,11 +331,49 @@
assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
}
- //test METHOD level
+ public void testTYPESOAPHandlerWithHandlerChain() throws Exception
+ {
+ boolean hasPassed = false;
+ try {
+ Collection<Annotation> typeAnnotations =
+ new ArrayList<Annotation>();
+ WebService wsAnnotation =
+ new FakeWebServiceAnnotation(
+ "name",
+ "serviceName",
+ "wsdlLocation",
+ "targetNamespace",
+ "endpointInterface"
+ );
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(new
SOAPMessageHandler[0]));
+ typeAnnotations.add(new FakeHandlerChainAnnotation("fileName",
"chainName"));
+ WebServiceTYPEMetadata type =
+ new WebServiceTYPEMetadata(
+ wsAnnotation,
+ "a.b.c.testclass",
+ typeAnnotations,
+ new ArrayList<WebServiceMETHODMetadata>()
+ );
+ }
+ catch (Exception e)
+ {
+ hasPassed = true;
+ }
+ if (! hasPassed)
+ {
+ fail("Error not caught: @SOAPMessageHandlers cannot be combined
with @HandlerChain");
+ }
+
+ }
+
+ //
+ // test METHOD level annotations
+ //
public void testMETHODRequiredAnnotations() throws Exception {
try {
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", Void.class, null, null);
+ null, "methodname", void.class, false, null, null);
assertTrue(
"Error, the METHOD annotation should fail without
@WebMethod",
false);
@@ -307,7 +383,7 @@
Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
try {
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", Void.class, methodAnnotations, null);
+ null, "methodname", void.class, false, methodAnnotations,
null);
assertTrue(
"Error, the METHOD annotation should fail without
@WebMethod",
false);
@@ -319,7 +395,7 @@
methodAnnotations.add(mAnnotation);
try {
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, null, Void.class, methodAnnotations,null);
+ mAnnotation, null, void.class, false,
methodAnnotations,null);
assertTrue(
"Error, the METHOD annotation should fail without method
name",
false);
@@ -328,7 +404,7 @@
}
try {
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodName", null, methodAnnotations,null);
+ mAnnotation, "methodName", null, false,
methodAnnotations,null);
assertTrue(
"Error, the METHOD annotation should fail without return
type class",
false);
@@ -342,7 +418,7 @@
WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
methodAnnotations.add(mAnnotation);
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations,null);
assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
assertTrue(method.getWmAction().length() == 0);
assertTrue(method.getWrName().compareTo("result") == 0);
@@ -354,7 +430,7 @@
WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
"action");
methodAnnotations.add(mAnnotation);
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertTrue(method.getWmOperationName().compareTo("operationname") ==
0);
assertTrue(method.getWmAction().compareTo("action") == 0);
@@ -365,7 +441,7 @@
WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
"action");
methodAnnotations.add(mAnnotation);
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertFalse(method.isOneWay());
}
@@ -375,7 +451,7 @@
methodAnnotations.add(mAnnotation);
methodAnnotations.add(new FakeOneWayAnnotation());
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertTrue(method.isOneWay());
}
@@ -385,7 +461,7 @@
methodAnnotations.add(mAnnotation);
methodAnnotations.add(new FakeWebResultAnnotation("result"));
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertTrue(method.getWrName().compareTo("result") == 0);
}
@@ -395,41 +471,11 @@
methodAnnotations.add(mAnnotation);
methodAnnotations.add(new FakeWebResultAnnotation("resultname"));
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertTrue(method.getWrName().compareTo("resultname") == 0);
}
-
- public void testMETHODSoapBindingDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
"action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.DEFAULT, SOAPBinding.Use.DEFAULT,
- SOAPBinding.ParameterStyle.DEFAULT));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
- assertTrue(method.getSoapBinding().getStyle() ==
SOAPBinding.Style.DOCUMENT);
- assertTrue(method.getSoapBinding().getUse() ==
SOAPBinding.Use.LITERAL);
- assertTrue(method.getSoapBinding().getParameterStyle() ==
SOAPBinding.ParameterStyle.WRAPPED);
- }
-
- public void testMETHODSoapBinding() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
"action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.BARE));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
- assertTrue(method.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
- assertTrue(method.getSoapBinding().getUse() ==
SOAPBinding.Use.ENCODED);
- assertTrue(method.getSoapBinding().getParameterStyle() ==
SOAPBinding.ParameterStyle.BARE);
-
- }
-
-
+
public void testMETHODSecurityRoleDefaults() throws Exception {
Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
"action");
@@ -437,7 +483,7 @@
methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertNull(method.getSecurityRoles().getRolesAllowed());
assertNull(method.getSecurityRoles().getRolesReferenced());
}
@@ -452,7 +498,7 @@
rolesReferenced));
WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations,
null);
+ mAnnotation, "methodname", void.class, false,
methodAnnotations, null);
assertTrue(method.getSecurityRoles().getRolesAllowed().size() == 1);
assertTrue(method.getSecurityRoles().getRolesAllowed().iterator().next()
.compareTo("rolesallowed") == 0);
@@ -461,9 +507,143 @@
.next().compareTo("rolesreferenced") == 0);
}
-
-
- //test PARAMETER level annotation
+
+ public void testMETHODOnewayWithWebResult() throws Exception
+ {
+ boolean hasPassed = false;
+ try {
+ Collection<Annotation> methodAnnotations = new
ArrayList<Annotation>();
+ FakeWebMethodAnnotation mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+ methodAnnotations.add(new FakeWebResultAnnotation("result"));
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation,
+ "methodname",
+ void.class,
+ false,
+ methodAnnotations,
+ null
+ );
+ }
+ catch (Exception e)
+ {
+ hasPassed = true;
+ }
+ if (! hasPassed)
+ {
+ fail("Error not caught: @Oneway method has @WebResult");
+ }
+ }
+
+ public void testMETHODOnewayWithReturnType() throws Exception
+ {
+ boolean hasPassed = false;
+ try {
+ Collection<Annotation> methodAnnotations = new
ArrayList<Annotation>();
+ FakeWebMethodAnnotation mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation,
+ "methodname",
+ int.class,
+ false,
+ methodAnnotations,
+ null
+ );
+ }
+ catch (Exception e)
+ {
+ hasPassed = true;
+ }
+ if (! hasPassed)
+ {
+ fail("Error not caught: @Oneway method has non-void return type");
+ }
+ }
+
+ public void testMETHODOnewayWithExceptions() throws Exception
+ {
+ boolean hasPassed = false;
+ try {
+ Collection<Annotation> methodAnnotations =
+ new ArrayList<Annotation>();
+ FakeWebMethodAnnotation mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation,
+ "methodname",
+ void.class,
+ true,
+ methodAnnotations,
+ null
+ );
+ }
+ catch (Exception e)
+ {
+ hasPassed = true;
+ }
+ if (! hasPassed)
+ {
+ fail("Error not caught: @Oneway method throws exceptions");
+ }
+ }
+
+ public void testMETHODOnewayOUTParam() throws Exception
+ {
+ boolean hasPassed = false;
+ try {
+
+ Collection<Annotation> methodAnnotations =
+ new ArrayList<Annotation>();
+ FakeWebMethodAnnotation mAnnotation =
+ new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+
+ List<WebServicePARAMETERMetadata> params =
+ new ArrayList<WebServicePARAMETERMetadata>();
+ Collection<Annotation> paramAnnotations =
+ new ArrayList<Annotation>();
+ FakeWebParamAnnotation pAnnotation =
+ new FakeWebParamAnnotation("param", WebParam.Mode.OUT, false);
+ paramAnnotations.add(pAnnotation);
+ WebServicePARAMETERMetadata param =
+ new WebServicePARAMETERMetadata(
+ pAnnotation, // annotation
+ String.class, // javaType
+ "paramname", // name
+ paramAnnotations // annotations
+ );
+ params.add(param);
+
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation,
+ "methodname",
+ void.class,
+ false,
+ methodAnnotations,
+ params
+ );
+ }
+ catch (Exception e)
+ {
+ hasPassed = true;
+ }
+ if (! hasPassed)
+ {
+ fail("Error not caught: @Oneway method has OUT or INOUT
parameters");
+ }
+ }
+
+ //
+ // test PARAMETER level annotations
+ //
public void testPARAMETERRequiredAnnotations() throws Exception {
try {
@@ -520,6 +700,4 @@
assertTrue(param.isWpHeader());
}
- // TODO: test combination of type, method, annotation
-}
-
+}
\ No newline at end of file
Modified:
incubator/beehive/trunk/wsm/samples/dropInDeployment/AddressBook/server/build.xml
==============================================================================
---
incubator/beehive/trunk/wsm/samples/dropInDeployment/AddressBook/server/build.xml
(original)
+++
incubator/beehive/trunk/wsm/samples/dropInDeployment/AddressBook/server/build.xml
Wed Sep 22 13:40:20 2004
@@ -1,6 +1,24 @@
<?xml version="1.0" ?>
-<project name="AddressBookWS" default="usage">
+<!--
+ 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:$
+ -->
+
+<project name="AddressBookWS" default="usage" basedir=".">
<property environment="env"/>
@@ -26,7 +44,8 @@
<!-- deploy - deploy into Servlet container -->
<!-- ========================================= -->
- <!-- Can be done automatically or manually -->
+ <!-- Automatically copies file into servlet container -->
+ <!-- Should this be done manually? -->
<target name="deploy" depends="build" if="AnnotatedAxis.base.dir">
<echo message="** Deploying Web service to ${webapp.dir} **" />
<copy file="AddressBookWS.jar"
todir="${AnnotatedAxis.base.dir}/WEB-INF/lib/" overwrite="true" />
@@ -123,8 +142,9 @@
<!-- ========================================= -->
<target name="clean">
- <delete dir="${classes.dir}"/>
- <delete dir="${logs.dir}"/>
+ <delete dir="${build.dir}" />
+ <delete dir="${logs.dir}" />
+ <delete file="AddressBookWS.jar" />
</target>
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
Wed Sep 22 13:40:20 2004
@@ -1,7 +1,5 @@
package org.apache.beehive.wsm.jsr181.model;
-import java.lang.annotation.Annotation;
-import java.util.Collection;
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -20,18 +18,13 @@
* $Header:$
*/
-//org.apache.beehive.wsm.AnnotationModel.java
+import java.lang.annotation.Annotation;
-public class AnnotationModel {
+import java.util.Collection;
- /**
- *
- */
- public AnnotationModel() {
- super();
- }
+public class AnnotationModel {
- static public boolean hasAnnotationType(Collection<Annotation>
annotations, Class<? extends Annotation> annotationType)
+ public static boolean hasAnnotationType(Collection<Annotation>
annotations, Class<? extends Annotation> annotationType)
{
if ((null != annotations) && (null != annotationType) && (0 <
annotations.size()))
{
@@ -47,7 +40,7 @@
}
//TODO: can this method be enhanced?
- static public Annotation getAnnotationOfType(Collection<Annotation>
annotations, Class<? extends Annotation> annotationType)
+ public static Annotation getAnnotationOfType(Collection<Annotation>
annotations, Class<? extends Annotation> annotationType)
{
if ((null != annotations) && (null != annotationType) && (0 <
annotations.size()))
{
@@ -61,7 +54,4 @@
}
return null;
}
-
-
-
-}
+}
\ No newline at end of file
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
Wed Sep 22 13:40:20 2004
@@ -1,24 +1,5 @@
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
*
@@ -37,43 +18,52 @@
* $Header:$
*/
-public class WebServiceMETHODMetadata extends AnnotationModel {
- String wmOperationName;
-
- String wmAction;
-
- boolean oneWay = false; // should be called oOneWay, but that looks
strange!
-
- List<WebServicePARAMETERMetadata> params = new
ArrayList<WebServicePARAMETERMetadata>();
-
- String wrName; // webresults
-
- SOAPBindingInfo soapBinding;
-
- QNameInfo dwRequestElement;
+import java.lang.annotation.Annotation;
- QNameInfo dwResponseElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
- SecurityRolesInfo securityRoles;
+import javax.jws.Oneway;
+import javax.jws.SecurityRoles;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+public class WebServiceMETHODMetadata extends AnnotationModel
+{
+ private String wmOperationName;
+ private String wmAction;
+ private boolean oneway = false;
+ private List<WebServicePARAMETERMetadata> params =
+ new ArrayList<WebServicePARAMETERMetadata>();
+ private String wrName; // webresults
+ private SOAPBindingInfo soapBinding;
+ private QNameInfo dwRequestElement;
+ private QNameInfo dwResponseElement;
+ private SecurityRolesInfo securityRoles;
private String javaMethodName;
-
private Class javaReturnType;
- /**
- *
- */
- public WebServiceMETHODMetadata(String methodName,
- Class returnType) {
+ public WebServiceMETHODMetadata(String methodName, Class returnType)
+ {
super();
javaMethodName = methodName;
javaReturnType = returnType;
}
- public WebServiceMETHODMetadata(javax.jws.WebMethod methodAnnotation,
- String javaMethodName, Class javaReturnType,
- Collection<Annotation> annotations, List< ? extends
WebServicePARAMETERMetadata> webParams) {
+ public WebServiceMETHODMetadata(
+ WebMethod methodAnnotation,
+ String javaMethodName,
+ Class javaReturnType,
+ boolean throwsExceptions,
+ Collection<Annotation> annotations,
+ List< ? extends WebServicePARAMETERMetadata> webParams
+ ) throws Exception
+ {
super();
+
// check parameters
if ((null == javaMethodName) || (null == javaReturnType)) {
throw new IllegalArgumentException(
@@ -81,273 +71,220 @@
}
this.javaMethodName = javaMethodName;
this.javaReturnType = javaReturnType;
- setWrName("result");
// check required parameters
if (null == methodAnnotation) {
throw new IllegalArgumentException("@WebMethod is required");
}
+ setWrName("result");
+
+ // enforce JSR-181 rules
+ if (AnnotationModel.hasAnnotationType(annotations, Oneway.class))
+ {
+ // prohibit @Oneway with @WebResult
+ if (AnnotationModel.hasAnnotationType(annotations,
WebResult.class))
+ {
+ // todo needs to be proper Exception subclass
+ throw new Exception("@Oneway method " + javaMethodName +
+ " has incompatible annotation: @WebResult");
+ }
+ // prohibit @Oneway with return types other than <code>void</code>
+ if (void.class != javaReturnType)
+ {
+ // todo needs to be proper Exception subclass
+ throw new Exception("@Oneway method " + javaMethodName +
+ " has illegal non-void return type: " + javaReturnType);
+ }
+ // prohibit @Oneway methods that throw Exceptions
+ if (throwsExceptions)
+ {
+ // todo needs to be proper Exception subclass
+ throw new Exception("@Oneway method " + javaMethodName +
+ " must not throw exceptions");
+ }
+ // prohibit @Oneway with "OUT" and "INOUT" parameters
+ if (null != webParams)
+ {
+ for (WebServicePARAMETERMetadata param : webParams)
+ {
+ if ((WebParam.Mode.OUT == param.getWpMode()) ||
+ (WebParam.Mode.INOUT == param.getWpMode()))
+ {
+ // todo needs to be proper Exception subclass
+ throw new Exception("@Oneway method " + javaMethodName
+
+ " has illegal INOUT or OUT parameter: " +
+ param.getWpName());
+ }
+ }
+ }
+ }
+
// initialize from required annotation
- initFromAnnotation(methodAnnotation);
-
- // set optional annotations
- for (Annotation a : annotations) {
+ initFromAnnotation(methodAnnotation);
+ // set optional annotations
+ for (Annotation a : annotations)
+ {
// add defaults
- if (a.annotationType() == javax.jws.Oneway.class) {
+ if (a.annotationType() == javax.jws.Oneway.class)
+ {
initFromAnnotation((javax.jws.Oneway) a);
-
- } else if (a.annotationType() == javax.jws.SecurityRoles.class) {
+ }
+ else if (a.annotationType() == javax.jws.SecurityRoles.class)
+ {
initFromAnnotation((javax.jws.SecurityRoles) a);
-
- } else if (a.annotationType() == javax.jws.WebResult.class) {
+ }
+ else if (a.annotationType() == javax.jws.WebResult.class)
+ {
initFromAnnotation((javax.jws.WebResult) a);
-
- } else if (a.annotationType() ==
javax.jws.soap.DocumentWrapper.class) {
- initFromAnnotation((javax.jws.soap.DocumentWrapper) a);
-
- } else if (a.annotationType() == javax.jws.soap.SOAPBinding.class)
{
- initFromAnnotation((javax.jws.soap.SOAPBinding) a);
-
- } else {
+ }
+ else
+ {
// todo: warning -- unknown annotation
}
}
// set WebServicePARAMETERMetadata
addParams(webParams);
-
-// TODO: Remove the default checking here, this should have been done
in the WebServiceParameter
-// if (null != webParams) {
-//
-// int i = 0;
-// for (WebServicePARAMETERMetadata wspm : webParams) {
-// i++;
-// // todo check defaults for wspm
-// if (0 == wspm.getWpName().length()) {
-// if (wspm.getDefaultName() == null
-// || wspm.getDefaultName().length() == 0)
-// wspm.setWpName("param_" + i);
-// else
-// wspm.setWpName(wspm.getDefaultName());
-// }
-//
-// addParam(wspm);
-// }
-// }
- }
-
- /**
- * @param annotation
- */
- private void initFromAnnotation(SecurityRoles annotation) {
- if (null != annotation) {
- setSecurityRoles(new SecurityRolesInfo(annotation));
- }
- // no defaults to handle
- return;
}
- /**
- * @param annotation
- */
- private void initFromAnnotation(SOAPBinding annotation) {
- if (null != annotation) {
- setSoapBinding(new SOAPBindingInfo(annotation));
+ private void initFromAnnotation(SecurityRoles annotation)
+ {
+ if (null != annotation)
+ {
+ setSecurityRoles(new SecurityRolesInfo(annotation));
}
- // deferred --> requires TYPE information: SOAPBinding
-
}
- /**
- * @param annotation
- */
- private void initFromAnnotation(DocumentWrapper annotation) {
- if (null != annotation) {
- setDwRequestElement(new QNameInfo(annotation.requestElement()));
- setDwResponseElement(new QNameInfo(annotation.responseElement()));
- }
- // deferred --> requires TYPE information: targetNamespace
-
- }
-
- /**
- * @param annotation
- */
- private void initFromAnnotation(WebResult annotation) {
- if (null != annotation) {
+ private void initFromAnnotation(WebResult annotation)
+ {
+ if (null != annotation)
+ {
setWrName(annotation.name());
}
}
- /**
- * @param annotation
- */
- private void initFromAnnotation(Oneway annotation) {
- if (null == annotation)
- setOneWay(false);
- else
- setOneWay(true);
-
- // no defaults to handle
-
+ private void initFromAnnotation(Oneway annotation)
+ {
+ setOneWay(null != annotation);
}
- /**
- * @param webMethodAnnotation
- */
- private void initFromAnnotation(WebMethod annotation) {
- if (null != annotation) {
+ private void initFromAnnotation(WebMethod annotation)
+ {
+ if (null != annotation)
+ {
setWmAction(annotation.action());
setWmOperationName(annotation.operationName());
}
- if(getWmOperationName() == null || getWmOperationName().length() == 0)
setWmOperationName(javaMethodName);
- if(getWmAction() == null || getWmAction().length() == 0)
setWmAction("");
-
+ if((null == getWmOperationName()) || (0 ==
getWmOperationName().length()))
+ {
+ setWmOperationName(javaMethodName);
+ }
+ if((null == getWmAction()) || (0 == getWmAction().length()))
+ {
+ setWmAction("");
+ }
}
- /**
- * @return Returns the dwRequestElement.
- */
- public QNameInfo getDwRequestElement() {
+ public QNameInfo getDwRequestElement()
+ {
return dwRequestElement;
}
- /**
- * @param dwRequestElement
- * The dwRequestElement to set.
- */
- public void setDwRequestElement(QNameInfo dwRequestElement) {
+ public void setDwRequestElement(QNameInfo dwRequestElement)
+ {
this.dwRequestElement = dwRequestElement;
}
- /**
- * @return Returns the dwResponseElement.
- */
- public QNameInfo getDwResponseElement() {
+ public QNameInfo getDwResponseElement()
+ {
return dwResponseElement;
}
- /**
- * @param dwResponseElement
- * The dwResponseElement to set.
- */
- public void setDwResponseElement(QNameInfo dwResponseElement) {
+ public void setDwResponseElement(QNameInfo dwResponseElement)
+ {
this.dwResponseElement = dwResponseElement;
}
- /**
- * @return Returns the oneWay.
- */
- public boolean isOneWay() {
- return oneWay;
- }
-
- /**
- * @param oneWay
- * The oneWay to set.
- */
- public void setOneWay(boolean oneWay) {
- this.oneWay = oneWay;
- }
-
- /**
- * @return Returns the securityRoles.
- */
- public SecurityRolesInfo getSecurityRoles() {
+ public boolean isOneWay()
+ {
+ return oneway;
+ }
+
+ public void setOneWay(boolean oneway)
+ {
+ this.oneway = oneway;
+ }
+
+ public SecurityRolesInfo getSecurityRoles()
+ {
return securityRoles;
}
- /**
- * @param securityRoles
- * The securityRoles to set.
- */
- public void setSecurityRoles(SecurityRolesInfo securityRoles) {
+ public void setSecurityRoles(SecurityRolesInfo securityRoles)
+ {
this.securityRoles = securityRoles;
}
- /**
- * @return Returns the soapBinding.
- */
- public SOAPBindingInfo getSoapBinding() {
- return soapBinding;
- }
-
- /**
- * @param soapBinding
- * The soapBinding to set.
- */
- public void setSoapBinding(SOAPBindingInfo soapBinding) {
- this.soapBinding = soapBinding;
- }
-
- /**
- * @return Returns the wmAction.
- */
- public String getWmAction() {
+ public String getWmAction()
+ {
return wmAction;
}
- /**
- * @param wmAction
- * The wmAction to set.
- */
- public void setWmAction(String wmAction) {
+ public void setWmAction(String wmAction)
+ {
this.wmAction = wmAction;
}
- /**
- * @return Returns the wmOperationName.
- */
- public String getWmOperationName() {
+ public String getWmOperationName()
+ {
return wmOperationName;
}
- /**
- * @param wmOperationName
- * The wmOperationName to set.
- */
- public void setWmOperationName(String wmOperationName) {
+ public void setWmOperationName(String wmOperationName)
+ {
this.wmOperationName = wmOperationName;
}
- /**
- * @return Returns the wrName.
- */
- public String getWrName() {
+ public String getWrName()
+ {
return wrName;
}
- /**
- * @param wrName
- * The wrName to set.
- */
- public void setWrName(String wrName) {
+ public void setWrName(String wrName)
+ {
this.wrName = wrName;
}
- /**
- * @return Returns the params.
- */
- public List<WebServicePARAMETERMetadata> getParams() {
+ public List<WebServicePARAMETERMetadata> getParams()
+ {
return Collections.unmodifiableList(params);
}
- public void addParams(Collection<? extends WebServicePARAMETERMetadata>
parameters) {
- if(null != parameters) this.params.addAll(parameters);
+ public void addParams(Collection<? extends WebServicePARAMETERMetadata>
parameters)
+ {
+ if (null != parameters)
+ {
+ params.addAll(parameters);
+ }
}
- public void addParam(WebServicePARAMETERMetadata parameter) {
- if(null != parameter) this.params.add(parameter);
+ public void addParam(WebServicePARAMETERMetadata parameter)
+ {
+ if (null != parameter)
+ {
+ params.add(parameter);
+ }
}
- public String getJavaMethodName() {
+ public String getJavaMethodName()
+ {
return javaMethodName;
}
- public Class getJavaReturnType() {
+ public Class getJavaReturnType()
+ {
return javaReturnType;
}
-
-}
+}
\ No newline at end of file
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
Wed Sep 22 13:40:20 2004
@@ -6,9 +6,9 @@
* 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.
@@ -24,144 +24,102 @@
import javax.jws.WebParam;
-public class WebServicePARAMETERMetadata extends AnnotationModel {
-
- String wpName;
-
- WebParam.Mode wpMode;
-
- boolean wpHeader;
-
+public class WebServicePARAMETERMetadata extends AnnotationModel
+{
+ private String wpName;
+ private WebParam.Mode wpMode;
+ private boolean wpHeader;
private Class javaType;
-
private String defaultName;
-
- /**
- *
- */
- public WebServicePARAMETERMetadata() {
+
+ public WebServicePARAMETERMetadata()
+ {
super();
}
-
- private void setDefaults(javax.jws.WebParam wp) {
- // deferred --> requires METHOD information: position
- }
-
+
// defaultName is argument name in the source file. It can be null if the
// name is not known.
- public WebServicePARAMETERMetadata(javax.jws.WebParam webParamAnnotation,
- Class javaType, String defaultName,
- Collection<Annotation> annotations) {
+ public WebServicePARAMETERMetadata(
+ javax.jws.WebParam webParamAnnotation,
+ Class javaType,
+ String defaultName,
+ Collection<Annotation> annotations)
+ {
// check parameters
- if (null == javaType) {
+ if (null == javaType)
+ {
throw new IllegalArgumentException("javaType not set");
}
-
this.javaType = javaType;
- setWpMode(WebParam.Mode.IN); // by default if there were no
anotations.
+ setWpMode(WebParam.Mode.IN); // by default if there were no anotations
setWpName(defaultName); // in case there are no annotations
-
- // check required parameters
+ // check required parameters
// initialize from required annotation
- if(null != webParamAnnotation) initFromAnnotation(webParamAnnotation);
+ if (null != webParamAnnotation)
+ {
+ initFromAnnotation(webParamAnnotation);
+ }
+
+ // set optional annotations .. None in the case of parameters
+ // for (Annotation a : annotations) {
+ //
+ // }
- // set optional annotations .. None in the case of parameters
-// for (Annotation a : annotations) {
-//
-// }
-
}
-
- /**
- * @return Returns the wpHeader.
- */
- public boolean isWpHeader() {
+
+ public boolean isWpHeader()
+ {
return wpHeader;
}
-
- /**
- * @param wpHeader
- * The wpHeader to set.
- */
- public void setWpHeader(boolean wpHeader) {
+
+ public void setWpHeader(boolean wpHeader)
+ {
this.wpHeader = wpHeader;
}
-
- /**
- * @return Returns the wpMode.
- */
- public WebParam.Mode getWpMode() {
+
+ public WebParam.Mode getWpMode()
+ {
return wpMode;
}
-
- /**
- * @param wpMode
- * The wpMode to set.
- */
- public void setWpMode(WebParam.Mode wpMode) {
+
+ public void setWpMode(WebParam.Mode wpMode)
+ {
this.wpMode = wpMode;
}
-
- /**
- * @return Returns the wpName.
- */
- public String getWpName() {
+
+ public String getWpName()
+ {
return wpName;
}
-
- /**
- * @param wpName
- * The wpName to set.
- */
- public void setWpName(String wpName) {
+
+ public void setWpName(String wpName)
+ {
this.wpName = wpName;
}
-
- /**
- * @return Returns the javaType.
- */
- public Class getJavaType() {
+
+ public Class getJavaType()
+ {
return javaType;
}
-
- public void setJavaType(Class javaType) {
+
+ public void setJavaType(Class javaType)
+ {
this.javaType = javaType;
}
-
- /**
- * @param webParam
- */
- private void initFromAnnotation(WebParam annotation) {
- if (null != annotation) {
- if(annotation.name().length()!=0) setWpName(annotation.name());
+
+ private void initFromAnnotation(WebParam annotation)
+ {
+ if (null != annotation)
+ {
+ if (0 < annotation.name().length())
+ {
+ setWpName(annotation.name());
+ }
setWpMode(annotation.mode());
setWpHeader(annotation.header());
}
-
}
-
- // /**
- // *
- // */
- // private void setDefaults() {
- // if(getWpName().length() == 0) setWpName(getDefaultName());
- // }
- //
- // /**
- // * @return Returns the defaultName.
- // */
- // public String getDefaultName() {
- // return defaultName;
- // }
- //
- // /**
- // * @param defaultName
- // * The defaultName to set.
- // */
- // public void setDefaultName(String sourceName) {
- // this.defaultName = sourceName;
- // }
}
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
Wed Sep 22 13:40:20 2004
@@ -1,32 +1,5 @@
package org.apache.beehive.wsm.jsr181.model;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.net.URL;
-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.SOAPBinding;
-import javax.jws.soap.SOAPMessageHandler;
-import javax.jws.soap.SOAPMessageHandlers;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-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
*
@@ -45,73 +18,97 @@
* $Header:$Factory
*/
-public class WebServiceTYPEMetadata extends AnnotationModel {
-
- String wsName;
-
- String wsServiceName;
+import java.io.IOException;
- String wsWsdlLocation;
+import java.lang.annotation.Annotation;
- String wsTargetNamespace;
+import java.net.URL;
- Collection<WebServiceMETHODMetadata> methods = new
ArrayList<WebServiceMETHODMetadata>();
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
- SOAPBindingInfo soapBinding;
+import javax.jws.HandlerChain;
+import javax.jws.SecurityIdentity;
+import javax.jws.SecurityRoles;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPMessageHandler;
+import javax.jws.soap.SOAPMessageHandlers;
- String hcFileName;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
- String hcName;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
- List<SOAPMessageHandlerInfo> soapHandlers = new
ArrayList<SOAPMessageHandlerInfo>();
+import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
- SecurityRolesInfo securityRoles;
+import org.apache.xmlbeans.XmlException;
- String siRunAs;
+import org.apache.beehive.wsm.jsr181.wsdl.WSDLProcessor;
+public class WebServiceTYPEMetadata extends AnnotationModel
+{
+ private String wsName;
+ private String wsServiceName;
+ private String wsWsdlLocation;
+ private String wsTargetNamespace;
+ private Collection<WebServiceMETHODMetadata> methods = new
ArrayList<WebServiceMETHODMetadata>();
+ private SOAPBindingInfo soapBinding;
+ private String hcFileName;
+ private String hcName;
+ private List<SOAPMessageHandlerInfo> soapHandlers = new
ArrayList<SOAPMessageHandlerInfo>();
+ private SecurityRolesInfo securityRoles;
+ private String siRunAs;
private String javaFQClassName;
- /**
- *
- */
- public WebServiceTYPEMetadata(String fqClassName) {
+ public WebServiceTYPEMetadata(String fqClassName)
+ {
super();
-
javaFQClassName = fqClassName;
}
-// TODO: not used anymore, remove it.
-// static public WebServiceTYPEMetadata buildWSMetadata(String filename)
-// throws InvalidFileType {
-// if (filename.endsWith(".java") || filename.endsWith(".jws")) {
-// //TODO: get the object model from 2 phase processor
-// return null;
-// } else {
-// throw new InvalidFileType(
-// "File: "
-// + filename
-// + " is not supported. Only .java, .jws, and
.class files are supported");
-// }
-// }
-
- public WebServiceTYPEMetadata(WebService webServiceAnnotation, String
fqClassName, Collection<Annotation> annotations,
- Collection< ? extends WebServiceMETHODMetadata> webMethods) {
+ public WebServiceTYPEMetadata(
+ WebService webServiceAnnotation,
+ String fqClassName,
+ Collection<Annotation> annotations,
+ Collection< ? extends WebServiceMETHODMetadata> webMethods
+ ) throws Exception
+ {
super();
+
// check required parameters
- if ((null == fqClassName) || (0 == fqClassName.length())) {
+ if ((null == fqClassName) || (0 == fqClassName.length()))
+ {
throw new IllegalArgumentException("className not set");
}
this.javaFQClassName = fqClassName;
// check required parameters
- if (null == webServiceAnnotation ) {
+ if (null == webServiceAnnotation )
+ {
throw new IllegalArgumentException("@WebService is required");
}
+
+ // enforce JSR-181 rules
+ if (AnnotationModel.hasAnnotationType(annotations,
SOAPMessageHandlers.class) &&
+ AnnotationModel.hasAnnotationType(annotations, HandlerChain.class))
+ {
+ // todo needs to be proper Exception subclass
+ throw new Exception(
+ "Illegal combination of @SOAPMessageHandlers and
@HandlerChain");
+ }
// initialize from required annotation
initFromAnnotation(webServiceAnnotation);
-
// set optional annotations
for (Annotation a : annotations) {
// @HandlerChain
@@ -135,24 +132,26 @@
}
// @SOAPMessageHandlers
- else if (a.annotationType() ==
javax.jws.soap.SOAPMessageHandlers.class) {
+ else if (a.annotationType() ==
javax.jws.soap.SOAPMessageHandlers.class)
+ {
initFromAnnotation((javax.jws.soap.SOAPMessageHandlers) a);
- } else {
+ }
+ 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
+ for (WebServiceMETHODMetadata wsmm : webMethods)
+ {
addMethod(wsmm);
}
}
- protected void initFromAnnotation(WebService annotation) {
+ protected void initFromAnnotation(WebService annotation)
+ {
if (null != annotation) {
setWsName(annotation.name());
setWsServiceName(annotation.serviceName());
@@ -434,8 +433,9 @@
return true;
}
- public DefinitionsDocument getWSDLAsDocument() throws IOException,
- XmlException {
+ public DefinitionsDocument getWSDLAsDocument()
+ throws IOException, XmlException
+ {
return WSDLProcessor.parseWSDL(getWsWsdlLocation());
}
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
Wed Sep 22 13:40:20 2004
@@ -38,10 +38,10 @@
import com.sun.mirror.type.AnnotationType;
-import org.apache.beehive.wsm.jsr181.model.*;
import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
-
-import java.io.*;
+import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
public class WsmAnnotationProcessor extends TwoPhaseAnnotationProcessor
{
@@ -49,10 +49,9 @@
* Constructor.
* @param _atds
* @param _env
- * @return
*/
public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> _atds,
- AnnotationProcessorEnvironment _env)
+ AnnotationProcessorEnvironment _env)
{
super(_atds, _env);
}
@@ -63,6 +62,7 @@
// check type of declaration
if ((null == decl) || (! (decl instanceof ClassDeclaration)))
{
+ return;
// todo: error --> @WebService is @Target(TYPE)
}
@@ -71,7 +71,7 @@
return;
// todo: log warning/error "@WebService" not defined (should never
happen)
}
-
+
// create & store object model
AnnotationModel objectModel =
getWebServiceTYPEMetadata((ClassDeclaration) decl);
@@ -115,9 +115,9 @@
WebServiceTYPEMetadata wstm = null;
try {
Collection<Annotation> annotations = getAnnotations(decl);
- wstm = new WebServiceTYPEMetadata(
-
(javax.jws.WebService)AnnotationModel.getAnnotationOfType(annotations,
javax.jws.WebService.class),
- decl.getQualifiedName(),
+ wstm = new WebServiceTYPEMetadata((javax.jws.WebService)
+ AnnotationModel.getAnnotationOfType(annotations,
javax.jws.WebService.class),
+ decl.getQualifiedName(),
annotations,
webMethods
);
@@ -147,10 +147,11 @@
WebServiceMETHODMetadata wsmm = null;
try {
Collection<Annotation> annotations = getAnnotations(decl);
- wsmm = new WebServiceMETHODMetadata(
+ wsmm = new WebServiceMETHODMetadata(
(javax.jws.WebMethod)AnnotationModel.getAnnotationOfType(annotations,
javax.jws.WebMethod.class),
decl.getSimpleName(),
classForName(decl.getReturnType().toString()),
+ (0 < decl.getThrownTypes().size()),
annotations,
webParams
);
@@ -182,8 +183,6 @@
}
return wspm;
}
-
-
private Collection<Annotation> getAnnotations(Declaration decl)
{
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
Wed Sep 22 13:40:20 2004
@@ -1,21 +1,5 @@
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;
-import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
-
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -34,7 +18,22 @@
* $Header:$
*/
-//org.apache.beehive.wsm.processor.reflection.WsmReflectionAnnotationProcessor.java
+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;
+import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
+
public class WsmReflectionAnnotationProcessor {
/**
@@ -45,33 +44,43 @@
// TODO Auto-generated constructor stub
}
- public static WebServiceTYPEMetadata getObjectModel(Class clazz) {
+ public static WebServiceTYPEMetadata getObjectModel(Class clazz)
+ {
WebService wsAnnotation;
- if (null == (wsAnnotation = (WebService) clazz
- .getAnnotation(WebService.class))) // no @WebService
+ if (null == (wsAnnotation = (WebService)
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);
+ Collection<WebServiceMETHODMetadata> webMethods =
+ new ArrayList<WebServiceMETHODMetadata>();
+ for (Method method : methods)
+ {
+ WebMethod webMethodAnnotation =
method.getAnnotation(WebMethod.class);
+
//method is a webmethod
- if (webMethodAnnotation != null) {
+ if (webMethodAnnotation != null)
+ {
// get all parameters
- List<WebServicePARAMETERMetadata> params = new
ArrayList<WebServicePARAMETERMetadata>();
+ List<WebServicePARAMETERMetadata> params =
+ new ArrayList<WebServicePARAMETERMetadata>();
int offset = 0;
Class< ? >[] methodParamTypes = method.getParameterTypes();
- Annotation[][] allAnnotations = method
- .getParameterAnnotations();
-// WebParam wpAnnotation = (WebParam) method
-// .getAnnotation(WebParam.class);
- for (Class paramType : methodParamTypes) {
- List<Annotation> allParmAnnotation =
Arrays.asList(allAnnotations[offset]);
- WebParam wpAnnotation =
(WebParam)AnnotationModel.getAnnotationOfType(allParmAnnotation,
WebParam.class);
- WebServicePARAMETERMetadata paramMetaData = new
WebServicePARAMETERMetadata(
- wpAnnotation, paramType, "in" +offset, // by
default parameter should be IN
- allParmAnnotation); // class
+ Annotation[][] allAnnotations =
method.getParameterAnnotations();
+ for (Class paramType : methodParamTypes)
+ {
+ List<Annotation> allParmAnnotation =
+ Arrays.asList(allAnnotations[offset]);
+ WebParam wpAnnotation =
+
(WebParam)AnnotationModel.getAnnotationOfType(allParmAnnotation,
WebParam.class);
+ WebServicePARAMETERMetadata paramMetaData =
+ new WebServicePARAMETERMetadata(
+ wpAnnotation,
+ paramType,
+ "in" + offset, // by default parameter should be
IN
+ allParmAnnotation // class
+ );
// reflection
// doesn't keep the
// name of
@@ -79,17 +88,38 @@
params.add(paramMetaData);
offset++;
}
- WebServiceMETHODMetadata methodMetaData = new
WebServiceMETHODMetadata(
- webMethodAnnotation, method.getName(), method
- .getReturnType(), Arrays.asList(method
- .getAnnotations()), params);
- webMethods.add(methodMetaData);
+ try {
+ WebServiceMETHODMetadata wsmm =
+ new WebServiceMETHODMetadata(
+ webMethodAnnotation,
+ method.getName(),
+ method.getReturnType(),
+ (0 < method.getExceptionTypes().length),
+ Arrays.asList(method.getAnnotations()),
+ params
+ );
+ webMethods.add(wsmm);
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace(); // todo proper error handling
+ return null;
+ }
}
-
}
- return new WebServiceTYPEMetadata(wsAnnotation, clazz.getName(), Arrays
- .asList(clazz.getAnnotations()), webMethods);
-
+ WebServiceTYPEMetadata wstm = null;
+ try {
+ wstm = new WebServiceTYPEMetadata(
+ wsAnnotation,
+ clazz.getName(),
+ Arrays.asList(clazz.getAnnotations()),
+ webMethods
+ );
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace(); // todo proper error handling
+ }
+ return wstm;
}
-
}
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/jsr181/wsdl/WSDLProcessor.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/wsdl/WSDLProcessor.java
Wed Sep 22 13:40:20 2004
@@ -368,13 +368,13 @@
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);
- }
+// 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);
@@ -391,12 +391,12 @@
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);
- }
+// if (sb != null && SOAPBinding.Use.LITERAL.equals(sb.getUse())) {
+// tBod.setUse(UseChoice.LITERAL);
+// }
+// else {
+// tBod.setUse(UseChoice.ENCODED);
+// }
/*
* NOTE [EMAIL PROTECTED] 2004-Aug-31 -- not sure what parts