List of usage examples for com.liferay.portal.kernel.servlet ServletContextPool get
public static ServletContext get(String servletContextName)
From source file:com.liferay.httpservice.internal.http.HttpSupport.java
License:Open Source License
public BundleServletContext getNonWABBundleServletContext(Bundle bundle) { String servletContextName = BundleServletContext.getServletContextName(bundle, true); ServletContext servletContext = ServletContextPool.get(servletContextName); if (servletContext == null) { BundleServletContext bundleServletContext = new BundleServletContext(bundle, servletContextName, _webExtenderServlet.getServletContext()); bundleServletContext.setServletContextName(servletContextName); ServletContextPool.put(servletContextName, bundleServletContext); servletContext = bundleServletContext; }// www.j av a2 s .c om return (BundleServletContext) servletContext; }
From source file:com.liferay.httpservice.internal.servlet.WebExtenderServlet.java
License:Open Source License
protected ServletContext getServletContext(String portletId, String requestURI) { Portlet portlet = null;/*from w w w . ja v a2 s. c om*/ if (Validator.isNotNull(portletId)) { try { String rootPortletId = PortletConstants.getRootPortletId(portletId); portlet = PortletLocalServiceUtil.getPortletById(rootPortletId); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } String servletContextName = null; if (portlet != null) { PortletApp portletApp = portlet.getPortletApp(); servletContextName = portletApp.getServletContextName(); } else if (requestURI != null) { servletContextName = requestURI; String contextPath = PortalUtil.getPathContext(); if (Validator.isNotNull(contextPath) && servletContextName.startsWith(contextPath)) { servletContextName = servletContextName.substring(contextPath.length()); } String modulePath = Portal.PATH_MODULE + StringPool.SLASH; if (servletContextName.startsWith(modulePath)) { servletContextName = servletContextName.substring(modulePath.length()); } if (servletContextName.startsWith(StringPool.SLASH)) { servletContextName = servletContextName.substring(1); } int index = servletContextName.indexOf(StringPool.SLASH); if (index != -1) { servletContextName = servletContextName.substring(0, index); } } return ServletContextPool.get(servletContextName); }
From source file:com.liferay.httpservice.internal.WebBundleDeployer.java
License:Open Source License
public void close() { Set<String> servletContextNames = ServletContextPool.keySet(); for (String servletContextName : servletContextNames) { ServletContext servletContext = ServletContextPool.get(servletContextName); if (!(servletContext instanceof BundleServletContext)) { continue; }//from w w w .j a v a2 s . c o m BundleServletContext bundleServletContext = (BundleServletContext) servletContext; Bundle bundle = bundleServletContext.getBundle(); try { doStop(bundle, servletContextName); } catch (Exception e) { _log.error(e, e); } } _webExtenderServlet = null; }
From source file:com.liferay.httpservice.internal.WebBundleDeployer.java
License:Open Source License
public void doStart(Bundle bundle, String servletContextName) { if (bundle.getState() != Bundle.ACTIVE) { return;//from w ww.j av a 2s . c o m } EventUtil.sendEvent(bundle, EventUtil.DEPLOYING, null, false); ServletContext servletContext = ServletContextPool.get(servletContextName); if (servletContext != null) { EventUtil.sendEvent(bundle, EventUtil.FAILED, null, true); _collidedWABBundleIds.add(bundle.getBundleId()); return; } try { BundleServletContext bundleServletContext = new BundleServletContext(bundle, servletContextName, _webExtenderServlet.getServletContext()); bundleServletContext.open(); ServletContextPool.put(servletContextName, bundleServletContext); } catch (Exception e) { EventUtil.sendEvent(bundle, EventUtil.FAILED, e, false); } }
From source file:com.liferay.httpservice.internal.WebBundleDeployer.java
License:Open Source License
public void doStop(Bundle bundle, String servletContextName) { EventUtil.sendEvent(bundle, EventUtil.UNDEPLOYING, null, false); BundleServletContext bundleServletContext = null; ServletContext servletContext = ServletContextPool.get(servletContextName); if ((servletContext != null) && (servletContext instanceof BundleServletContext)) { bundleServletContext = (BundleServletContext) servletContext; }/* www.j a va 2 s. c o m*/ if (bundleServletContext == null) { EventUtil.sendEvent(bundle, EventUtil.UNDEPLOYED, null, false); ServletContextPool.remove(servletContextName); return; } try { bundleServletContext.close(); } catch (Exception e) { EventUtil.sendEvent(bundle, EventUtil.FAILED, null, false); } EventUtil.sendEvent(bundle, EventUtil.UNDEPLOYED, null, false); ServletContextPool.remove(servletContextName); handleCollidedWABs(bundle, servletContextName); }
From source file:com.liferay.marketplace.app.manager.web.internal.portlet.MarketplaceAppManagerPortlet.java
License:Open Source License
public void updatePluginSettings(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] contextNames = StringUtil.split(ParamUtil.getString(actionRequest, "contextNames")); boolean active = ParamUtil.getBoolean(actionRequest, "active"); for (String contextName : contextNames) { ServletContext servletContext = ServletContextPool.get(contextName); List<LayoutTemplate> layoutTemplates = (List<LayoutTemplate>) servletContext .getAttribute(WebKeys.PLUGIN_LAYOUT_TEMPLATES); if (layoutTemplates != null) { for (LayoutTemplate layoutTemplate : layoutTemplates) { PluginSetting pluginSetting = _pluginSettingLocalService.getPluginSetting( themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE); _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE, pluginSetting.getRoles(), active); }/*from ww w.j a va2 s. c om*/ } List<Portlet> portlets = (List<Portlet>) servletContext.getAttribute(WebKeys.PLUGIN_PORTLETS); if (portlets != null) { for (Portlet portlet : portlets) { _portletService.updatePortlet(themeDisplay.getCompanyId(), portlet.getPortletId(), StringPool.BLANK, active); } } List<Theme> themes = (List<Theme>) servletContext.getAttribute(WebKeys.PLUGIN_THEMES); if (themes != null) { for (Theme theme : themes) { PluginSetting pluginSetting = _pluginSettingLocalService .getPluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME); _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME, pluginSetting.getRoles(), active); } } } }
From source file:com.liferay.marketplace.appmanager.portlet.AppManagerPortlet.java
License:Open Source License
public void updatePluginSettings(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] contextNames = StringUtil.split(ParamUtil.getString(actionRequest, "contextNames")); boolean active = ParamUtil.getBoolean(actionRequest, "active"); for (String contextName : contextNames) { ServletContext servletContext = ServletContextPool.get(contextName); List<LayoutTemplate> layoutTemplates = (List<LayoutTemplate>) servletContext .getAttribute(WebKeys.PLUGIN_LAYOUT_TEMPLATES); if (layoutTemplates != null) { for (LayoutTemplate layoutTemplate : layoutTemplates) { PluginSetting pluginSetting = PluginSettingLocalServiceUtil.getPluginSetting( themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE); PluginSettingServiceUtil.updatePluginSetting(themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE, pluginSetting.getRoles(), active); }//from w w w . j av a2 s . c om } List<Portlet> portlets = (List<Portlet>) servletContext.getAttribute(WebKeys.PLUGIN_PORTLETS); if (portlets != null) { for (Portlet portlet : portlets) { PortletServiceUtil.updatePortlet(themeDisplay.getCompanyId(), portlet.getPortletId(), StringPool.BLANK, active); } } List<Theme> themes = (List<Theme>) servletContext.getAttribute(WebKeys.PLUGIN_THEMES); if (themes != null) { for (Theme theme : themes) { PluginSetting pluginSetting = PluginSettingLocalServiceUtil .getPluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME); PluginSettingServiceUtil.updatePluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME, pluginSetting.getRoles(), active); } } } }
From source file:com.liferay.marketplace.service.impl.AppLocalServiceImpl.java
License:Open Source License
@Override public Map<String, String> getBundledApps() { if (_bundledApps != null) { return _bundledApps; }//from w ww. ja v a 2 s. c o m Map<String, String> bundledApps = new HashMap<String, String>(); List<PluginPackage> pluginPackages = DeployManagerUtil.getInstalledPluginPackages(); for (PluginPackage pluginPackage : pluginPackages) { ServletContext servletContext = ServletContextPool.get(pluginPackage.getContext()); InputStream inputStream = null; try { inputStream = servletContext.getResourceAsStream("/WEB-INF/liferay-releng.changelog.md5"); if (inputStream == null) { continue; } String relengHash = StringUtil.read(inputStream); if (Validator.isNotNull(relengHash)) { bundledApps.put(pluginPackage.getContext(), relengHash); } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to read plugin package MD5 checksum for " + pluginPackage.getContext()); } } finally { StreamUtil.cleanUp(inputStream); } } _bundledApps = bundledApps; return _bundledApps; }
From source file:com.liferay.marketplace.util.comparator.PluginComparator.java
License:Open Source License
public PluginComparator() { _locale = LocaleUtil.getDefault(); _servletContext = ServletContextPool.get(PortalUtil.getPathContext()); }
From source file:com.liferay.mvc.freemarker.internal.FreeMarkerMVCContextHelper.java
License:Open Source License
public static void addPortletJSPTaglibSupport(FreeMarkerContext freeMarkerContext, PortletRequest portletRequest, PortletResponse portletResponse, Set<String> templateRegistry) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); HttpServletResponse response = PortalUtil.getHttpServletResponse(portletResponse); FreeMarkerVariablesUtil.insertVariables(freeMarkerContext, request); Portlet portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET); String servletContextName = portlet.getPortletApp().getServletContextName(); final ServletContext servletContext = ServletContextPool.get(servletContextName); Object templateRegistryAttribute = servletContext.getAttribute(TEMPLATE_REGISTRY_ATTRIBUTE); if ((templateRegistry != null) && (templateRegistryAttribute == null)) { servletContext.setAttribute(TEMPLATE_REGISTRY_ATTRIBUTE, templateRegistry); }//from w w w . ja v a 2s . co m freeMarkerContext.put("fullTemplatesPath", StringPool.SLASH + servletContextName + FreeMarkerTemplateLoader.SERVLET_SEPARATOR); TemplateHashModel taglibsFactory = FreeMarkerTaglibFactoryUtil.createTaglibFactory(servletContext); freeMarkerContext.put("PortletJspTagLibs", taglibsFactory); ServletConfig servletConfig = (ServletConfig) portletRequest .getAttribute(PortletServlet.PORTLET_SERVLET_CONFIG); final PortletServlet portletServlet = new PortletServlet(); portletServlet.init(servletConfig); ServletContextHashModel servletContextHashModel = new ServletContextHashModel(portletServlet, ObjectWrapper.DEFAULT_WRAPPER); freeMarkerContext.put("Application", servletContextHashModel); HttpRequestHashModel httpRequestHashModel = new HttpRequestHashModel(request, response, ObjectWrapper.DEFAULT_WRAPPER); freeMarkerContext.put("Request", httpRequestHashModel); }