* @param name a PortletControl name available in the registry or a classname
* @return the created PortletControl
*/
public PortletControl getControl(String name)
{
PortletControl pc = null;
PortletControlEntry entry = null;
if (name != null)
{
entry = (PortletControlEntry) Registry.getEntry(Registry.PORTLET_CONTROL, name);
}
Map params = null;
try
{
if (entry == null)
{
if (name != null)
{
pc = (PortletControl) Class.forName(name).newInstance();
params = new Hashtable();
}
}
else
{
pc = (PortletControl) Class.forName(entry.getClassname()).newInstance();
params = entry.getParameterMap();
}
}
catch (Exception e)
{
logger.error("Unable to instanciate control " + name + ", using default", e);
}
if ((pc == null) && (defaultControl != null) && (!defaultControl.equals(name)))
{
return getControl(defaultControl);
}
PortletControlConfig pcConf = new BasePortletControlConfig();
pcConf.setName(name);
pcConf.setInitParameters(params);
pc.setConfig(pcConf);
return pc;
}