// Portlet context wrapper
Iterator itr1 = _portlets.iterator();
while (itr1.hasNext()) {
Portlet portlet = (Portlet)itr1.next();
com.dotcms.repackage.javax.portlet.Portlet portletInstance =
(com.dotcms.repackage.javax.portlet.Portlet)contextClassLoader.loadClass(
portlet.getPortletClass()).newInstance();
Indexer indexerInstance = null;
if (Validator.isNotNull(portlet.getIndexerClass())) {
indexerInstance = (Indexer)contextClassLoader.loadClass(
portlet.getIndexerClass()).newInstance();
}
Scheduler schedulerInstance = null;
if (Validator.isNotNull(portlet.getSchedulerClass())) {
schedulerInstance = (Scheduler)contextClassLoader.loadClass(
portlet.getSchedulerClass()).newInstance();
}
PreferencesValidator prefsValidator = null;
if (Validator.isNotNull(portlet.getPreferencesValidator())) {
prefsValidator =
(PreferencesValidator)contextClassLoader.loadClass(
portlet.getPreferencesValidator()).newInstance();
try {
if (GetterUtil.getBoolean(PropsUtil.get(
PropsUtil.PREFERENCE_VALIDATE_ON_STARTUP))) {
prefsValidator.validate(
PortletPreferencesSerializer.fromDefaultXML(
portlet.getDefaultPreferences()));
}
}
catch (Exception e1) {
_log.warn(
"Portlet with the name " + portlet.getPortletId() +
" does not have valid default preferences");
}
}
Map resourceBundles = null;
if (Validator.isNotNull(portlet.getResourceBundle())) {
resourceBundles = CollectionFactory.getHashMap();
Iterator itr2 = portlet.getSupportedLocales().iterator();
while (itr2.hasNext()) {
String supportedLocale = (String)itr2.next();
Locale locale = new Locale(supportedLocale);
try {
ResourceBundle resourceBundle =
ResourceBundle.getBundle(
portlet.getResourceBundle(), locale,
contextClassLoader);
resourceBundles.put(
locale.getLanguage(), resourceBundle);
}
catch (MissingResourceException mre) {
_log.warn(mre.getMessage());
}
}
}
Map customUserAttributes = CollectionFactory.getHashMap();
Iterator itr2 =
portlet.getCustomUserAttributes().entrySet().iterator();
while (itr2.hasNext()) {
Map.Entry entry = (Map.Entry)itr2.next();
String attrName = (String)entry.getKey();
String attrCustomClass = (String)entry.getValue();
customUserAttributes.put(
attrCustomClass,
contextClassLoader.loadClass(
attrCustomClass).newInstance());
}
PortletContextWrapper pcw = new PortletContextWrapper(
portlet.getPortletId(), ctx, portletInstance,
indexerInstance, schedulerInstance, prefsValidator,
resourceBundles, customUserAttributes);
PortletContextPool.put(portlet.getPortletId(), pcw);
}
// Portlet class loader
String servletPath = ctx.getRealPath("/");