geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r896187 [2/6] - in /geronimo/xbean/trunk/xbean-blueprint: ./ src/main/java/org/apache/xbean/blueprint/ src/main/java/org/apache/xbean/blueprint/context/ src/main/java/org/apache/xbean/blueprint/context/impl/ src/main/java/org/apache/xbean/b...
Date Tue, 05 Jan 2010 19:31:42 GMT
Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class DocumentationGenerator implements GeneratorPlugin {
+    private final File destFile;
+    private LogFacade log;
+
+    public DocumentationGenerator(File destFile) {
+        this.destFile = destFile;
+    }
+
+    public void generate(NamespaceMapping namespaceMapping) throws IOException {
+        String namespace = namespaceMapping.getNamespace();
+
+        // TODO can only handle 1 schema document so far...
+        File file = new File(destFile.getParentFile(), destFile.getName() + ".html");
+        log.log("Generating HTML documentation file: " + file + " for namespace: " + namespace);
+        PrintWriter out = new PrintWriter(new FileWriter(file));
+        try {
+            generateDocumentation(out, namespaceMapping);
+        } finally {
+            out.close();
+        }
+    }
+
+    private void generateDocumentation(PrintWriter out, NamespaceMapping namespaceMapping) {
+        String namespace = namespaceMapping.getNamespace();
+
+        out.println("<!-- NOTE: this file is autogenerated by Apache XBean -->");
+        out.println("<html>");
+        out.println("<head>");
+        out.println("<title>Schema for namespace: " + namespace + "</title>");
+        out.println("<link rel='stylesheet' href='style.css' type='text/css'>");
+        out.println("<link rel='stylesheet' href='http://activemq.org/style.css' type='text/css'>");
+        out.println("<link rel='stylesheet' href='http://activemq.org/style-xb.css' type='text/css'>");
+        out.println("</head>");
+        out.println();
+        out.println("<body>");
+        out.println();
+
+        generateRootElement(out, namespaceMapping);
+
+        generateElementsSummary(out, namespaceMapping);
+        out.println();
+        out.println();
+
+        generateElementsDetail(out, namespaceMapping);
+
+        out.println();
+        out.println("</body>");
+        out.println("</html>");
+    }
+
+    private void generateRootElement(PrintWriter out, NamespaceMapping namespaceMapping) {
+        ElementMapping rootElement = namespaceMapping.getRootElement();
+        if (rootElement != null) {
+            out.println("<h1>Root Element</h1>");
+            out.println("<table>");
+            out.println("  <tr><th>Element</th><th>Description</th><th>Class</th>");
+            generateElementSummary(out, rootElement);
+            out.println("</table>");
+            out.println();
+        }
+    }
+
+    private void generateElementsSummary(PrintWriter out, NamespaceMapping namespaceMapping) {
+        out.println("<h1>Element Summary</h1>");
+        out.println("<table>");
+        out.println("  <tr><th>Element</th><th>Description</th><th>Class</th>");
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            generateElementSummary(out, element);
+        }
+        out.println("</table>");
+    }
+
+    private void generateElementSummary(PrintWriter out, ElementMapping element) {
+        out.println("  <tr>" +
+                "<td><a href='#" + element.getElementName() + "'>" + element.getElementName() + "</a></td>" +
+                "<td>" + element.getDescription() + "</td>" +
+                "<td>" + element.getClassName() + "</td></tr>");
+    }
+
+    private void generateElementsDetail(PrintWriter out, NamespaceMapping namespaceMapping) {
+        out.println("<h1>Element Detail</h1>");
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            generateHtmlElementDetail(out, namespaceMapping, element);
+        }
+    }
+
+    private void generateHtmlElementDetail(PrintWriter out, NamespaceMapping namespaceMapping, ElementMapping element) {
+        out.println("<h2>Element: <a name='" + element.getElementName() + "'>" + element.getElementName() + "</a></h2>");
+
+        boolean hasAttributes = false;
+        boolean hasElements = false;
+        for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext() && (!hasAttributes || !hasElements);) {
+            AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+            Type type = attributeMapping.getType();
+            if (namespaceMapping.isSimpleType(type)) {
+                hasAttributes = true;
+            } else {
+                hasElements = true;
+            }
+        }
+
+        if (hasAttributes) {
+            out.println("<table>");
+            out.println("  <tr><th>Attribute</th><th>Type</th><th>Description</th>");
+            for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+                AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+                Type type = attributeMapping.getPropertyEditor() != null ?  Type.newSimpleType(String.class.getName()) : attributeMapping.getType();
+                if (namespaceMapping.isSimpleType(type)) {
+                    out.println("  <tr><td>" + attributeMapping.getAttributeName() + "</td><td>" + Utils.getXsdType(type)
+                            + "</td><td>" + attributeMapping.getDescription() + "</td></tr>");
+                }
+
+            }
+            out.println("</table>");
+        }
+
+        if (hasElements) {
+            out.println("<table>");
+            out.println("  <tr><th>Element</th><th>Type</th><th>Description</th>");
+            for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) {
+                AttributeMapping attributeMapping = (AttributeMapping) iterator.next();
+                Type type = attributeMapping.getType();
+                if (!namespaceMapping.isSimpleType(type)) {
+                    out.print("  <tr><td>" + attributeMapping.getAttributeName() + "</td><td>");
+                    printComplexPropertyTypeDocumentation(out, namespaceMapping, type);
+                    out.println("</td><td>" + attributeMapping.getDescription() + "</td></tr>");
+                }
+            }
+            out.println("</table>");
+        }
+    }
+
+    private void printComplexPropertyTypeDocumentation(PrintWriter out, NamespaceMapping namespaceMapping, Type type) {
+        if (type.isCollection()) {
+            out.print("(");
+        }
+
+        List types;
+        if (type.isCollection()) {
+            types = Utils.findImplementationsOf(namespaceMapping, type.getNestedType());
+        } else {
+            types = Utils.findImplementationsOf(namespaceMapping, type);
+        }
+
+        for (Iterator iterator = types.iterator(); iterator.hasNext();) {
+            ElementMapping element = (ElementMapping) iterator.next();
+            out.print("<a href='#" + element.getElementName() + "'>" + element.getElementName() + "</a>");
+            if (iterator.hasNext()) {
+                out.print(" | ");
+            }
+        }
+        if (types.size() == 0) {
+            out.print("&lt;spring:bean/&gt;");
+        }
+
+        if (type.isCollection()) {
+            out.print(")*");
+        }
+    }
+
+    public LogFacade getLog() {
+        return log;
+    }
+
+    public void setLog(LogFacade log) {
+        this.log = log;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/DocumentationGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class ElementMapping implements Comparable {
+    private final String namespace;
+    private final String elementName;
+    private final String className;
+    private final String description;
+    private final boolean rootElement;
+    private final String initMethod;
+    private final String destroyMethod;
+    private final String factoryMethod;
+    private final String contentProperty;
+    private final Set attributes;
+    private final Map attributesByName;
+    private final List constructors;
+    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, 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");
+        if (constructors == null) throw new NullPointerException("constructors");
+
+        this.namespace = namespace;
+        this.elementName = elementName;
+        this.className = className;
+        this.description = description;
+        this.rootElement = rootElement;
+        this.initMethod = initMethod;
+        this.destroyMethod = destroyMethod;
+        this.factoryMethod = factoryMethod;
+        this.contentProperty = contentProperty;
+        this.constructors = constructors;
+        this.attributes = Collections.unmodifiableSet(new TreeSet(attributes));
+        this.maps = Collections.unmodifiableMap(maps);
+        this.flatProperties = Collections.unmodifiableList(flatProperties);
+        this.flatCollections = Collections.unmodifiableMap(flatCollections);
+        
+        Map attributesByName = new HashMap();
+        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+            AttributeMapping attribute = (AttributeMapping) iterator.next();
+            attributesByName.put(attribute.getAttributeName(), attribute);
+        }
+        this.attributesByName = Collections.unmodifiableMap(attributesByName);
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public String getElementName() {
+        return elementName;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public boolean isRootElement() {
+        return rootElement;
+    }
+
+    public String getInitMethod() {
+        return initMethod;
+    }
+
+    public String getDestroyMethod() {
+        return destroyMethod;
+    }
+
+    public String getFactoryMethod() {
+        return factoryMethod;
+    }
+
+    public String getContentProperty() {
+        return contentProperty;
+    }
+
+    public Set getAttributes() {
+        return attributes;
+    }
+
+    public AttributeMapping getAttribute(String attributeName) {
+        return (AttributeMapping) attributesByName.get(attributeName);
+    }
+
+    public Map getMapMappings() {
+        return maps;
+    }
+
+    public MapMapping getMapMapping(String name) {
+        return (MapMapping) maps.get(name);
+    }
+    
+    public Map getFlatCollections() {
+        return flatCollections;
+    }
+
+    public List getFlatProperties() {
+        return flatProperties;
+    }
+
+    public List getConstructors() {
+        return constructors;
+    }
+
+    public int hashCode() {
+        return elementName.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof ElementMapping) {
+            return elementName.equals(((ElementMapping) obj).elementName);
+        }
+        return false;
+    }
+
+    public int compareTo(Object obj) {
+        return elementName.compareTo(((ElementMapping) obj).elementName);
+    }
+
+	public HashSet getInterfaces() {
+		return interfaces;
+	}
+
+	public List getSuperClasses() {
+		return superClasses;
+	}
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ElementMapping.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.io.IOException;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public interface GeneratorPlugin {
+    void generate(NamespaceMapping namespaceMapping) throws IOException;
+    
+	LogFacade getLog();
+	void setLog(LogFacade log);
+
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/GeneratorPlugin.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class InvalidModelException extends RuntimeException {
+    public InvalidModelException(String message) {
+        super(message);
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/InvalidModelException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+public interface LogFacade {
+
+    void log(String message);
+    
+    void log(String message, int level);
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/LogFacade.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+public class MapMapping {
+    private String entryName;
+    private String keyName;
+    private boolean flat;
+    private String dupsMode;
+    private String defaultKey;
+
+    public MapMapping(String entryName, 
+                      String keyName, 
+                      boolean flat, 
+                      String dupsMode, 
+                      String defaultKey) {
+        this.entryName = entryName;
+        this.keyName = keyName;
+        this.flat = flat;
+        this.dupsMode = dupsMode;
+        this.defaultKey = defaultKey;
+    }
+
+    public String getEntryName() {
+        return entryName;
+    }
+
+    public String getKeyName() {
+        return keyName;
+    }
+
+    public boolean isFlat() {
+        return flat;
+    }
+
+    public String getDupsMode() {
+        return dupsMode;
+    }
+
+    public String getDefaultKey() {
+        return defaultKey;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MapMapping.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.Path;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.StringTokenizer;
+import java.beans.PropertyEditorManager;
+
+/**
+ * An Ant task for executing generating mapping metadata.
+ *
+ * @version $Revision$
+ */
+public class MappingGeneratorTask extends MatchingTask implements LogFacade {
+    private String namespace;
+    private Path srcDir;
+    private String excludedClasses = null;
+    private File destFile = new File("target/classes/schema.xsd");
+    private String metaInfDir = "target/classes/";
+    private String propertyEditorPaths = "org.apache.xbean.blueprint.context.impl";
+
+    public File getDestFile() {
+        return destFile;
+    }
+
+    public void setDestFile(File destFile) {
+        this.destFile = destFile;
+    }
+
+    public String getMetaInfDir() {
+        return metaInfDir;
+    }
+
+    public void setMetaInfDir(String metaInfDir) {
+        this.metaInfDir = metaInfDir;
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public Path getSrcDir() {
+        return srcDir;
+    }
+
+    public void setSrcDir(Path srcDir) {
+        this.srcDir = srcDir;
+    }
+
+    public String getPropertyEditorPaths() {
+        return propertyEditorPaths;
+    }
+
+    public void setPropertyEditorPaths(String propertyEditorPaths) {
+        this.propertyEditorPaths = propertyEditorPaths;
+    }
+
+    public void execute() throws BuildException {
+        if (namespace == null) {
+            throw new BuildException("'namespace' must be specified");
+        }
+        if (srcDir == null) {
+            throw new BuildException("'srcDir' must be specified");
+        }
+        if (destFile == null) {
+            throw new BuildException("'destFile' must be specified");
+        }
+
+        if (propertyEditorPaths != null) {
+            List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath()));
+            StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,");
+            editorSearchPath.addAll(Collections.list(paths));
+            PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()]));
+        }
+
+        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+        try {
+            String[] excludedClasses = null;
+            if (this.excludedClasses != null) {
+                excludedClasses = this.excludedClasses.split(" *, *");
+            }
+            MappingLoader mappingLoader = new QdoxMappingLoader(namespace, getFiles(srcDir), excludedClasses);
+
+            GeneratorPlugin[] plugins = new GeneratorPlugin[]{
+                new XmlMetadataGenerator(metaInfDir, destFile),
+                new DocumentationGenerator(destFile),
+                new XsdGenerator(destFile)
+            };
+
+            // load the mappings
+            Set namespaces = mappingLoader.loadNamespaces();
+            if (namespaces.isEmpty()) {
+                System.out.println("Warning: no namespaces found!");
+            }
+
+            // generate the files
+            for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) {
+                NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next();
+                for (int i = 0; i < plugins.length; i++) {
+                    GeneratorPlugin plugin = plugins[i];
+                    plugin.setLog(this);
+                    plugin.generate(namespaceMapping);
+                }
+            }
+
+            log("...done.");
+        } catch (Exception e) {
+            throw new BuildException(e);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCL);
+        }
+    }
+
+    private File[] getFiles(Path path) {
+        if (path == null) {
+            return null;
+        }
+        String[] paths = path.list();
+        File[] files = new File[paths.length];
+        for (int i = 0; i < files.length; i++) {
+            files[i] = new File(paths[i]).getAbsoluteFile();
+        }
+        return files;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingGeneratorTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public interface MappingLoader {
+    Set<NamespaceMapping> loadNamespaces() throws IOException;
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/MappingLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class NamespaceMapping implements Comparable {
+    private final String namespace;
+    private final Set elements;
+    private final Map elementsByName;
+    private final ElementMapping rootElement;
+
+    public NamespaceMapping(String namespace, Set elements, ElementMapping rootElement) {
+        this.namespace = namespace;
+        this.elements = Collections.unmodifiableSet(new TreeSet(elements));
+        this.rootElement = rootElement;
+
+        Map elementsByName = new HashMap();
+        for (Iterator iterator = elements.iterator(); iterator.hasNext();) {
+            ElementMapping elementMapping = (ElementMapping) iterator.next();
+            elementsByName.put(elementMapping.getElementName(), elementMapping);
+        }
+        this.elementsByName = Collections.unmodifiableMap(elementsByName);
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public Set getElements() {
+        return elements;
+    }
+
+    public ElementMapping getElement(String elementName) {
+        return (ElementMapping) elementsByName.get(elementName);
+    }
+
+    public ElementMapping getRootElement() {
+        return rootElement;
+    }
+
+    public int hashCode() {
+        return namespace.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof NamespaceMapping) {
+            return namespace.equals(((NamespaceMapping) obj).namespace);
+        }
+        return false;
+    }
+
+    public int compareTo(Object obj) {
+        return namespace.compareTo(((NamespaceMapping) obj).namespace);
+    }
+
+    private final HashMap checkedTypes = new HashMap();
+
+    public boolean isSimpleType(Type type) {
+        Boolean b = (Boolean) checkedTypes.get(type);
+        if (b == null){
+            b = Utils.isSimpleType(type)? Boolean.TRUE: Boolean.FALSE;
+            checkedTypes.put(type, b);
+        }
+        return b.booleanValue();
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/NamespaceMapping.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ParameterMapping {
+    private final String name;
+    private final Type type;
+
+    public ParameterMapping(String name, Type type) {
+        this.name = name;
+        this.type = type;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Type getType() {
+        return type;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/ParameterMapping.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,567 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.model.BeanProperty;
+import com.thoughtworks.qdox.model.DocletTag;
+import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaParameter;
+import com.thoughtworks.qdox.model.JavaSource;
+import com.thoughtworks.qdox.model.Type;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class QdoxMappingLoader implements MappingLoader {
+    public static final String XBEAN_ANNOTATION = "org.apache.xbean.XBean";
+    public static final String PROPERTY_ANNOTATION = "org.apache.xbean.Property";
+    public static final String INIT_METHOD_ANNOTATION = "org.apache.xbean.InitMethod";
+    public static final String DESTROY_METHOD_ANNOTATION = "org.apache.xbean.DestroyMethod";
+    public static final String FACTORY_METHOD_ANNOTATION = "org.apache.xbean.FactoryMethod";
+    public static final String MAP_ANNOTATION = "org.apache.xbean.Map";
+    public static final String FLAT_PROPERTY_ANNOTATION = "org.apache.xbean.Flat";
+    public static final String FLAT_COLLECTION_ANNOTATION = "org.apache.xbean.FlatCollection";
+    public static final String ELEMENT_ANNOTATION = "org.apache.xbean.Element";
+
+    private static final Log log = LogFactory.getLog(QdoxMappingLoader.class);
+    private final String defaultNamespace;
+    private final File[] srcDirs;
+    private final String[] excludedClasses;
+    private Type collectionType;
+
+    public QdoxMappingLoader(String defaultNamespace, File[] srcDirs, String[] excludedClasses) {
+        this.defaultNamespace = defaultNamespace;
+        this.srcDirs = srcDirs;
+        this.excludedClasses = excludedClasses;
+    }
+
+    public String getDefaultNamespace() {
+        return defaultNamespace;
+    }
+
+    public File[] getSrcDirs() {
+        return srcDirs;
+    }
+
+    public Set<NamespaceMapping> loadNamespaces() throws IOException {
+        JavaDocBuilder builder = new JavaDocBuilder();
+
+        log.debug("Source directories: ");
+
+        for (File sourceDirectory : srcDirs) {
+            if (!sourceDirectory.isDirectory() && !sourceDirectory.toString().endsWith(".jar")) {
+                log.warn("Specified source directory isn't a directory or a jar file: '" + sourceDirectory.getAbsolutePath() + "'.");
+            }
+            log.debug(" - " + sourceDirectory.getAbsolutePath());
+
+            getSourceFiles(sourceDirectory, excludedClasses, builder);
+        }
+
+        collectionType = builder.getClassByName("java.util.Collection").asType();
+        return loadNamespaces(builder);
+    }
+
+    private Set<NamespaceMapping> loadNamespaces(JavaDocBuilder builder) {
+        // load all of the elements
+        List<ElementMapping> elements = loadElements(builder);
+
+        // index the elements by namespace and find the root element of each namespace
+        Map<String, Set<ElementMapping>> elementsByNamespace = new HashMap<String, Set<ElementMapping>>();
+        Map<String, ElementMapping> namespaceRoots = new HashMap<String, ElementMapping>();
+        for (ElementMapping element : elements) {
+            String namespace = element.getNamespace();
+            Set<ElementMapping> namespaceElements = elementsByNamespace.get(namespace);
+            if (namespaceElements == null) {
+                namespaceElements = new HashSet<ElementMapping>();
+                elementsByNamespace.put(namespace, namespaceElements);
+            }
+            namespaceElements.add(element);
+            if (element.isRootElement()) {
+                if (namespaceRoots.containsKey(namespace)) {
+                    log.info("Multiple root elements found for namespace " + namespace);
+                }
+                namespaceRoots.put(namespace, element);
+            }
+        }
+
+        // build the NamespaceMapping objects
+        Set<NamespaceMapping> namespaces = new TreeSet<NamespaceMapping>();
+        for (Map.Entry<String, Set<ElementMapping>> entry : elementsByNamespace.entrySet()) {
+            String namespace = entry.getKey();
+            Set namespaceElements = entry.getValue();
+            ElementMapping rootElement = namespaceRoots.get(namespace);
+            NamespaceMapping namespaceMapping = new NamespaceMapping(namespace, namespaceElements, rootElement);
+            namespaces.add(namespaceMapping);
+        }
+        return Collections.unmodifiableSet(namespaces);
+    }
+
+    private List<ElementMapping> loadElements(JavaDocBuilder builder) {
+        JavaSource[] javaSources = builder.getSources();
+        List<ElementMapping> elements = new ArrayList<ElementMapping>();
+        for (JavaSource javaSource : javaSources) {
+            if (javaSource.getClasses().length == 0) {
+                log.info("No Java Classes defined in: " + javaSource.getURL());
+            } else {
+                JavaClass[] classes = javaSource.getClasses();
+                for (JavaClass javaClass : classes) {
+                    ElementMapping element = loadElement(builder, javaClass);
+                    if (element != null && !javaClass.isAbstract()) {
+                        elements.add(element);
+                    } else {
+                        log.debug("No XML annotation found for type: " + javaClass.getFullyQualifiedName());
+                    }
+                }
+            }
+        }
+        return elements;
+    }
+
+    private ElementMapping loadElement(JavaDocBuilder builder, JavaClass javaClass) {
+        DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION);
+        if (xbeanTag == null) {
+            return null;
+        }
+
+        String element = getElementName(javaClass, xbeanTag);
+        String description = getProperty(xbeanTag, "description");
+        if (description == null) {
+            description = javaClass.getComment();
+
+        }
+        String namespace = getProperty(xbeanTag, "namespace", defaultNamespace);
+        boolean root = getBooleanProperty(xbeanTag, "rootElement");
+        String contentProperty = getProperty(xbeanTag, "contentProperty");
+        String factoryClass = getProperty(xbeanTag, "factoryClass");
+
+        Map<String, MapMapping> mapsByPropertyName = new HashMap<String, MapMapping>();
+        List<String> flatProperties = new ArrayList<String>();
+        Map<String, String> flatCollections = new HashMap<String, String>();
+        Set<AttributeMapping> attributes = new HashSet<AttributeMapping>();
+        Map<String, AttributeMapping> attributesByPropertyName = new HashMap<String, AttributeMapping>();
+
+        for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
+            BeanProperty[] beanProperties = jClass.getBeanProperties();
+            for (BeanProperty beanProperty : beanProperties) {
+                // we only care about properties with a setter
+                if (beanProperty.getMutator() != null) {
+                    AttributeMapping attributeMapping = loadAttribute(beanProperty, "");
+                    if (attributeMapping != null) {
+                        attributes.add(attributeMapping);
+                        attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+                    }
+                    JavaMethod acc = beanProperty.getAccessor();
+                    if (acc != null) {
+                        DocletTag mapTag = acc.getTagByName(MAP_ANNOTATION);
+                        if (mapTag != null) {
+                            MapMapping mm = new MapMapping(
+                                    mapTag.getNamedParameter("entryName"),
+                                    mapTag.getNamedParameter("keyName"),
+                                    Boolean.valueOf(mapTag.getNamedParameter("flat")),
+                                    mapTag.getNamedParameter("dups"),
+                                    mapTag.getNamedParameter("defaultKey"));
+                            mapsByPropertyName.put(beanProperty.getName(), mm);
+                        }
+
+                        DocletTag flatColTag = acc.getTagByName(FLAT_COLLECTION_ANNOTATION);
+                        if (flatColTag != null) {
+                            String childName = flatColTag.getNamedParameter("childElement");
+                            if (childName == null)
+                                throw new InvalidModelException("Flat collections must specify the childElement attribute.");
+                            flatCollections.put(beanProperty.getName(), childName);
+                        }
+
+                        DocletTag flatPropTag = acc.getTagByName(FLAT_PROPERTY_ANNOTATION);
+                        if (flatPropTag != null) {
+                            flatProperties.add(beanProperty.getName());
+                        }
+                    }
+                }
+            }
+        }
+
+        String initMethod = null;
+        String destroyMethod = null;
+        String factoryMethod = null;
+        for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
+            JavaMethod[] methods = javaClass.getMethods();
+            for (JavaMethod method : methods) {
+                if (method.isPublic() && !method.isConstructor()) {
+                    if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) {
+                        initMethod = method.getName();
+                    }
+                    if (destroyMethod == null && method.getTagByName(DESTROY_METHOD_ANNOTATION) != null) {
+                        destroyMethod = method.getName();
+                    }
+                    if (factoryMethod == null && method.getTagByName(FACTORY_METHOD_ANNOTATION) != null) {
+                        factoryMethod = method.getName();
+                    }
+
+                }
+            }
+        }
+
+        List<List<ParameterMapping>> constructorArgs = new ArrayList<List<ParameterMapping>>();
+        JavaMethod[] methods = javaClass.getMethods();
+        for (JavaMethod method : methods) {
+            JavaParameter[] parameters = method.getParameters();
+            if (isValidConstructor(factoryMethod, method, parameters)) {
+                List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.length);
+                for (JavaParameter parameter : parameters) {
+                    AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
+                    if (attributeMapping == null) {
+                        attributeMapping = loadParameter(parameter);
+
+                        attributes.add(attributeMapping);
+                        attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+                    }
+                    args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
+                }
+                constructorArgs.add(Collections.unmodifiableList(args));
+            }
+        }
+
+        HashSet<String> interfaces = new HashSet<String>();
+        interfaces.addAll(getFullyQualifiedNames(javaClass.getImplementedInterfaces()));
+
+        JavaClass actualClass = javaClass;
+        if (factoryClass != null) {
+            JavaClass clazz = builder.getClassByName(factoryClass);
+            if (clazz != null) {
+                log.info("Detected factory: using " + factoryClass + " instead of " + javaClass.getFullyQualifiedName());
+                actualClass = clazz;
+            } else {
+                log.info("Could not load class built by factory: " + factoryClass);
+            }
+        }
+
+        ArrayList<String> superClasses = new ArrayList<String>();
+        JavaClass p = actualClass;
+        if (actualClass != javaClass) {
+            superClasses.add(actualClass.getFullyQualifiedName());
+        }
+        while (true) {
+            JavaClass s = p.getSuperJavaClass();
+            if (s == null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName())) {
+                break;
+            }
+            p = s;
+            superClasses.add(p.getFullyQualifiedName());
+            interfaces.addAll(getFullyQualifiedNames(p.getImplementedInterfaces()));
+        }
+
+        return new ElementMapping(namespace,
+                element,
+                javaClass.getFullyQualifiedName(),
+                description,
+                root,
+                initMethod,
+                destroyMethod,
+                factoryMethod,
+                contentProperty,
+                attributes,
+                constructorArgs,
+                flatProperties,
+                mapsByPropertyName,
+                flatCollections,
+                superClasses,
+                interfaces);
+    }
+
+    private List<String> getFullyQualifiedNames(JavaClass[] implementedInterfaces) {
+        ArrayList<String> l = new ArrayList<String>();
+        for (JavaClass implementedInterface : implementedInterfaces) {
+            l.add(implementedInterface.getFullyQualifiedName());
+        }
+        return l;
+    }
+
+    private String getElementName(JavaClass javaClass, DocletTag tag) {
+        String elementName = getProperty(tag, "element");
+        if (elementName == null) {
+            String className = javaClass.getFullyQualifiedName();
+            int index = className.lastIndexOf(".");
+            if (index > 0) {
+                className = className.substring(index + 1);
+            }
+            // strip off "Bean" from a spring factory bean
+            if (className.endsWith("FactoryBean")) {
+                className = className.substring(0, className.length() - 4);
+            }
+            elementName = Utils.decapitalise(className);
+        }
+        return elementName;
+    }
+
+    private AttributeMapping loadAttribute(BeanProperty beanProperty, String defaultDescription) {
+        DocletTag propertyTag = getPropertyTag(beanProperty);
+
+        if (getBooleanProperty(propertyTag, "hidden")) {
+            return null;
+        }
+
+        String attribute = getProperty(propertyTag, "alias", beanProperty.getName());
+        String attributeDescription = getAttributeDescription(beanProperty, propertyTag, defaultDescription);
+        String defaultValue = getProperty(propertyTag, "default");
+        boolean fixed = getBooleanProperty(propertyTag, "fixed");
+        boolean required = getBooleanProperty(propertyTag, "required");
+        String nestedType = getProperty(propertyTag, "nestedType");
+        String propertyEditor = getProperty(propertyTag, "propertyEditor");
+
+        return new AttributeMapping(attribute,
+                beanProperty.getName(),
+                attributeDescription,
+                toMappingType(beanProperty.getType(), nestedType),
+                defaultValue,
+                fixed,
+                required,
+                propertyEditor);
+    }
+
+    private static DocletTag getPropertyTag(BeanProperty beanProperty) {
+        JavaMethod accessor = beanProperty.getAccessor();
+        if (accessor != null) {
+            DocletTag propertyTag = accessor.getTagByName(PROPERTY_ANNOTATION);
+            if (propertyTag != null) {
+                return propertyTag;
+            }
+        }
+        JavaMethod mutator = beanProperty.getMutator();
+        if (mutator != null) {
+            DocletTag propertyTag = mutator.getTagByName(PROPERTY_ANNOTATION);
+            if (propertyTag != null) {
+                return propertyTag;
+            }
+        }
+        return null;
+    }
+
+    private String getAttributeDescription(BeanProperty beanProperty, DocletTag propertyTag, String defaultDescription) {
+        String description = getProperty(propertyTag, "description");
+        if (description != null && description.trim().length() > 0) {
+            return description.trim();
+        }
+
+        JavaMethod accessor = beanProperty.getAccessor();
+        if (accessor != null) {
+            description = accessor.getComment();
+            if (description != null && description.trim().length() > 0) {
+                return description.trim();
+            }
+        }
+
+        JavaMethod mutator = beanProperty.getMutator();
+        if (mutator != null) {
+            description = mutator.getComment();
+            if (description != null && description.trim().length() > 0) {
+                return description.trim();
+            }
+        }
+        return defaultDescription;
+    }
+
+    private AttributeMapping loadParameter(JavaParameter parameter) {
+        String parameterName = parameter.getName();
+        String parameterDescription = getParameterDescription(parameter);
+
+        // first attempt to load the attribute from the java beans accessor methods
+        JavaClass javaClass = parameter.getParentMethod().getParentClass();
+        BeanProperty beanProperty = javaClass.getBeanProperty(parameterName);
+        if (beanProperty != null) {
+            AttributeMapping attributeMapping = loadAttribute(beanProperty, parameterDescription);
+            // if the attribute mapping is null, the property was tagged as hidden and this is an error
+            if (attributeMapping == null) {
+                throw new InvalidModelException("Hidden property usage: " +
+                        "The construction method " + toMethodLocator(parameter.getParentMethod()) +
+                        " can not use a hidded property " + parameterName);
+            }
+            return attributeMapping;
+        }
+
+        // create an attribute solely based on the parameter information
+        return new AttributeMapping(parameterName,
+                parameterName,
+                parameterDescription,
+                toMappingType(parameter.getType(), null),
+                null,
+                false,
+                false,
+                null);
+    }
+
+    private String getParameterDescription(JavaParameter parameter) {
+        String parameterName = parameter.getName();
+        DocletTag[] tags = parameter.getParentMethod().getTagsByName("param");
+        for (DocletTag tag : tags) {
+            if (tag.getParameters()[0].equals(parameterName)) {
+                String parameterDescription = tag.getValue().trim();
+                if (parameterDescription.startsWith(parameterName)) {
+                    parameterDescription = parameterDescription.substring(parameterName.length()).trim();
+                }
+                return parameterDescription;
+            }
+        }
+        return null;
+    }
+
+    private boolean isValidConstructor(String factoryMethod, JavaMethod method, JavaParameter[] parameters) {
+        if (!method.isPublic() || parameters.length == 0) {
+            return false;
+        }
+
+        if (factoryMethod == null) {
+            return method.isConstructor();
+        } else {
+            return method.getName().equals(factoryMethod);
+        }
+    }
+
+    private static String getProperty(DocletTag propertyTag, String propertyName) {
+        return getProperty(propertyTag, propertyName, null);
+    }
+
+    private static String getProperty(DocletTag propertyTag, String propertyName, String defaultValue) {
+        String value = null;
+        if (propertyTag != null) {
+            value = propertyTag.getNamedParameter(propertyName);
+        }
+        if (value == null) {
+            return defaultValue;
+        }
+        return value;
+    }
+
+    private boolean getBooleanProperty(DocletTag propertyTag, String propertyName) {
+        return toBoolean(getProperty(propertyTag, propertyName));
+    }
+
+    private static boolean toBoolean(String value) {
+        if (value != null) {
+            return Boolean.valueOf(value);
+        }
+        return false;
+    }
+
+    private org.apache.xbean.blueprint.generator.Type toMappingType(Type type, String nestedType) {
+        try {
+            if (type.isArray()) {
+                return org.apache.xbean.blueprint.generator.Type.newArrayType(type.getValue(), type.getDimensions());
+            } else if (type.isA(collectionType)) {
+                if (nestedType == null) nestedType = "java.lang.Object";
+                return org.apache.xbean.blueprint.generator.Type.newCollectionType(type.getValue(),
+                        org.apache.xbean.blueprint.generator.Type.newSimpleType(nestedType));
+            }
+        } catch (Throwable t) {
+            log.debug("Could not load type mapping", t);
+        }
+        return org.apache.xbean.blueprint.generator.Type.newSimpleType(type.getValue());
+    }
+
+    private static String toMethodLocator(JavaMethod method) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(method.getParentClass().getFullyQualifiedName());
+        if (!method.isConstructor()) {
+            buf.append(".").append(method.getName());
+        }
+        buf.append("(");
+        JavaParameter[] parameters = method.getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            JavaParameter parameter = parameters[i];
+            if (i > 0) {
+                buf.append(", ");
+            }
+            buf.append(parameter.getName());
+        }
+        buf.append(") : ").append(method.getLineNumber());
+        return buf.toString();
+    }
+
+    private static void getSourceFiles(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+        if (base.isDirectory()) {
+            listAllFileNames(base, "", excludedClasses, builder);
+        } else {
+            listAllJarEntries(base, excludedClasses, builder);
+        }
+    }
+
+    private static void listAllFileNames(File base, String prefix, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+        if (!base.canRead() || !base.isDirectory()) {
+            throw new IllegalArgumentException(base.getAbsolutePath());
+        }
+        File[] hits = base.listFiles();
+        for (File hit : hits) {
+            String name = prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName();
+            if (hit.canRead() && !isExcluded(name, excludedClasses)) {
+                if (hit.isDirectory()) {
+                    listAllFileNames(hit, name, excludedClasses, builder);
+                } else if (name.endsWith(".java")) {
+                    builder.addSource(hit);
+                }
+            }
+        }
+    }
+
+    private static void listAllJarEntries(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+        JarFile jarFile = new JarFile(base);
+        for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+            if (name.endsWith(".java") && !isExcluded(name, excludedClasses) && !name.endsWith("/package-info.java")) {
+                builder.addSource(new URL("jar:" + base.toURL().toString() + "!/" + name));
+            }
+        }
+    }
+
+    private static boolean isExcluded(String sourceName, String[] excludedClasses) {
+        if (excludedClasses == null) {
+            return false;
+        }
+
+        String className = sourceName;
+        if (sourceName.endsWith(".java")) {
+            className = className.substring(0, className.length() - ".java".length());
+        }
+        className = className.replace('/', '.');
+        for (String excludedClass : excludedClasses) {
+            if (className.equals(excludedClass)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @version $Revision$
+ */
+public class SchemaGenerator {
+    private final MappingLoader mappingLoader;
+    private final GeneratorPlugin[] plugins;
+    private final LogFacade log;
+
+    public SchemaGenerator(LogFacade log, MappingLoader mappingLoader, GeneratorPlugin[] plugins) {
+        this.log = log;
+        this.mappingLoader = mappingLoader;
+        this.plugins = plugins;
+    }
+
+    public void generate() throws IOException {
+        Set namespaces = mappingLoader.loadNamespaces();
+        if (namespaces.isEmpty()) {
+            log.log("Warning: no namespaces found!");
+        }
+
+        for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) {
+            NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next();
+            for (int i = 0; i < plugins.length; i++) {
+                GeneratorPlugin plugin = plugins[i];
+                plugin.generate(namespaceMapping);
+            }
+        }
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/SchemaGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class Type {
+    private final String name;
+    private final Type nestedType;
+    private final boolean primitive;
+
+    public static Type newSimpleType(String name) {
+        if (name == null) throw new NullPointerException("type");
+        if (name.indexOf("[") >= 0 || name.indexOf("]") >= 0) {
+            throw new IllegalArgumentException("Name can not contain '[' or ']' " + name);
+        }
+        return new Type(name, null);
+    }
+
+    public static Type newArrayType(String type, int dimensions) {
+        if (type == null) throw new NullPointerException("type");
+        if (dimensions < 1) throw new IllegalArgumentException("dimensions must be atleast one");
+        StringBuffer buf = new StringBuffer(type.length() + (dimensions * 2));
+        buf.append(type);
+        for (int i = 0; i < dimensions; i ++) {
+            buf.append("[]");
+        }
+        return new Type(buf.toString(), newSimpleType(type));
+    }
+
+    public static Type newCollectionType(String collectionType, Type elementType) {
+        if (collectionType == null) throw new NullPointerException("collectionType");
+        if (elementType == null) throw new NullPointerException("elementType");
+        return new Type(collectionType, elementType);
+    }
+
+    private Type(String name, Type nestedType) {
+        this.name = name;
+        this.nestedType = nestedType;
+        primitive = (nestedType == null) && primitives.contains(name);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Type getNestedType() {
+        return nestedType;
+    }
+
+    public boolean isCollection() {
+        return nestedType != null;
+    }
+
+    public boolean isPrimitive() {
+        return primitive;
+    }
+
+    public int hashCode() {
+        return super.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        return super.equals(obj);
+    }
+
+    private static final Set primitives;
+
+    static {
+        Set set = new HashSet();
+        set.add("boolean");
+        set.add("byte");
+        set.add("char");
+        set.add("short");
+        set.add("int");
+        set.add("long");
+        set.add("float");
+        set.add("double");
+        primitives = Collections.unmodifiableSet(set);
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Type.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java?rev=896187&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java (added)
+++ geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java Tue Jan  5 19:31:05 2010
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.xbean.blueprint.generator;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public final class Utils {
+    public static final String XBEAN_ANNOTATION = "org.apache.xbean.XBean";
+    public static final String PROPERTY_ANNOTATION = "org.apache.xbean.Property";
+
+    private Utils() {
+    }
+
+    public static String decapitalise(String value) {
+        if (value == null || value.length() == 0) {
+            return value;
+        }
+        return value.substring(0, 1).toLowerCase() + value.substring(1);
+    }
+
+    public static boolean isSimpleType(Type type) {
+        if (type.isPrimitive()) {
+            return true;
+        }
+        if (type.isCollection()) {
+            return false;
+        }
+
+        String name = type.getName();
+        if (name.equals("java.lang.Class") ||
+                name.equals("javax.xml.namespace.QName")) {
+            return true;
+        }
+        return hasPropertyEditor(name);
+    }
+
+    private static boolean hasPropertyEditor(String type) {
+        Class theClass;
+        try {
+            theClass = loadClass(type);
+            // lets see if we can find a property editor for this type
+            PropertyEditor editor = PropertyEditorManager.findEditor(theClass);
+            return editor != null;
+        } catch (Throwable e) {
+            System.out.println("Warning, could not load class: " + type + ": " + e);
+            return false;
+        }
+    }
+
+    /**
+     * Attempts to load the class on the current thread context class loader or
+     * the class loader which loaded us
+     */
+    private static Class loadClass(String name) throws ClassNotFoundException {
+        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+        if (contextClassLoader != null) {
+            try {
+                return contextClassLoader.loadClass(name);
+            } catch (ClassNotFoundException e) {
+            }
+        }
+        return Utils.class.getClassLoader().loadClass(name);
+    }
+
+    public static String getXsdType(Type type) {
+        String name = type.getName();
+        String xsdType = (String) XSD_TYPES.get(name);
+        if (xsdType == null) {
+            xsdType = "xs:string";
+        }
+        return xsdType;
+    }
+
+    public static final Map XSD_TYPES;
+
+    static {
+        // TODO check these XSD types are right...
+        Map map = new HashMap();
+        map.put(String.class.getName(), "xs:string");
+        map.put(Boolean.class.getName(), "xs:boolean");
+        map.put(boolean.class.getName(), "xs:boolean");
+        map.put(Byte.class.getName(), "xs:byte");
+        map.put(byte.class.getName(), "xs:byte");
+        map.put(Short.class.getName(), "xs:short");
+        map.put(short.class.getName(), "xs:short");
+        map.put(Integer.class.getName(), "xs:integer");
+        map.put(int.class.getName(), "xs:integer");
+        map.put(Long.class.getName(), "xs:long");
+        map.put(long.class.getName(), "xs:long");
+        map.put(Float.class.getName(), "xs:float");
+        map.put(float.class.getName(), "xs:float");
+        map.put(Double.class.getName(), "xs:double");
+        map.put(double.class.getName(), "xs:double");
+        map.put(java.util.Date.class.getName(), "xs:date");
+        map.put(java.sql.Date.class.getName(), "xs:date");
+        map.put("javax.xml.namespace.QName", "xs:QName");
+        XSD_TYPES = Collections.unmodifiableMap(map);
+    }
+
+    public static List findImplementationsOf(NamespaceMapping namespaceMapping, Type type) {
+        List elements = new ArrayList();
+        String nestedTypeName = type.getName();
+        for (Iterator iter = namespaceMapping.getElements().iterator(); iter.hasNext();) {
+            ElementMapping element = (ElementMapping) iter.next();
+            if (element.getClassName().equals(nestedTypeName) ||
+                element.getInterfaces().contains(nestedTypeName) ||
+                element.getSuperClasses().contains(nestedTypeName)) 
+            {
+                elements.add(element);
+            }
+        }
+        return elements;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/Utils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message