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 10:14:16 UTC
[sling-org-apache-sling-serviceusermapper] 09/17: SLING-4930 :
InventoryPrinter for Service User Mappings
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.serviceusermapper-1.2.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-serviceusermapper.git
commit 6934258fa9a35200ae1ba95dc08fb880065f184a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Aug 7 13:52:18 2015 +0000
SLING-4930 : InventoryPrinter for Service User Mappings
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/serviceusermapper@1694686 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 1 +
.../impl/MappingInventoryPrinter.java | 24 +++++++++------
.../impl/ServiceUserMapperImpl.java | 34 +---------------------
3 files changed, 17 insertions(+), 42 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5bff61c..7b21244 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
<configuration>
<instructions>
<Import-Package>
+ org.apache.sling.commons.json,
org.apache.felix.inventory;resolution:=optional,
*
</Import-Package>
diff --git a/src/main/java/org/apache/sling/serviceusermapping/impl/MappingInventoryPrinter.java b/src/main/java/org/apache/sling/serviceusermapping/impl/MappingInventoryPrinter.java
index f078887..b431b19 100644
--- a/src/main/java/org/apache/sling/serviceusermapping/impl/MappingInventoryPrinter.java
+++ b/src/main/java/org/apache/sling/serviceusermapping/impl/MappingInventoryPrinter.java
@@ -27,21 +27,27 @@ import java.util.TreeMap;
import org.apache.felix.inventory.Format;
import org.apache.felix.inventory.InventoryPrinter;
+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.Service;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;
/** InventoryPrinter for service user mappings */
+@Component
+@Service(value = InventoryPrinter.class)
+@Properties({
+ @Property(name = InventoryPrinter.FORMAT, value = { "JSON", "TEXT" }),
+ @Property(name = InventoryPrinter.NAME, value = "slingserviceusers"),
+ @Property(name = InventoryPrinter.TITLE, value = "Sling Service User Mappings"),
+ @Property(name = InventoryPrinter.WEBCONSOLE, boolValue = true)
+})
public class MappingInventoryPrinter implements InventoryPrinter {
- private volatile ServiceUserMapperImpl mapper;
-
- MappingInventoryPrinter(final ServiceUserMapperImpl mapper) {
- this.mapper = mapper;
- }
-
- void deactivate() {
- this.mapper = null;
- }
+ @Reference
+ private ServiceUserMapperImpl mapper;
@Override
public void print(PrintWriter out, Format format, boolean isZip) {
diff --git a/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java b/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
index 555de03..db819c3 100644
--- a/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
+++ b/src/main/java/org/apache/sling/serviceusermapping/impl/ServiceUserMapperImpl.java
@@ -51,7 +51,6 @@ import org.apache.sling.serviceusermapping.ServiceUserValidator;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +59,7 @@ import org.slf4j.LoggerFactory;
metatype = true,
label = "Apache Sling Service User Mapper Service",
description = "Configuration for the service mapping service names to names of users.")
-@Service(value=ServiceUserMapper.class)
+@Service(value={ServiceUserMapper.class, ServiceUserMapperImpl.class})
@References( {
@Reference(name="amendment",
referenceInterface=MappingConfigAmendment.class,
@@ -112,8 +111,6 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
private BundleContext bundleContext;
- private ServiceRegistration invPrinterReg;
-
@Activate
@Modified
void configure(BundleContext bundleContext, final Map<String, Object> config) {
@@ -138,39 +135,10 @@ public class ServiceUserMapperImpl implements ServiceUserMapper {
this.bundleContext = bundleContext;
this.updateMappings();
}
-
- // check for reconfiguration (bundleContext is only null during tests!)
- if ( invPrinterReg == null && bundleContext != null ) {
- final Dictionary<String, Object> serviceProps = new Hashtable<String, Object>();
- serviceProps.put("felix.inventory.printer.format", new String[] { "JSON", "TEXT" });
- serviceProps.put("felix.inventory.printer.name", "serviceusers");
- serviceProps.put("felix.inventory.printer.title", "Service User Mappings");
- serviceProps.put("felix.inventory.printer.webconsole", true);
- invPrinterReg = bundleContext.registerService("org.apache.felix.inventory.InventoryPrinter",
- new ServiceFactory() {
-
- @Override
- public Object getService(final Bundle bundle, final ServiceRegistration registration) {
- return new MappingInventoryPrinter(ServiceUserMapperImpl.this);
- }
-
- @Override
- public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
- if ( service instanceof MappingInventoryPrinter) {
- ((MappingInventoryPrinter)service).deactivate();
- }
- }
- }, serviceProps);
- }
}
@Deactivate
void deactivate() {
- if (invPrinterReg != null) {
- invPrinterReg.unregister();
- invPrinterReg = null;
- }
-
synchronized ( this.amendments) {
updateServiceMappings(new ArrayList<Mapping>());
bundleContext = null;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.