geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r432437 - in /geronimo/xbean/trunk: maven-xbean-plugin/src/main/java/org/apache/xbean/maven/ xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/
Date Thu, 17 Aug 2006 23:59:09 GMT
Author: chirino
Date: Thu Aug 17 16:59:09 2006
New Revision: 432437

URL: http://svn.apache.org/viewvc?rev=432437&view=rev
Log:
Applied reviewed patch.  http://issues.apache.org/jira/browse/XBEAN-33
- Added a new Wiki source generator that generates wiki markup so that reference docs can
be pasted into confluence.

Modified:
    geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/DocumentationGenerator.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ElementMapping.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/GeneratorPlugin.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
    geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java

Modified: geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
(original)
+++ geronimo/xbean/trunk/maven-xbean-plugin/src/main/java/org/apache/xbean/maven/XBeanMojo.java
Thu Aug 17 16:59:09 2006
@@ -39,6 +39,7 @@
 import org.apache.xbean.spring.generator.MappingLoader;
 import org.apache.xbean.spring.generator.NamespaceMapping;
 import org.apache.xbean.spring.generator.QdoxMappingLoader;
+import org.apache.xbean.spring.generator.WikiDocumentationGenerator;
 import org.apache.xbean.spring.generator.XmlMetadataGenerator;
 import org.apache.xbean.spring.generator.XsdGenerator;
 
@@ -89,9 +90,16 @@
      * @parameter expression="org.apache.xbean.spring.context.impl"
      */
     private String propertyEditorPaths;
-
-
-    public void execute() throws MojoExecutionException, MojoFailureException {
+
+    /**
+     * A list of additional GeneratorPlugins that should get used executed
+     * when generating output.
+     *
+     * @parameter
+     */
+    private List generatorPlugins = Collections.EMPTY_LIST;
+    
+	public void execute() throws MojoExecutionException, MojoFailureException {
         getLog().debug( " ======= XBeanMojo settings =======" );
         getLog().debug( "namespace[" + namespace + "]" );
         getLog().debug( "srcDir[" + srcDir + "]" );
@@ -122,9 +130,10 @@
             }
             MappingLoader mappingLoader = new QdoxMappingLoader(namespace, new File[] { srcDir
}, excludedClasses);
             GeneratorPlugin[] plugins = new GeneratorPlugin[]{
-                new XmlMetadataGenerator(this, outputDir.getAbsolutePath(), schema),
-                new DocumentationGenerator(this, schema),
-                new XsdGenerator(this, schema)
+                new XmlMetadataGenerator(outputDir.getAbsolutePath(), schema),
+                new DocumentationGenerator(schema),
+                new XsdGenerator(schema),
+                new WikiDocumentationGenerator(schema),
             };
 
             // load the mappings
@@ -138,8 +147,14 @@
                 NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next();
                 for (int i = 0; i < plugins.length; i++) {
                     GeneratorPlugin plugin = plugins[i];
+                    plugin.setLog(this);
+                    plugin.generate(namespaceMapping);
+                }                
+                for (Iterator iter = generatorPlugins.iterator(); iter.hasNext();) {
+					GeneratorPlugin plugin = (GeneratorPlugin) iter.next();
+                    plugin.setLog(this);
                     plugin.generate(namespaceMapping);
-                }
+				}
             }
 
             Resource res = new Resource();

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/DocumentationGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/DocumentationGenerator.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/DocumentationGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/DocumentationGenerator.java
Thu Aug 17 16:59:09 2006
@@ -30,11 +30,10 @@
  */
 public class DocumentationGenerator implements GeneratorPlugin {
     private final File destFile;
-    private final LogFacade log;
+    private LogFacade log;
 
-    public DocumentationGenerator(LogFacade log, File destFile) {
+    public DocumentationGenerator(File destFile) {
         this.destFile = destFile;
-        this.log = log;
     }
 
     public void generate(NamespaceMapping namespaceMapping) throws IOException {
@@ -190,4 +189,12 @@
             out.print(")*");
         }
     }
+
+	public LogFacade getLog() {
+		return log;
+	}
+
+	public void setLog(LogFacade log) {
+		this.log = log;
+	}
 }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ElementMapping.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ElementMapping.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ElementMapping.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/ElementMapping.java
Thu Aug 17 16:59:09 2006
@@ -18,6 +18,7 @@
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -45,11 +46,16 @@
     private final List flatProperties;
     private final Map maps;
     private final Map flatCollections;
+	private final List superClasses;
+	private final HashSet interfaces;
     
     public ElementMapping(String namespace, String elementName, String className, String
description, 
             boolean rootElement, String initMethod, String destroyMethod, String factoryMethod,

-            String contentProperty, Set attributes, List constructors, List flatProperties,
Map maps, Map flatCollections) {
-        if (namespace == null) throw new NullPointerException("namespace");
+            String contentProperty, Set attributes, List constructors, List flatProperties,
Map maps, 
+            Map flatCollections, List superClasses, HashSet interfaces) {
+        this.superClasses = superClasses;
+		this.interfaces = interfaces;
+		if (namespace == null) throw new NullPointerException("namespace");
         if (elementName == null) throw new NullPointerException("elementName");
         if (className == null) throw new NullPointerException("className");
         if (attributes == null) throw new NullPointerException("attributes");
@@ -156,4 +162,12 @@
     public int compareTo(Object obj) {
         return elementName.compareTo(((ElementMapping) obj).elementName);
     }
+
+	public HashSet getInterfaces() {
+		return interfaces;
+	}
+
+	public List getSuperClasses() {
+		return superClasses;
+	}
 }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/GeneratorPlugin.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/GeneratorPlugin.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/GeneratorPlugin.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/GeneratorPlugin.java
