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/16 01:51:49 UTC
svn commit: rev 46139 - in incubator/beehive/trunk/wsm: drt/tests/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/axis/util src/runtime/org/apache/beehive/wsm/jsr181/model src/runtime/org/apache/beehive/wsm/util test/webapps/AnnotatedAxis/WEB-INF
Author: mmerz
Date: Wed Sep 15 16:51:49 2004
New Revision: 46139
Added:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java (contents, props changed)
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/HandlerHandler.java (contents, props changed)
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/
- copied from rev 45985, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/ClasspathUtils.java
- copied, changed from rev 46132, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/ClasspathUtils.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/JavaArchiveFilter.java
- copied, changed from rev 46132, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/JavaArchiveFilter.java
Removed:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
incubator/beehive/trunk/wsm/test/webapps/AnnotatedAxis/WEB-INF/server-config.wsdd
Log:
Added support for SOAPMessageHandler annotations and refactored the functionality of the AnnotatedJWSHandler into the DropInDeploymentHandler.
Contributor: Jonathan Colwell
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 15 16:51:49 2004
@@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import javax.jws.InitParam;
import javax.jws.QName;
@@ -32,463 +33,448 @@
public class Jsr181ModelTest extends TestCase {
- public void setUp() {
- }
+ public void setUp() {
+ }
- public void tearDown() {
- }
+ public void tearDown() {
+ }
- // test TYPE level annotations
-
- 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);
- assertTrue(
- "Error, the TYPE annotation should fail without @WebService",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
-
- 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));
- try {
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(null,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(
- "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<Annotation> typeAnnotations = new ArrayList<Annotation>();
- 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);
- }
-
- public void testTYPEWebServiceAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
- "testserviceName", "testwsdllocation", "testtargetnamespace",
- "testendpointinterface");
- typeAnnotations.add(wsAnnotation);
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getWsName().compareTo("testname") == 0);
- assertTrue(type.getWsServiceName().compareTo("testserviceName") == 0);
- assertTrue(type.getWsWsdlLocation().compareTo("testwsdllocation") == 0);
- assertTrue(type.getWsTargetNamespace().compareTo("testtargetnamespace") == 0);
-
- }
-
- public void testTYPESOAPBindingAnnotationDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
- "testserviceName", "testwsdllocation", "testtargetnamespace",
- "testendpointinterface");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.DEFAULT, SOAPBinding.Use.DEFAULT,
- SOAPBinding.ParameterStyle.DEFAULT));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT);
- assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.LITERAL);
- assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED);
- }
-
- public void testTYPESOAPBindingAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSOAPBindingAnnotation(
- SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
- SOAPBinding.ParameterStyle.BARE));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
- assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED);
- assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.BARE);
- }
-
- // no test for default HandlerChains, all fields are required in the
- // @HandlerChain
-
- public void testTYPEHandlerChainAnnotation() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
-
- typeAnnotations.add(new FakeHandlerChainAnnotation("testfile",
- "testname"));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getHcFileName() == "testfile");
- assertTrue(type.getHcName() == "testname");
- }
-
- // test empty handler list
- public void testTYPESoapMessageHandlersDefaults1() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
-
- FakeSOAPMessageHandlerAnnotation[] emptyHandlers = new FakeSOAPMessageHandlerAnnotation[0];
- typeAnnotations
- .add(new FakeSOAPMessageHandlersAnnotation(emptyHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSoapHandlers().size() == 0);
-
- }
-
- // test a single default handler in the handlers list
- public void testTYPESoapMessageHandlersDefaults2() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
-
- SOAPMessageHandler[] defaultHandlers = new FakeSOAPMessageHandlerAnnotation[1];
- defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
- "soaphandlerclass", new FakeInitParamAnnotation[0],
- new String[0], new FakeQName[0]);
- typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
- defaultHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue("number of handlers returned: "
- + type.getSoapHandlers().size(),
- type.getSoapHandlers().size() == 1);
- SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
- assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getParams().size() == 0);
- assertTrue(handler.getRoles().size() == 0);
- assertTrue(handler.getHeaders().size() == 0);
- }
-
- public void testTYPESoapMessageHandlers() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
-
- InitParam[] params = { new FakeInitParamAnnotation("paramname",
- "paramvalue") };
- String[] roles = { "messagehandlerroles" };
- QName[] headers = { new FakeQName("messagehanderheadernamespace",
- "messagehanderheaderlocalname") };
- SOAPMessageHandler[] defaultHandlers = { new FakeSOAPMessageHandlerAnnotation(
- "", "soaphandlerclass", params, roles, headers) };
- typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
- defaultHandlers));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue("number of handlers returned: "
- + type.getSoapHandlers().size(),
- type.getSoapHandlers().size() == 1);
- SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
- assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
- assertTrue(handler.getParams().size() == 1);
- assertTrue(handler.getRoles().size() == 1);
- assertTrue(handler.getHeaders().size() == 1);
-
- InitParamInfo p = handler.getParams().iterator().next();
- assert (p.getName().compareTo("paramname") == 0);
- assert (p.getValue().compareTo("paramvalue") == 0);
-
- assert (handler.getRoles().iterator().next().compareTo(
- "messagehandlerroles") == 0);
-
- QNameInfo q = handler.getHeaders().iterator().next();
- assert (q.getNamespaceURI().compareTo("messagehanderheadernamespace") == 0);
- assert (q.getLocalName().compareTo("messagehanderheaderlocalname") == 0);
- }
-
- public void testTYPESecurityRolesDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
-
- assertNull(type.getSecurityRoles().getRolesAllowed());
- assertNull(type.getSecurityRoles().getRolesReferenced());
-
- }
-
- public void testTYPESecurityRoles() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
- String[] rolesAllowed = { "rolesallowed" };
- String[] rolesReferenced = { "rolesreferenced" };
- typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
- rolesReferenced));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
-
- assertTrue(type.getSecurityRoles().getRolesAllowed().size() == 1);
- assertTrue(type.getSecurityRoles().getRolesAllowed().iterator().next()
- .compareTo("rolesallowed") == 0);
- assertTrue(type.getSecurityRoles().getRolesReferenced().size() == 1);
- assertTrue(type.getSecurityRoles().getRolesReferenced().iterator()
- .next().compareTo("rolesreferenced") == 0);
- }
-
- public void testTYPESecurityIdentityDefaults() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations.add(new FakeSecurityIdentityAnnotation(null));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
-
- assertNull(type.getSiRunAs());
-
- }
-
- public void testTYPESecurityIdentity() throws Exception {
- Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
- Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
- WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
- "");
- typeAnnotations.add(wsAnnotation);
- typeAnnotations
- .add(new FakeSecurityIdentityAnnotation("runasidentity"));
- WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(wsAnnotation,
- "a.b.c.testclass", typeAnnotations, methodMetadata);
- assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
- }
-
- //test METHOD level
- public void testMETHODRequiredAnnotations() throws Exception {
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", Void.class, null, null);
- assertTrue(
- "Error, the METHOD annotation should fail without @WebMethod",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- null, "methodname", Void.class, methodAnnotations, null);
- assertTrue(
- "Error, the METHOD annotation should fail without @WebMethod",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
-
- WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
- methodAnnotations.add(mAnnotation);
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, null, Void.class, methodAnnotations, null);
- assertTrue(
- "Error, the METHOD annotation should fail without method name",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- try {
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodName", null, methodAnnotations, null);
- assertTrue(
- "Error, the METHOD annotation should fail without return type class",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
- }
-
- public void testMETHODWebMethodDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
- assertTrue(method.getWmAction().length() == 0);
-
- }
-
- public void testMETHODWebMethod() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertTrue(method.getWmOperationName().compareTo("operationname") == 0);
- assertTrue(method.getWmAction().compareTo("action") == 0);
-
- }
-
- public void testMETHODOneWayDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertFalse(method.isOneWay());
- }
-
- public void testMETHODOneWay() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeOneWayAnnotation());
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertTrue(method.isOneWay());
- }
-
- public void testMETHODWebResultDefaults() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeWebResultAnnotation("result"));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertTrue(method.getWrName().compareTo("result") == 0);
- }
-
- public void testMETHODWebResult() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeWebResultAnnotation("resultname"));
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, 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");
- methodAnnotations.add(mAnnotation);
- methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
-
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertNull(method.getSecurityRoles().getRolesAllowed());
- assertNull(method.getSecurityRoles().getRolesReferenced());
- }
-
- public void testMETHODSecurityRole() throws Exception {
- Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
- WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname",
- "action");
- methodAnnotations.add(mAnnotation);
- String[] rolesAllowed = { "rolesallowed" };
- String[] rolesReferenced = { "rolesreferenced" };
- methodAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
- rolesReferenced));
-
- WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
- mAnnotation, "methodname", Void.class, methodAnnotations, null);
- assertTrue(method.getSecurityRoles().getRolesAllowed().size() == 1);
- assertTrue(method.getSecurityRoles().getRolesAllowed().iterator()
- .next().compareTo("rolesallowed") == 0);
- assertTrue(method.getSecurityRoles().getRolesReferenced().size() == 1);
- assertTrue(method.getSecurityRoles().getRolesReferenced().iterator()
- .next().compareTo("rolesreferenced") == 0);
-
- }
-
- //test PARAMETER level annotation
- public void testPARAMETERRequiredAnnotations() throws Exception {
-
- try {
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
- null, null, "paramname", null);
- assertTrue("Java type should be a required field in Parameter",
- false);
- } catch (IllegalArgumentException e) {
- // good case
- }
-
- }
+ // test TYPE level annotations
+ 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);
+ assertTrue(
+ "Error, the TYPE annotation should fail without @WebService",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+
+ 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));
+ try {
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ null, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(
+ "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<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ 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);
+ }
+
+ public void testTYPEWebServiceAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
+ "testserviceName", "testwsdllocation", "testtargetnamespace",
+ "testendpointinterface");
+ typeAnnotations.add(wsAnnotation);
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getWsName().compareTo("testname") == 0);
+ assertTrue(type.getWsServiceName().compareTo("testserviceName") == 0);
+ assertTrue(type.getWsWsdlLocation().compareTo("testwsdllocation") == 0);
+ assertTrue(type.getWsTargetNamespace().compareTo("testtargetnamespace") == 0);
+
+ }
+
+ public void testTYPESOAPBindingAnnotationDefaults() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("testname",
+ "testserviceName", "testwsdllocation", "testtargetnamespace",
+ "testendpointinterface");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeSOAPBindingAnnotation(
+ SOAPBinding.Style.DEFAULT, SOAPBinding.Use.DEFAULT,
+ SOAPBinding.ParameterStyle.DEFAULT));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT);
+ assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.LITERAL);
+ assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.WRAPPED);
+ }
+
+ public void testTYPESOAPBindingAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeSOAPBindingAnnotation(
+ SOAPBinding.Style.RPC, SOAPBinding.Use.ENCODED,
+ SOAPBinding.ParameterStyle.BARE));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getSoapBinding().getStyle() == SOAPBinding.Style.RPC);
+ assertTrue(type.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED);
+ assertTrue(type.getSoapBinding().getParameterStyle() == SOAPBinding.ParameterStyle.BARE);
+ }
+
+ // no test for default HandlerChains, all fields are required in the
+ // @HandlerChain
+
+ public void testTYPEHandlerChainAnnotation() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+
+ typeAnnotations.add(new FakeHandlerChainAnnotation("testfile",
+ "testname"));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getHcFileName() == "testfile");
+ assertTrue(type.getHcName() == "testname");
+ }
+
+ // test empty handler list
+ public void testTYPESoapMessageHandlersDefaults1() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+
+ FakeSOAPMessageHandlerAnnotation[] emptyHandlers = new FakeSOAPMessageHandlerAnnotation[0];
+ typeAnnotations
+ .add(new FakeSOAPMessageHandlersAnnotation(emptyHandlers));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getSoapHandlers().size() == 0);
+
+ }
+
+ // test a single default handler in the handlers list
+ public void testTYPESoapMessageHandlersDefaults2() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+
+ SOAPMessageHandler[] defaultHandlers = new FakeSOAPMessageHandlerAnnotation[1];
+ defaultHandlers[0] = new FakeSOAPMessageHandlerAnnotation("",
+ "soaphandlerclass", new FakeInitParamAnnotation[0],
+ new String[0], new FakeQName[0]);
+ typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
+ defaultHandlers));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue("number of handlers returned: "
+ + type.getSoapHandlers().size(),
+ type.getSoapHandlers().size() == 1);
+ SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
+ assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
+ assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
+ assertTrue(handler.getParameterMap().size() == 0);
+ assertTrue(handler.getRoles().size() == 0);
+ assertTrue(handler.getHeaders().size() == 0);
+ }
+
+ public void testTYPESoapMessageHandlers() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+
+ InitParam[] params = { new FakeInitParamAnnotation("paramname",
+ "paramvalue") };
+ String[] roles = { "messagehandlerroles" };
+ QName[] headers = { new FakeQName("messagehanderheadernamespace",
+ "messagehanderheaderlocalname") };
+ SOAPMessageHandler[] defaultHandlers = { new FakeSOAPMessageHandlerAnnotation(
+ "", "soaphandlerclass", params, roles, headers) };
+ typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(
+ defaultHandlers));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue("number of handlers returned: "
+ + type.getSoapHandlers().size(),
+ type.getSoapHandlers().size() == 1);
+ SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
+ assertTrue(handler.getName().compareTo("soaphandlerclass") == 0);
+ assertTrue(handler.getClassName().compareTo("soaphandlerclass") == 0);
+ assertTrue(handler.getParameterMap().size() == 1);
+ assertTrue(handler.getRoles().size() == 1);
+ assertTrue(handler.getHeaders().size() == 1);
+
+ Map.Entry<String,String> me =
+ handler.getParameterMap().entrySet().iterator().next();
+ assert (me.getKey().compareTo("paramname") == 0);
+ assert (me.getValue().compareTo("paramvalue") == 0);
+
+ assert (handler.getRoles().iterator().next().compareTo(
+ "messagehandlerroles") == 0);
+
+ QNameInfo q = handler.getHeaders().iterator().next();
+ assert (q.getNamespaceURI().compareTo("messagehanderheadernamespace") == 0);
+ assert (q.getLocalName().compareTo("messagehanderheaderlocalname") == 0);
+ }
+
+ public void testTYPESecurityRolesDefaults() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertNull(type.getSecurityRoles().getRolesAllowed());
+ assertNull(type.getSecurityRoles().getRolesReferenced());
+
+ }
+
+ public void testTYPESecurityRoles() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ String[] rolesAllowed = { "rolesallowed" };
+ String[] rolesReferenced = { "rolesreferenced" };
+ typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
+ rolesReferenced));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertTrue(type.getSecurityRoles().getRolesAllowed().size() == 1);
+ assertTrue(type.getSecurityRoles().getRolesAllowed().iterator().next()
+ .compareTo("rolesallowed") == 0);
+ assertTrue(type.getSecurityRoles().getRolesReferenced().size() == 1);
+ assertTrue(type.getSecurityRoles().getRolesReferenced().iterator()
+ .next().compareTo("rolesreferenced") == 0);
+ }
+
+ public void testTYPESecurityIdentityDefaults() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations.add(new FakeSecurityIdentityAnnotation(null));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+
+ assertNull(type.getSiRunAs());
+
+ }
+
+ public void testTYPESecurityIdentity() throws Exception {
+ Collection<WebServiceMETHODMetadata> methodMetadata = new ArrayList<WebServiceMETHODMetadata>();
+ Collection<Annotation> typeAnnotations = new ArrayList<Annotation>();
+ WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "", "");
+ typeAnnotations.add(wsAnnotation);
+ typeAnnotations
+ .add(new FakeSecurityIdentityAnnotation("runasidentity"));
+ WebServiceTYPEMetadata type = new WebServiceTYPEMetadata(
+ wsAnnotation, "a.b.c.testclass", typeAnnotations, methodMetadata);
+ assertTrue(type.getSiRunAs().compareTo("runasidentity") == 0);
+ }
+
+ //test METHOD level
+ public void testMETHODRequiredAnnotations() throws Exception {
+ try {
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ null, "methodname", Void.class, null, null);
+ assertTrue(
+ "Error, the METHOD annotation should fail without @WebMethod",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ try {
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ null, "methodname", Void.class, methodAnnotations, null);
+ assertTrue(
+ "Error, the METHOD annotation should fail without @WebMethod",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+ try {
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, null, Void.class, methodAnnotations,null);
+ assertTrue(
+ "Error, the METHOD annotation should fail without method name",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+ try {
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodName", null, methodAnnotations,null);
+ assertTrue(
+ "Error, the METHOD annotation should fail without return type class",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+ }
+
+ public void testMETHODWebMethodDefaults() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("", "");
+ methodAnnotations.add(mAnnotation);
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations,null);
+ assertTrue(method.getWmOperationName().compareTo("methodname") == 0);
+ assertTrue(method.getWmAction().length() == 0);
+
+ }
+
+ public void testMETHODWebMethod() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertTrue(method.getWmOperationName().compareTo("operationname") == 0);
+ assertTrue(method.getWmAction().compareTo("action") == 0);
+
+ }
+
+ public void testMETHODOneWayDefaults() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertFalse(method.isOneWay());
+ }
+
+ public void testMETHODOneWay() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeOneWayAnnotation());
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertTrue(method.isOneWay());
+ }
+
+ public void testMETHODWebResultDefaults() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeWebResultAnnotation("result"));
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertTrue(method.getWrName().compareTo("result") == 0);
+ }
+
+ public void testMETHODWebResult() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeWebResultAnnotation("resultname"));
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, 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");
+ methodAnnotations.add(mAnnotation);
+ methodAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
+
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertNull(method.getSecurityRoles().getRolesAllowed());
+ assertNull(method.getSecurityRoles().getRolesReferenced());
+ }
+
+ public void testMETHODSecurityRole() throws Exception {
+ Collection<Annotation> methodAnnotations = new ArrayList<Annotation>();
+ WebMethod mAnnotation = new FakeWebMethodAnnotation("operationname", "action");
+ methodAnnotations.add(mAnnotation);
+ String[] rolesAllowed = { "rolesallowed" };
+ String[] rolesReferenced = { "rolesreferenced" };
+ methodAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
+ rolesReferenced));
+
+ WebServiceMETHODMetadata method = new WebServiceMETHODMetadata(
+ mAnnotation, "methodname", Void.class, methodAnnotations, null);
+ assertTrue(method.getSecurityRoles().getRolesAllowed().size() == 1);
+ assertTrue(method.getSecurityRoles().getRolesAllowed().iterator().next()
+ .compareTo("rolesallowed") == 0);
+ assertTrue(method.getSecurityRoles().getRolesReferenced().size() == 1);
+ assertTrue(method.getSecurityRoles().getRolesReferenced().iterator()
+ .next().compareTo("rolesreferenced") == 0);
+
+ }
+
+
+ //test PARAMETER level annotation
+ public void testPARAMETERRequiredAnnotations() throws Exception {
+
+ try {
+ WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
+ null, null, "paramname", null );
+ assertTrue(
+ "Java type should be a required field in Parameter",
+ false);
+ } catch (IllegalArgumentException e) {
+ // good case
+ }
+
+ }
+
public void testPARAMETERWebParamDefault1() {
WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
null, String.class, "paramname", null);
@@ -496,8 +482,7 @@
assertTrue(param.getWpMode() == WebParam.Mode.IN);
assertTrue(param.getWpName().compareTo("paramname") == 0);
assertFalse(param.isWpHeader());
- }
-
+ }
public void testPARAMETERWebParamDefault2() {
Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
@@ -506,35 +491,32 @@
assertTrue(param.getWpMode() == WebParam.Mode.IN);
assertTrue(param.getWpName().compareTo("paramname") == 0);
assertFalse(param.isWpHeader());
- }
-
+ }
+
public void testPARAMETERWebParamDefault3() {
-
Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
- WebParam wpAnnotation = new FakeWebParamAnnotation("",
- WebParam.Mode.IN, false);
- paramAnnotations.add(wpAnnotation);
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
- wpAnnotation, String.class, "paramname", paramAnnotations);
-
- assertTrue(param.getWpMode() == WebParam.Mode.IN);
- assertTrue(param.getWpName().compareTo("paramname") == 0);
- assertFalse(param.isWpHeader());
- }
-
- public void testPARAMETERWebParam() {
- Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
- WebParam wpAnnotation = new FakeWebParamAnnotation(
- "paramannotationname", WebParam.Mode.INOUT, true);
- paramAnnotations.add(wpAnnotation);
- WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata(
- wpAnnotation, String.class, "paramname", paramAnnotations);
-
- assertTrue(param.getWpMode() == WebParam.Mode.INOUT);
- assertTrue(param.getWpName().compareTo("paramannotationname") == 0);
- assertTrue(param.isWpHeader());
-
- }
- // TODO: test combination of type, method, annotation
+ WebParam wpAnnotation = new FakeWebParamAnnotation("", WebParam.Mode.IN, false);
+ paramAnnotations.add(wpAnnotation);
+ WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
+ wpAnnotation, String.class, "paramname", paramAnnotations);
+
+ assertTrue(param.getWpMode() == WebParam.Mode.IN);
+ assertTrue(param.getWpName().compareTo("paramname") == 0);
+ assertFalse(param.isWpHeader());
+ }
+
+ public void testPARAMETERWebParam() {
+ Collection<Annotation> paramAnnotations = new ArrayList<Annotation>();
+ WebParam wpAnnotation = new FakeWebParamAnnotation("paramannotationname", WebParam.Mode.INOUT, true);
+ paramAnnotations.add(wpAnnotation);
+ WebServicePARAMETERMetadata param = new WebServicePARAMETERMetadata (
+ wpAnnotation, String.class, "paramname", paramAnnotations);
+
+ assertTrue(param.getWpMode() == WebParam.Mode.INOUT);
+ assertTrue(param.getWpName().compareTo("paramannotationname") == 0);
+ assertTrue(param.isWpHeader());
+
+ }
+ // TODO: test combination of type, method, annotation
}
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedJWSHandler.java Wed Sep 15 16:51:49 2004
@@ -58,7 +58,8 @@
import org.apache.axis.utils.JWSClassLoader;
import org.apache.axis.utils.Messages;
import org.apache.axis.utils.XMLUtils;
-import org.apache.beehive.wsm.util.ClasspathUtils;
+import org.apache.beehive.wsm.axis.HandlerHandler;
+import org.apache.beehive.wsm.axis.util.ClasspathUtils;
import org.apache.commons.logging.Log;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -87,8 +88,6 @@
*/
protected void setupService(MessageContext msgContext) throws Exception {
// FORCE the targetService to be JWS if the URL is right.
-
- System.out.println("..............JWSAnnotatedHandler: setUpService"); //TODO: use log4j
String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
String extension = (String)getOption(OPTION_JWS_FILE_EXTENSION);
if (extension == null) extension = DEFAULT_JWS_FILE_EXTENSION;
@@ -262,17 +261,13 @@
// in the system at a time.
SOAPService rpc = (SOAPService)soapServices.get(clsName);
if (rpc == null) {
- rpc = new SOAPService(new RPCProvider());
+ HandlerHandler hh = new HandlerHandler();
+ hh.init(wsm);
+ rpc = new SOAPService(hh, new RPCProvider(), hh);
rpc.setName(wsm.getWsName());
rpc.setOption(RPCProvider.OPTION_CLASSNAME, clsName );
rpc.setEngine(msgContext.getAxisEngine());
- /* Support specification of "allowedMethods" as a parameter.
- String allowed = (String)getOption(RPCProvider.OPTION_ALLOWEDMETHODS);
- if (allowed == null) allowed = "*";
- */
-
-
// Take the setting for the scope option from the handler
// parameter named "scope"
String scope = (String)getOption(RPCProvider.OPTION_SCOPE);
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java Wed Sep 15 16:51:49 2004
@@ -83,8 +83,8 @@
String javaMethodName = meth.getJavaMethodName();
od.setElementQName(new QName(operationName));
- od.setName(javaMethodName);
- allowedMethods.add(javaMethodName);
+ od.setName(operationName);
+ allowedMethods.add(operationName);
od.setSoapAction(meth.getWmAction());
Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java Wed Sep 15 16:51:49 2004
@@ -0,0 +1,340 @@
+/*
+ * DropInDeploymentHandler.java
+ *
+ * Copyright 2001-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.
+ *
+ */
+
+package org.apache.beehive.wsm.axis;
+
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileNotFoundException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.axis.AxisFault;
+import org.apache.axis.AxisProperties;
+import org.apache.axis.Constants;
+import org.apache.axis.MessageContext;
+import org.apache.axis.components.compiler.Compiler;
+import org.apache.axis.components.compiler.CompilerError;
+import org.apache.axis.components.compiler.CompilerFactory;
+import org.apache.axis.components.logger.LogFactory;
+import org.apache.axis.description.ServiceDesc;
+import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.handlers.soap.SOAPService;
+import org.apache.axis.providers.java.RPCProvider;
+import org.apache.axis.transport.http.HTTPConstants;
+import org.apache.axis.utils.ClassUtils;
+import org.apache.axis.utils.JWSClassLoader;
+import org.apache.axis.utils.Messages;
+import org.apache.axis.utils.XMLUtils;
+import org.apache.beehive.wsm.axis.HandlerHandler;
+import org.apache.beehive.wsm.axis.util.ClasspathUtils;
+import org.apache.commons.logging.Log;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/*******************************************************************************
+ * A few annotation specific things added and lots of code copied
+ * from the JWSHandler class by
+ *
+ * @author Jonathan Colwell (jcolwell@bea.com)
+ *
+ * but most of the original code was written by:
+ * @author Glen Daniels (gdaniels@allaire.com)
+ * @author Doug Davis (dug@us.ibm.com)
+ * @author Sam Ruby (rubys@us.ibm.com)
+ *
+ */
+public class DropInDeploymentHandler extends BasicHandler {
+
+ private Map<Class, SOAPService> mSoapServiceMap =
+ new HashMap<Class, SOAPService>();
+
+
+ public void invoke(MessageContext mc)
+ throws AxisFault
+ {
+ try {
+ SOAPService ss =
+ createSOAPServiceUsingAnnotations(compileDroppedInSource(mc));
+ if (ss != null) {
+ ss.setEngine(mc.getAxisEngine());
+ ss.init();
+ mc.setService(ss);
+ }
+
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+
+ public void generateWSDL(MessageContext msgContext) throws AxisFault {
+ invoke(msgContext);
+ }
+
+
+ private SOAPService createSOAPServiceUsingAnnotations(Class cls)
+ throws Exception
+ {
+
+ if (cls != null) {
+
+ WebServiceTYPEMetadata wsm = WsmReflectionAnnotationProcessor
+ .getObjectModel(cls);
+
+ SOAPService rpc = mSoapServiceMap.get(cls);
+
+ if (rpc == null) {
+ HandlerHandler hh = new HandlerHandler();
+ hh.init(wsm);
+ rpc = new SOAPService(hh, new RPCProvider(), hh);
+ rpc.setName(wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName() );
+
+ // Take the setting for the scope option from the handler
+ // parameter named "scope"
+ String scope = (String)getOption(RPCProvider.OPTION_SCOPE);
+ if (scope == null) {
+ scope = "Request";
+ }
+ rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
+
+ ServiceDesc sd = AxisHook.createServiceDesc(wsm,
+ cls
+ .getClassLoader());
+ rpc.setServiceDescription(sd);
+
+ List allowedMethodNames = sd.getAllowedMethods();
+ Iterator allowIt = allowedMethodNames.iterator();
+ StringBuffer sb = new StringBuffer();
+ boolean firstPass = true;
+ while (allowIt.hasNext()) {
+ if (firstPass) {
+ sb.append(' ');
+ firstPass = false;
+ }
+ sb.append(((String)allowIt.next()));
+ }
+ rpc.setOption(RPCProvider.OPTION_ALLOWEDMETHODS, sb.toString());
+ rpc.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT,
+ wsm.getWsName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT,
+ wsm.getWsServiceName());
+ rpc.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE,
+ wsm.getWsTargetNamespace());
+
+ rpc.setStyle(sd.getStyle());
+ rpc.setUse(sd.getUse());
+
+ mSoapServiceMap.put(cls, rpc);
+ }
+ return rpc;
+ }
+ return null;
+ }
+
+ private Class compileDroppedInSource(MessageContext mc)
+ throws Exception
+ {
+ if (mc != null) {
+
+ String realpath = mc.getStrProp(Constants.MC_REALPATH);
+ String extension = (String)getOption("extension");
+ if (extension == null) {
+ extension = ".jws";
+ }
+
+ if ((realpath!=null) && (realpath.endsWith(extension))) {
+ /* Grab the *.jws filename from the context - should have been */
+ /* placed there by another handler (ie. HTTPActionHandler) */
+ /***************************************************************/
+ String srcPath = realpath;
+ String rel = mc.getStrProp(Constants.MC_RELATIVE_PATH);
+
+ // Check for file existance, report error with
+ // relative path to avoid giving out directory info.
+ File srcFile = new File( srcPath );
+ if (!srcFile.exists()) {
+ throw new FileNotFoundException(rel);
+ }
+
+ //clean up the relative path to use as the class destination dir
+ if (rel.charAt(0) == '/') {
+ rel = rel.substring(1);
+ }
+
+ int lastSlash = rel.lastIndexOf('/');
+ String dir = null;
+
+ if (lastSlash > 0) {
+ dir = rel.substring(0, lastSlash);
+ }
+
+ String relativeOutputPath = rel.substring(lastSlash + 1);
+
+ String outDirPath = mc
+ .getStrProp( Constants.MC_JWS_CLASSDIR );
+ if ( outDirPath == null ) outDirPath = "." ;
+
+ // Build matching directory structure under the output
+ // directory. In other words, if we have:
+ // /webroot/jws1/Foo.jws
+ //
+ // That will be compiled to:
+ // .../jwsOutputDirectory/jws1/Foo.class
+ if (dir != null) {
+ outDirPath = outDirPath + File.separator + dir;
+ }
+
+ // Confirm output directory exists. If not, create it IF we're
+ // allowed to.
+ // !!! TODO: add a switch to control this.
+ File outDirectory = new File(outDirPath);
+ if (!outDirectory.exists()) {
+ outDirectory.mkdirs();
+ }
+
+ String jFile = outDirPath + File.separator
+ + relativeOutputPath
+ .substring(0, relativeOutputPath.length()-extension.length())
+ + ".java";
+
+ String cFile = outDirPath + File.separator
+ + relativeOutputPath
+ .substring(0, relativeOutputPath.length()-extension.length())
+ + ".class";
+
+ File clsFile = new File( cFile );
+
+ /* Get the class */
+ /*****************/
+ String clsName = null ;
+ //clsName = mc.getStrProp(Constants.MC_RELATIVE_PATH);
+ if ( clsName == null ) clsName = srcFile.getName();
+ if ( clsName != null && clsName.charAt(0) == '/' )
+ clsName = clsName.substring(1);
+
+ clsName = clsName.substring( 0, clsName.length()-4 );
+ clsName = clsName.replace('/', '.');
+
+
+ /* Check to see if we need to recompile */
+ /****************************************/
+ if ( !clsFile.exists()
+ || srcFile.lastModified() > clsFile.lastModified() ) {
+ /* If the class file doesn't exist, or it's older than the */
+ /* java file then recompile the java file. */
+ /***********************************************************/
+ File javaFile = new File(jFile);
+ try {
+ srcFile.renameTo(javaFile);
+
+ /* Now run javac on the *.java file */
+ /************************************/
+ Compiler compiler = CompilerFactory.getCompiler();
+
+ compiler.setClasspath(ClasspathUtils
+ .getDefaultClasspath(mc));
+ compiler.setDestination(outDirPath);
+ compiler.addFile(jFile);
+
+ boolean result = compiler.compile();
+
+ if ( !result ) {
+ /*
+ * Delete the *class file - sometimes it gets created
+ * even when there are errors - so erase it so it
+ * doesn't confuse us.
+ */
+ clsFile.delete();
+
+ Document doc = XMLUtils.newDocument();
+
+ Element root = doc.createElementNS("",
+ "Errors");
+ StringBuffer message =
+ new StringBuffer("Error compiling ");
+ message.append(jFile);
+ message.append(":\n");
+
+ List errors = compiler.getErrors();
+ int count = errors.size();
+ for (int i = 0; i < count; i++) {
+ CompilerError error =
+ (CompilerError) errors.get(i);
+ if (i > 0) message.append("\n");
+ message.append("Line ");
+ message.append(error.getStartLine());
+ message.append(", column ");
+ message.append(error.getStartColumn());
+ message.append(": ");
+ message.append(error.getMessage());
+ }
+ root.appendChild(doc.createTextNode(message
+ .toString()));
+ throw new AxisFault( "Server.compileError",
+ Messages
+ .getMessage("badCompile00",
+ jFile),
+ null, new Element[] { root } );
+ }
+
+ ClassUtils.removeClassLoader( clsName );
+ // And clean out the cached service.
+ mSoapServiceMap.remove(clsName);
+ }
+ finally {
+ javaFile.renameTo(srcFile);
+ }
+ }
+ ClassLoader cl = ClassUtils.getClassLoader(clsName);
+ if (cl == null) {
+ cl = new JWSClassLoader(clsName,
+ mc.getClassLoader(),
+ cFile);
+ }
+ mc.setClassLoader(cl);
+ return cl.loadClass(clsName);
+ }
+ }
+ return null;
+ }
+}
Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/HandlerHandler.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/HandlerHandler.java Wed Sep 15 16:51:49 2004
@@ -0,0 +1,75 @@
+/*
+ * HandlerHandler.java
+ *
+ * Copyright 2001-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.
+ *
+ */
+package org.apache.beehive.wsm.axis;
+
+import org.apache.axis.AxisFault;
+import org.apache.axis.MessageContext;
+import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.handlers.HandlerChainImpl;
+import org.apache.axis.handlers.JAXRPCHandler;
+
+import org.apache.beehive.wsm.jsr181.model.SOAPMessageHandlerInfo;
+import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
+
+/*******************************************************************************
+ * Yes, this class name is a bit silly in order to highlight the confusion
+ * caused by overloading the term "Handler" used both by jaxrpc and AXIS.
+ * Might as well embrace the insanity rather than using an equally uninteresting
+ * name like HandlerManager or something.
+ *
+ * @author Jonathan Colwell
+ *
+ * All but the init method was copied from org.apache.axis.handlers.JAXRPCHandler
+ * written by Davanum Srinivas (dims@yahoo.com) but the JAXRPCHandler only
+ * allowed a single handler to be added to the HandlerChain. Subclassing would
+ * have be preferable but the internal HandlerChainImpl was package private.
+ */
+public class HandlerHandler extends BasicHandler {
+
+ private HandlerChainImpl impl;
+
+ /**
+ * Uses the soap handler configuration information in the metadata to
+ * configure the HandlerChain.
+ */
+ public void init(WebServiceTYPEMetadata wsm) {
+ impl = new HandlerChainImpl();
+ for (SOAPMessageHandlerInfo info : wsm.getSoapHandlers()) {
+ impl.addNewHandler(info.getClassName(), info.getParameterMap());
+ }
+ }
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+
+ if (!msgContext.getPastPivot()) {
+ impl.handleRequest(msgContext);
+ } else {
+ impl.handleResponse(msgContext);
+ }
+ }
+
+ public void onFault(MessageContext msgContext) {
+ impl.handleFault(msgContext);
+ }
+
+ public void cleanup() {
+ impl.destroy();
+ }
+}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/ClasspathUtils.java (from rev 46132, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/ClasspathUtils.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/ClasspathUtils.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/ClasspathUtils.java Wed Sep 15 16:51:49 2004
@@ -17,12 +17,26 @@
* limitations under the License.
*
*/
-package org.apache.beehive.wsm.util;
+package org.apache.beehive.wsm.axis.util;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
-import org.apache.beehive.wsm.util.JavaArchiveFilter;
+import org.apache.axis.AxisProperties;
+import org.apache.axis.MessageContext;
+import org.apache.axis.transport.http.HTTPConstants;
+
+import org.apache.beehive.wsm.axis.util.JavaArchiveFilter;
/*******************************************************************************
*
@@ -58,5 +72,156 @@
}
}
return buffer.toString();
+ }
+
+
+ // an exception or emptiness signifies not a jar
+ public static boolean isJar(InputStream is) {
+ try {
+ JarInputStream jis = new JarInputStream(is);
+ if (jis.getNextEntry() != null) {
+ return true;
+ }
+ } catch (IOException ioe) {
+ }
+
+ return false;
+ }
+
+
+ public static String getDefaultClasspath(MessageContext msgContext)
+ {
+ StringBuffer classpath = new StringBuffer();
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ fillClassPath(cl, classpath);
+
+ // Just to be safe (the above doesn't seem to return the webapp
+ // classpath in all cases), manually do this:
+
+ String webBase = (String)msgContext.getProperty(
+ HTTPConstants.MC_HTTP_SERVLETLOCATION);
+ if (webBase != null) {
+ classpath.append(webBase + File.separatorChar + "classes" +
+ File.pathSeparatorChar);
+ try {
+ String libBase = webBase + File.separatorChar + "lib";
+ File libDir = new File(libBase);
+ String [] jarFiles = libDir.list();
+ for (int i = 0; i < jarFiles.length; i++) {
+ String jarFile = jarFiles[i];
+ if (jarFile.endsWith(".jar")) {
+ classpath.append(libBase +
+ File.separatorChar +
+ jarFile +
+ File.pathSeparatorChar);
+ }
+ }
+ } catch (Exception e) {
+ // Oh well. No big deal.
+ }
+ }
+
+ // axis.ext.dirs can be used in any appserver
+ getClassPathFromDirectoryProperty(classpath, "axis.ext.dirs");
+
+ // classpath used by Jasper
+ getClassPathFromProperty(classpath, "org.apache.catalina.jsp_classpath");
+
+ // websphere stuff.
+ getClassPathFromProperty(classpath, "ws.ext.dirs");
+ getClassPathFromProperty(classpath, "com.ibm.websphere.servlet.application.classpath");
+
+ // java class path
+ getClassPathFromProperty(classpath, "java.class.path");
+
+ // Load jars from java external directory
+ getClassPathFromDirectoryProperty(classpath, "java.ext.dirs");
+
+ // boot classpath isn't found in above search
+ getClassPathFromProperty(classpath, "sun.boot.class.path");
+
+ return classpath.toString();
+ }
+
+ private static void getClassPathFromDirectoryProperty(StringBuffer classpath, String property) {
+ String dirs = AxisProperties.getProperty(property);
+ String path = null;
+ try {
+ path = ClasspathUtils.expandDirs(dirs);
+ } catch (Exception e) {
+ // Oh well. No big deal.
+ }
+ if( path!= null) {
+ classpath.append(path);
+ classpath.append(File.pathSeparatorChar);
+ }
+ }
+
+ private static void getClassPathFromProperty(StringBuffer classpath, String property) {
+ String path = AxisProperties.getProperty(property);
+ if( path != null) {
+ classpath.append(path);
+ classpath.append(File.pathSeparatorChar);
+ }
+ }
+
+ /**
+ * Walk the classloader hierarchy and add to the classpath
+ *
+ * @param cl
+ * @param classpath
+ */
+ private static void fillClassPath(ClassLoader cl, StringBuffer classpath) {
+ while (cl != null) {
+ if (cl instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader) cl).getURLs();
+ for (int i = 0; (urls != null) && i < urls.length; i++) {
+ String path = urls[i].getPath();
+ //If it is a drive letter, adjust accordingly.
+ if (path.length() >= 3 && path.charAt(0) == '/' && path.charAt(2) == ':')
+ path = path.substring(1);
+ classpath.append(URLDecoder.decode(path));
+ classpath.append(File.pathSeparatorChar);
+
+ // if its a jar extract Class-Path entries from manifest
+ File file = new File(urls[i].getFile());
+ if (file.isFile()) {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(file);
+
+ if (isJar(fis)) {
+ JarFile jar = new JarFile(file);
+ Manifest manifest = jar.getManifest();
+ if (manifest != null) {
+ Attributes attributes = manifest.getMainAttributes();
+ if (attributes != null) {
+ String s = attributes.getValue(Attributes.Name.CLASS_PATH);
+ String base = file.getParent();
+
+ if (s != null) {
+ StringTokenizer st = new StringTokenizer(s, " ");
+ while (st.hasMoreTokens()) {
+ String t = st.nextToken();
+ classpath.append(base + File.separatorChar + t);
+ classpath.append(File.pathSeparatorChar);
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException ioe) {
+ if (fis != null)
+ try {
+ fis.close();
+ } catch (IOException ioe2) {
+ }
+ }
+ }
+ }
+ }
+ cl = cl.getParent();
+ }
}
}
Copied: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/JavaArchiveFilter.java (from rev 46132, incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/JavaArchiveFilter.java)
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/util/JavaArchiveFilter.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/JavaArchiveFilter.java Wed Sep 15 16:51:49 2004
@@ -17,7 +17,7 @@
* limitations under the License.
*
*/
-package org.apache.beehive.wsm.util;
+package org.apache.beehive.wsm.axis.util;
import java.io.File;
import java.io.FileFilter;
Modified: 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/SOAPMessageHandlerInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java Wed Sep 15 16:51:49 2004
@@ -5,6 +5,8 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import javax.jws.InitParam;
import javax.jws.QName;
@@ -32,7 +34,7 @@
public class SOAPMessageHandlerInfo {
String name;
String className;
- Collection<InitParamInfo> params = new ArrayList<InitParamInfo>();
+ HashMap<String, String> parameterMap = new HashMap<String, String>();
Collection<String> roles = new ArrayList<String>();
Collection<QNameInfo> headers = new ArrayList<QNameInfo>();
/**
@@ -42,12 +44,12 @@
setName(annotation.name());
setClassName(annotation.className());
for (InitParam p : annotation.initParams()) {
- addInitParam(new InitParamInfo(p));
- }
- addRoles(Arrays.asList(annotation.roles()));
- for (QName q : annotation.headers()) {
- addHeader(new QNameInfo(q));
- }
+ addInitParam(p.name(), p.value());
+ }
+ addRoles(Arrays.asList(annotation.roles()));
+ for (QName q : annotation.headers()) {
+ addHeader(new QNameInfo(q));
+ }
}
/**
* @return Returns the className.
@@ -93,16 +95,16 @@
/**
* @return Returns the params.
*/
- public Collection<InitParamInfo> getParams() {
- return Collections.unmodifiableCollection(params);
+ public Map<String, String> getParameterMap() {
+ return Collections.unmodifiableMap(parameterMap);
}
- public void addInitParam(InitParamInfo param) {
- this.params.add(param);
+ public void addInitParam(String key, String value) {
+ parameterMap.put(name, value);
}
- public void addInitParam(Collection<InitParamInfo> params) {
- this.params.addAll(params);
+ public void addInitParams(Map<String,String> params) {
+ parameterMap.putAll(params);
}
/**
* @return Returns the roles.
Modified: incubator/beehive/trunk/wsm/test/webapps/AnnotatedAxis/WEB-INF/server-config.wsdd
==============================================================================
--- incubator/beehive/trunk/wsm/test/webapps/AnnotatedAxis/WEB-INF/server-config.wsdd (original)
+++ incubator/beehive/trunk/wsm/test/webapps/AnnotatedAxis/WEB-INF/server-config.wsdd Wed Sep 15 16:51:49 2004
@@ -5,16 +5,19 @@
<parameter name="disablePrettyXML" value="true"/>
<parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
<parameter name="sendXsiTypes" value="true"/>
- <parameter name="sendMultiRefs" value="true"/>
+ <!--<parameter name="sendMultiRefs" value="true"/>-->
<parameter name="sendXMLDeclaration" value="true"/>
<requestFlow>
- <handler type="java:org.apache.beehive.wsm.axis.AnnotatedJWSHandler">
+ <handler type="java:org.apache.beehive.wsm.axis.DropInDeploymentHandler">
<parameter name="scope" value="session"/>
</handler>
- <handler type="java:org.apache.beehive.wsm.axis.AnnotatedJWSHandler">
+ <!--<handler type="java:org.apache.axis.handlers.JWSHandler">
+ <parameter name="scope" value="session"/>
+ </handler>
+ <handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
- </handler>
+ </handler>-->
</requestFlow>
</globalConfiguration>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
@@ -44,4 +47,5 @@
<handler type="LocalResponder"/>
</responseFlow>
</transport>
-</deployment>
+</deployment>
+