You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ae...@apache.org on 2007/02/27 17:58:46 UTC
svn commit: r512322 - in
/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator:
analyzer/ synthesizer/ util/
Author: aeberbac
Date: Tue Feb 27 08:58:45 2007
New Revision: 512322
URL: http://svn.apache.org/viewvc?view=rev&rev=512322
Log:
MUSE-119: Empty capabilities work now. This only applies when
generating from a descriptor because otherwise there's no way to
tell which namespaces that we find in schemas are capabilities (no one
wants a http://schemas.xmlsoap.org/wsdl/soap/ capability). Now if you have
a capability in your descriptor and the analyzer phase doesn't find any wsdl
properties or operations in that namespace (read: capability uri) then it means
it's an empty capability. Don't worry, I'm doing a check to make sure it's not a
built-in empty capability. The code that's generated for this capability is
an empty capability that just has an initialize method with a todo in it. There's no
interface generated (since there aren't any properties or operations).
Modified:
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerClassSynthesizer.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerInterfaceSynthesizer.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DeploymentDescriptorHelper.java
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java Tue Feb 27 08:58:45 2007
@@ -343,11 +343,13 @@
_capabilityMaps[i] = new HashMap();
extractOperations(inspector, _capabilityMaps[i]);
- extractProperties(inspector, _capabilityMaps[i]);
+ extractProperties(inspector, _capabilityMaps[i]);
+ }
+ for(int i=0; i < _wsdlDocuments.length; i++) {
updateFromDescriptor(configuration, i);
- }
-
+ }
+
return createResultData(configuration);
}
@@ -499,21 +501,47 @@
DeploymentDescriptorHelper helper =
new DeploymentDescriptorHelper(descriptorDocument, _wsdlDocuments[resourceIndex], resourceIndex);
- for(Iterator i = _capabilityMaps[resourceIndex].values().iterator(); i.hasNext(); ) {
- Capability capability = (Capability)i.next();
-
+ Capability[] capsFromDescriptor = helper.getCapabilities();
+ Map currentCapabilityMap = _capabilityMaps[resourceIndex];
+
+ for(int i=0; i < capsFromDescriptor.length; i++) {
+ Capability capability = capsFromDescriptor[i];
+
+ //
+ // If the capability is in the capability map then
+ // it means that we found some wsdl operations or properties. If
+ // it isn't in this map then it's something that has no wsdl properties
+ // or operations which means it's one of those empty capabilities. We
+ // want to generate code for this, just in case.
+ //
String uri = capability.getURI();
- String implClass = helper.getCapabilityClass(uri);
- if(implClass != null) {
- String existingClass = capability.getImplementingClass();
- if(existingClass == null) {
- capability.setImplementingClass(implClass);
- capability.setBuiltIn(false);
- } else {
- if(!existingClass.equals(implClass)) {
- capability.setImplementingClass(implClass);
- capability.setBuiltIn(false);
+ Capability existingCapability = (Capability) currentCapabilityMap.get(uri);
+ System.out.println("existing ["+ uri + " == " + existingCapability);
+ if(existingCapability != null) {
+ String implClass = capability.getImplementingClass();
+
+ if(implClass != null) {
+ String existingClass = existingCapability.getImplementingClass();
+ if(existingClass == null) {
+ existingCapability.setImplementingClass(implClass);
+ existingCapability.setBuiltIn(false);
+ } else {
+ if(!existingClass.equals(implClass)) {
+ existingCapability.setImplementingClass(implClass);
+ existingCapability.setBuiltIn(false);
+ }
}
+ }
+ } else {
+ //
+ // Make sure this isn't a built-in empty capability
+ //
+ Class implementingClass = (Class)_internalImplMap.get(uri);
+ System.out.println("empty impl [" + uri + "] == " + implementingClass);
+ if(implementingClass == null) {
+ System.out.println("putting in empty " + capability.getImplementingClass());
+ currentCapabilityMap.put(uri, capability);
+ capability.setBuiltIn(false);
}
}
}
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java Tue Feb 27 08:58:45 2007
@@ -142,7 +142,8 @@
return true;
}
}
- return false;
+
+ return _capability.isEmpty();
}
public void addImports(Set set) {
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties Tue Feb 27 08:58:45 2007
@@ -1,2 +1,3 @@
InitTODO=TODO perform intitialization of the following non-primitive properties
-InitThrow=User needs to update initialization code
\ No newline at end of file
+InitThrow=User needs to update initialization code
+InitEmptyTODO=TODO Perform any needed initialization for this empty capability
\ No newline at end of file
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerClassSynthesizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerClassSynthesizer.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerClassSynthesizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerClassSynthesizer.java Tue Feb 27 08:58:45 2007
@@ -46,9 +46,11 @@
generateInitialize(classInfo, _bodyCode);
}
- generatePropertiesDeclarations(classInfo, _bodyCode);
- generatePropertyOperations(classInfo, _bodyCode);
- generateOperations(classInfo, _bodyCode);
+ if(!capability.isEmpty()) {
+ generatePropertiesDeclarations(classInfo, _bodyCode);
+ generatePropertyOperations(classInfo, _bodyCode);
+ generateOperations(classInfo, _bodyCode);
+ }
classInfo.addImports(_importSet);
@@ -60,12 +62,15 @@
protected void endHeaderCode(ClassInfo classInfo) {
generateImports(classInfo, _headerCode);
Capability capability = classInfo.getCapability();
- String[] interfaces = { ReflectUtils.getShortName(generateClassName(INTERFACE_PREFIX,capability)) };
+ String[] interfaces = null;
+ if(!capability.isEmpty()) {
+ interfaces = new String[]{ ReflectUtils.getShortName(generateClassName(INTERFACE_PREFIX,capability)) };
+ }
String parentClass = convertType(getBaseClass(capability), classInfo);
generateClassDef(_className, parentClass, interfaces , false, _headerCode);
}
- private void generatePropertiesDeclarations(ClassInfo classInfo, StringBuffer code) {
+ protected void generatePropertiesDeclarations(ClassInfo classInfo, StringBuffer code) {
Capability capability = classInfo.getCapability();
if(capability.getProperties().size() == 0) {
@@ -134,13 +139,45 @@
}
}
- private void generateInitialize(ClassInfo classInfo, StringBuffer code) {
+ protected void generateInitialize(ClassInfo classInfo, StringBuffer code) {
+ indent(code);
+ code.append("public void initialize() throws SoapFault ");
+ newLine(code);
indent(code);
- code.append("public void initialize() throws SoapFault ");
generateOpenBlock(code);
addImport(SoapFault.class);
newLine(code);
+ if(classInfo.getCapability().isEmpty()) {
+ generateEmptyInitTodo(code);
+ } else {
+ generatePropertyInitTodo(classInfo, code);
+ }
+
+ indent(code);
+ generateCloseBlock(code);
+ newLine(2, code);
+ }
+
+ protected void generateEmptyInitTodo(StringBuffer code) {
+ indent(2, code);
+ code.append("//");
+ newLine(code);
+
+ indent(2, code);
+ code.append("//" + _MESSAGES.get("InitEmptyTODO", false));
+ newLine(code);
+
+ indent(2, code);
+ code.append("//");
+ newLine(code);
+ }
+
+ protected void generatePropertyInitTodo(ClassInfo classInfo, StringBuffer code) {
+ indent(2, code);
+ code.append("//");
+ newLine(code);
+
indent(2, code);
code.append("//" + _MESSAGES.get("InitTODO", false));
newLine(code);
@@ -165,10 +202,6 @@
indent(2, code);
code.append("throw new RuntimeException(\"" + _MESSAGES.get("InitThrow", false) + "\");");
newLine(code);
-
- indent(code);
- generateCloseBlock(code);
- newLine(2, code);
}
protected void generateGetOperationBody(JavaProperty property, StringBuffer code) {
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerInterfaceSynthesizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerInterfaceSynthesizer.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerInterfaceSynthesizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerInterfaceSynthesizer.java Tue Feb 27 08:58:45 2007
@@ -102,6 +102,10 @@
}
protected void generateCapability(Capability capability, Map files, Set ignoreSet) {
+ if(capability.isEmpty()) {
+ return;
+ }
+
ClassInfo classInfo = new ClassInfo(capability);
String className = generateClassName(INTERFACE_PREFIX, capability);
initializeCode(className, classInfo);
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java Tue Feb 27 08:58:45 2007
@@ -88,4 +88,8 @@
public void setBuiltIn(boolean builtIn) {
_builtIn = builtIn;
}
+
+ public boolean isEmpty() {
+ return (_operations.size() + _properties.size()) == 0;
+ }
}
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DeploymentDescriptorHelper.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DeploymentDescriptorHelper.java?view=diff&rev=512322&r1=512321&r2=512322
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DeploymentDescriptorHelper.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DeploymentDescriptorHelper.java Tue Feb 27 08:58:45 2007
@@ -40,6 +40,7 @@
private Element _resourceTypeElement;
private Element _contextPathElement;
private Element _javaResourceClass;
+ private Object _index;
private static Messages _MESSAGES = MessagesFactory.get(DeploymentDescriptorHelper.class);
/**
@@ -54,6 +55,7 @@
*/
public DeploymentDescriptorHelper(Document descriptorDocument, Document wsdlDocument, int resourceIndex) throws Exception {
_descriptorDocument = descriptorDocument;
+ _index = resourceIndex;
_resourceTypeElement = findResourceTypeElement(_descriptorDocument, wsdlDocument, resourceIndex);
_wsdlFileElement = XmlUtils.findFirstInSubTree(_resourceTypeElement, DescriptorConstants.WSDL_FILE_QNAME);
_contextPathElement = XmlUtils.findFirstInSubTree(_resourceTypeElement, DescriptorConstants.CONTEXT_PATH_QNAME);
@@ -140,20 +142,27 @@
return null;
}
- public String getCapabilityClass(String uri) {
- Element capabilityElement = findCapabilityElement(uri);
-
- if(capabilityElement == null) {
- return null;
+ public Capability[] getCapabilities() {
+ Element[] capabilityElements = XmlUtils.findInSubTree(_resourceTypeElement, DescriptorConstants.CAPABILITY_QNAME);
+ Capability[] capabilities = new Capability[capabilityElements.length];
+ System.out.println("index " + _index + " size == " + capabilities.length);
+ for(int i=0; i < capabilityElements.length; i++) {
+ Element capabilityURIElement = XmlUtils.findFirstInSubTree(capabilityElements[i], DescriptorConstants.CAPABILITY_URI_QNAME);
+ Element javaResourceClassElement = XmlUtils.findFirstInSubTree(capabilityElements[i], DescriptorConstants.JAVA_CAPABILITY_QNAME);
+
+ String capabilityURI = XmlUtils.extractText(capabilityURIElement);
+ String javaResourceClass = XmlUtils.extractText(javaResourceClassElement);
+ if(javaResourceClass == null || javaResourceClass.length() == 0) {
+ javaResourceClass = null;
+ }
+
+ capabilities[i] = new Capability(capabilityURI);
+ capabilities[i].setImplementingClass(javaResourceClass);
+ System.out.println("adding " + capabilityURI + " impled " + javaResourceClass);
}
- Element javaResourceClassElement = XmlUtils.findFirstInSubTree(capabilityElement, DescriptorConstants.JAVA_CAPABILITY_QNAME);
- if(javaResourceClassElement != null) {
- return XmlUtils.extractText(javaResourceClassElement);
- }
-
- return null;
+ return capabilities;
}
private Element findCapabilityElement(String uri) {
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org