Author: mmerz
Date: Wed Jan 19 13:34:04 2005
New Revision: 125666
URL: http://svn.apache.org/viewcvs?view=rev&rev=125666
Log:
Bug fixes:
- object model (more to follow...)
- @HandlerChain: fix configuration file processing
Clean up:
- object model (more to follow...)
- Remove reflection-package and dependencies
Added:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.javax
- copied, changed from r125455,
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
Removed:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/util/bytecode/
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
Deleted:
/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java?view=auto&rev=125665
==============================================================================
Copied:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.javax
(from r125455,
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java)
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.javax?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.java&r1=125455&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Jsr181ModelTest.javax&r2=125666
==============================================================================
---
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.javax
Wed Jan 19 13:34:04 2005
@@ -84,25 +84,27 @@
// does missing @WebService throw an error?
try {
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(null, fqClassname,
typeAnnotations, webMethods);
+ new Jsr181TypeMetadataImpl(null, fqClassname, null,
typeAnnotations, webMethods);
fail("Failed to generate error for TYPE without @WebService
annotation");
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e) {
// good case
}
// does missing fqClassname throw an error?
try {
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(fakeWebServiceAnnotation, null,
typeAnnotations, webMethods);
+ new Jsr181TypeMetadataImpl(fakeWebServiceAnnotation, null,
null, typeAnnotations, webMethods);
fail("Failed to generate error for TYPE without TYPE name");
- } catch (IllegalArgumentException e) {
+ }
+ catch (IllegalArgumentException e) {
// good case
}
// does missing annotations throw an error?
try {
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(fakeWebServiceAnnotation,
fqClassname, null, webMethods);
+ new Jsr181TypeMetadataImpl(fakeWebServiceAnnotation,
fqClassname, null, null, webMethods);
fail("Failed to generate error for TYPE without TYPE annotations");
} catch (IllegalArgumentException e) {
// good case
@@ -192,7 +194,7 @@
new FakeWebServiceAnnotation("", "", "", "", "");
typeAnnotations.add(wsAnnotation);
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals("testclass", type.getWsName());
assertEquals("http://c.b.a", type.getWsTargetNamespace());
assertEquals("testclassService", type.getWsServiceName());
@@ -208,7 +210,7 @@
new FakeWebServiceAnnotation("testname", "testserviceName",
"testwsdllocation", "testtargetnamespace", "");
typeAnnotations.add(wsAnnotation);
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals("testname", type.getWsName());
assertEquals("testtargetnamespace", type.getWsTargetNamespace());
assertEquals("testserviceName", type.getWsServiceName());
@@ -303,7 +305,7 @@
// create type
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methods);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methods);
/*** *** ***/
@@ -355,7 +357,7 @@
// create type
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methods);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methods);
/*** *** ***/
@@ -384,7 +386,7 @@
// no default values to check
public void testTYPEHandlerChain() throws Exception {
- String hcFileName =
"org/apache/beehive/wsm/jsr181/model/fakeAnnotations/handlerChainConfig.xml";
+ String hcFileName =
"/org/apache/beehive/wsm/jsr181/model/fakeAnnotations/handlerChainConfig.xml";
String hcName = "testname";
Collection<Jsr181MethodMetadata> methodMetadata =
new ArrayList<Jsr181MethodMetadata>();
@@ -393,7 +395,7 @@
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeHandlerChainAnnotation(hcFileName,
hcName));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals(hcFileName, type.getHcFileName());
assertEquals(hcName, type.getHcName());
}
@@ -417,7 +419,7 @@
SOAPBinding.Use.ENCODED,
SOAPBinding.ParameterStyle.BARE));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals(SOAPBinding.Style.RPC, type.getSoapBinding().getStyle());
assertEquals(SOAPBinding.Use.ENCODED, type.getSoapBinding().getUse());
assertEquals(SOAPBinding.ParameterStyle.BARE,
type.getSoapBinding().getParameterStyle());
@@ -440,7 +442,7 @@
new FakeSOAPMessageHandlerAnnotation[0];
typeAnnotations.add(new
FakeSOAPMessageHandlersAnnotation(emptyHandlers));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertTrue(type.getSoapHandlers().isEmpty());
}
@@ -456,7 +458,7 @@
};
typeAnnotations.add(new
FakeSOAPMessageHandlersAnnotation(defaultHandlers));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals("number of handlers returned: " +
type.getSoapHandlers().size(),
1, type.getSoapHandlers().size());
SOAPMessageHandlerInfo handler = type.getSoapHandlers().get(0);
@@ -483,7 +485,7 @@
};
typeAnnotations.add(new
FakeSOAPMessageHandlersAnnotation(defaultHandlers));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
// handlers
List<SOAPMessageHandlerInfo> soapHandlers = type.getSoapHandlers();
@@ -524,7 +526,7 @@
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeSecurityRoleAnnotation(null, null));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertNull(type.getSecurityRoles().getRolesAllowed());
assertNull(type.getSecurityRoles().getRolesReferenced());
}
@@ -539,7 +541,7 @@
String[] rolesReferenced = {"rolesreferenced"};
typeAnnotations.add(new FakeSecurityRoleAnnotation(rolesAllowed,
rolesReferenced));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
typeAnnotations, methodMetadata);
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals(1, type.getSecurityRoles().getRolesAllowed().size());
assertEquals("rolesallowed", (String)
type.getSecurityRoles().getRolesAllowed().iterator().next());
assertEquals(1, type.getSecurityRoles().getRolesReferenced().size());
@@ -559,7 +561,8 @@
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
"");
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeSecurityIdentityAnnotation(null));
- Jsr181TypeMetadata type = new Jsr181TypeMetadataImpl(wsAnnotation,
"a.b.c.testclass", typeAnnotations, methodMetadata);
+ Jsr181TypeMetadata type =
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertNull(type.getSiValue());
}
@@ -570,7 +573,8 @@
WebService wsAnnotation = new FakeWebServiceAnnotation("", "", "", "",
"");
typeAnnotations.add(wsAnnotation);
typeAnnotations.add(new FakeSecurityIdentityAnnotation("value"));
- Jsr181TypeMetadata type = new Jsr181TypeMetadataImpl(wsAnnotation,
"a.b.c.testclass", typeAnnotations, methodMetadata);
+ Jsr181TypeMetadata type =
+ new Jsr181TypeMetadataImpl(wsAnnotation, "a.b.c.testclass",
null, typeAnnotations, methodMetadata);
assertEquals(type.getSiValue(), "value");
}
@@ -595,7 +599,7 @@
typeAnnotations.add(new FakeSOAPMessageHandlersAnnotation(new
SOAPMessageHandler[0]));
typeAnnotations.add(new FakeHandlerChainAnnotation("fileName",
"chainName"));
Jsr181TypeMetadata type =
- new Jsr181TypeMetadataImpl(wsAnnotation,
"a.b.c.testclass", typeAnnotations, new ArrayList<Jsr181MethodMetadata>());
+ new Jsr181TypeMetadataImpl(wsAnnotation,
"a.b.c.testclass", null, typeAnnotations, new
ArrayList<Jsr181MethodMetadata>());
} catch (Exception e) {
hasPassed = true;
}
Modified:
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java&r1=125665&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java&r2=125666
==============================================================================
---
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
(original)
+++
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
Wed Jan 19 13:34:04 2005
@@ -50,7 +50,6 @@
import org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadata;
import org.apache.beehive.wsm.jsr181.model.Jsr181ParameterMetadata;
import org.apache.beehive.wsm.jsr181.model.Jsr181TypeMetadata;
-import
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java&r1=125665&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java&r2=125666
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
Wed Jan 19 13:34:04 2005
@@ -19,10 +19,11 @@
*/
import org.apache.beehive.wsm.jsr181.model.Jsr181TypeMetadata;
+import org.apache.beehive.wsm.jsr181.model.Jsr181TypeMetadataImpl;
import org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadata;
import org.apache.beehive.wsm.jsr181.model.Jsr181ParameterMetadata;
import org.apache.beehive.wsm.jsr181.model.SecurityRolesInfo;
-import
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+//import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
import org.apache.beehive.wsm.axis.security.SecurityModel;
@@ -93,8 +94,14 @@
}
// get a object model of the requested class.
- Jsr181TypeMetadata wsm =
- (Jsr181TypeMetadata)
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
+ Jsr181TypeMetadata wsm = null;
+ try {
+ wsm = Jsr181TypeMetadataImpl.load(clazz);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AxisFault(e.getMessage(),e);
+ }
if (null == wsm)
{
return; // the request class is not annotated with @WebService.
Thus, simply return.
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r1=125665&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r2=125666
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
Wed Jan 19 13:34:04 2005
@@ -31,6 +31,9 @@
import javax.jws.security.SecurityRoles;
public class Jsr181MethodMetadataImpl implements Jsr181MethodMetadata,
java.io.Serializable {
+
+ private static final String DEFAULT_WRNAME = "result";
+
private String wmOperationName;
private String wmAction;
private boolean oneway = false;
@@ -78,7 +81,7 @@
// throw new IllegalArgumentException("@WebMethod is required");
// }
- setWrName("result");
+ setWrName(DEFAULT_WRNAME);
// enforce JSR-181 rules
if (AnnotationModel.hasAnnotationType(annotations, Oneway.class)) {
@@ -119,13 +122,17 @@
for (Annotation a : annotations) {
if (a.annotationType() == javax.jws.WebMethod.class) {
initFromAnnotation((javax.jws.WebMethod) a);
- } else if (a.annotationType() == javax.jws.Oneway.class) {
+ }
+ else if (a.annotationType() == javax.jws.Oneway.class) {
initFromAnnotation((javax.jws.Oneway) a);
- } else if (a.annotationType() ==
javax.jws.security.SecurityRoles.class) {
+ }
+ else if (a.annotationType() ==
javax.jws.security.SecurityRoles.class) {
initFromAnnotation((javax.jws.security.SecurityRoles) a);
- } else if (a.annotationType() == javax.jws.WebResult.class) {
+ }
+ else if (a.annotationType() == javax.jws.WebResult.class) {
initFromAnnotation((javax.jws.WebResult) a);
- } else {
+ }
+ else {
// unknown annotation
}
}
@@ -261,14 +268,11 @@
public String toString() {
- return getSignature();
-/*
String signature = getJavaReturnType().toString() + " " +
getJavaMethodName() + "( ";
for (Jsr181ParameterMetadata p : params) {
signature += p.getJavaType().toString() + " ";
}
return signature + ")";
- */
}
public boolean equals(Object o) {
@@ -305,7 +309,7 @@
/* (non-Javadoc)
* @see
org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadata#getJavaReturnTypeFullName()
*
- * * NOTE THIS METHOD AND SUPPORTING METHOD SHOULD BE MOVED OUT TO A
ELEMENT CLASS
+ * NOTE THIS METHOD AND SUPPORTING METHOD SHOULD BE MOVED OUT TO A ELEMENT
CLASS
* THAT ENCAPSULATES QNAME AND CLASS
*/
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java&r1=125665&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java&r2=125666
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
Wed Jan 19 13:34:04 2005
@@ -28,6 +28,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -74,6 +75,7 @@
private SecurityRolesInfo securityRoles;
private String siValue;
private String className;
+ private File classLocation;
/**
* Default constructor.
@@ -82,22 +84,19 @@
}
/**
- * This method does not require to load the service implementation bean
- * class.
- *
- * @param wsAnnotation The @WebService annotation of the service
- * implementation bean.
- * @param className The fully-qualified name of the service
- * implementation bean class.
- * @param annotations All annotations (including @WebService) of the
- * service endpoint interface if it exists; all
annotations
- * (including @WebService) of the service
implementation bean otherwise.
- * @param webMethods All methods that are published by the service.
+ * @param wsAnnotation The @WebService annotation of the class.
+ * @param className The fully-qualified name of the class.
+ * @param classLocation The location of the class file being processed;
+ * can be source or binary depending on the context; if null, relative
+ * paths e.g. in @HandlerChain would not work, however.
+ * @param annotations All annotations (including @WebService) of the class.
+ * @param webMethods All methods that are published by the service.
* @throws Exception
*/
public Jsr181TypeMetadataImpl(
WebService wsAnnotation,
String className,
+ File classLocation,
Collection<Annotation> annotations,
Collection<? extends Jsr181MethodMetadata> webMethods
) throws Exception
@@ -114,6 +113,7 @@
throw new IllegalArgumentException("service implementation bean
class not set");
}
this.className = className;
+ this.classLocation = classLocation;
// check required parameters: annotations, webMethods
if ((null == annotations) || (null == webMethods)) {
@@ -191,22 +191,20 @@
}
}
- protected void initFromAnnotation(WebService wsAnnotation) {
+ protected void initFromAnnotation(WebService annotation) {
- if (null == wsAnnotation) {
+ if (null == annotation) {
return;
}
// initialize fields with values from annotations
- wsEndpointInterface = wsAnnotation.endpointInterface().trim();
-
- // todo: check for concrete class, etc.
+ wsEndpointInterface = annotation.endpointInterface().trim();
- setWsName(wsAnnotation.name());
- setWsTargetNamespace(wsAnnotation.targetNamespace());
- setWsWsdlLocation(wsAnnotation.wsdlLocation());
- setWsServiceName(wsAnnotation.serviceName());
- setWsEndpointInterface(wsAnnotation.endpointInterface());
+ setWsName(annotation.name());
+ setWsTargetNamespace(annotation.targetNamespace());
+ setWsWsdlLocation(annotation.wsdlLocation());
+ setWsServiceName(annotation.serviceName());
+ setWsEndpointInterface(annotation.endpointInterface());
// set default values
@@ -237,9 +235,15 @@
}
private void initFromAnnotation(SOAPBinding annotation) {
- if (null != annotation) {
- setSoapBinding(new SOAPBindingInfo(annotation));
+
+ if (null == annotation) {
+ return;
}
+
+ // set soap binding from annotation
+ setSoapBinding(new SOAPBindingInfo(annotation));
+
+ // validate soap binding
SOAPBindingInfo sbi = getSoapBinding();
if (null == sbi) {
throw new IllegalArgumentException("illegal SOAPBinding annotation
on WebService class:\n\t" + sbi);
@@ -249,40 +253,43 @@
}
private void initFromAnnotation(HandlerChain annotation) {
- if (null != annotation) {
- if (getSoapHandlers().isEmpty()) {
- String hcPath = annotation.file();
- String hcName = annotation.name();
- setHcFileName(hcPath);
- setHcName(hcName);
- try {
- configureHandlerChain(hcPath, hcName);
- } catch (Exception e) {
- throw new RuntimeException
- ("An Exception occurred while configuring"
- + " the HandlerChain", e);
- }
- } else {
- throw new IllegalArgumentException
- ("SOAPMessageHandlers and HandlerChain annotations" +
- " are mutually exclusive, and a SOAPMessageHandlers " +
- "annotation is already present.");
- }
+
+ if (null == annotation) {
+ return;
+ }
+
+ if (! getSoapHandlers().isEmpty()) {
+ throw new IllegalArgumentException("@SOAPMessageHandlers and
@HandlerChain are mutually exclusive");
+ }
+
+ String hcPath = annotation.file();
+ String hcName = annotation.name();
+
+ setHcName(hcName);
+ setHcFileName(hcPath);
+
+ try {
+ configureHandlerChain(hcPath, hcName);
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.getMessage());
}
}
private void initFromAnnotation(SOAPMessageHandlers annotation) {
- if (null != annotation) {
- if (null == getHcFileName()) {
- SOAPMessageHandler[] soapMsgHandlerArray = annotation.value();
- for (int i = 0; i < soapMsgHandlerArray.length; i++) {
- addSOAPHandler(new
SOAPMessageHandlerInfo(soapMsgHandlerArray[i]));
- }
- } else {
- throw new IllegalArgumentException("SOAPMessageHandlers and
HandlerChain annotations " +
- "are mutually exclusive, and a HandlerChain " +
- "annotation is already present.");
- }
+
+ if (null == annotation) {
+ return;
+ }
+
+ if (null != getHcFileName()) {
+ throw new IllegalArgumentException("@SOAPMessageHandlers and
@HandlerChain are mutually exclusive");
+ }
+
+ for (SOAPMessageHandler soapMessageHandler : annotation.value()) {
+ SOAPMessageHandlerInfo smhi = new
SOAPMessageHandlerInfo(soapMessageHandler);
+ // todo: validate smhi.getClassName()
+ addSOAPHandler(smhi);
}
}
@@ -302,43 +309,70 @@
// no defaults to handle
}
- private void configureHandlerChain(
- String handlerChainConfigPath,
- String handlerChainName
- )
+ private void configureHandlerChain(String handlerChainConfigPath, String
handlerChainName)
throws Exception
{
- URL handlerChainConfigURL;
+ // get URL for handler-chain config
+ URL handlerChainConfigURL =
findHandlerChainConfig(handlerChainConfigPath);
- // check if we have a likely absolute URL
- if (handlerChainConfigPath.indexOf("://") > 2) {
+ // throw an exception if we can't find the file
+ if (null == handlerChainConfigURL) {
+ throw new Exception("Cannot find handler-chain configuration file:
" + handlerChainConfigPath);
+ }
+
+ // parse handler-chain config and add handler-chain to object model
+ initHandlersFromChainConfig(handlerChainConfigURL, handlerChainName);
+ }
+
+ /**
+ * Starts with '<protocol>//:': absolute URL
+ * Starts with '/': URL relative to class' base dir
+ * Else: URL relative to class
+ */
+ private URL findHandlerChainConfig(String handlerChainConfigPath)
+ throws MalformedURLException
+ {
+ // validate handlerChainConfigPath
+ if (null == handlerChainConfigPath || 0 ==
handlerChainConfigPath.length()) {
+ throw new MalformedURLException("@HandlerChain: empty path for
handler-chain config");
+ }
+
+ URL handlerChainConfigURL = null;
+
+ // handle absolute URL
+ if (0 < handlerChainConfigPath.indexOf(":/")) {
handlerChainConfigURL = new URL(handlerChainConfigPath);
}
- else {
- // attempt to load a handler config file as a resource.
- /*
- * FIXME [EMAIL PROTECTED] 2004-Sep-16 -- perhaps add code to
ensure
- * that ClassLoader used to load the config file is the same one
- * that would be able to load the Class providing these
annotations.
- *
- * Using the current ClassLoader for the moment.
- */
- handlerChainConfigURL =
-
getClass().getClassLoader().getResource(handlerChainConfigPath);
- if (handlerChainConfigURL == null) {
- // try again using the classes package as a prefix
- StringBuffer fullPath =
- new StringBuffer(className.substring(0,
className.lastIndexOf('.')));
- if (! handlerChainConfigPath.startsWith("/")) {
- fullPath.append('/');
- }
- handlerChainConfigURL =
-
getClass().getClassLoader().getResource(fullPath.toString().replace('.', '/') +
handlerChainConfigPath);
+
+ // handle relative URL (e.g. "/dir/Handler", "dir/Handler")
+ if (null == classLocation) {
+ throw new MalformedURLException("@HandlerChain: cannot resolve
relative URL: " + handlerChainConfigPath);
+ }
+ String classLocationString = classLocation.toString();
+ String baseDir = null;
+ if (handlerChainConfigPath.startsWith("/")) {
+ String temp = className;
+ int lastIdx = className.lastIndexOf('.');
+ if (0 < lastIdx) {
+ temp = temp.substring(0, lastIdx);
+ }
+ temp = temp.replace('.', File.separatorChar);
+ if (! classLocationString.endsWith(temp)) {
+ throw new MalformedURLException("@HandlerChain: cannot resolve
relative URL, handler-chain config path inconsistent with package name: " +
handlerChainConfigPath + " -> " + temp);
}
+ temp = classLocationString.substring(0, temp.length());
+ handlerChainConfigURL = new File(new File(temp,
handlerChainConfigPath), handlerChainConfigPath).toURL();
+ }
+ else {
+ handlerChainConfigURL = new File(classLocation,
handlerChainConfigPath).toURL();
+ }
+ if (null == handlerChainConfigURL) {
+ throw new MalformedURLException("@HandlerChain: cannot resolve
relative URL: " + handlerChainConfigPath);
}
- initHandlersFromChainConfig(handlerChainConfigURL, handlerChainName);
- }
+ return handlerChainConfigURL;
+ }
+
/**
* Made public so specific implementations can configure handlers relevant
* to their own environment. Calls to this are ignored if SOAPHandlers are
@@ -346,34 +380,40 @@
* e.g. in case the config file is located next to the .jws source file in
* the context root of an axis webapp rather than in the classpath
*/
- public void initHandlersFromChainConfig(URL chainConfigURL,
- String chainName)
- throws Exception {
- if (getSoapHandlers().isEmpty() &&
- chainConfigURL != null && chainName != null) {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setNamespaceAware(true);
- factory.setIgnoringComments(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(chainConfigURL.openStream());
- NodeList handlerChainNodes = doc
- .getElementsByTagName("handler-chain");
- for (int j = 0; j < handlerChainNodes.getLength(); j++) {
- Node handlerChainNode = handlerChainNodes.item(j);
- if (handlerChainNode.getNodeType() == Node.ELEMENT_NODE) {
- Element chainElement = (Element) handlerChainNode;
- NodeList chainNames = chainElement
- .getElementsByTagName("handler-chain-name");
- //should only be one chain name so just grab the first one
- if (chainNames.getLength() > 0
- &&
chainName.equals(chainNames.item(0).getFirstChild()
- .getNodeValue())) {
- NodeList handlers = chainElement
- .getElementsByTagName("handler");
- for (int k = 0; k < handlers.getLength(); k++) {
- processHandlerNode(handlers.item(k));
- }
+ public void initHandlersFromChainConfig(URL chainConfigURL, String
chainName)
+ throws Exception
+ {
+ // check input parameters
+ if (! getSoapHandlers().isEmpty()) {
+ throw new Exception("@HandlerChain: annotation doesn't allow for
@SOAPMessageHandlers");
+ }
+ if (null == chainConfigURL || null == chainName) {
+ throw new Exception("@HandlerChain: URL for handler-chain config
required");
+ }
+
+ // create and configure factory
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setIgnoringComments(true);
+
+ // parse handler-chain config file
+ InputStream is = chainConfigURL.openStream();
+
+ // todo: this is broken; validate the document!!!
+
+ NodeList handlerChainNodes =
factory.newDocumentBuilder().parse(is).getElementsByTagName("handler-chain");
+ for (int j = 0; j < handlerChainNodes.getLength(); j++) {
+ Node handlerChainNode = handlerChainNodes.item(j);
+ if (handlerChainNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element chainElement = (Element) handlerChainNode;
+ NodeList chainNames =
chainElement.getElementsByTagName("handler-chain-name");
+
+ // should only be one chain name so just grab the first one
+ // todo: this is broken; validate!!!
+ if (chainNames.getLength() > 0 &&
chainName.equals(chainNames.item(0).getFirstChild().getNodeValue())) {
+ NodeList handlers =
chainElement.getElementsByTagName("handler");
+ for (int k = 0; k < handlers.getLength(); k++) {
+ processHandlerNode(handlers.item(k));
}
}
}
@@ -382,8 +422,11 @@
/**
* @param handlerNode
+ * todo: hack: use "endsWith()" to ignore namespace
*/
- private void processHandlerNode(Node handlerNode) {
+ private void processHandlerNode(Node handlerNode)
+ throws Exception
+ {
if (handlerNode.hasChildNodes()) {
String handlerName = null;
String handlerClassName = null;
@@ -393,26 +436,26 @@
Node currentChild = handlerNode.getFirstChild();
while (currentChild != null) {
String nodeName = currentChild.getNodeName();
- if ("handler-name".equals(nodeName)) {
+ if (nodeName.endsWith("handler-name")) {
handlerName = currentChild.getFirstChild().getNodeValue();
}
- else if ("handler-class".equals(nodeName)) {
+ else if (nodeName.endsWith("handler-class")) {
handlerClassName =
currentChild.getFirstChild().getNodeValue();
}
- else if ("soap-role".equals(nodeName)) {
+ else if (nodeName.endsWith("soap-role")) {
roles.add(currentChild.getFirstChild().getNodeValue());
}
- else if ("soap-header".equals(nodeName)) {
+ else if (nodeName.endsWith("soap-header")) {
headers.add(currentChild.getFirstChild().getNodeValue());
}
- else if ("init-param".equals(nodeName)) {
+ else if (nodeName.endsWith("init-param")) {
nodeName = currentChild.getFirstChild().getNodeName();
- if ("param-name".equals(nodeName)) {
+ if (nodeName.endsWith("param-name")) {
initParams.put(
currentChild.getFirstChild().getNodeValue(),
currentChild.getLastChild().getNodeValue());
}
- else {
+ else if (nodeName.endsWith("param-value")) {
initParams.put(
currentChild.getLastChild().getNodeValue(),
currentChild.getFirstChild().getNodeValue()
@@ -421,6 +464,7 @@
}
currentChild = currentChild.getNextSibling();
}
+
addSOAPHandler(new SOAPMessageHandlerInfo(
handlerClassName,
handlerName,
@@ -638,9 +682,8 @@
int j = 0;
for (Jsr181ParameterMetadata param : params) {
Class javaType = param.getJavaType();
- if (javaType == null) {
- throw new NullPointerException
- ("null is not a valid parameter class");
+ if (null == javaType) {
+ throw new NullPointerException("null is not a valid parameter
class");
}
paramTypes[j++] = javaType;
}
@@ -648,17 +691,12 @@
String sig = createCompleteMethodSignature(opName, paramTypes);
if (methodMap.containsKey(sig)) {
- throw new ValidationException(sig
- + " is already present in this Web
Service and duplicate methods are not permitted.");
+ throw new ValidationException(
+ sig + " is already present in this Web Service and duplicate
methods are not permitted."
+ );
}
- else if (SOAPBinding.Style.DOCUMENT
- .equals(getSoapBinding().getStyle())
- && methodMap.containsKey(opName)) {
-
- throw new ValidationException
- ("This Web Service already contains an operation called "
- + opName
- + " and method overloading is not permitted when using the
Document style.");
+ else if
(SOAPBinding.Style.DOCUMENT.equals(getSoapBinding().getStyle()) &&
methodMap.containsKey(opName)) {
+ throw new ValidationException("document-style does not allow
duplicate methods: " + opName);
}
else {
methodMap.put(sig, method);
@@ -753,11 +791,11 @@
public static File getLocation(String className) {
return new File("models", className + ".ser");
}
-
+
/**
* @param clazz
*/
- public static Jsr181TypeMetadata load(Class clazz) throws IOException,
ClassNotFoundException {
+ public static Jsr181TypeMetadata load(Class clazz) throws IOException,
ClassNotFoundException{
return
load(clazz.getClassLoader().getResourceAsStream(getLocation(clazz.getName()).toString()));
}
@@ -809,4 +847,4 @@
}
}
}
-}
+}
\ No newline at end of file
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java&r1=125665&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/SOAPMessageHandlerInfo.java&r2=125666
==============================================================================
---
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 Jan 19 13:34:04 2005
@@ -39,29 +39,32 @@
*
*/
public SOAPMessageHandlerInfo(SOAPMessageHandler annotation) {
- String handlerClassName = annotation.className();
- if (handlerClassName.length() == 0) {
- throw new IllegalArgumentException
- ("A className is required to configure a
SOAPMessageHandler");
- } else {
- setClassName(handlerClassName);
- String handlerName = annotation.name();
- setName((handlerName.length() > 0) ? handlerName :
handlerClassName);
- for (InitParam p : annotation.initParams()) {
- addInitParam(p.name(), p.value());
- }
- addRoles(Arrays.asList(annotation.roles()));
- for (String s : annotation.headers()) {
- addHeader(s);
- }
+
+ // validate className
+ String className = annotation.className();
+ if (0 == className.length()) {
+ throw new IllegalArgumentException("className required to
configure a SOAPMessageHandler");
+ }
+
+ // set fields from annotation
+ setClassName(className);
+ setName((0 < annotation.name().length()) ? annotation.name() :
className);
+ for (InitParam p : annotation.initParams()) {
+ addInitParam(p.name(), p.value());
+ }
+ addRoles(Arrays.asList(annotation.roles()));
+ for (String s : annotation.headers()) {
+ addHeader(s);
}
}
- public SOAPMessageHandlerInfo(String handlerClassName,
- String handlerName,
- Map<String, String> initParams,
- Collection<String> roles,
- Collection<String> headers) {
+ public SOAPMessageHandlerInfo(
+ String handlerClassName,
+ String handlerName,
+ Map<String, String> initParams,
+ Collection<String> roles,
+ Collection<String> headers
+ ) {
setClassName(handlerClassName);
setName((handlerName != null && handlerName.length() > 0)
? handlerName : handlerClassName);
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
Url:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java?view=diff&rev=125666&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java&r1=125665&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java&r2=125666
==============================================================================
---
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 Jan 19 13:34:04 2005
@@ -221,7 +221,8 @@
try {
objectModel = new Jsr181TypeMetadataImpl(
wsAnnotation,
- decl.getQualifiedName(), // decl.getSimpleName(),
+ decl.getQualifiedName(),
+ decl.getPosition().file().getParentFile(),
getAnnotations(decl),
webMethods
);