You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:49:51 UTC

[sling-org-apache-sling-jcr-webconsole] 18/29: SLING-2561 - adding a configuration printer for repository descriptors

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.webconsole-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-webconsole.git

commit e50cabdb16a36a5fd380a882a54d14a5f9ae237c
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Thu Aug 16 02:03:49 2012 +0000

    SLING-2561 - adding a configuration printer for repository descriptors
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/webconsole@1373694 13f79535-47bb-0310-9956-ffa450edef68
---
 .../internal/DescriptorsConfigurationPrinter.java  | 74 ++++++++++++++++++++++
 .../OSGI-INF/metatype/metatype.properties          |  3 +
 2 files changed, 77 insertions(+)

diff --git a/src/main/java/org/apache/sling/jcr/webconsole/internal/DescriptorsConfigurationPrinter.java b/src/main/java/org/apache/sling/jcr/webconsole/internal/DescriptorsConfigurationPrinter.java
new file mode 100644
index 0000000..a79ad3b
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/webconsole/internal/DescriptorsConfigurationPrinter.java
@@ -0,0 +1,74 @@
+/**
+ * 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.sling.jcr.webconsole.internal;
+
+import java.io.PrintWriter;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.webconsole.ConfigurationPrinter;
+import org.apache.sling.jcr.api.SlingRepository;
+
+/**
+ * A Felix WebConsole ConfigurationPrinter which outputs the current JCR
+ * repository descriptors.
+ */
+@Component(label = "%descriptors.printer.name", description = "%descriptors.printer.description", metatype = false)
+@Service(ConfigurationPrinter.class)
+@Properties({
+    @Property(name = "service.description", value = "JCR Descriptors Configuration Printer"),
+    @Property(name = "service.vendor", value = "The Apache Software Foundation")
+})
+public class DescriptorsConfigurationPrinter implements ConfigurationPrinter {
+
+
+    @Reference(policy=ReferencePolicy.DYNAMIC)
+    private SlingRepository slingRepository;
+
+    /**
+     * Get the title of the configuration status page.
+     *
+     * @return the title
+     */
+    public String getTitle() {
+        return "JCR Descriptors";
+    }
+
+    /**
+     * Output a list of repository descriptors.
+     *
+     * @param pw a PrintWriter
+     */
+    public void printConfiguration(PrintWriter pw) {
+        if (slingRepository != null) {
+            final String[] descriptorKeys = slingRepository.getDescriptorKeys();
+            for (final String key : descriptorKeys) {
+                pw.printf("%s = %s\n", key, slingRepository.getDescriptor(key));
+            }
+        } else {
+            pw.println("SlingRepository is not available.");
+        }
+
+    }
+
+}
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index ea277ab..71f49b8 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -29,3 +29,6 @@ namespace.printer.description = Namespace Mapping Configuration Printer
 nodetype.printer.name = NodeType Configuration Printer
 nodetype.printer.description = NodeType Configuration Printer
 
+descriptors.printer.name = Repository Descriptors Configuration Printer
+nodetype.printer.description = Repository Descriptors Configuration Printer
+

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.