List of usage examples for com.liferay.portal.util PropsValues LOCALES
String[] LOCALES
To view the source code for com.liferay.portal.util PropsValues LOCALES.
Click Source Link
From source file:com.liferay.portlet.PortletBagFactory.java
License:Open Source License
public PortletBag create(Portlet portlet) throws Exception { PortletApp portletApp = portlet.getPortletApp(); if (!portletApp.isWARFile() && _warFile) { String contextPath = PortalUtil.getPathContext(); _servletContext = ServletContextPool.get(contextPath); _classLoader = PortalClassLoaderUtil.getClassLoader(); }//from www. ja v a 2 s . co m Class<?> portletClass = null; try { portletClass = _classLoader.loadClass(portlet.getPortletClass()); } catch (Throwable e) { _log.error(e, e); PortletLocalServiceUtil.destroyPortlet(portlet); return null; } javax.portlet.Portlet portletInstance = (javax.portlet.Portlet) portletClass.newInstance(); ConfigurationAction configurationActionInstance = newConfigurationAction(portlet); List<Indexer> indexerInstances = newIndexers(portlet); OpenSearch openSearchInstance = newOpenSearch(portlet); initSchedulers(portlet); FriendlyURLMapper friendlyURLMapperInstance = newFriendlyURLMapper(portlet); URLEncoder urlEncoderInstance = newURLEncoder(portlet); PortletDataHandler portletDataHandlerInstance = newPortletDataHandler(portlet); PortletLayoutListener portletLayoutListenerInstance = newPortletLayoutListener(portlet); PollerProcessor pollerProcessorInstance = newPollerProcessor(portlet); MessageListener popMessageListenerInstance = newPOPMessageListener(portlet); SocialActivityInterpreter socialActivityInterpreterInstance = initSocialActivityInterpreterInstance( portlet); SocialRequestInterpreter socialRequestInterpreterInstance = null; if (Validator.isNotNull(portlet.getSocialRequestInterpreterClass())) { socialRequestInterpreterInstance = (SocialRequestInterpreter) newInstance( SocialRequestInterpreter.class, portlet.getSocialRequestInterpreterClass()); socialRequestInterpreterInstance = new SocialRequestInterpreterImpl(portlet.getPortletId(), socialRequestInterpreterInstance); SocialRequestInterpreterLocalServiceUtil.addRequestInterpreter(socialRequestInterpreterInstance); } WebDAVStorage webDAVStorageInstance = null; if (Validator.isNotNull(portlet.getWebDAVStorageClass())) { webDAVStorageInstance = (WebDAVStorage) newInstance(WebDAVStorage.class, portlet.getWebDAVStorageClass()); webDAVStorageInstance.setToken(portlet.getWebDAVStorageToken()); WebDAVUtil.addStorage(webDAVStorageInstance); } Method xmlRpcMethodInstance = null; if (Validator.isNotNull(portlet.getXmlRpcMethodClass())) { xmlRpcMethodInstance = (Method) newInstance(Method.class, portlet.getXmlRpcMethodClass()); XmlRpcServlet.registerMethod(xmlRpcMethodInstance); } ControlPanelEntry controlPanelEntryInstance = null; if (Validator.isNotNull(portlet.getControlPanelEntryClass())) { controlPanelEntryInstance = (ControlPanelEntry) newInstance(ControlPanelEntry.class, portlet.getControlPanelEntryClass()); } List<AssetRendererFactory> assetRendererFactoryInstances = newAssetRendererFactoryInstances(portlet); List<AtomCollectionAdapter<?>> atomCollectionAdapterInstances = newAtomCollectionAdapterInstances(portlet); List<CustomAttributesDisplay> customAttributesDisplayInstances = new ArrayList<CustomAttributesDisplay>(); for (String customAttributesDisplayClass : portlet.getCustomAttributesDisplayClasses()) { CustomAttributesDisplay customAttributesDisplayInstance = (CustomAttributesDisplay) newInstance( CustomAttributesDisplay.class, customAttributesDisplayClass); customAttributesDisplayInstance .setClassNameId(PortalUtil.getClassNameId(customAttributesDisplayInstance.getClassName())); customAttributesDisplayInstance.setPortletId(portlet.getPortletId()); customAttributesDisplayInstances.add(customAttributesDisplayInstance); } PermissionPropagator permissionPropagatorInstance = newPermissionPropagator(portlet); List<WorkflowHandler> workflowHandlerInstances = new ArrayList<WorkflowHandler>(); for (String workflowHandlerClass : portlet.getWorkflowHandlerClasses()) { WorkflowHandler workflowHandlerInstance = (WorkflowHandler) newInstance(WorkflowHandler.class, workflowHandlerClass); workflowHandlerInstances.add(workflowHandlerInstance); WorkflowHandlerRegistryUtil.register(workflowHandlerInstance); } PreferencesValidator preferencesValidatorInstance = null; if (Validator.isNotNull(portlet.getPreferencesValidator())) { preferencesValidatorInstance = (PreferencesValidator) newInstance(PreferencesValidator.class, portlet.getPreferencesValidator()); try { if (PropsValues.PREFERENCE_VALIDATE_ON_STARTUP) { preferencesValidatorInstance.validate( PortletPreferencesFactoryUtil.fromDefaultXML(portlet.getDefaultPreferences())); } } catch (Exception e) { _log.warn("Portlet with the name " + portlet.getPortletId() + " does not have valid default preferences"); } } Map<String, ResourceBundle> resourceBundles = null; String resourceBundle = portlet.getResourceBundle(); if (Validator.isNotNull(resourceBundle) && !resourceBundle.equals(StrutsResourceBundle.class.getName())) { resourceBundles = new HashMap<String, ResourceBundle>(); initResourceBundle(resourceBundles, portlet, null); initResourceBundle(resourceBundles, portlet, LocaleUtil.getDefault()); Set<String> supportedLocales = portlet.getSupportedLocales(); if (supportedLocales.isEmpty()) { supportedLocales = SetUtil.fromArray(PropsValues.LOCALES); } for (String supportedLocale : supportedLocales) { Locale locale = LocaleUtil.fromLanguageId(supportedLocale); initResourceBundle(resourceBundles, portlet, locale); } } PortletBag portletBag = new PortletBagImpl(portlet.getPortletId(), _servletContext, portletInstance, configurationActionInstance, indexerInstances, openSearchInstance, friendlyURLMapperInstance, urlEncoderInstance, portletDataHandlerInstance, portletLayoutListenerInstance, pollerProcessorInstance, popMessageListenerInstance, socialActivityInterpreterInstance, socialRequestInterpreterInstance, webDAVStorageInstance, xmlRpcMethodInstance, controlPanelEntryInstance, assetRendererFactoryInstances, atomCollectionAdapterInstances, customAttributesDisplayInstances, permissionPropagatorInstance, workflowHandlerInstances, preferencesValidatorInstance, resourceBundles); PortletBagPool.put(portlet.getRootPortletId(), portletBag); try { PortletInstanceFactoryUtil.create(portlet, _servletContext); } catch (Exception e) { _log.error(e, e); } return portletBag; }