portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r918551 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/test/java/org/apache/jetspeed/ components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/ jetspeed-api/src/main/java/org/apache/jetspeed/factory/
Date Wed, 03 Mar 2010 16:27:47 GMT
Author: woonsan
Date: Wed Mar  3 16:27:47 2010
New Revision: 918551

URL: http://svn.apache.org/viewvc?rev=918551&view=rev
Log:
JS2-1094: Adding reloadResourceBundles() methods in portlet factory.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/PortletFactoryMock.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/InlinePortletResourceBundle.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/PortletFactoryMock.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/PortletFactoryMock.java?rev=918551&r1=918550&r2=918551&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/PortletFactoryMock.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/PortletFactoryMock.java
Wed Mar  3 16:27:47 2010
@@ -90,4 +90,12 @@
     {
         return false;
     }
+
+    public void reloadResourceBundles(PortletApplication pa) throws PortletException
+    {
+    }
+
+    public void reloadResourceBundles(PortletDefinition pd) throws PortletException
+    {
+    }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/InlinePortletResourceBundle.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/InlinePortletResourceBundle.java?rev=918551&r1=918550&r2=918551&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/InlinePortletResourceBundle.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/InlinePortletResourceBundle.java
Wed Mar  3 16:27:47 2010
@@ -32,6 +32,7 @@
     private final static String KEYWORDS_KEY = "javax.portlet.keywords";
 
     private Object[][] contents;
+    private ResourceBundle parent;
 
     public InlinePortletResourceBundle(String title, String shortTitle, String keywords)
     {
@@ -69,6 +70,12 @@
     
     public void setParent(ResourceBundle parent)
     {
+        this.parent = parent;
         super.setParent(parent);
     }
+    
+    ResourceBundle getParent()
+    {
+        return parent;
+    }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java?rev=918551&r1=918550&r2=918551&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
Wed Mar  3 16:27:47 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed.factory;
 
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -24,6 +25,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 
 import javax.portlet.GenericPortlet;
@@ -49,6 +51,7 @@
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.util.GenericPortletUtils;
+import org.apache.jetspeed.util.ReloadablePropertyResourceBundle;
 import org.apache.pluto.container.RequestDispatcherService;
 import org.apache.portals.bridges.common.ServletContextProvider;
 import org.slf4j.Logger;
@@ -145,14 +148,21 @@
     protected ResourceBundle loadResourceBundle( Locale locale, String bundleName, ClassLoader
cl )
     {
         ResourceBundle resourceBundle = null;
+        
         try
         {
             resourceBundle = ResourceBundle.getBundle(bundleName, locale, cl);
+            
+            if (resourceBundle instanceof PropertyResourceBundle)
+            {
+                resourceBundle = new ReloadablePropertyResourceBundle((PropertyResourceBundle)
resourceBundle, bundleName);
+            }
         }
         catch (MissingResourceException x)
         {
             return null;
         }
+        
         return resourceBundle;
     }
     
@@ -754,5 +764,95 @@
             return false;
         }
     }
+
+    public void reloadResourceBundles(PortletApplication pa) throws PortletException
+    {
+        String paName = pa.getName();
+        Map<Locale, ResourceBundle> bundleCache = applicationResourceBundleCache.get(paName);
+        
+        if (bundleCache != null)
+        {
+            List<Locale> locales = null;
+            
+            synchronized (bundleCache)
+            {
+                locales = new ArrayList<Locale>(bundleCache.keySet());
+            }
+            
+            for (Locale locale : locales)
+            {
+                ResourceBundle bundle = bundleCache.get(locale);
+                
+                if (bundle != null)
+                {
+                    if (bundle instanceof InlinePortletResourceBundle)
+                    {
+                        bundle = ((InlinePortletResourceBundle) bundle).getParent();
+                    }
+                    
+                    if (bundle instanceof ReloadablePropertyResourceBundle)
+                    {
+                        try
+                        {
+                            ((ReloadablePropertyResourceBundle) bundle).reload(getPortletApplicationClassLoader(pa));
+                        }
+                        catch (IOException e)
+                        {
+                            log.error("Failed to reload resource bundle of " + paName + "
for locale, " + locale, e);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void reloadResourceBundles(PortletDefinition pd) throws PortletException
+    {
+        PortletApplication pa = pd.getApplication();
+        String paName = pa.getName();
+        String pdName = pd.getPortletName();
+        
+        Map<String, Map<Locale, ResourceBundle>> portletResourceBundleCache =
portletsResourceBundleCache.get(paName);
+        
+        if (portletResourceBundleCache != null)
+        {
+            Map<Locale, ResourceBundle> bundleCache = portletResourceBundleCache.get(pdName);
+            
+            if (bundleCache != null)
+            {
+                List<Locale> locales = null;
+                
+                synchronized (bundleCache)
+                {
+                    locales = new ArrayList<Locale>(bundleCache.keySet());
+                }
+                
+                for (Locale locale : locales)
+                {
+                    ResourceBundle bundle = bundleCache.get(locale);
+                    
+                    if (bundle != null)
+                    {
+                        if (bundle instanceof InlinePortletResourceBundle)
+                        {
+                            bundle = ((InlinePortletResourceBundle) bundle).getParent();
+                        }
+                        
+                        if (bundle instanceof ReloadablePropertyResourceBundle)
+                        {
+                            try
+                            {
+                                ((ReloadablePropertyResourceBundle) bundle).reload(getPortletApplicationClassLoader(pa));
+                            }
+                            catch (IOException e)
+                            {
+                                log.error("Failed to reload resource bundle of " + paName
+ "::" + pdName + " for locale, " + locale, e);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
     
 }

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java?rev=918551&r1=918550&r2=918551&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/factory/PortletFactory.java
Wed Mar  3 16:27:47 2010
@@ -83,4 +83,21 @@
      * @see javax.portlet.GenericPortlet#doHelp(RenderRequest, RenderResponse)
      */
     boolean hasRenderHelperMethod( PortletDefinition pd, PortletMode mode );
+    
+    /**
+     * Tries to reload resource bundles of portlet application.
+     * @param pa portlet application
+     * @return True if the reloading has been succeeded.
+     * @throws PortletException
+     */
+    void reloadResourceBundles(PortletApplication pa) throws PortletException;
+    
+    /**
+     * Tries to reload resource bundles of portlet definition.
+     * @param pd portlet definition
+     * @return True if the reloading has been succeeded.
+     * @throws PortletException
+     */
+    void reloadResourceBundles(PortletDefinition pd) throws PortletException;
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message