This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.discovery.support-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-support.git
commit cc75d3751883ada7b5c161cee188db72ba2bd3e3 Author: Carsten Ziegeler <[email protected]> AuthorDate: Wed Jul 24 06:56:26 2013 +0000 SLING-2976 : Add support for instance name and description git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/support@1506416 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 6 ++++ .../impl/support/StandardPropertyProvider.java | 33 +++++----------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 69d81e6..1223a9d 100644 --- a/pom.xml +++ b/pom.xml @@ -82,5 +82,11 @@ <version>1.0.0</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.settings</artifactId> + <version>1.2.3-SNAPSHOT</version> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/src/main/java/org/apache/sling/discovery/impl/support/StandardPropertyProvider.java b/src/main/java/org/apache/sling/discovery/impl/support/StandardPropertyProvider.java index b698659..9358688 100644 --- a/src/main/java/org/apache/sling/discovery/impl/support/StandardPropertyProvider.java +++ b/src/main/java/org/apache/sling/discovery/impl/support/StandardPropertyProvider.java @@ -35,6 +35,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.sling.discovery.InstanceDescription; import org.apache.sling.discovery.PropertyProvider; +import org.apache.sling.settings.SlingSettingsService; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; @@ -55,24 +56,18 @@ public class StandardPropertyProvider { private volatile long changeCount; - private String instanceName; - - private String instanceDescription; - private ServiceRegistration propagationService; private final Map<Long, String[]> endpoints = new HashMap<Long, String[]>(); private String endpointString; + @Reference SlingSettingsService settings; + private Dictionary<String, Object> getRegistrationProperties() { final List<String> names = new ArrayList<String>(); - if ( this.instanceName != null ) { - names.add(InstanceDescription.PROPERTY_NAME); - } - if ( this.instanceDescription != null ) { - names.add(InstanceDescription.PROPERTY_DESCRIPTION); - } + names.add(InstanceDescription.PROPERTY_NAME); + names.add(InstanceDescription.PROPERTY_DESCRIPTION); names.add(InstanceDescription.PROPERTY_ENDPOINTS); final StringBuilder sb = new StringBuilder(); @@ -101,17 +96,6 @@ public class StandardPropertyProvider { return serviceProps; } - private String getPropertyValue(final ComponentContext bc, final String key) { - Object value = bc.getProperties().get(key); - if ( value == null ) { - value = bc.getBundleContext().getProperty(key); - } - if ( value != null ) { - return value.toString(); - } - return null; - } - @Activate protected void activate(final ComponentContext cc) { this.modified(cc); @@ -119,18 +103,15 @@ public class StandardPropertyProvider { @Modified protected void modified(final ComponentContext cc) { - this.instanceName = this.getPropertyValue(cc, "sling.name"); - this.instanceDescription = this.getPropertyValue(cc, "sling.description"); - this.propagationService = cc.getBundleContext().registerService(PropertyProvider.class.getName(), new PropertyProvider() { public String getProperty(final String name) { if ( InstanceDescription.PROPERTY_DESCRIPTION.equals(name) ) { - return instanceDescription; + return settings.getSlingDescription(); } if ( InstanceDescription.PROPERTY_NAME.equals(name) ) { - return instanceName; + return settings.getSlingName(); } if ( InstanceDescription.PROPERTY_ENDPOINTS.equals(name) ) { return endpointString; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
