Search in sources :

Example 11 with SuperProperties

use of org.apache.openejb.util.SuperProperties in project tomee by apache.

the class WikiGenerator method generateService.

private void generateService(final ServiceProvider provider, final String serviceType) {
    final String type = provider.getTypes().get(0);
    out.println("# " + type + " <small>" + serviceType + " </small>");
    out.println();
    out.println("Declarable in openejb.xml via");
    out.println();
    out.println("    <" + provider.getService() + " id=\"Foo\" type=\"" + type + "\">");
    out.println("    </" + provider.getService() + ">");
    out.println();
    out.println("Declarable in properties via");
    out.println();
    out.println("    Foo = new://" + provider.getService() + "?type=" + type);
    out.println();
    final SuperProperties properties = (SuperProperties) provider.getProperties();
    final Map<String, String> defaults = new LinkedHashMap<String, String>();
    if (properties.size() > 0) {
        out.println("## Properties");
        out.println();
        for (final Object key : properties.keySet()) {
            if (key instanceof String) {
                final String name = (String) key;
                final Map<String, String> attributes = properties.getAttributes(name);
                if (attributes.containsKey("hidden")) {
                    continue;
                }
                out.println("### " + key);
                out.println();
                final String value = properties.getProperty(name);
                String comment = properties.getComment(name);
                comment = scrubText(comment);
                defaults.put(name, String.valueOf(value));
                if (comment.length() == 0) {
                    comment = "No description.";
                }
                out.println(comment);
                out.println();
            }
        }
        out.println("## Default declaration");
        out.println("    <" + provider.getService() + " id=\"" + provider.getId() + "\" type=\"" + type + "\">");
        for (final Map.Entry<String, String> entry : defaults.entrySet()) {
            out.print("        ");
            out.print(entry.getKey());
            out.print(" = ");
            out.println(entry.getValue());
        }
        out.println("    </" + provider.getService() + ">");
    } else {
        out.println("No properties.");
    }
    out.println();
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SuperProperties(org.apache.openejb.util.SuperProperties) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SuperProperties (org.apache.openejb.util.SuperProperties)11 Map (java.util.Map)5 Properties (java.util.Properties)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 PrintWriter (java.io.PrintWriter)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 NamingException (javax.naming.NamingException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 ObjectRecipe (org.apache.xbean.recipe.ObjectRecipe)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 InvalidObjectException (java.io.InvalidObjectException)1 ObjectStreamException (java.io.ObjectStreamException)1 Serializable (java.io.Serializable)1 Type (java.lang.reflect.Type)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1