sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1613901 - in /sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl: I18NFilter.java JcrResourceBundleProvider.java
Date Mon, 28 Jul 2014 07:18:03 GMT
Author: cziegeler
Date: Mon Jul 28 07:18:03 2014
New Revision: 1613901

URL: http://svn.apache.org/r1613901
Log:
SLING-3805 : Fields for dynamic references must be volatile

Modified:
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
    sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java?rev=1613901&r1=1613900&r2=1613901&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
Mon Jul 28 07:18:03 2014
@@ -62,7 +62,7 @@ import org.slf4j.LoggerFactory;
  * the resource bundle for the current request.
  */
 @SlingFilter(generateComponent = false, generateService = true, order = -700, scope = { SlingFilterScope.REQUEST,
SlingFilterScope.ERROR })
-@Component(immediate = true, metatype = false, specVersion="1.2")
+@Component(immediate = true, specVersion="1.2")
 @Properties({
     @Property(name = "pattern", value="/.*"),
     @Property(name = Constants.SERVICE_DESCRIPTION, value = "Internationalization Support
Filter"),
@@ -75,10 +75,10 @@ public class I18NFilter implements Filte
     private final DefaultLocaleResolver DEFAULT_LOCALE_RESOLVER = new DefaultLocaleResolver();
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC,
policyOption=ReferencePolicyOption.GREEDY)
-    private LocaleResolver localeResolver = DEFAULT_LOCALE_RESOLVER;
+    private volatile LocaleResolver localeResolver = DEFAULT_LOCALE_RESOLVER;
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC,
policyOption=ReferencePolicyOption.GREEDY)
-    private RequestLocaleResolver requestLocaleResolver = DEFAULT_LOCALE_RESOLVER;
+    private volatile RequestLocaleResolver requestLocaleResolver = DEFAULT_LOCALE_RESOLVER;
 
     @Reference(name = "resourceBundleProvider",
                referenceInterface = ResourceBundleProvider.class,
@@ -96,6 +96,7 @@ public class I18NFilter implements Filte
     /**
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
      */
+    @Override
     public void init(FilterConfig filterConfig) {
         synchronized(this) {
             initCount++;
@@ -105,6 +106,7 @@ public class I18NFilter implements Filte
     /**
      * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
javax.servlet.FilterChain)
      */
+    @Override
     public void doFilter(ServletRequest request,
                          final ServletResponse response,
                          final FilterChain chain)
@@ -131,6 +133,7 @@ public class I18NFilter implements Filte
     /**
      * @see javax.servlet.Filter#destroy()
      */
+    @Override
     public void destroy() {
         synchronized(this) {
             initCount--;
@@ -178,6 +181,7 @@ public class I18NFilter implements Filte
     /** Provider that goes through a list of registered providers and takes the first non-null
responses */
     private class CombinedBundleProvider implements ResourceBundleProvider {
 
+        @Override
         public Locale getDefaultLocale() {
             // ask all registered providers, use the first one that returns
             final ResourceBundleProvider[] providers = sortedProviders;
@@ -191,6 +195,7 @@ public class I18NFilter implements Filte
             return null;
         }
 
+        @Override
         public ResourceBundle getResourceBundle(final Locale locale) {
             // ask all registered providers, use the first one that returns
             final ResourceBundleProvider[] providers = sortedProviders;
@@ -204,6 +209,7 @@ public class I18NFilter implements Filte
             return null;
         }
 
+        @Override
         public ResourceBundle getResourceBundle(final String baseName, final Locale locale)
{
             // ask all registered providers, use the first one that returns
             final ResourceBundleProvider[] providers = sortedProviders;

Modified: sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?rev=1613901&r1=1613900&r2=1613901&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
(original)
+++ sling/trunk/contrib/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
Mon Jul 28 07:18:03 2014
@@ -90,7 +90,7 @@ public class JcrResourceBundleProvider i
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC)
-    private ResourceResolverFactory resourceResolverFactory;
+    private volatile ResourceResolverFactory resourceResolverFactory;
 
     /**
      * The default Locale as configured with the <i>locale.default</i>
@@ -141,6 +141,7 @@ public class JcrResourceBundleProvider i
      * fallback for {@link #getResourceBundle(Locale)} and also as the basis for
      * any messages requested from resource bundles.
      */
+    @Override
     public Locale getDefaultLocale() {
         return defaultLocale;
     }
@@ -156,10 +157,12 @@ public class JcrResourceBundleProvider i
      * @throws MissingResourceException If the <code>ResourceResolver</code>
      *             is not available to access the resources.
      */
+    @Override
     public ResourceBundle getResourceBundle(Locale locale) {
         return getResourceBundle(null, locale);
     }
 
+    @Override
     public ResourceBundle getResourceBundle(String baseName, Locale locale) {
         if (locale == null) {
             locale = defaultLocale;
@@ -181,6 +184,7 @@ public class JcrResourceBundleProvider i
      */
     private final EventListener messageChangeHandler = new EventListener() {
 
+        @Override
         public void onEvent(EventIterator events) {
             log.debug("onEvent: Resource changes, removing cached ResourceBundles");
             clearCache();
@@ -193,6 +197,7 @@ public class JcrResourceBundleProvider i
      * In this case we check if the given language is already loaded and only then invalidate
the cache.
      */
     private final EventListener languageChangeHandler = new EventListener() {
+        @Override
         public void onEvent(EventIterator events) {
             log.debug("onEvent: Resource changes. checking for cached bundle.");
             while (events.hasNext()) {
@@ -240,6 +245,7 @@ public class JcrResourceBundleProvider i
         this.bundleServiceRegistrations = new ArrayList<ServiceRegistration>();
         if (this.resourceResolverFactory != null) {
             final Thread t = new Thread() {
+                @Override
                 public void run() {
                     preloadBundles();
                 }



Mime
View raw message