You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/10/31 05:49:45 UTC
svn commit: r329739 - in /beehive/trunk/wsm: ./ src/api/schemas/
src/core/org/apache/beehive/wsm/model/
src/core/org/apache/beehive/wsm/model/impl/
src/core/org/apache/beehive/wsm/model/jsr181/
src/core/org/apache/beehive/wsm/processor/ src/core/org/ap...
Author: ekoneil
Date: Sun Oct 30 20:49:33 2005
New Revision: 329739
URL: http://svn.apache.org/viewcvs?rev=329739&view=rev
Log:
Re-implement handler config file parsing on DOM instead of XMLBeans. This change also moves the XSDs from src/api/schemas into an internal package.
Still need tests and some code cleanup here.
BB: self
Test: WSM pass
Added:
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorFactoryImpl.java
- copied, changed from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java (contents, props changed)
- copied, changed from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorTypeResolver.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionFactoryImpl.java
- copied, changed from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/ReflectionFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WSDLFactoryImpl.java
- copied, changed from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/WSDLFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/schemas/
- copied from r329311, beehive/trunk/wsm/src/api/schemas/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java (with props)
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java (with props)
Removed:
beehive/trunk/wsm/src/api/schemas/
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorTypeResolver.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/ReflectionFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/WSDLFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/resolver/
Modified:
beehive/trunk/wsm/build.xml
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/BeehiveWsTypeMetadata.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/impl/DefaultTypeMetadataImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/ProcessorException.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/TwoPhaseAnnotationProcessor.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/checker/Jsr181AnnotationChecker.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/AxisGenerator.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/BeehiveWsMetadataFactory.java
Modified: beehive/trunk/wsm/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/build.xml?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/build.xml (original)
+++ beehive/trunk/wsm/build.xml Sun Oct 30 20:49:33 2005
@@ -147,8 +147,6 @@
<echo message="| WSM Core build starting |"/>
<echo message="--------------------------------------------------"/>
- <build-xbean schemaDir="${api.schema.dir}" classgenDir="${core.classes}"/>
-
<javac destdir="${core.classes}" classpathref="core.classpath" debug="on">
<src path="${core.dir}"/>
</javac>
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/BeehiveWsTypeMetadata.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/BeehiveWsTypeMetadata.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/BeehiveWsTypeMetadata.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/BeehiveWsTypeMetadata.java Sun Oct 30 20:49:33 2005
@@ -23,11 +23,7 @@
/**
*/
public abstract class BeehiveWsTypeMetadata {
-/*
- public abstract String getSiValue();
- public abstract void setSiValue(String siValue);
-*/
public abstract BeehiveWsSOAPBindingInfo getSoapBinding();
public abstract void setSoapBinding(BeehiveWsSOAPBindingInfo soapBinding);
@@ -43,14 +39,7 @@
public abstract String getTargetNamespace();
public abstract void setTargetNamespace(String wsTargetNamespace);
-/*
- public abstract String[] getTargetNamespaceParts();
-*/
-/*
- public abstract String getWsEndpointInterface();
- public abstract void setWsEndpointInterface(String wsEndpointInterface);
-*/
public abstract String getWsdlLocation();
public abstract void setWsdlLocation(String wsWsdlLocation);
@@ -61,9 +50,11 @@
public abstract void addMethod(BeehiveWsMethodMetadata method);
- public abstract List<? extends BeehiveWsSOAPMessageHandlerInfo> getSoapHandlers();
+ public abstract void setSOAPHandlers(List soapHandlers);
- public abstract void addSOAPHandler(BeehiveWsSOAPMessageHandlerInfo soapHandler);
+ public abstract List getSoapHandlers();
+
+ public abstract void addSOAPHandler(BeehiveWsSOAPMessageHandlerInfo handlerInfo);
public abstract String getServiceClassName();
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/impl/DefaultTypeMetadataImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/impl/DefaultTypeMetadataImpl.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/impl/DefaultTypeMetadataImpl.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/impl/DefaultTypeMetadataImpl.java Sun Oct 30 20:49:33 2005
@@ -47,13 +47,12 @@
private String _wsWsdlLocation;
private String _wsTargetNamespace;
private String _wsEndpointInterface;
- //private String _siValue;
private String _className;
private String _hcFileName;
private String _hcName;
private HashMap<String, BeehiveWsMethodMetadata> _methodMap;
private Set<BeehiveWsMethodMetadata> _noDuplicateMethods;
- private LinkedList<BeehiveWsSOAPMessageHandlerInfo> _soapHandlers;
+ private List _soapHandlers;
private BeehiveWsSOAPBindingInfo _soapBinding;
/**
@@ -250,11 +249,18 @@
}
}
- public List<? extends BeehiveWsSOAPMessageHandlerInfo> getSoapHandlers() {
+ public void setSOAPHandlers(List soapHandlers) {
+ _soapHandlers = soapHandlers;
+ }
+
+ public List getSoapHandlers() {
return Collections.unmodifiableList(_soapHandlers);
}
public void addSOAPHandler(BeehiveWsSOAPMessageHandlerInfo soapHandler) {
+ if(_soapHandlers != null)
+ _soapHandlers = new LinkedList();
+
_soapHandlers.add(soapHandler);
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java Sun Oct 30 20:49:33 2005
@@ -35,7 +35,6 @@
/**
* Encapsulates all knowledge about where and how object models are persisted.
- *
*/
public class Jsr181ObjectModelStore {
@@ -61,7 +60,7 @@
if(url == null)
throw new IOException("Unable to load URL for object model represented by '" + resourceName + "'");
- BeehiveWsTypeMetadata typeMetadata = null;
+ BeehiveWsTypeMetadata typeMetadata = null;
InputStream is = null;
try {
is = url.openStream();
@@ -108,8 +107,6 @@
if(objectModel == null)
throw new ObjectModelStoreException("Can not persist empty object model");
- env.getMessager().printNotice("======= Persisting object model: " + objectModel.getServiceClassName());
-
OutputStream os = null;
ObjectOutputStream oos = null;
@@ -124,7 +121,7 @@
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
env.getMessager().printNotice(sw.toString());
-
+
throw new ObjectModelStoreException("Exception occurred writing WSM object model. Cause: " + e, e);
}
finally {
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/ProcessorException.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/ProcessorException.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/ProcessorException.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/ProcessorException.java Sun Oct 30 20:49:33 2005
@@ -24,17 +24,21 @@
*/
public class ProcessorException
extends RuntimeException {
+
+ public ProcessorException() {
+ super();
+ }
- public ProcessorException(String msg, Exception e) {
- super(msg, e);
+ public ProcessorException(String msg, Throwable t) {
+ super(msg, t);
}
public ProcessorException(String msg) {
super(msg);
}
- public ProcessorException(Exception e) {
- super("Code Generation Exception", e);
+ public ProcessorException(Throwable t) {
+ super("Code Generation Exception", t);
}
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/TwoPhaseAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/TwoPhaseAnnotationProcessor.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/TwoPhaseAnnotationProcessor.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/TwoPhaseAnnotationProcessor.java Sun Oct 30 20:49:33 2005
@@ -90,38 +90,6 @@
* annotations claimed by this AnnotationProcessor.
*/
public abstract void generate();
-/*
- throws ProcessorException {
- for(AnnotationTypeDeclaration atd : _atds) {
- Collection<Declaration> decls = _env.getDeclarationsAnnotatedWith(atd);
- for(Declaration decl : decls) {
- System.out.println("----- found declaration: " + decl.getSimpleName());
- generate(decl);
- }
- }
- }
-*/
-
- /**
- * The check method is responsible for all semantic validation of the input Declaration.
- * All semantic warnings/errors associated with the input Declaration should
- * be output during check via a Messager obtained from the
- * AnnotationProcessorEnvironment.
- * If the presence of the input Declaration implies the need to add new files,
- * and those files need to be visible during the check phase for
- * other Declarations, then the AnnotationProcessorEnvironment's Filer API should be
- * used to add those files in this phase. The adding of such files at this point
- * should typically not result in their emission to persistent storage (i.e. disk),
- * but rather be kept in memory to be referenced by the check phase of other
- * Declarations.
- */
- //abstract public void check(Declaration decl);
-
- /**
- * The generate method is responsible for the generation of any additional artifacts
- * (source, class, or binary) that are derived from the input Declaration.
- */
- //public abstract void generate(Declaration decl);
protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() {
return _env;
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java Sun Oct 30 20:49:33 2005
@@ -45,7 +45,9 @@
public void check() {
- /* create lists of the classes and interfaces to process */
+ /*
+ create lists of the classes and interfaces to process
+ */
AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
for(AnnotationTypeDeclaration atd : getAnnotationTypeDeclarations()) {
Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd);
@@ -53,7 +55,6 @@
if(decl instanceof InterfaceDeclaration)
getServiceInterfaces().add((InterfaceDeclaration)decl);
else if(decl instanceof ClassDeclaration && !getServiceImplementations().contains(decl)) {
- env.getMessager().printNotice("????? examine type declaration: " + decl.getSimpleName());
getServiceImplementations().add((ClassDeclaration)decl);
}
}
@@ -63,8 +64,10 @@
Jsr181AnnotationChecker checker = Jsr181AnnotationChecker.getInstance();
checker.setMessager(env.getMessager());
- /* process service interfaces to validate according to specification and to build model
- of check port / binding info */
+ /*
+ Process service interfaces to validate according to specification and to build model
+ of check port / binding info
+ */
if(_serviceInterfaces != null) {
for(InterfaceDeclaration serviceInterface : _serviceInterfaces) {
checker.check(serviceInterface);
@@ -82,7 +85,6 @@
}
}
- //public void generate(Declaration decl) {
public void generate() {
if(_serviceImplementations == null)
return;
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/checker/Jsr181AnnotationChecker.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/checker/Jsr181AnnotationChecker.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/checker/Jsr181AnnotationChecker.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/checker/Jsr181AnnotationChecker.java Sun Oct 30 20:49:33 2005
@@ -156,6 +156,9 @@
- @SOAPMessageHandlers is allowed
- all others are illegal
*/
+ if(wsAnnotation == null)
+ return;
+
String endpointInterface = wsAnnotation.endpointInterface();
if(!endpointInterface.equals("")) {
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/AxisGenerator.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/AxisGenerator.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/AxisGenerator.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/AxisGenerator.java Sun Oct 30 20:49:33 2005
@@ -17,8 +17,6 @@
*/
package org.apache.beehive.wsm.processor.generator;
-import javax.jws.WebService;
-
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
@@ -26,7 +24,7 @@
import org.apache.beehive.wsm.processor.model.factory.BeehiveWsMetadataFactory;
import org.apache.beehive.wsm.processor.model.factory.BeehiveWsTypeMetadataFactory;
import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
-import org.apache.beehive.wsm.processor.model.factory.impl.MirrorTypeResolver;
+import org.apache.beehive.wsm.processor.model.factory.mirror.MirrorTypeResolver;
public class AxisGenerator
extends WsmResourceGenerator {
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java Sun Oct 30 20:49:33 2005
@@ -25,8 +25,9 @@
*/
public abstract class WsmResourceGenerator {
+ /*
+ serviceEndpoint interface generation should be performed in implementations of this base class
+ depending on the service's target execution environment
+ */
public abstract void generate(AnnotationProcessorEnvironment env, TypeDeclaration typeDeclaration);
-
- /* serviceEndpoint interface generation should be performed in implementations of this base class
- depending on the service's target execution environment */
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/BeehiveWsMetadataFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/BeehiveWsMetadataFactory.java?rev=329739&r1=329738&r2=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/BeehiveWsMetadataFactory.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/BeehiveWsMetadataFactory.java Sun Oct 30 20:49:33 2005
@@ -32,7 +32,7 @@
String className = null;
if(factoryType == FactoryType.MIRROR)
- className = "org.apache.beehive.wsm.processor.model.factory.impl.MirrorFactoryImpl";
+ className = "org.apache.beehive.wsm.processor.model.factory.mirror.MirrorFactoryImpl";
else throw new IllegalArgumentException("Can not create factory of type " + factoryType);
BeehiveWsTypeMetadataFactory factory = null;
Copied: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorFactoryImpl.java (from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java)
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorFactoryImpl.java?p2=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorFactoryImpl.java&p1=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java&r1=329714&r2=329739&rev=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorFactoryImpl.java Sun Oct 30 20:49:33 2005
@@ -15,16 +15,16 @@
*
* $Header:$
*/
-package org.apache.beehive.wsm.processor.model.factory.impl;
+package org.apache.beehive.wsm.processor.model.factory.mirror;
-import java.io.IOException;
import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.Oneway;
@@ -55,14 +55,9 @@
import org.apache.beehive.wsm.model.impl.DefaultSOAPMessageHandlerInfoImpl;
import org.apache.beehive.wsm.exception.Jsr181ValidationException;
import org.apache.beehive.wsm.exception.IllegalHandlerConfigException;
-import org.apache.beehive.wsm.handlerconfig.HandlerChainType;
-import org.apache.beehive.wsm.handlerconfig.HandlerConfigDocument;
-import org.apache.beehive.wsm.handlerconfig.j2ee.PortComponentHandlerType;
-import org.apache.beehive.wsm.handlerconfig.j2ee.ParamValueType;
-import org.apache.beehive.wsm.handlerconfig.j2ee.XsdQNameType;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
+import org.apache.beehive.wsm.util.HandlerChainParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class is used to create a {@link BeehiveWsTypeMetadata} object model given
@@ -82,8 +77,6 @@
private static final String SERVICE_SUFFIX = "Service";
private static final String DEFAULT_WR_NAME = "return";
- /* todo: this method signature would be cleaner if there was a context object that was independent of Mirror or Java reflection. */
- /* todo: need an abstraction for resolving a type here */
public BeehiveWsTypeMetadata create(String serviceBeanClassName,
TypeResolver typeResolver,
String baseLocation) {
@@ -123,8 +116,13 @@
if(method.getAnnotation(WebMethod.class) != null)
allWebMethods = false;
- /* todo: expose *all* methods up to java.lang.Object as web service methods */
+ /* process the @WebMethods */
for(MethodDeclaration method : implDecl.getMethods()) {
+ /*
+ In the case that a class doesn't have any @WebMethod annotations, all web methods
+ except those matching method names / signatures matching those inherited from
+ java.lang.Object are exposed as @WebMethods
+ */
if(allWebMethods && acceptWebMethod(method, typeResolver))
processMethod(wsMetadata, method);
else if(method.getAnnotation(WebMethod.class) != null)
@@ -182,13 +180,12 @@
soapMessageHandlerInfo.setName(soapMessageHandler.name());
else soapMessageHandlerInfo.setName(className);
- for(InitParam p : soapMessageHandler.initParams()) {
+ for(InitParam p : soapMessageHandler.initParams())
soapMessageHandlerInfo.addInitParam(p.name(), p.value());
- }
+
soapMessageHandlerInfo.addRoles(Arrays.asList(soapMessageHandler.roles()));
- for(String s : soapMessageHandler.headers()) {
+ for(String s : soapMessageHandler.headers())
soapMessageHandlerInfo.addHeader(s);
- }
wsMetadata.addSOAPHandler(soapMessageHandlerInfo);
}
@@ -203,16 +200,10 @@
}
private void processMethod(BeehiveWsTypeMetadata wsMetadata, MethodDeclaration methodDecl) {
- System.out.println("Service: " + wsMetadata.getServiceName() + " add web method: " + methodDecl.getSimpleName());
- System.out.println("is public: " + methodDecl.getModifiers().contains(Modifier.PUBLIC));
-
if(!methodDecl.getModifiers().contains(Modifier.PUBLIC))
return;
- System.out.println("Service: " + wsMetadata.getServiceName() + " add web method: " + methodDecl.getSimpleName());
-
WebMethod webMethod = methodDecl.getAnnotation(WebMethod.class);
-
String methodName = methodDecl.getSimpleName();
BeehiveWsMethodMetadata wsMethod = new DefaultMethodMetadataImpl();
@@ -282,84 +273,43 @@
* during processing.
*/
private void configureHandlerChain(HandlerChain handlerChain, BeehiveWsTypeMetadata wsMetadata, String baseLocation) {
- /* todo: need to figure out if URLs are the right thing to use here. the spec says
- that URLs are relative (at the time of processing) or absolute. how does
- that affect the runtime? does it mean that the contents of this file need to be
- processed and deployed with the service and that this file *isn't* parsed
- at runtime?
+ /*
+ todo: need to figure out if URLs are the right thing to use here. the spec says
+ that URLs are relative (at the time of processing) or absolute. how does
+ that affect the runtime? does it mean that the contents of this file need to be
+ processed and deployed with the service and that this file *isn't* parsed
+ at runtime?
*/
String handlerChainFile = handlerChain.file();
- String handlerChainName = handlerChain.name();
+ String chainName = handlerChain.name();
- URL handlerChainConfigURL = findResource(baseLocation, handlerChainFile);
- if(null == handlerChainConfigURL)
+ URL chainConfigURL = findResource(baseLocation, handlerChainFile);
+ if(null == chainConfigURL)
throw new IllegalHandlerConfigException("Can not resolve relative URL: " +
handlerChainFile + " from directory: " + baseLocation);
- // parse handler-chain config and add handler-chain to object model
- initHandlersFromChainConfig(wsMetadata, handlerChainConfigURL, handlerChainName);
- }
-
- /**
- * Made public so specific implementations can configure handlers relevant
- * to their own environment. Calls to this are ignored if SOAPHandlers are
- * already configured.
- * 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
- */
- private void initHandlersFromChainConfig(BeehiveWsTypeMetadata wsMetadata, URL chainConfigURL, String chainName) {
+ if(null == chainName)
+ throw new Jsr181ValidationException("@HandlerChain: URL for handler-chain config required");
/* todo: the JSR 181 annotation validation needs to occurr extenrally to where this XML file is processed */
if(!wsMetadata.getSoapHandlers().isEmpty())
throw new Jsr181ValidationException("@HandlerChain: annotation doesn't allow for @SOAPMessageHandlers");
- if(null == chainConfigURL || null == chainName)
- throw new Jsr181ValidationException("@HandlerChain: URL for handler-chain config required");
-
- HandlerConfigDocument handlerConfigDocument = null;
+ final String xmlResourcePath = chainConfigURL.toString();
+ InputStream xmlInputStream = null;
try {
- handlerConfigDocument = HandlerConfigDocument.Factory.parse(chainConfigURL);
- }
- catch(IOException e) {
- throw new IllegalHandlerConfigException("Exception occurred attempting to parse @HandlerConfig file from URL '" +
- chainConfigURL + "'. Cause: " + e);
- }
- catch(XmlException e) {
- throw new IllegalHandlerConfigException("Exception occurred attempting to parse @HandlerConfig file from URL '" +
- chainConfigURL + "'. Cause: " + e);
- }
-
- /* this method throws an exception if validation fails */
- validate(handlerConfigDocument);
-
- HandlerChainType[] handlers = handlerConfigDocument.getHandlerConfig().getHandlerChainArray();
- for(HandlerChainType handlerChain : handlers) {
- /* todo: what does one do with a handler chain name? */
- // String handlerChainName = handlerChain.getHandlerChainName().getStringValue();
- for(PortComponentHandlerType handler : handlerChain.getHandlerArray()) {
- String handlerName = null;
- String handlerClassName = null;
- HashMap<String, String> initParams = new HashMap<String, String>();
- ArrayList<String> roles = new ArrayList<String>();
- ArrayList<String> headers = new ArrayList<String>();
-
- handlerName = handler.getHandlerName().getStringValue();
- handlerClassName = handler.getHandlerClass().getStringValue();
- for(ParamValueType initParam : handler.getInitParamArray())
- initParams.put(initParam.getParamName().getStringValue(), initParam.getParamValue().getStringValue());
-
- for(XsdQNameType xsdQName : handler.getSoapHeaderArray())
- headers.add(xsdQName.getStringValue());
+ xmlInputStream = chainConfigURL.openStream();
- for(org.apache.beehive.wsm.handlerconfig.j2ee.String soapRole : handler.getSoapRoleArray())
- roles.add(soapRole.getStringValue());
+ List soapHandlers = HandlerChainParser.getInstance().parse(xmlInputStream, xmlResourcePath);
- BeehiveWsSOAPMessageHandlerInfo soapHandler =
- new DefaultSOAPMessageHandlerInfoImpl(handlerClassName, handlerName, initParams, roles, headers);
-
- wsMetadata.addSOAPHandler(soapHandler);
- }
+ wsMetadata.setSOAPHandlers(soapHandlers);
+ }
+ catch(Exception e) {
+ throw new IllegalHandlerConfigException("Exception parsing handler config file. Cause: " + e, e);
+ }
+ finally {
+ try {if(xmlInputStream != null) xmlInputStream.close();} catch(IOException ignore) {/**/}
}
}
@@ -403,33 +353,8 @@
return "http://" + targetNamespace;
}
- /**
- * Internal method used to validate an XMLBean.
- * @param xmlObject
- */
- /* todo: switch to DOM for this validation */
- private static void validate(XmlObject xmlObject) {
- /* todo: compost up into a base class */
- XmlOptions validateOptions = new XmlOptions();
- validateOptions.setLoadLineNumbers();
- ArrayList errorList = new ArrayList();
- validateOptions.setErrorListener(errorList);
- boolean isValid = xmlObject.validate(validateOptions);
- if (!isValid) {
- StringBuilder sb = new StringBuilder(128);
- for(Object error : errorList) {
- sb.append(error);
- sb.append("\n");
- }
- throw new IllegalHandlerConfigException("Error parsing @HandlerChain definition. " + sb.toString());
- }
- }
-
private boolean acceptWebMethod(MethodDeclaration webMethod, TypeResolver typeResolver) {
TypeDeclaration objectDecl = (TypeDeclaration)typeResolver.resolveType("java.lang.Object");
-
- System.out.println("object decl: " + objectDecl);
-
Iterator objectMethodsIterator = objectDecl.getMethods().iterator();
while(objectMethodsIterator.hasNext()) {
Copied: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java (from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorTypeResolver.java)
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java?p2=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java&p1=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorTypeResolver.java&r1=329714&r2=329739&rev=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorTypeResolver.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java Sun Oct 30 20:49:33 2005
@@ -15,7 +15,7 @@
$Header:$
*/
-package org.apache.beehive.wsm.processor.model.factory.impl;
+package org.apache.beehive.wsm.processor.model.factory.mirror;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionFactoryImpl.java (from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/ReflectionFactoryImpl.java)
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionFactoryImpl.java?p2=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionFactoryImpl.java&p1=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/ReflectionFactoryImpl.java&r1=329714&r2=329739&rev=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/ReflectionFactoryImpl.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionFactoryImpl.java Sun Oct 30 20:49:33 2005
@@ -15,7 +15,7 @@
*
* $Header:$
*/
-package org.apache.beehive.wsm.processor.model.factory.impl;
+package org.apache.beehive.wsm.processor.model.factory.reflection;
import org.apache.beehive.wsm.processor.model.factory.BeehiveWsTypeMetadataFactory;
import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
Copied: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WSDLFactoryImpl.java (from r329714, beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/WSDLFactoryImpl.java)
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WSDLFactoryImpl.java?p2=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WSDLFactoryImpl.java&p1=beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/WSDLFactoryImpl.java&r1=329714&r2=329739&rev=329739&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/WSDLFactoryImpl.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WSDLFactoryImpl.java Sun Oct 30 20:49:33 2005
@@ -15,7 +15,7 @@
*
* $Header:$
*/
-package org.apache.beehive.wsm.processor.model.factory.impl;
+package org.apache.beehive.wsm.processor.model.factory.wsdl;
import org.apache.beehive.wsm.processor.model.factory.BeehiveWsTypeMetadataFactory;
import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
Added: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java?rev=329739&view=auto
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java (added)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java Sun Oct 30 20:49:33 2005
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.wsm.util;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * <p>This class exists simply because DOM is so inconvenient to use.</p>
+ */
+public final class DomUtils {
+
+ /* do not construct */
+ private DomUtils() {}
+
+ /**
+ * <p>Returns the first child element with the given localName. Returns
+ * <code>null</code> if not found.</p>
+ *
+ * @param parent parent element
+ * @param localName localName of the child element
+ * @return child element
+ */
+ public static Element getChildElementByName(Element parent, String localName) {
+ return getChildElementByName(parent, null, localName);
+ }
+
+ public static Element getChildElementByName(Element parent, String namespace, String localName) {
+ NodeList children = null;
+ children = (namespace != null ? parent.getElementsByTagNameNS(namespace, localName) : parent.getElementsByTagName(localName));
+
+ for(int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if(node.getNodeType() == Node.ELEMENT_NODE)
+ return (Element)node;
+ }
+
+ return null;
+ }
+
+ /**
+ * <p>Returns a list of child elements with the given
+ * name. Returns an empty list if there are no such child
+ * elements.</p>
+ *
+ * @param parent parent element
+ * @param localName name of the child element
+ * @return child elements
+ */
+ public static List getChildElementsByName(Element parent, String localName) {
+ return getChildElementsByName(parent, null, localName);
+ }
+
+ public static List getChildElementsByName(Element parent, String namespace, String localName) {
+ NodeList children =
+ (namespace != null ? parent.getElementsByTagNameNS(namespace, localName) : parent.getElementsByTagName(localName));
+
+ ArrayList elements = new ArrayList(children.getLength());
+ for(int i = 0; i < children.getLength(); i++)
+ if(children.item(i).getNodeType() == Node.ELEMENT_NODE)
+ elements.add((Element)children.item(i));
+
+ return elements;
+ }
+
+ /**
+ * <p>Returns the text value of a child element. Returns
+ * <code>null</code> if there is no child element found.</p>
+ *
+ * @param parent parent element
+ * @param localName name of the child element
+ * @return text value
+ */
+ public static String getChildElementText(Element parent, String localName) {
+ return getChildElementText(parent, null, localName);
+ }
+
+ public static String getChildElementText(Element parent, String namespace, String localName) {
+ List list = DomUtils.getChildElementsByName(parent, namespace, localName);
+ if(list.size() == 1) {
+ Element child = (Element) list.get(0);
+ StringBuffer buf = new StringBuffer();
+ NodeList children = child.getChildNodes();
+ for(int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if(node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) {
+ buf.append(((Text)node).getData());
+ }
+ }
+ return buf.toString();
+ }
+ else return null;
+ }
+
+ /**
+ * <p>Returns the text value of a child element. Returns
+ * <code>null</code> if there is no child element found.</p>
+ *
+ * @param element element
+ * @return text value
+ */
+ public static String getElementText(Element element) {
+ StringBuffer buf = new StringBuffer();
+
+ NodeList children = element.getChildNodes();
+ for(int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if(node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) {
+ buf.append(((Text)node).getData());
+ }
+ }
+
+ return buf.toString();
+ }
+}
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/DomUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java?rev=329739&view=auto
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java (added)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java Sun Oct 30 20:49:33 2005
@@ -0,0 +1,160 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.beehive.wsm.util;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.LinkedList;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import org.apache.beehive.wsm.model.BeehiveWsSOAPMessageHandlerInfo;
+import org.apache.beehive.wsm.model.impl.DefaultSOAPMessageHandlerInfoImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Document;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ */
+public class HandlerChainParser {
+
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+ private static final Log LOGGER = LogFactory.getLog(HandlerChainParser.class);
+
+ public static final HandlerChainParser getInstance() {
+ return new HandlerChainParser();
+ }
+
+ private HandlerChainParser() {}
+
+ public List /*BeehiveWsSOAPMessageHandlerInfo*/ parse(final InputStream xmlInputStream,
+ final String xmlResourcePath) {
+
+ LinkedList handlerInfoList = new LinkedList();
+ Document document = null;
+ final String xsdResourcePath = "org/apache/beehive/wsm/schemas/jsr181-handler-config.xsd";
+ final InputStream xsdInputStream = getClass().getResourceAsStream(xsdResourcePath);
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setValidating(true);
+ dbf.setNamespaceAware(true);
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
+ dbf.setAttribute(JAXP_SCHEMA_SOURCE, xsdInputStream);
+
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setErrorHandler(new ErrorHandler() {
+ public void warning(SAXParseException exception) {
+ if (LOGGER.isInfoEnabled())
+ LOGGER.info("Validation warning validating config file \"" + xmlResourcePath +
+ "\" against XML Schema \"" + xsdResourcePath);
+ }
+
+ public void error(SAXParseException exception) {
+ throw new IllegalStateException("Validation errors occurred parsing the config file \"" +
+ xmlResourcePath + "\". Cause: " + exception, exception);
+ }
+
+ public void fatalError(SAXParseException exception) {
+ throw new IllegalStateException("Validation errors occurred parsing the config file \"" +
+ xmlResourcePath + "\". Cause: " + exception, exception);
+ }
+ });
+
+ db.setEntityResolver(new EntityResolver() {
+ public InputSource resolveEntity(String publicId, String systemId) {
+ String path = "org/apache/beehive/wsm/schemas/" + systemId;
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path);
+ return new InputSource(inputStream);
+ }
+ });
+
+ document = db.parse(xmlInputStream);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException("Exception occurred parsing handler config document. Cause: " + e, e);
+ }
+
+ Element root = document.getDocumentElement();
+ NodeList handlerChainArray = root.getElementsByTagName("handler-chain");
+ for(int j = 0; j < handlerChainArray.getLength(); j++) {
+ Element handlerChain = (Element)handlerChainArray.item(j);
+ String handlerChainName = DomUtils.getChildElementText(handlerChain, "handler-chain-name");
+
+ NodeList portComponentArray = handlerChain.getElementsByTagName("handler");
+ for(int k = 0; k < portComponentArray.getLength(); k++) {
+ Element parent = (Element)portComponentArray.item(k);
+ String handlerName = DomUtils.getChildElementText(parent, "handler-name");
+ String handlerClassName = DomUtils.getChildElementText(parent, "handler-class");
+
+ HashMap<String, String> initParams = new HashMap<String, String>();
+ ArrayList<String> roles = new ArrayList<String>();
+ ArrayList<String> headers = new ArrayList<String>();
+
+ NodeList initParamList = parent.getElementsByTagName("init-param");
+ if(initParamList != null) {
+ for(int i = 0; i < initParamList.getLength(); i++) {
+ Element initParam = (Element)initParamList.item(i);
+ initParams.put(
+ DomUtils.getChildElementText(initParam, "param-name"),
+ DomUtils.getChildElementText(initParam, "param-value")
+ );
+ }
+ }
+
+ NodeList soapHeaderList = parent.getElementsByTagName("soap-header");
+ if(soapHeaderList != null) {
+ for(int i = 0; i < soapHeaderList.getLength(); i++)
+ headers.add(
+ DomUtils.getElementText((Element)soapHeaderList.item(i))
+ );
+ }
+
+ NodeList soapRoleList = parent.getElementsByTagName("soap-role");
+ if(soapRoleList != null) {
+ for(int i = 0; i < soapRoleList.getLength(); i++)
+ headers.add(
+ DomUtils.getElementText((Element)soapRoleList.item(i))
+ );
+ }
+
+ BeehiveWsSOAPMessageHandlerInfo soapHandler =
+ new DefaultSOAPMessageHandlerInfoImpl(handlerClassName,
+ handlerName,
+ initParams,
+ roles,
+ headers);
+
+ /* todo: doesn't seem right to have this here... */
+ handlerInfoList.add(soapHandler);
+ }
+ }
+
+ return handlerInfoList;
+ }
+}
\ No newline at end of file
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/HandlerChainParser.java
------------------------------------------------------------------------------
svn:eol-style = native