Author: cziegeler
Date: Tue Aug  2 11:21:44 2016
New Revision: 1754873

URL: http://svn.apache.org/viewvc?rev=1754873&view=rev
Log:
SLING-5940 : Register filter using http whiteboard

Modified:
    sling/trunk/bundles/extensions/i18n/pom.xml
    
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
    
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
    
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java

Modified: sling/trunk/bundles/extensions/i18n/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/pom.xml?rev=1754873&r1=1754872&r2=1754873&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/i18n/pom.xml (original)
+++ sling/trunk/bundles/extensions/i18n/pom.xml Tue Aug  2 11:21:44 2016
@@ -71,11 +71,9 @@
                             
jackrabbit-jcr-commons;inline="org/apache/jackrabbit/util/ISO9075.*|org/apache/jackrabbit/util/XMLChar.*|org/apache/jackrabbit/util/Text.*|org/apache/jackrabbit/commons/json/Json*",
                             
org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/ServiceUtil*|org/apache/sling/commons/osgi/PropertiesUtil*"
                         </Embed-Dependency>
-<!-- 
                         <Require-Capability>
                             
osgi.implementation;filter:="(&amp;(osgi.implementation=osgi.http)(version=1.0))"
                         </Require-Capability>
- -->
                     </instructions>
                 </configuration>
             </plugin>
@@ -139,6 +137,12 @@
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.http.whiteboard</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.event</artifactId>
             <version>1.3.1</version>
             <scope>provided</scope>

Modified: 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java?rev=1754873&r1=1754872&r2=1754873&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
 (original)
+++ 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
 Tue Aug  2 11:21:44 2016
@@ -53,6 +53,7 @@ import org.apache.sling.i18n.LocaleResol
 import org.apache.sling.i18n.RequestLocaleResolver;
 import org.apache.sling.i18n.ResourceBundleProvider;
 import org.osgi.framework.Constants;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,7 +64,9 @@ import org.slf4j.LoggerFactory;
 @SlingFilter(generateService = true,
              order = 700, scope = { SlingFilterScope.REQUEST, 
SlingFilterScope.ERROR })
 @Properties({
-    @Property(name = "pattern", value="/.*"),
+    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, 
value="/"),
+    @Property(name = HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,
+              value = "(" + 
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=org.apache.sling)"),
     @Property(name = Constants.SERVICE_DESCRIPTION, value = 
"Internationalization Support Filter"),
     @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software 
Foundation") })
 public class I18NFilter implements Filter {

Modified: 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java?rev=1754873&r1=1754872&r2=1754873&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
 (original)
+++ 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundle.java
 Tue Aug  2 11:21:44 2016
@@ -48,7 +48,7 @@ public class JcrResourceBundle extends R
 
     /** default primary type (=resource type) for message entry dictionaries */
     static final String RT_MESSAGE_ENTRY = "sling:MessageEntry";
-    
+
     static final String MIXIN_MESSAGE = "sling:Message";
 
     static final String MIXIN_LANGUAGE = "mix:language";
@@ -102,7 +102,7 @@ public class JcrResourceBundle extends R
     protected void setParent(ResourceBundle parent) {
         super.setParent(parent);
     }
-    
+
     public ResourceBundle getParent() {
         return parent;
     }
@@ -164,7 +164,6 @@ public class JcrResourceBundle extends R
      *
      * @throws NullPointerException if either of the parameters is {@code 
null}.
      */
-    @SuppressWarnings("deprecation")
     private Map<String, Object> loadFully(final ResourceResolver resolver, 
Set<String> roots, Set<String> languageRoots) {
 
         final String[] searchPath = resolver.getSearchPath();

Modified: 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?rev=1754873&r1=1754872&r2=1754873&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
 (original)
+++ 
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
 Tue Aug  2 11:21:44 2016
@@ -139,7 +139,7 @@ public class JcrResourceBundleProvider i
     /**
      * Each ResourceBundle is registered as a service. Each registration is 
stored in this map with the locale & base name used as a key.
      */
-    private Map<Key, ServiceRegistration> bundleServiceRegistrations;
+    private Map<Key, ServiceRegistration<ResourceBundle>> 
bundleServiceRegistrations;
 
     private boolean preloadBundles;
 
@@ -324,7 +324,7 @@ public class JcrResourceBundleProvider i
         resourceBundleCache.remove(key);
         log.info("Reloading resource bundle for {}", key);
         // unregister bundle
-        ServiceRegistration serviceRegistration = null;
+        ServiceRegistration<ResourceBundle> serviceRegistration = null;
         synchronized (this) {
             serviceRegistration = bundleServiceRegistrations.remove(key);
         }
@@ -382,7 +382,7 @@ public class JcrResourceBundleProvider i
         this.preloadBundles = 
PropertiesUtil.toBoolean(props.get(PROP_PRELOAD_BUNDLES), 
DEFAULT_PRELOAD_BUNDLES);
 
         this.bundleContext = context;
-        this.bundleServiceRegistrations = new HashMap<Key, 
ServiceRegistration>();
+        this.bundleServiceRegistrations = new HashMap<Key, 
ServiceRegistration<ResourceBundle>>();
         invalidationDelay = 
PropertiesUtil.toLong(props.get(PROP_INVALIDATION_DELAY), 
DEFAULT_INVALIDATION_DELAY);
         if (this.resourceResolverFactory != null) { // this is only null 
during test execution!
             if (repoCredentials == null) {
@@ -448,7 +448,7 @@ public class JcrResourceBundleProvider i
             serviceProps.put("baseName", key.baseName);
         }
         serviceProps.put("locale", key.locale.toString());
-        ServiceRegistration serviceReg = 
bundleContext.registerService(ResourceBundle.class.getName(),
+        ServiceRegistration<ResourceBundle> serviceReg = 
bundleContext.registerService(ResourceBundle.class,
                 resourceBundle, serviceProps);
         synchronized (this) {
             bundleServiceRegistrations.put(key, serviceReg);
@@ -532,7 +532,7 @@ public class JcrResourceBundleProvider i
         languageRootPaths.clear();
 
         synchronized (this) {
-            for (ServiceRegistration serviceReg : 
bundleServiceRegistrations.values()) {
+            for (ServiceRegistration<ResourceBundle> serviceReg : 
bundleServiceRegistrations.values()) {
                 serviceReg.unregister();
             }
             bundleServiceRegistrations.clear();


Reply via email to