Thu Aug 17 16:59:09 2006
@@ -25,4 +25,8 @@
  */
 public interface GeneratorPlugin {
     void generate(NamespaceMapping namespaceMapping) throws IOException;
+    
+	LogFacade getLog();
+	void setLog(LogFacade log);
+
 }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/MappingGeneratorTask.java
Thu Aug 17 16:59:09 2006
@@ -95,9 +95,9 @@
             MappingLoader mappingLoader = new QdoxMappingLoader(namespace, getFiles(srcDir),
excludedClasses);
 
             GeneratorPlugin[] plugins = new GeneratorPlugin[]{
-                new XmlMetadataGenerator(this, metaInfDir, destFile),
-                new DocumentationGenerator(this, destFile),
-                new XsdGenerator(this, destFile)
+                new XmlMetadataGenerator(metaInfDir, destFile),
+                new DocumentationGenerator(destFile),
+                new XsdGenerator(destFile)
             };
 
             // load the mappings
@@ -111,6 +111,7 @@
                 NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next();
                 for (int i = 0; i < plugins.length; i++) {
                     GeneratorPlugin plugin = plugins[i];
+                    plugin.setLog(this);
                     plugin.generate(namespaceMapping);
                 }
             }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
Thu Aug 17 16:59:09 2006
@@ -260,6 +260,25 @@
             }
         }
 
+        HashSet interfaces = new HashSet();
+        interfaces.addAll( getFullyQulifiedNames( javaClass.getImplementedInterfaces() )
);
+
+    	System.out.println("Checking: "+javaClass.getFullyQualifiedName());
+
+    	ArrayList superClasses = new ArrayList();        
+        JavaClass p = javaClass;
+        while( true ) {
+
+            JavaClass s = javaClass.getSuperJavaClass();
+            if(  s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName())
) {
+            	break;
+            }
+        	p=s;
+        	
+        	superClasses.add(p.getFullyQualifiedName());
+            interfaces.addAll( getFullyQulifiedNames( p.getImplementedInterfaces() ) );
+        }
+
         return new ElementMapping(namespace,
                 element,
                 javaClass.getFullyQualifiedName(),
@@ -273,10 +292,20 @@
                 constructorArgs,
                 flatProperties,
                 mapsByPropertyName,
-                flatCollections);
+                flatCollections,
+                superClasses,
+                interfaces);
     }
 
-    private String getElementName(JavaClass javaClass, DocletTag tag) {
+    private List getFullyQulifiedNames(JavaClass[] implementedInterfaces) {
+    	ArrayList l = new ArrayList();
+    	for (int i = 0; i < implementedInterfaces.length; i++) {
+			l.add( implementedInterfaces[i].getFullyQualifiedName() );
+		}
+		return l;
+	}
+
+	private String getElementName(JavaClass javaClass, DocletTag tag) {
         String elementName = getProperty(tag, "element");
         if (elementName == null) {
             String className = javaClass.getFullyQualifiedName();

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XmlMetadataGenerator.java
Thu Aug 17 16:59:09 2006
@@ -36,14 +36,13 @@
  */
 public class XmlMetadataGenerator implements GeneratorPlugin {
     private final String metaInfDir;
-    private final LogFacade log;
+    private LogFacade log;
     private final File schema;
     
     public static final String NAMESPACE_HANDLER = "org.apache.xbean.spring.context.v2.XBeanNamespaceHandler";
 
-    public XmlMetadataGenerator(LogFacade log, String metaInfDir, File schema) {
+    public XmlMetadataGenerator(String metaInfDir, File schema) {
         this.metaInfDir = metaInfDir;
-        this.log = log;
         this.schema = schema;
     }
 
@@ -195,4 +194,12 @@
             }
         }
     }
+
+	public LogFacade getLog() {
+		return log;
+	}
+
+	public void setLog(LogFacade log) {
+		this.log = log;
+	}
 }

Modified: geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java?rev=432437&r1=432436&r2=432437&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
Thu Aug 17 16:59:09 2006
@@ -31,11 +31,10 @@
  */
 public class XsdGenerator implements GeneratorPlugin {
     private final File destFile;
-    private final LogFacade log;
+    private LogFacade log;
 
-    public XsdGenerator(LogFacade log, File destFile) {
+    public XsdGenerator(File destFile) {
         this.destFile = destFile;
-        this.log = log;
     }
 
     public void generate(NamespaceMapping namespaceMapping) throws IOException {
@@ -155,4 +154,12 @@
         out.println("          </xs:complexType>");
         out.println("        </xs:element>");
     }
+
+	public LogFacade getLog() {
+		return log;
+	}
+
+	public void setLog(LogFacade log) {
+		this.log = log;
+	}
 }



Mime
View raw message