You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/11/15 14:50:11 UTC
svn commit: r1769844 - in
/sling/trunk/contrib/extensions/resource-inventory: pom.xml
src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java
src/main/resources/
Author: cziegeler
Date: Tue Nov 15 14:50:11 2016
New Revision: 1769844
URL: http://svn.apache.org/viewvc?rev=1769844&view=rev
Log:
Switch to parent pom 29 and OSGi annotations
Removed:
sling/trunk/contrib/extensions/resource-inventory/src/main/resources/
Modified:
sling/trunk/contrib/extensions/resource-inventory/pom.xml
sling/trunk/contrib/extensions/resource-inventory/src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java
Modified: sling/trunk/contrib/extensions/resource-inventory/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resource-inventory/pom.xml?rev=1769844&r1=1769843&r2=1769844&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resource-inventory/pom.xml (original)
+++ sling/trunk/contrib/extensions/resource-inventory/pom.xml Tue Nov 15 14:50:11 2016
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>26</version>
+ <version>29</version>
<relativePath/>
</parent>
@@ -81,20 +81,12 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Modified: sling/trunk/contrib/extensions/resource-inventory/src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resource-inventory/src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java?rev=1769844&r1=1769843&r2=1769844&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resource-inventory/src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java (original)
+++ sling/trunk/contrib/extensions/resource-inventory/src/main/java/org/apache/sling/resource/inventory/impl/ResourceInventoryPrinterFactory.java Tue Nov 15 14:50:11 2016
@@ -19,50 +19,60 @@
package org.apache.sling.resource.inventory.impl;
import java.io.PrintWriter;
-import java.util.Map;
import org.apache.felix.inventory.Format;
import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.ConfigurationPolicy;
-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.Service;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.commons.json.JSONException;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.ConfigurationPolicy;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.slf4j.LoggerFactory;
-@Component(configurationFactory=true, policy=ConfigurationPolicy.REQUIRE, metatype=true)
-@Service(value=InventoryPrinter.class)
-@Properties({
- @Property(name=InventoryPrinter.FORMAT, value="JSON", propertyPrivate=true),
- @Property(name=InventoryPrinter.NAME),
- @Property(name=InventoryPrinter.TITLE),
- @Property(name=InventoryPrinter.WEBCONSOLE, boolValue=false, propertyPrivate=true)
-})
+@Component(service = InventoryPrinter.class,
+ configurationPolicy=ConfigurationPolicy.REQUIRE,
+ property = {
+ InventoryPrinter.FORMAT + "=JSON",
+ InventoryPrinter.WEBCONSOLE + ":Boolean=false"
+ })
+@Designate(ocd=ResourceInventoryPrinterFactory.Config.class, factory=true)
public class ResourceInventoryPrinterFactory implements InventoryPrinter {
- @Property(value = "")
- private static final String PROP_PATH = "path";
+ @ObjectClassDefinition(name = "Apache Sling Resource Inventory Printer Factory",
+ description = "This factory can be used to add " +
+ "resource trees to the inventory of the system.")
+ public @interface Config {
- private String path;
+ @AttributeDefinition(name="Name", description="The unique name of the inventory printer.")
+ String felix_inventory_printer_name();
- @Activate
- protected void activate(final Map<String, Object> props) {
- this.path = (String)props.get(PROP_PATH);
+ @AttributeDefinition(name="Title", description="The title of the inventory printer.")
+ String felix_inventory_printer_title();
+
+ @AttributeDefinition(name="Path", description="The resource path to include.")
+ String path() default "";
}
+ private String path;
@Reference
private ResourceResolverFactory factory;
+ @Activate
+ protected void activate(final Config config) {
+ this.path = config.path();
+ }
+
/**
* @see org.apache.felix.inventory.InventoryPrinter#print(java.io.PrintWriter, org.apache.felix.inventory.Format, boolean)
*/
+ @Override
public void print(PrintWriter printWriter, Format format, boolean isZip) {
if ( this.path == null || !format.equals(Format.JSON) ) {
return;