Author: julien_viet
Date: 2009-08-30 17:20:59 -0400 (Sun, 30 Aug 2009)
New Revision: 134
Modified:
components/pc/trunk/mc/src/main/java/org/gatein/pc/mc/PortletApplicationDeployer.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/ContainerInfoBuilderContextImpl.java
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/metadata/PortletApplication10MetaData.java
Log:
GTNPC-6 : Add resource bundle factory plugin via portlet application metadata mechanism
Modified:
components/pc/trunk/mc/src/main/java/org/gatein/pc/mc/PortletApplicationDeployer.java
===================================================================
---
components/pc/trunk/mc/src/main/java/org/gatein/pc/mc/PortletApplicationDeployer.java 2009-08-30
12:32:29 UTC (rev 133)
+++
components/pc/trunk/mc/src/main/java/org/gatein/pc/mc/PortletApplicationDeployer.java 2009-08-30
21:20:59 UTC (rev 134)
@@ -268,7 +268,7 @@
broadcaster = null;
}
- private PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
+ protected PortletApplication10MetaData buildPortletApplicationMetaData(WebApp webApp)
{
try
{
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/ContainerInfoBuilderContextImpl.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/ContainerInfoBuilderContextImpl.java 2009-08-30
12:32:29 UTC (rev 133)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/jsr168/ContainerInfoBuilderContextImpl.java 2009-08-30
21:20:59 UTC (rev 134)
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.HashMap;
+import java.lang.reflect.Constructor;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -85,8 +86,33 @@
ResourceBundleManager bundleMgr =
portletBundleMgrs.get(portletMD.getPortletName());
if (bundleMgr == null)
{
- String baseName = portletMD.getResourceBundle();
- ResourceBundleFactory rbf = new
SimpleResourceBundleFactory(webApp.getClassLoader(), baseName);
+ ResourceBundleFactory rbf = null;
+ String rbfName = metaData.getResourceBundleFactoryName();
+ if (rbfName != null)
+ {
+ try
+ {
+ Class<?> tmpClass = webApp.getClassLoader().loadClass(rbfName);
+ if (ResourceBundleFactory.class.isAssignableFrom(tmpClass))
+ {
+ Class<? extends ResourceBundleFactory> rbfClass =
tmpClass.asSubclass(ResourceBundleFactory.class);
+ Constructor<? extends ResourceBundleFactory> rbfCtor =
rbfClass.getConstructor(ClassLoader.class, String.class);
+ rbf = rbfCtor.newInstance(webApp.getClassLoader(),
portletMD.getResourceBundle());
+ }
+ }
+ catch (Exception e)
+ {
+ // Need to log
+ }
+ }
+
+ //
+ if (rbf == null)
+ {
+ rbf = new SimpleResourceBundleFactory(webApp.getClassLoader(),
portletMD.getResourceBundle());
+ }
+
+ //
bundleMgr = new ResourceBundleManager(null, rbf);
portletBundleMgrs.put(portletMD.getPortletName(), bundleMgr);
}
Modified:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/metadata/PortletApplication10MetaData.java
===================================================================
---
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/metadata/PortletApplication10MetaData.java 2009-08-30
12:32:29 UTC (rev 133)
+++
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/impl/metadata/PortletApplication10MetaData.java 2009-08-30
21:20:59 UTC (rev 134)
@@ -75,6 +75,9 @@
/** The security constraints */
private List<SecurityConstraintMetaData> securityConstraints;
+ /** The resource bundle factory class name. */
+ private String resourceBundleFactoryName;
+
@XmlAttribute(name = "id")
public String getId()
{
@@ -217,4 +220,14 @@
}
this.securityConstraints.add(securityConstraint);
}
+
+ public String getResourceBundleFactoryName()
+ {
+ return resourceBundleFactoryName;
+ }
+
+ public void setResourceBundleFactoryName(String resourceBundleFactoryName)
+ {
+ this.resourceBundleFactoryName = resourceBundleFactoryName;
+ }
}
Show replies by date