Jetspeed 2
  1. Jetspeed 2
  2. JS2-1094

Reloading resource bundle of portlet definition at runtime

    Details

    • Type: Wish Wish
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.1
    • Component/s: Portlet Registry
    • Labels:
      None

      Description

      Currently, the resource bundle defined in the portlet descriptor for a portlet definition cannot be reloaded at runtime.
      It would be great if it is possible in admin UI.

        Issue Links

          Activity

          Hide
          Ate Douma added a comment -

          I think this is the same as JS2-1045 (reported as bug).

          Show
          Ate Douma added a comment - I think this is the same as JS2-1045 (reported as bug).
          Hide
          Woonsan Ko added a comment -

          In JS2-1045, it is mentioned, "If I change the properties and redeploy, the changes will not be shown".
          So, I have thought that he meant another problem, not taking the new resource bundle, even if he redeployed the portlet application.
          Meanwhile, this issue seems slightly different to me because this covers dynamic reloading on resource bundles, even though the portlet application is not redeployed.

          Show
          Woonsan Ko added a comment - In JS2-1045 , it is mentioned, "If I change the properties and redeploy, the changes will not be shown". So, I have thought that he meant another problem, not taking the new resource bundle, even if he redeployed the portlet application. Meanwhile, this issue seems slightly different to me because this covers dynamic reloading on resource bundles, even though the portlet application is not redeployed.
          Hide
          Ate Douma added a comment -

          I agree Woonsan, but once we have support for dynamic reloading on resource bundles, the problem in JS2-1045 might be dealt with too

          If I understand the report from Frank Otto correctly, he only modified the resource bundle and on redeployment those changes were not picked up.
          Which would be correct as currently we run a checksum on only web.xml, portlet.xml and jetspeed-portlet.xml, so with those still matching up we simply assume no changes.
          If the only thing Frank wants is merging resource bundle changes, dynamic reloading from an admin UI would do the trick for him just as well.

          Show
          Ate Douma added a comment - I agree Woonsan, but once we have support for dynamic reloading on resource bundles, the problem in JS2-1045 might be dealt with too If I understand the report from Frank Otto correctly, he only modified the resource bundle and on redeployment those changes were not picked up. Which would be correct as currently we run a checksum on only web.xml, portlet.xml and jetspeed-portlet.xml, so with those still matching up we simply assume no changes. If the only thing Frank wants is merging resource bundle changes, dynamic reloading from an admin UI would do the trick for him just as well.
          Hide
          Woonsan Ko added a comment -

          Hi All,

          I've tried to find a proper solution for dynamic reloading of resource bundles, but with JVM 1.5 or earlier, it is not possible to refresh the internal cache in java.util.ResourceBundle.

          One possible trick is to not depend on the classloader, but to use separate loading mechanism from a other location than the classpath.
          You can find this style for a solution in the springframework. (Please have a look at org.springframework.context.support.ReloadableResourceBundleMessageSource if you're interested in.)
          However, I think this kind of technique is kind of overkilling and risky for our specific case.

          On the other hand, Java 1.6 or later now provides java.util.ResourceBundle.clearCache(ClassLoader) operation to clear all resource bundle cache from the classloader.
          I think this is very simple and good enough to refresh resource bundles for a portlet application.
          We can simply add a button to clear all resource bundles of a portlet application in a j2-admin portlet.

          Therefore, I'd like to add the functionality in the portlet application management portlet with a limitation, "Java 1.6 or higher for this". Otherwise, it will just ignore the operation.
          I'd like to implement this in this simple way for v2.2.1.

          Any comment would be appreciated.

          Regards, Woonsan

          Show
          Woonsan Ko added a comment - Hi All, I've tried to find a proper solution for dynamic reloading of resource bundles, but with JVM 1.5 or earlier, it is not possible to refresh the internal cache in java.util.ResourceBundle. One possible trick is to not depend on the classloader, but to use separate loading mechanism from a other location than the classpath. You can find this style for a solution in the springframework. (Please have a look at org.springframework.context.support.ReloadableResourceBundleMessageSource if you're interested in.) However, I think this kind of technique is kind of overkilling and risky for our specific case. On the other hand, Java 1.6 or later now provides java.util.ResourceBundle.clearCache(ClassLoader) operation to clear all resource bundle cache from the classloader. I think this is very simple and good enough to refresh resource bundles for a portlet application. We can simply add a button to clear all resource bundles of a portlet application in a j2-admin portlet. Therefore, I'd like to add the functionality in the portlet application management portlet with a limitation, "Java 1.6 or higher for this". Otherwise, it will just ignore the operation. I'd like to implement this in this simple way for v2.2.1. Any comment would be appreciated. Regards, Woonsan
          Hide
          Woonsan Ko added a comment -

          FYI, it doesn't seem to work with ResourceBundle.clearCache(...) methods in Tomcat in my testing.
          Also, please refer to the following page for the problem:

          http://forums.sun.com/thread.jspa?threadID=5304834

          I will try to find a solution a little later.

          Show
          Woonsan Ko added a comment - FYI, it doesn't seem to work with ResourceBundle.clearCache(...) methods in Tomcat in my testing. Also, please refer to the following page for the problem: http://forums.sun.com/thread.jspa?threadID=5304834 I will try to find a solution a little later.
          Hide
          Woonsan Ko added a comment - - edited

          Fixed by implementing a reloadable property resource bundle class and levering it in portlet factory.

          Administrator can reload resource bundles for a portlet application or a portlet definition in Portlet Application Manager portlet. In each detail tab pane, you can find "Reload" button for resource bundle field.

          By the way, I'd like to mention that JSTL fmt:setBundle tag does not use portletConfig.getResourceBundle(). Instead, it invokes ResourceBundle.getResourceBundle() directly, which cannot be controlled in Jetspeed.
          So, if you want to have the portlet resource bundle reloaded in admin UI, then the portlet should have access to "portletConfig" object like javax.portlet.PortletConfig#getResourceBundle(renderRequest.getLocale()).

          Also, there's one limitation:
          The portlet info keys ("javax.portlet.title", "javax.porlet.short-title" and "javax.portlet.keywords") are never reloaded because those must be properly registered during deployment time.
          So, if you want to reload those, you must re-deploy the portlet application.

          Show
          Woonsan Ko added a comment - - edited Fixed by implementing a reloadable property resource bundle class and levering it in portlet factory. Administrator can reload resource bundles for a portlet application or a portlet definition in Portlet Application Manager portlet. In each detail tab pane, you can find "Reload" button for resource bundle field. By the way, I'd like to mention that JSTL fmt:setBundle tag does not use portletConfig.getResourceBundle(). Instead, it invokes ResourceBundle.getResourceBundle() directly, which cannot be controlled in Jetspeed. So, if you want to have the portlet resource bundle reloaded in admin UI, then the portlet should have access to "portletConfig" object like javax.portlet.PortletConfig#getResourceBundle(renderRequest.getLocale()). Also, there's one limitation: The portlet info keys ("javax.portlet.title", "javax.porlet.short-title" and "javax.portlet.keywords") are never reloaded because those must be properly registered during deployment time. So, if you want to reload those, you must re-deploy the portlet application.
          Hide
          Woonsan Ko added a comment -

          By the way, the portlet info keys ("javax.portlet.title", "javax.porlet.short-title" and "javax.portlet.keywords") could be changed at runtime by using "Language" tab in the portlet definition management portlet.

          Show
          Woonsan Ko added a comment - By the way, the portlet info keys ("javax.portlet.title", "javax.porlet.short-title" and "javax.portlet.keywords") could be changed at runtime by using "Language" tab in the portlet definition management portlet.
          Hide
          Woonsan Ko added a comment - - edited

          A support tag to set localization context based on portlet config is added.
          Please see http://issues.apache.org/jira/browse/APA-34 for detail.

          Here's one test scenario to test resource bundle reloading with the demo::PickANumberPortlet example:

          (1) Navigate to the default page (http://localhost:8080/jetspeed/ui/default-page.psml) of the portal which contains demo::PickANumberPortlet.
          You can see the button, "Guess" or other localized string.
          (2) Open the resource bundle properties files in /demo/WEB-INF/classes/org/apache/portals/applications/demo/simple/resources/ folder.
          For example, you can open PickANumberResources_en.properties and edit the the property like this:

          pickanumber.label.guess=Guess a number

          (3) Navigate to http://localhost:8080/jetspeed/ui/Administrative/pam.psml
          And, select demo application and PickANumber portlet ("Pick a number game").
          (4) Find the "PortletDetailsManager - PickANumberPortlet" portlet window.
          In the "Details" tab, you can find the "Resource" row and the "Reload" button.
          Click "Reload" and continue.
          (5) Navigate to the default page (http://localhost:8080/jetspeed/ui/default-page.psml) again.
          Confirm that the label of the button of PickANumberPortlet changed to "Guess a number".

          Additional Note: If you want to leverage this feature with JSTL fmt tag in jsp pages, you should use <fmt-portlet:setBundle /> instead of <fmt:setBundle .../>. Please see the example in /demo/WEB-INF/demo/simple/PickANumber.jsp.

          Cheers, Woonsan

          Show
          Woonsan Ko added a comment - - edited A support tag to set localization context based on portlet config is added. Please see http://issues.apache.org/jira/browse/APA-34 for detail. Here's one test scenario to test resource bundle reloading with the demo::PickANumberPortlet example: (1) Navigate to the default page ( http://localhost:8080/jetspeed/ui/default-page.psml ) of the portal which contains demo::PickANumberPortlet. You can see the button, "Guess" or other localized string. (2) Open the resource bundle properties files in /demo/WEB-INF/classes/org/apache/portals/applications/demo/simple/resources/ folder. For example, you can open PickANumberResources_en.properties and edit the the property like this: pickanumber.label.guess=Guess a number (3) Navigate to http://localhost:8080/jetspeed/ui/Administrative/pam.psml And, select demo application and PickANumber portlet ("Pick a number game"). (4) Find the "PortletDetailsManager - PickANumberPortlet" portlet window. In the "Details" tab, you can find the "Resource" row and the "Reload" button. Click "Reload" and continue. (5) Navigate to the default page ( http://localhost:8080/jetspeed/ui/default-page.psml ) again. Confirm that the label of the button of PickANumberPortlet changed to "Guess a number". Additional Note: If you want to leverage this feature with JSTL fmt tag in jsp pages, you should use <fmt-portlet:setBundle /> instead of <fmt:setBundle .../>. Please see the example in /demo/WEB-INF/demo/simple/PickANumber.jsp. Cheers, Woonsan

            People

            • Assignee:
              Woonsan Ko
              Reporter:
              Woonsan Ko
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development