You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2008/01/22 01:26:04 UTC

svn commit: r614070 - in /openejb/trunk/openejb3/container/openejb-core/src/main: java/org/apache/openejb/config/sys/ServiceProvider.java java/org/apache/openejb/config/sys/WikiGenerator.java resources/META-INF/org.apache.openejb/service-jar.xml

Author: dain
Date: Mon Jan 21 16:26:03 2008
New Revision: 614070

URL: http://svn.apache.org/viewvc?rev=614070&view=rev
Log:
Added simple documentation generator for service provider file

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/ServiceProvider.java
    openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/ServiceProvider.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/ServiceProvider.java?rev=614070&r1=614069&r2=614070&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/ServiceProvider.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/ServiceProvider.java Mon Jan 21 16:26:03 2008
@@ -17,6 +17,9 @@
  */
 package org.apache.openejb.config.sys;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -24,9 +27,8 @@
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.Properties;
-import java.util.List;
-import java.util.ArrayList;
+
+import org.apache.openejb.util.SuperProperties;
 
 
 /**
@@ -97,7 +99,7 @@
      */
     public Properties getProperties() {
         if (properties == null) {
-            properties = new Properties();
+            properties = new SuperProperties();
         }
         return properties;
     }

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java?rev=614070&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/sys/WikiGenerator.java Mon Jan 21 16:26:03 2008
@@ -0,0 +1,139 @@
+/**
+ *
+ * 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.openejb.config.sys;
+
+import java.io.PrintWriter;
+import java.util.Map;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.util.SuperProperties;
+
+public class WikiGenerator {
+    public static void main(String[] args) throws Exception {
+        System.out.println();
+        System.out.println();
+        System.out.println();
+        
+        new WikiGenerator("org.apache.openejb").generate(new PrintWriter(System.out));
+
+        System.out.println();
+        System.out.println();
+        System.out.println();
+    }
+
+    protected ServicesJar servicesJar;
+
+    public WikiGenerator(String providerName) throws OpenEJBException {
+        servicesJar = JaxbOpenejb.readServicesJar(providerName);
+    }
+
+    public WikiGenerator(ServicesJar servicesJar) {
+        this.servicesJar = servicesJar;
+    }
+
+    public void generate(PrintWriter out) throws Exception {
+
+        // generate containers
+        out.println("{anchor: containers}");
+        out.println("h2. Containers");
+        for (ServiceProvider provider : servicesJar.getServiceProvider()) {
+            if ("Container".equals(provider.getService())) {
+                generateService(out, provider, "container");
+            }
+        }
+        out.println();
+
+        out.println("{anchor: resources}");
+        out.println("h2. Resources");
+        for (ServiceProvider provider : servicesJar.getServiceProvider()) {
+            if ("Resource".equals(provider.getService())) {
+                generateService(out, provider, "resource");
+            }
+        }
+        out.println();
+        out.flush();
+    }
+
+    private void generateService(PrintWriter out, ServiceProvider provider, String serviceType) {
+        out.println("{anchor:" + provider.getId() + "-" + serviceType + "}");
+        out.println("h3. " + provider.getId() );
+
+//        out.println("    class: " + provider.getClassName());
+//
+//        if (provider.getFactoryName() != null) {
+//            out.println("    factory-method: " + provider.getFactoryName());
+//        }
+
+        SuperProperties properties = (SuperProperties) provider.getProperties();
+        if (properties.size() > 0) {
+            out.println("    || Property Name || Description ||");
+
+            for (Object key : properties.keySet()) {
+                if (key instanceof String) {
+                    String name = (String) key;
+
+                    Map<String, String> attributes = properties.getAttributes(name);
+                    if (!attributes.containsKey("hidden")) {
+                        String value = properties.getProperty(name);
+                        String comment = properties.getComment(name);
+
+                        comment = scrubText(comment);
+
+                        if (value != null && value.length() > 0) {
+                            if (comment.length() > 0) {
+                                comment += "\\\\ \\\\ ";
+                            }
+                            comment += "Default value is _" + scrubText(value) + "_.|";
+                        }
+
+                        if (comment.length() == 0) comment = "No description.";
+
+                        out.println("    | " + name + " | " + comment + "|");
+                    }
+                }
+            }
+        } else {
+            out.println("No properties.");
+        }
+        out.println();
+    }
+
+    private String scrubText(String text) {
+        if (text == null) text = "";
+        text = text.replaceAll("\r?\n", "\\\\\\\\ ");
+        text = text.replaceAll("\\*", "\\\\*");
+        text = text.replaceAll("\\_", "\\\\_");
+        text = text.replaceAll("\\?", "\\\\?");
+        text = text.replaceAll("\\-", "\\\\-");
+        text = text.replaceAll("\\^", "\\\\^");
+        text = text.replaceAll("\\~", "\\\\~");
+        text = text.replaceAll("\\#", "\\\\#");
+        text = text.replaceAll("\\[", "\\\\[");
+        text = text.replaceAll("\\]", "\\\\]");
+        text = text.replaceAll("\\{", "\\\\{");
+        text = text.replaceAll("\\}", "\\\\}");
+        text = text.replaceAll("\\(", "\\\\(");
+        text = text.replaceAll("\\)", "\\\\)");
+        text = text.replaceAll("http:", "{html}http:{html}");
+        text = text.replaceAll("file:", "{html}file:{html}");
+        text = text.replaceAll("    ", "{html}&nbsp;&nbsp;&nbsp;&nbsp;{html}");
+        text = text.replaceAll("   ", "{html}&nbsp;&nbsp;&nbsp;{html}");
+        text = text.replaceAll("  ", "{html}&nbsp;&nbsp;{html}");
+        return text;
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml?rev=614070&r1=614069&r2=614070&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml Mon Jan 21 16:26:03 2008
@@ -51,12 +51,15 @@
 
     CmpEngineFactory org.apache.openejb.core.cmp.jpa.JpaCmpEngineFactory
 
-    #Engine  derby
+    # Engine  derby
+    # @hidden
+
     Engine  instantdb
 
 
     # ConnectorName is he id of the Connector element which
     # should provide connectivity for this CMP Container
+    # @hidden
 
     ConnectorName  Default JDBC Database
   </ServiceProvider>
@@ -298,7 +301,7 @@
     # If not set then the setReadOnly method will not be called.
     # (Some drivers don't support read only mode, ex: Informix)
 
-    # DefaultReadOnly
+    DefaultReadOnly
 
 
     # The default TransactionIsolation state of new connections
@@ -312,7 +315,7 @@
     #
     # Note: Most JDBC drivers do not support all isolation levels
 
-    # DefaultTransactionIsolation
+    DefaultTransactionIsolation
 
 
     # The initial number of connections that are created when the
@@ -350,7 +353,7 @@
     # this query MUST be an SQL SELECT statement that returns at
     # least one row.
 
-    # ValidationQuery
+    ValidationQuery
 
     # If true connections will be validated before being returned
     # from the pool. If the validation fails, the connection is
@@ -450,22 +453,18 @@
 
     # Driver class name
 
-    #JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
     JdbcDriver org.hsqldb.jdbcDriver
 
     # Url for creating connections
 
-    #JdbcUrl jdbc:derby:derbyDB;create=true
     JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb
 
     # Default user name
 
-    #UserName admin
     UserName sa
 
     # Default password
 
-    #Password pass
     Password
 
     # The connection properties that will be sent to the JDBC
@@ -486,7 +485,7 @@
     # If not set then the setReadOnly method will not be called.
     # (Some drivers don't support read only mode, ex: Informix)
 
-    # DefaultReadOnly
+    DefaultReadOnly
 
 
     # The default TransactionIsolation state of new connections
@@ -500,7 +499,7 @@
     #
     # Note: Most JDBC drivers do not support all isolation levels
 
-    # DefaultTransactionIsolation
+    DefaultTransactionIsolation
 
 
     # The initial number of connections that are created when the
@@ -538,7 +537,7 @@
     # this query MUST be an SQL SELECT statement that returns at
     # least one row.
 
-    # ValidationQuery
+    ValidationQuery
 
     # If true connections will be validated before being returned
     # from the pool. If the validation fails, the connection is
@@ -682,6 +681,9 @@
           types="javax.jms.Queue, Queue"
           constructor="destination"
           class-name="org.apache.activemq.command.ActiveMQQueue">
+
+    # Specifies the name of the queue
+
     destination
   </ServiceProvider>
 
@@ -691,6 +693,9 @@
           types="javax.jms.Topic, Topic"
           constructor="destination"
           class-name="org.apache.activemq.command.ActiveMQTopic">
+
+    # Specifies the name of the topic
+
     destination
   </ServiceProvider>