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/11 11:53:47 UTC
svn commit: r312852 - in /beehive/trunk:
system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/
system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/
wsm/src/axis/org/apache/beehive/wsm/ax...
Author: ekoneil
Date: Tue Oct 11 02:51:07 2005
New Revision: 312852
URL: http://svn.apache.org/viewcvs?rev=312852&view=rev
Log:
Additional JSR 181 work.
- filling out the Jsr181AnnotationChecker
- cleaning up the wsdl2ajava.vm codegen template
- fixing Bar3.jws, which didn't comply to the JSR 181 spec
- rework the way that endpoint interfaces are handled in relation to service implementations. WSDL contract validation still needs to be written...
BB: self
Test: WSM + web service pass
Added:
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java (with props)
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java (with props)
Modified:
beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ServiceControlGenerator.java
beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java
beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/AxisHook.java
beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
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/model/wsdl/XmlBeanWSDLProcessor.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/WsmResourceGenerator.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/Model2AJava.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/WSDL2AJavaTask.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm
beehive/trunk/wsm/test/src/junit-services/web/Bar3.jws
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/axis/AxisHookTest.java
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/BarTestCase.java
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/FooTestCase.java
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
Modified: beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ServiceControlGenerator.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ServiceControlGenerator.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ServiceControlGenerator.java (original)
+++ beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/generator/ServiceControlGenerator.java Tue Oct 11 02:51:07 2005
@@ -105,7 +105,7 @@
ArrayList<MethodInfo> methodList = buildMethodList(bwtm);
if (pkgName == null) {
- pkgName = Utils.makePackageName(bwtm.getWsTargetNamespace());
+ pkgName = Utils.makePackageName(bwtm.getTargetNamespace());
}
if (_velocityEngine == null) {
@@ -114,12 +114,12 @@
VelocityContext context = new VelocityContext();
context.put("controlPackageName", pkgName);
- context.put("serviceName", bwtm.getWsServiceName());
+ context.put("serviceName", bwtm.getServiceName());
context.put("serviceURLString", serviceURLString);
context.put("wsdlPath", wsdlPath);
context.put("methodList", methodList);
- Writer jcxWriter = getJcxWriter(outputDir, pkgName, bwtm.getWsServiceName());
+ Writer jcxWriter = getJcxWriter(outputDir, pkgName, bwtm.getServiceName());
try {
_velocityTemplate.merge(context, jcxWriter);
Modified: beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java (original)
+++ beehive/trunk/system-controls/src/webservice/org/apache/beehive/controls/system/webservice/jaxrpc/ServiceControlImpl.java Tue Oct 11 02:51:07 2005
@@ -441,7 +441,7 @@
throw new ControlException(se.getMessage(), se);
}
- call.setOperationName(new QName(_beehiveTypeMetadata.getWsTargetNamespace(), wmm.getWmOperationName()));
+ call.setOperationName(new QName(_beehiveTypeMetadata.getTargetNamespace(), wmm.getWmOperationName()));
SOAPBinding.Style omStyle = _beehiveTypeMetadata.getSoapBinding().getStyle();
final String style;
@@ -622,7 +622,7 @@
_handlerInfo = new HandlerInfo();
_handlerInfo.setHandlerClass(HeaderHandler.class);
- _portType = new QName(_beehiveTypeMetadata.getWsTargetNamespace(), _beehiveTypeMetadata.getWsName());
+ _portType = new QName(_beehiveTypeMetadata.getTargetNamespace(), _beehiveTypeMetadata.getName());
configureEndPoint();
}
Modified: beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/AxisHook.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/AxisHook.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/AxisHook.java (original)
+++ beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/AxisHook.java Tue Oct 11 02:51:07 2005
@@ -80,7 +80,7 @@
// If no classloader was provided, use the one that loaded this Class
cl = AxisHook.class.getClassLoader();
}
- final Class serviceClass = cl.loadClass(wsm.getClassName());
+ final Class serviceClass = cl.loadClass(wsm.getServiceClassName());
// Create a list of the allowed methods
List<String> allowedMethods = new ArrayList<String>();
@@ -90,9 +90,9 @@
}
// set the ServiceDesc base information
- sd.setName(wsm.getWsName());
+ sd.setName(wsm.getName());
sd.setImplClass(serviceClass);
- String targetNamespace = wsm.getWsTargetNamespace();
+ String targetNamespace = wsm.getTargetNamespace();
sd.setDefaultNamespace(targetNamespace);
sd.setAllowedMethods(allowedMethods);
configureSoapBinding(sd, wsm.getSoapBinding());
Modified: beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java (original)
+++ beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java Tue Oct 11 02:51:07 2005
@@ -145,7 +145,7 @@
if(null != (jaxrpcChain = getJaxRPCHandlerChainFactory(wsm))) {
ss.setOption(Constants.ATTR_HANDLERINFOCHAIN, jaxrpcChain);
}
- ss.setName(wsm.getWsName());
+ ss.setName(wsm.getName());
ss.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName());
// Take the setting for the scope option from the handler
@@ -175,10 +175,10 @@
sb.append(((String)allowIt.next()));
}
ss.setOption(RPCProvider.OPTION_ALLOWEDMETHODS, sb.toString());
- ss.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsm.getWsName());
- ss.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsm.getWsName());
- ss.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, wsm.getWsServiceName());
- ss.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, wsm.getWsTargetNamespace());
+ ss.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsm.getName());
+ ss.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsm.getName());
+ ss.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, wsm.getServiceName());
+ ss.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, wsm.getTargetNamespace());
ss.setStyle(sd.getStyle());
ss.setUse(sd.getUse());
soapServices.put(cls.getName(), ss);
Added: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java?rev=312852&view=auto
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java (added)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java Tue Oct 11 02:51:07 2005
@@ -0,0 +1,41 @@
+/**
+ 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.exception;
+
+/**
+ *
+ */
+public class CodeGenerationException
+ extends RuntimeException {
+
+ public CodeGenerationException() {
+ super();
+ }
+
+ public CodeGenerationException(String message) {
+ super(message);
+ }
+
+ public CodeGenerationException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public CodeGenerationException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/CodeGenerationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java?rev=312852&view=auto
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java (added)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java Tue Oct 11 02:51:07 2005
@@ -0,0 +1,41 @@
+/**
+ 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.exception;
+
+/**
+ *
+ */
+public class InvalidContractException
+ extends RuntimeException {
+
+ public InvalidContractException() {
+ super();
+ }
+
+ public InvalidContractException(String message) {
+ super(message);
+ }
+
+ public InvalidContractException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public InvalidContractException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/exception/InvalidContractException.java
------------------------------------------------------------------------------
svn:eol-style = native
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -22,37 +22,38 @@
/**
*/
-public abstract class BeehiveWsTypeMetadata {
-
+public abstract class BeehiveWsTypeMetadata {
+/*
public abstract String getSiValue();
public abstract void setSiValue(String siValue);
-
+*/
public abstract BeehiveWsSOAPBindingInfo getSoapBinding();
public abstract void setSoapBinding(BeehiveWsSOAPBindingInfo soapBinding);
- public abstract String getWsName();
-
- public abstract void setWsName(String wsName);
+ public abstract String getName();
- public abstract String getWsServiceName();
+ public abstract void setName(String wsName);
- public abstract void setWsServiceName(String wsServiceName);
+ public abstract String getServiceName();
- public abstract String getWsTargetNamespace();
+ public abstract void setServiceName(String wsServiceName);
- public abstract void setWsTargetNamespace(String wsTargetNamespace);
+ 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 String getWsWsdlLocation();
-
- public abstract void setWsWsdlLocation(String wsWsdlLocation);
+ public abstract void setWsdlLocation(String wsWsdlLocation);
public abstract Collection<? extends BeehiveWsMethodMetadata> getMethods();
@@ -64,7 +65,7 @@
public abstract void addSOAPHandler(BeehiveWsSOAPMessageHandlerInfo soapHandler);
- public abstract String getClassName();
+ public abstract String getServiceClassName();
- public abstract void setClassName(String className);
+ public abstract void setServiceClassName(String className);
}
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -47,7 +47,7 @@
private String _wsWsdlLocation;
private String _wsTargetNamespace;
private String _wsEndpointInterface;
- private String _siValue;
+ //private String _siValue;
private String _className;
private String _hcFileName;
private String _hcName;
@@ -65,55 +65,45 @@
}
/**
- * @return Returns the hcFileName.
*/
- public String getHcFileName() {
+ public String getHandlerChainFileName() {
return _hcFileName;
}
/**
- * @param hcFileName The hcFileName to set.
*/
- public void setHcFileName(String hcFileName) {
+ public void setHandlerChainFileName(String hcFileName) {
_hcFileName = hcFileName;
}
/**
- * @return Returns the hcName.
*/
- public String getHcName() {
+ public String getHandlerChainName() {
return _hcName;
}
/**
- * @param hcName The hcName to set.
*/
- public void setHcName(String hcName) {
+ public void setHandlerChainName(String hcName) {
_hcName = hcName;
}
-
- /**
- * @return Returns the siRunAs.
- */
+/*
public String getSiValue() {
return _siValue;
}
- /**
- * @param siValue The siRunAs to set.
- */
public void setSiValue(String siValue) {
_siValue = siValue;
}
+*/
/**
* @return Returns the soapBinding.
*/
public BeehiveWsSOAPBindingInfo getSoapBinding() {
- if(_soapBinding == null) {
+ if(_soapBinding == null)
_soapBinding = new DefaultSOAPBindingInfoImpl();
- }
return _soapBinding;
}
@@ -127,49 +117,49 @@
/**
* @return Returns the wsName.
*/
- public String getWsName() {
+ public String getName() {
return _wsName;
}
/**
* @param wsName The wsName to set.
*/
- public void setWsName(String wsName) {
+ public void setName(String wsName) {
_wsName = wsName;
}
/**
* @return Returns the wsServiceName.
*/
- public String getWsServiceName() {
+ public String getServiceName() {
return _wsServiceName;
}
/**
* @param wsServiceName The wsServiceName to set.
*/
- public void setWsServiceName(String wsServiceName) {
+ public void setServiceName(String wsServiceName) {
_wsServiceName = wsServiceName;
}
/**
* @return Returns the wsTargetNamespace.
*/
- public String getWsTargetNamespace() {
+ public String getTargetNamespace() {
return _wsTargetNamespace;
}
/**
* @param wsTargetNamespace The wsTargetNamespace to set.
*/
- public void setWsTargetNamespace(String wsTargetNamespace) {
+ public void setTargetNamespace(String wsTargetNamespace) {
_wsTargetNamespace = wsTargetNamespace;
}
public String[] getTargetNamespaceParts() {
// strip the "http://" from the targetnamespace
- String namespace = getWsTargetNamespace().substring(7, getWsTargetNamespace().length());
+ String namespace = getTargetNamespace().substring(7, getTargetNamespace().length());
String[] beforeTranspose = namespace.split("[\\./]");
String[] res = new String[beforeTranspose.length];
for(int i = 0; i < res.length; i++)
@@ -194,14 +184,14 @@
/**
* @return Returns the _wsWsdlLocation.
*/
- public String getWsWsdlLocation() {
+ public String getWsdlLocation() {
return _wsWsdlLocation;
}
/**
* @param wsWsdlLocation The _wsWsdlLocation to set.
*/
- public void setWsWsdlLocation(String wsWsdlLocation) {
+ public void setWsdlLocation(String wsWsdlLocation) {
_wsWsdlLocation = wsWsdlLocation;
}
@@ -209,11 +199,8 @@
* @return Returns the methods.
*/
public Collection<BeehiveWsMethodMetadata> getMethods() {
- if(_noDuplicateMethods == null) {
- _noDuplicateMethods = Collections
- .unmodifiableSet(new HashSet<BeehiveWsMethodMetadata>
- (_methodMap.values()));
- }
+ if(_noDuplicateMethods == null)
+ _noDuplicateMethods = Collections.unmodifiableSet(new HashSet<BeehiveWsMethodMetadata>(_methodMap.values()));
return _noDuplicateMethods;
}
@@ -271,11 +258,11 @@
_soapHandlers.add(soapHandler);
}
- public String getClassName() {
+ public String getServiceClassName() {
return _className;
}
- public void setClassName(String className) {
+ public void setServiceClassName(String className) {
_className = className;
}
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -107,14 +107,14 @@
if(objectModel == null)
throw new ObjectModelStoreException("Can not persist empty object model");
- //env.getMessager().printNotice("Persisting object model: " + objectModel.getClassName());
+ //env.getMessager().printNotice("Persisting object model: " + objectModel.getServiceClassName());
OutputStream os = null;
ObjectOutputStream oos = null;
try {
Filer filer = env.getFiler();
- os = filer.createBinaryFile(Filer.Location.CLASS_TREE, "", getLocation(objectModel.getClassName()));
+ os = filer.createBinaryFile(Filer.Location.CLASS_TREE, "", getLocation(objectModel.getServiceClassName()));
oos = new ObjectOutputStream(os);
oos.writeObject(objectModel);
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/model/wsdl/XmlBeanWSDLProcessor.java Tue Oct 11 02:51:07 2005
@@ -116,11 +116,11 @@
BeehiveWsTypeMetadata wsm = new DefaultTypeMetadataImpl();
HashMap<String, BeehiveWsMethodMetadata> methodMap = new HashMap<String, BeehiveWsMethodMetadata>();
TDefinitions defs = defDoc.getDefinitions();
- wsm.setWsTargetNamespace(defs.getTargetNamespace());
+ wsm.setTargetNamespace(defs.getTargetNamespace());
Map<String, TPart[]> messageMap = new HashMap<String, TPart[]>();
if(defs.sizeOfServiceArray() > 0) {
- wsm.setWsServiceName(defs.getServiceArray(0).getName());
+ wsm.setServiceName(defs.getServiceArray(0).getName());
}
if(defs.sizeOfMessageArray() > 0) {
@@ -138,7 +138,7 @@
if(defs.sizeOfPortTypeArray() > 0) {
TPortType tP = defs.getPortTypeArray(0);
- wsm.setWsName(tP.getName());
+ wsm.setName(tP.getName());
TOperation[] operations = tP.getOperationArray();
TTypes types = null;
if(defs.sizeOfTypesArray() > 0) {
@@ -472,7 +472,7 @@
BeehiveWsParameterMetadata wpm = new DefaultParameterMetadataImpl();
// FIXME jcolwell@bea.com 2004-Nov-09 -- figure out where
// RPC parameter namespaces should be specified in the WSDL.
- wpm.setWpTargetNamespace(wsm.getWsTargetNamespace());
+ wpm.setWpTargetNamespace(wsm.getTargetNamespace());
wpm.setWpName(messagePart.getName());
QName type = messagePart.getType();
wpm.setXmlType(type);
@@ -632,8 +632,8 @@
if(tbMsg != null) {
org.xmlsoap.schemas.wsdl.soap.TBody[] bodies = getSOAPBody(tbMsg);
if(bodies.length > 0) {
- if(wsm.getWsTargetNamespace() == null) {
- wsm.setWsTargetNamespace(bodies[0].getNamespace());
+ if(wsm.getTargetNamespace() == null) {
+ wsm.setTargetNamespace(bodies[0].getNamespace());
}
BeehiveWsSOAPBindingInfo soapInfo = wsm.getSoapBinding();
if(UseChoice.ENCODED.equals(bodies[0].getUse())) {
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -83,7 +83,9 @@
* Performs semantic validation of input Declarations that are annotated with
* annotations claimed by this AnnotationProcessor.
*/
- public void check() {
+ public abstract void check();
+/*
+ {
for(AnnotationTypeDeclaration atd : _atds) {
Collection<Declaration> decls = _env.getDeclarationsAnnotatedWith(atd);
for(Declaration decl : decls) {
@@ -91,6 +93,7 @@
}
}
}
+*/
/**
* Emits additional artifacts for input Declarations that are annotated with
@@ -119,15 +122,19 @@
* but rather be kept in memory to be referenced by the check phase of other
* Declarations.
*/
- abstract public void check(Declaration decl);
+ //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.
*/
- abstract public void generate(Declaration decl);
+ public abstract void generate(Declaration decl);
protected AnnotationProcessorEnvironment getAnnotationProcessorEnvironment() {
return _env;
+ }
+
+ protected Set<AnnotationTypeDeclaration> getAnnotationTypeDeclarations() {
+ return _atds;
}
}
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -24,43 +24,96 @@
import com.sun.mirror.declaration.Declaration;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.EnumDeclaration;
+import com.sun.mirror.declaration.InterfaceDeclaration;
+import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import java.util.Set;
+import java.util.LinkedList;
+import java.util.Collection;
public class WsmAnnotationProcessor
extends TwoPhaseAnnotationProcessor {
+ private LinkedList<InterfaceDeclaration> _serviceInterfaces = null;
+ private LinkedList<ClassDeclaration> _serviceImplementations = null;
+
public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
super(atds, env);
}
- public void check(Declaration decl) {
-
- if(!(decl instanceof TypeDeclaration) || decl instanceof EnumDeclaration)
- return;
+ public void check() {
+ /* create lists of the classes and interfaces to process */
AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
- TypeDeclaration typeDecl = (TypeDeclaration)decl;
-
- env.getMessager().printNotice("Processing type: " + decl.getSimpleName());
+ for(AnnotationTypeDeclaration atd : getAnnotationTypeDeclarations()) {
+ Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd);
+ for(Declaration decl : decls) {
+ if(decl instanceof InterfaceDeclaration)
+ getServiceInterfaces().add((InterfaceDeclaration)decl);
+ else if(decl instanceof ClassDeclaration)
+ getServiceImplementations().add((ClassDeclaration)decl);
+ }
+ }
+ /* by contract, a checker is static and can be reused for many types */
Jsr181AnnotationChecker checker = Jsr181AnnotationChecker.getInstance();
checker.setMessager(env.getMessager());
- checker.check(typeDecl);
+
+ /* 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);
+ }
+ }
+
+ /* process service implementations to validate according to specification
+and to verify serviceEndpoint interface contract (as needed) */
+ if(_serviceImplementations != null) {
+ for(ClassDeclaration serviceImplementation : _serviceImplementations) {
+ checker.check(serviceImplementation);
+ }
+ }
}
public void generate(Declaration decl) {
if(!(decl instanceof TypeDeclaration))
return;
- AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
TypeDeclaration typeDecl = (TypeDeclaration)decl;
- //env.getMessager().printNotice("Generating type: " + decl.getSimpleName());
-
WsmResourceGenerator generator = AxisGenerator.getInstance();
generator.generate(getAnnotationProcessorEnvironment(), typeDecl);
}
+
+ private LinkedList<ClassDeclaration> getServiceImplementations() {
+ if(_serviceImplementations == null)
+ _serviceImplementations = new LinkedList<ClassDeclaration>();
+
+ return _serviceImplementations;
+ }
+
+ private LinkedList<InterfaceDeclaration> getServiceInterfaces() {
+ if(_serviceInterfaces == null)
+ _serviceInterfaces = new LinkedList<InterfaceDeclaration>();
+
+ return _serviceInterfaces;
+ }
+/*
+ public void check(Declaration decl) {
+
+ if(!(decl instanceof TypeDeclaration) || decl instanceof EnumDeclaration)
+ return;
+
+ AnnotationProcessorEnvironment env = getAnnotationProcessorEnvironment();
+ TypeDeclaration typeDecl = (TypeDeclaration)decl;
+
+ env.getMessager().printNotice("Processing type: " + decl.getSimpleName());
+
+ Jsr181AnnotationChecker checker = Jsr181AnnotationChecker.getInstance();
+ checker.setMessager(env.getMessager());
+ checker.check(typeDecl);
+ }
+*/
}
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -18,11 +18,14 @@
package org.apache.beehive.wsm.processor.checker;
import java.util.Collection;
+import java.net.URL;
+import java.net.MalformedURLException;
import javax.jws.WebService;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.HandlerChain;
import javax.jws.WebParam;
+import javax.jws.WebResult;
import javax.jws.soap.SOAPMessageHandlers;
import com.sun.mirror.declaration.TypeDeclaration;
@@ -53,6 +56,8 @@
*/
public class Jsr181AnnotationChecker {
+ /* todo: resource internationalization */
+
public static Jsr181AnnotationChecker getInstance() {
return new Jsr181AnnotationChecker();
}
@@ -68,16 +73,23 @@
public void check(TypeDeclaration typeDecl) {
- if(typeDecl instanceof ClassDeclaration)
+ if(typeDecl instanceof ClassDeclaration) {
validateClassDeclaration((ClassDeclaration)typeDecl);
- else if(typeDecl instanceof InterfaceDeclaration)
+
+ Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
+ for(MethodDeclaration methodDecl : methods) {
+ validateMethod(methodDecl);
+ }
+ }
+ else if(typeDecl instanceof InterfaceDeclaration) {
validateInterfaceDeclaration((InterfaceDeclaration)typeDecl);
- else assert false : "JSR 181 annotation checker received invalid declaration";
- Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
- for(MethodDeclaration methodDecl : methods) {
- validateMethod(methodDecl);
+ Collection<? extends MethodDeclaration> methods = typeDecl.getMethods();
+ for(MethodDeclaration methodDecl : methods) {
+ validateMethod(methodDecl);
+ }
}
+ else assert false : "JSR 181 annotation checker received invalid declaration";
}
private void validateClassDeclaration(ClassDeclaration classDecl) {
@@ -95,7 +107,7 @@
/* todo: check that this is an outer class */
- /* todo: check for a default constructor */
+ /* check for a default constructor */
boolean hasDefaultConstructor = false;
Collection<ConstructorDeclaration> ctors = classDecl.getConstructors();
for(ConstructorDeclaration ctor : ctors) {
@@ -106,19 +118,19 @@
if(!hasDefaultConstructor)
_messager.printError("Service implementation does not have a default contructor");
- /* todo: ensure no finalize() method */
+ /* ensure no finalize() method */
boolean hasFinalizer = false;
- Collection<MethodDeclaration> methods = classDecl.getMethods();
- for(MethodDeclaration method : methods) {
- if(method.getSimpleName().equals("finalize") && method.getParameters().size() == 0)
- hasFinalizer = true;
+ {
+ Collection<MethodDeclaration> methods = classDecl.getMethods();
+ for(MethodDeclaration method : methods) {
+ if(method.getSimpleName().equals("finalize") && method.getParameters().size() == 0)
+ hasFinalizer = true;
+ }
}
if(hasFinalizer)
_messager.printError("Service implementation can not have a finalize() method");
- /* todo: 4.1.5 -- ensure that in the presence of an endpointInterface no other annotations exist */
-
HandlerChain handlerChain = classDecl.getAnnotation(HandlerChain.class);
SOAPMessageHandlers soapHandlers = classDecl.getAnnotation(SOAPMessageHandlers.class);
@@ -126,15 +138,88 @@
_messager.printError("Service implementation can not have both SOAP handlers and a handler chain");
}
- /* todo: check WSDL location */
+ /* endpointInterface checks
+ - @WebService endpointInterface and serviceName is allowed
+ - @HandlerChain is allowed
+ - @SOAPMessageHandlers is allowed
+ - all others are illegal
+ */
+ String endpointInterface = wsAnnotation.endpointInterface();
+ if(!endpointInterface.equals("")) {
+
+ if(!wsAnnotation.name().equals(""))
+ _messager.printError("Service implementation bean can not use the @WebService's name attribute");
+
+ if(!wsAnnotation.targetNamespace().equals(""))
+ _messager.printError("Service implementation bean can not use the @WebService's targetNamespace attribute");
+
+ if(!wsAnnotation.wsdlLocation().equals(""))
+ _messager.printError("Service implementation bean can not use the @WebService's wsdlLocation attribute");
+
+ /* ensure no @WebMethod or @Oneway methods*/
+ Collection<MethodDeclaration> methods = classDecl.getMethods();
+ for(MethodDeclaration method : methods) {
+ if(method.getAnnotation(Oneway.class) != null)
+ _messager.printError("Service implementation bean can not declare a method as @Oneway");
+
+ if(method.getAnnotation(WebMethod.class) != null)
+ _messager.printError("Service implementation bean can not declare a method as @WebMethod");
+
+ Collection<ParameterDeclaration> params = method.getParameters();
+ for(ParameterDeclaration param : params) {
+ if(param.getAnnotation(WebParam.class) != null)
+ _messager.printError("Service implementation bean can not declare a web method parameter as @WebParam");
+ }
+
+ if(method.getAnnotation(WebResult.class) != null)
+ _messager.printError("Service implementation bean can use a @WebResult on a web method");
+ }
+ }
+ /* perform checks that apply to service implementations that don't use the @WebService.endpointInterface attribute */
+ else {
+ /* check wsdlLocation
+ - relative or absolute URL to a WSDL file
+ - check consistency with the portType and bindings declared in the WSDL
+ */
+ String wsdlLocation = wsAnnotation.wsdlLocation();
+ if(!wsdlLocation.equals("")) {
+ try {
+ URL wsdlURL = new URL(wsdlLocation);
- /* todo: validate SOAPHandler annotations */
+ /* todo: check consistency with the portType and bindings declared in the WSDL */
+ validateWsdlContract(classDecl, wsdlURL);
+ }
+ catch(MalformedURLException e) {
+ _messager.printError("The URL \"" + wsdlLocation + "\" is not a valid URL. Reason: " + e);
+ }
+ }
+ }
- /* todo: validate HandlerChain annotation */
+ /* SOAPHandler annotations -- no validation required */
+ /* SOAPBinding annotation -- no validation required */
+ /* HandlerChain annotation -- no validation required*/
}
private void validateInterfaceDeclaration(InterfaceDeclaration intfDecl) {
- /* todo: need to validate the endpoint interface */
+ /*
+ All endpointInterface methods are mapped to web service operations. The
+ use of an @WebMethod is optional, and if present, this customizes the
+ mappings of the endpoint interface to a WSDL file.
+ */
+
+ /* check outer, public interface */
+ if(!intfDecl.getModifiers().contains(Modifier.PUBLIC))
+ _messager.printError("Service endpoint interface must be public");
+
+ /* ensure that WebService.endpointInterface isn't set on an interface */
+/* not sure why this check was put here...
+ WebService wsAnnotation = intfDecl.getAnnotation(WebService.class);
+ if(wsAnnotation.endpointInterface() != null) {
+ _messager.printError("The endpointInterface attribute is not allowed on an interface");
+ }
+*/
+
+ /* todo: handle @WebMethod annotations for customizing the mapping to a WSDL */
}
private void validateMethod(MethodDeclaration methodDecl) {
@@ -173,13 +258,15 @@
/* todo: check not throwing RemoteException */
}
- /* todo: check additional exceptions */
+ /* todo: JAX-RPC 1.1 section 5 validation */
+ }
+ }
- /* todo: something about return types? */
+ /* todo: need to compost this up into a base class so that it can be reused across
+ the mirror, XMLBean, and reflection based ways of constructing JSR-181
+ compliant services
+ */
+ private void validateWsdlContract(TypeDeclaration typeDeclaration, URL wsdlLocation) {
- /* skipped checks -- are these still valid?
- - @Oneway and @WebMethod mutually exclusive
- */
- }
}
}
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=312852&r1=312851&r2=312852&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 Tue Oct 11 02:51:07 2005
@@ -26,4 +26,7 @@
public abstract class WsmResourceGenerator {
public abstract void generate(AnnotationProcessorEnvironment env, TypeDeclaration typeDeclaration);
+
+ /* serviceEndpoint interface generation should be peerformed 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/impl/MirrorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/processor/model/factory/impl/MirrorFactoryImpl.java?rev=312852&r1=312851&r2=312852&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/impl/MirrorFactoryImpl.java Tue Oct 11 02:51:07 2005
@@ -96,12 +96,12 @@
String serviceName = implDecl.getAnnotation(WebService.class).serviceName();
if(serviceName.trim().length() == 0)
- wsMetadata.setWsServiceName(implDecl.getSimpleName() + SERVICE_SUFFIX);
- else wsMetadata.setWsServiceName(serviceName);
+ wsMetadata.setServiceName(implDecl.getSimpleName() + SERVICE_SUFFIX);
+ else wsMetadata.setServiceName(serviceName);
/* todo: what to do when the service impl has a WebService.endpointInterface annotation? */
- wsMetadata.setClassName(implDecl.getQualifiedName());
+ wsMetadata.setServiceClassName(implDecl.getQualifiedName());
/* todo: verify that no additional annotations are visible on the implementation type */
@@ -117,6 +117,7 @@
if(method.getAnnotation(WebMethod.class) != null)
allWebMethods = false;
+ /* todo: expose *all* methods up to java.lang.Object as web service methods */
for(MethodDeclaration method : implDecl.getMethods())
if(allWebMethods || method.getAnnotation(WebMethod.class) != null)
processMethod(wsMetadata, method);
@@ -128,23 +129,24 @@
private void processClass(BeehiveWsTypeMetadata wsMetadata, TypeDeclaration typeDecl, String baseLocation) {
WebService ws = typeDecl.getAnnotation(WebService.class);
- wsMetadata.setClassName(typeDecl.getQualifiedName());
+ wsMetadata.setServiceClassName(typeDecl.getQualifiedName());
if(ws.name().trim().length() == 0)
- wsMetadata.setWsName(typeDecl.getSimpleName());
- else wsMetadata.setWsName(ws.name());
+ wsMetadata.setName(typeDecl.getSimpleName());
+ else wsMetadata.setName(ws.name());
if(ws.serviceName().trim().length() == 0)
- wsMetadata.setWsServiceName(typeDecl.getSimpleName() + SERVICE_SUFFIX);
- else wsMetadata.setWsServiceName(ws.serviceName());
+ wsMetadata.setServiceName(typeDecl.getSimpleName() + SERVICE_SUFFIX);
+ else wsMetadata.setServiceName(ws.serviceName());
if(ws.targetNamespace() == null || ws.targetNamespace().length() == 0)
- wsMetadata.setWsTargetNamespace(computeTargetNamespace(typeDecl.getQualifiedName()));
- else wsMetadata.setWsTargetNamespace(ws.targetNamespace());
+ wsMetadata.setTargetNamespace(computeTargetNamespace(typeDecl.getQualifiedName()));
+ else wsMetadata.setTargetNamespace(ws.targetNamespace());
- /* todo: verify wsdlLocation annotation */
- wsMetadata.setWsWsdlLocation(ws.wsdlLocation());
- wsMetadata.setWsEndpointInterface(ws.endpointInterface());
+ /* assume that the wsdlLocation annotation has already been validated */
+ // todo: this JavaBean property doesn't seem like it's needed */
+ //wsMetadata.setWsdlLocation(ws.wsdlLocation());
+ //wsMetadata.setWsEndpointInterface(ws.endpointInterface());
/* annot: SOAPBinding.class */
SOAPBinding soapBinding = typeDecl.getAnnotation(SOAPBinding.class);
@@ -157,6 +159,8 @@
}
/* annot: SOAPMessageHandlers.class */
+ /* todo: in the presence of both an endpoint interface and service implementation bean with a @SOAPMessageHandler
+ interface, the implementation's version wins */
SOAPMessageHandlers soapMessageHandlers = typeDecl.getAnnotation(SOAPMessageHandlers.class);
if(soapMessageHandlers != null) {
for(SOAPMessageHandler soapMessageHandler : soapMessageHandlers.value()) {
@@ -182,6 +186,8 @@
}
/* annot: HandlerChain.class */
+ /* todo: in the presence of both an endpoint interface and service implementation bean with a @HandlerChain
+ interface, the implementation's version wins */
HandlerChain handlerChain = typeDecl.getAnnotation(HandlerChain.class);
if(handlerChain != null)
configureHandlerChain(handlerChain, wsMetadata, baseLocation);
@@ -225,7 +231,7 @@
*/
String webMethodNamespace = wsMethod.getWrTargetNamespace();
if(webMethodNamespace == null || webMethodNamespace.length() == 0)
- wsMethod.setWrTargetNamespace(wsMetadata.getWsTargetNamespace());
+ wsMethod.setWrTargetNamespace(wsMetadata.getTargetNamespace());
for(ParameterDeclaration paramDecl : methodDecl.getParameters()) {
BeehiveWsParameterMetadata wsParam = new DefaultParameterMetadataImpl();
@@ -245,7 +251,7 @@
String wpTargetNamespace = wsParam.getWpTargetNamespace();
if(wpTargetNamespace == null || wpTargetNamespace.length() == 0)
- wsParam.setWpTargetNamespace(wsMetadata.getWsTargetNamespace());
+ wsParam.setWpTargetNamespace(wsMetadata.getTargetNamespace());
wsMethod.addParam(wsParam);
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/Model2AJava.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/Model2AJava.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/Model2AJava.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/Model2AJava.java Tue Oct 11 02:51:07 2005
@@ -23,11 +23,10 @@
import java.util.Properties;
import org.apache.beehive.wsm.model.BeehiveWsTypeMetadata;
+import org.apache.beehive.wsm.exception.CodeGenerationException;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
@@ -37,95 +36,67 @@
*/
public final class Model2AJava {
- /* todo: should these be cached in the type? */
- private static VelocityEngine ve = null;
- private static Template template = null;
- private static boolean initialized = false;
-
- /**
- * @throws Exception
- * @throws ResourceNotFoundException
- * @throws ParseErrorException
- * @throws MethodInvocationException
- */
- private static void init()
- throws Exception, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
-
- Properties p = new Properties();
- p.setProperty(VelocityEngine.RESOURCE_LOADER, "class");
- p.setProperty("class." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName());
- ve = new VelocityEngine();
- ve.init(p);
- String templateFileName = "org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm";
+ private static final String TEMPLATE_FILE_NAME = "org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm";
+ private static final String DEFAULT_PACKAGE_NAME = "web";
+ private static final Template TEMPLATE;
+ private static final String VELOCITY_CONTEXT_KEY_WEB_SERVICE = "webService";
+ static {
try {
- template = ve.getTemplate(templateFileName);
+ Properties p = new Properties();
+ p.setProperty(VelocityEngine.RESOURCE_LOADER, "class");
+ p.setProperty("class." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName());
+ VelocityEngine VELOCITY_ENGINE = new VelocityEngine();
+ VELOCITY_ENGINE.init(p);
+
+ TEMPLATE = VELOCITY_ENGINE.getTemplate(TEMPLATE_FILE_NAME);
}
catch(ResourceNotFoundException e) {
- System.err.println("Failed to find the tempate file: " + templateFileName + " in classpath: " + System.getProperty("java.class.path"));
- throw e;
- }
- catch(ParseErrorException e) {
- throw e;
- }
- catch(MethodInvocationException e) {
- throw e;
+ throw new CodeGenerationException("Unable to find the template file \"" + TEMPLATE_FILE_NAME + "\" in classpath");
}
catch(Exception e) {
- throw e;
+ throw new CodeGenerationException("An exception occurred while generating a web service. Cause: " + e, e);
}
-
- initialized = true;
}
- static public void generateAnnotatedJavaFromOM(BeehiveWsTypeMetadata om, File baseSrcDir)
- throws Exception {
+ public static void generateAnnotatedJavaFromOM(BeehiveWsTypeMetadata om, File baseSrcDir) {
- String className = om.getWsName();
+ String className = om.getName();
+ assert className != null : "Found null class name";
/* todo: need to pick a better default package name than 'web' -- should this be derived from
- the targetNamespace by default? Should the caller be able to provide one?
- */
- String packageName = "web";
+ the targetNamespace by default? Should the caller be able to provide one?
+ */
+ String packageName = DEFAULT_PACKAGE_NAME;
+ assert packageName != null : "Found null package name";
// doesn't do any thing right now, useful if the target package name had dots
String packageDirName = packageName.replaceAll("\\.", "/");
File packageDir = new File(baseSrcDir, packageDirName);
+ if(packageDir.exists() && !packageDir.isDirectory())
+ throw new CodeGenerationException("Unable to create destination directory for the generated web " +
+ "service. File already exists ' " + packageDir.toString() + "'");
+
if(!packageDir.exists())
packageDir.mkdirs();
- File srcFile = new File(baseSrcDir, className + ".java");
- srcFile.createNewFile();
-
Writer writer = null;
try {
+ File srcFile = new File(baseSrcDir, className + ".java");
+ srcFile.createNewFile();
+
writer = new FileWriter(srcFile, false);
- generateAnnotatedJavaFromOM(om, writer);
+
+ VelocityContext context = new VelocityContext();
+ context.put(VELOCITY_CONTEXT_KEY_WEB_SERVICE, om);
+ TEMPLATE.merge(context, writer);
+ }
+ catch(Exception e) {
+ throw new CodeGenerationException("An exception occurred while generating a web service. Cause: " + e, e);
}
finally {
- if(writer != null)
- writer.close();
+ try {if(writer != null) writer.close();}catch(Exception e) {}
}
- }
-
- /**
- * @param w
- * @param om
- * @throws ResourceNotFoundException
- * @throws ParseErrorException
- * @throws MethodInvocationException
- * @throws Exception
- * @throws IOException
- */
- public static void generateAnnotatedJavaFromOM(BeehiveWsTypeMetadata om, Writer w)
- throws ResourceNotFoundException, ParseErrorException,
- MethodInvocationException, Exception, IOException {
- if(!initialized)
- init();
-
- VelocityContext context = new VelocityContext();
- context.put("webServiceOM", om);
- template.merge(context, w);
}
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/WSDL2AJavaTask.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/WSDL2AJavaTask.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/WSDL2AJavaTask.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/WSDL2AJavaTask.java Tue Oct 11 02:51:07 2005
@@ -1,6 +1,4 @@
/*
- * AxisTypeGeneratorTask.java
- *
* Copyright 2001-2004 The Apache Software Foundation.
*
*
@@ -15,8 +13,6 @@
* 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.tools.wsdl2ajava;
@@ -24,62 +20,38 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
public class WSDL2AJavaTask
extends Java {
- private File mWSDL;
- private File mOutDir;
+ private static final String WSDL2JAVA_CLASS = "org.apache.beehive.wsm.axis.tools.Wsdl2AJava";
- public WSDL2AJavaTask() {
- super();
- }
+ private File _wsdlFile;
+ private File _outputDir;
- public void setWSDLFile(File wsdl) {
- mWSDL = wsdl;
+ public void setWSDLFile(File wsdlFile) {
+ _wsdlFile = wsdlFile;
}
public void setOutputDir(File outputDir) {
- mOutDir = outputDir;
- }
-
- /**
- * Classpath to use, by reference.
- *
- * @param r a reference to an existing classpath
- */
- public void setClasspathRef(Reference r) {
- super.setClasspathRef(r);
- }
-
- /**
- * Set the classpath to be used when running the Java class
- *
- * @param s an Ant Path object containing the classpath.
- */
- public void setClasspath(Path s) {
- super.setClasspath(s);
+ _outputDir = outputDir;
}
public void execute()
throws BuildException {
+
+ /* todo: checks to ensure that the given Files are a file and directory respectively */
+
try {
- setClassname("org.apache.beehive.wsm.axis.tools.Wsdl2AJava");
- setArgs(mWSDL.getCanonicalPath());
- setArgs(mOutDir.getCanonicalPath());
- super.execute();
+ setClassname(WSDL2JAVA_CLASS);
+ /* todo: use the nested arg element here; the setArgs(...) method is deprecated */
+ setArgs(_wsdlFile.getCanonicalPath());
+ setArgs(_outputDir.getCanonicalPath());
+ super.execute();
}
- catch(Throwable e) {
- e.printStackTrace();
- if(e instanceof BuildException) {
- throw (BuildException)e;
- }
- else {
- throw new BuildException(e.toString(), e);
- }
+ catch(Exception e) {
+ throw new BuildException("Exception occurred generating annotated web service. Cause: " + e, e);
}
}
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/tools/wsdl2ajava/wsdl2ajava.vm Tue Oct 11 02:51:07 2005
@@ -1,6 +1,20 @@
-
##
+## 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:$Factory
+
##
#macro(webService $name $targetNamespace $wsdlLocation)
@WebService (
@@ -114,13 +128,13 @@
##
/*
This file is an Annotated java file that that is automatically generated
-from wsdl: $webServiceOM.wsWsdlLocation
+from wsdl: $webService.wsWsdlLocation
*/
#set($packageName="")
#set($ctr=0)
-#set($size=$webServiceOM.targetNamespaceParts.size())
-#foreach( $dirName in $webServiceOM.targetNamespaceParts)
+#set($size=$webService.targetNamespaceParts.size())
+#foreach( $dirName in $webService.targetNamespaceParts)
#if($ctr != 0) #set($packageName="$packageName.")#end
#set($ctr=$ctr + 1)
#set($packageName="$packageName$dirName")
@@ -130,7 +144,7 @@
package web;
import java.rmi.RemoteException;
-
+import javax.jws.HandlerChain;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@@ -138,14 +152,13 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
+#webService($webService.name $webService.targetNamespace $webService.wsdlLocation)
+#handlerChain($webService.handlerChainFileName $webService.handlerChainName)
+#soapBinding($webService.soapBinding)
+#soapMsgHandlers($webService.soapHandlers)
+public class $webService.name {
-#webService($webServiceOM.wsName $webServiceOM.wsTargetNamespace $webServiceOM.wsWsdlLocation)
-#handlerChain($webServiceOM.hcFileName $webServiceOM.name)
-#soapBinding($webServiceOM.soapBinding)
-#soapMsgHandlers($webServiceOM.soapHandlers)
-public class $webServiceOM.wsName {
-
-#foreach( $method in $webServiceOM.methods)
+#foreach( $method in $webService.methods)
/**********************************************
*
#foreach( $param in $method.params)
@@ -167,15 +180,13 @@
)
#if(!$method.oneWay)throws RemoteException#end {
#end
- //TODO: Implement the method logic here...
+
#if($method.javaReturnType == "void")
return;
#else
return null;
#end
-
}
-
#end
}
Modified: beehive/trunk/wsm/test/src/junit-services/web/Bar3.jws
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit-services/web/Bar3.jws?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit-services/web/Bar3.jws (original)
+++ beehive/trunk/wsm/test/src/junit-services/web/Bar3.jws Tue Oct 11 02:51:07 2005
@@ -26,12 +26,10 @@
@WebService(serviceName = "Bar3Service", endpointInterface = "Cheetorama")
public class Bar3 {
- @WebMethod
public boolean getNutty(int level, String detail) {
return (level > 5);
}
- @WebMethod
public void goHome(long time) {
}
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/axis/AxisHookTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/axis/AxisHookTest.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/axis/AxisHookTest.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/axis/AxisHookTest.java Tue Oct 11 02:51:07 2005
@@ -138,14 +138,14 @@
protected BeehiveWsTypeMetadata makeFakeMetadata() throws Exception {
BeehiveWsTypeMetadata wstm = new DefaultTypeMetadataImpl();
- wstm.setClassName(WS_CLASS.getName());
- wstm.setWsName(WS_NAME);
+ wstm.setServiceClassName(WS_CLASS.getName());
+ wstm.setName(WS_NAME);
/*
* NOTE jcolwell@bea.com 2004-Sep-13 --
* service name not used in the ServiceDesc
*/
- //wstm.setWsServiceName(WS_SERVICENAME);
- wstm.setWsTargetNamespace(WS_NAMESPACE);
+ //wstm.setServiceName(WS_SERVICENAME);
+ wstm.setTargetNamespace(WS_NAMESPACE);
wstm.setSoapBinding(makeFakeSoapBinding());
wstm.addMethod(makeFakeMethod());
wstm.addMethod(makeFakeOnewayMethod());
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/BarTestCase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/BarTestCase.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/BarTestCase.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/BarTestCase.java Tue Oct 11 02:51:07 2005
@@ -44,10 +44,10 @@
public void testWebServiceAbacus() throws Exception {
assertEquals("Invalid wsName;", "Abacus",
- ((BeehiveWsTypeMetadata) objectModel).getWsName());
+ ((BeehiveWsTypeMetadata) objectModel).getName());
assertEquals("Invalid wsTargetNamespace;",
"http://www.superflaco.com/AnnotationEndpointInterfaceTest",
- ((BeehiveWsTypeMetadata) objectModel).getWsTargetNamespace());
+ ((BeehiveWsTypeMetadata) objectModel).getTargetNamespace());
}
public void testWebMethodGoLoco() throws Exception {
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/FooTestCase.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/FooTestCase.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/FooTestCase.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/FooTestCase.java Tue Oct 11 02:51:07 2005
@@ -42,13 +42,13 @@
public void testWebServiceAbacus() throws Exception {
assertEquals("Invalid wsName;", "Abacus",
- ((BeehiveWsTypeMetadata) objectModel).getWsName());
+ ((BeehiveWsTypeMetadata) objectModel).getName());
// todo test endpointInterface
assertEquals("Invalid wsTargetNamespace;",
"http://www.superflaco.com/AnnotationTest",
- ((BeehiveWsTypeMetadata) objectModel).getWsTargetNamespace());
+ ((BeehiveWsTypeMetadata) objectModel).getTargetNamespace());
}
public void testWebMethodGoLoco() throws Exception {
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/wsdl/XmlBeanWSDLProcessorTest.java?rev=312852&r1=312851&r2=312852&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/wsdl/XmlBeanWSDLProcessorTest.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/wsdl/XmlBeanWSDLProcessorTest.java Tue Oct 11 02:51:07 2005
@@ -59,9 +59,9 @@
public void testServiceWideSettings() throws Exception {
- assertEquals(serverModel.getWsName(), clientModel.getWsName());
- assertEquals(serverModel.getWsServiceName(), clientModel.getWsServiceName());
- assertEquals(serverModel.getWsTargetNamespace(), clientModel.getWsTargetNamespace());
+ assertEquals(serverModel.getName(), clientModel.getName());
+ assertEquals(serverModel.getServiceName(), clientModel.getServiceName());
+ assertEquals(serverModel.getTargetNamespace(), clientModel.getTargetNamespace());
// NOTE jcolwell@bea.com 2005-Jan-07 -- not checking equivalence of Parameter style since the
// client can use BARE even if the server uses WRAPPED