protected void checkWebResources( BundleContext bundleContext, String contextName, ClassLoader classLoader, ServiceRegistrations serviceRegistrations) { serviceRegistrations.addServiceRegistration(createDefaultServlet(bundleContext, contextName)); serviceRegistrations.addServiceRegistration( createJspServlet(bundleContext, contextName, classLoader)); serviceRegistrations.addServiceRegistration( createPortletServlet(bundleContext, contextName, classLoader)); serviceRegistrations.addServiceRegistration( createRestrictPortletServletRequestFilter(bundleContext, contextName, classLoader)); }
protected void checkResourceBundles( BundleContext bundleContext, ClassLoader classLoader, com.liferay.portal.model.Portlet portletModel, ServiceRegistrations serviceRegistrations) { if (Validator.isBlank(portletModel.getResourceBundle())) { return; } for (Locale locale : LanguageUtil.getAvailableLocales()) { ResourceBundle resourceBundle = ResourceBundleUtil.getBundle(portletModel.getResourceBundle(), locale, classLoader); Dictionary<String, Object> properties = new HashMapDictionary<>(); properties.put("javax.portlet.name", portletModel.getPortletId()); properties.put("language.id", LocaleUtil.toLanguageId(locale)); ServiceRegistration<ResourceBundle> serviceRegistration = bundleContext.registerService(ResourceBundle.class, resourceBundle, properties); serviceRegistrations.addServiceRegistration(serviceRegistration); } }
protected void createContext( Bundle bundle, PortletApp portletApp, ServiceRegistrations serviceRegistrations) { ServletContextHelper servletContextHelper = new BundlePortletServletContextHelper(bundle); BundleContext bundleContext = bundle.getBundleContext(); Dictionary<String, Object> properties = new HashMapDictionary<>(); properties.put( HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, portletApp.getServletContextName()); properties.put( HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/" + portletApp.getServletContextName()); properties.put(Constants.SERVICE_RANKING, 1000); serviceRegistrations.addServiceRegistration( bundleContext.registerService( ServletContextHelper.class, servletContextHelper, properties)); }
protected BundlePortletApp createBundlePortletApp( Bundle bundle, ClassLoader classLoader, ServiceRegistrations serviceRegistrations) { BundlePortletApp bundlePortletApp = serviceRegistrations.getBundlePortletApp(); if (bundlePortletApp != null) { return bundlePortletApp; } com.liferay.portal.model.Portlet portalPortletModel = _portletLocalService.getPortletById(CompanyConstants.SYSTEM, PortletKeys.PORTAL); bundlePortletApp = new BundlePortletApp(bundle, portalPortletModel, _httpServiceEndpoint); createContext(bundle, bundlePortletApp, serviceRegistrations); initLogger(classLoader); serviceRegistrations.setBundlePortletApp(bundlePortletApp); serviceRegistrations.doConfiguration(classLoader); BundleContext bundleContext = bundle.getBundleContext(); Dictionary<String, Object> properties = new HashMapDictionary<>(); properties.put( HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, bundlePortletApp.getServletContextName()); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString()); serviceRegistrations.addServiceRegistration( bundleContext.registerService(ServletContextListener.class, bundlePortletApp, properties)); return bundlePortletApp; }