For those that use WebSphere Commerce, especially if you’re taking advantage of internationalization and localization, you’ve used many a resource bundles. You also understand how challenging it can be when you have to consistently modify your properties, only to have to restart your application server in order to view the updates.
Here is a solution that will allow you to change your property files, and refresh them automatically without restarting your application server. This piece of logic resides in a JSP page, as I can just copy it around to the projects I’m working on.
Here is the JSP code that I leverage in order to refresh my property resource bundles.
<%@ page import="java.util.*, java.lang.reflect.*"%> <% Class klass = Class.forName("java.util.ResourceBundle").getSuperclass(); Field field = klass.getDeclaredField("cacheList"); field.setAccessible(true); sun.misc.SoftCache cache = (sun.misc.SoftCache)field.get(null); cache.clear(); field.setAccessible(false); %> <body> <p style="text-align: center;">The Property Resource Bundles were reset on <%=new java.util.Date()%>.</p> </body>