@Override public void removedService( ServiceReference<CustomJspBag> serviceReference, CustomJspBag customJspBag) { Registry registry = RegistryUtil.getRegistry(); registry.ungetService(serviceReference); String contextId = GetterUtil.getString(serviceReference.getProperty("context.id")); for (String customJsp : customJspBag.getCustomJsps()) { String customJspDir = customJspBag.getCustomJspDir(); int pos = customJsp.indexOf(customJspDir); String portalJsp = customJsp.substring(pos + customJspDir.length()); if (customJspBag.isCustomJspGlobal()) { File portalJspFile = new File(PortalUtil.getPortalWebDir() + portalJsp); File portalJspBackupFile = getPortalJspBackupFile(portalJspFile); if (portalJspBackupFile.exists()) { try { FileUtil.copyFile(portalJspBackupFile, portalJspFile); } catch (IOException e) { return; } portalJspBackupFile.delete(); } else if (portalJspFile.exists()) { portalJspFile.delete(); } } else { portalJsp = CustomJspRegistryUtil.getCustomJspFileName(contextId, portalJsp); File portalJspFile = new File(PortalUtil.getPortalWebDir() + portalJsp); if (portalJspFile.exists()) { portalJspFile.delete(); } } } if (!customJspBag.isCustomJspGlobal()) { CustomJspRegistryUtil.unregisterServletContextName(contextId); } _customJspBagsMap.remove(serviceReference); }
protected void initCustomJspBag(String contextId, String contextName, CustomJspBag customJspBag) throws Exception { String customJspDir = customJspBag.getCustomJspDir(); boolean customJspGlobal = customJspBag.isCustomJspGlobal(); List<String> customJsps = customJspBag.getCustomJsps(); String portalWebDir = PortalUtil.getPortalWebDir(); for (String customJsp : customJsps) { String portalJsp = getPortalJsp(customJsp, customJspDir); if (customJspGlobal) { File portalJspFile = new File(portalWebDir + portalJsp); File portalJspBackupFile = getPortalJspBackupFile(portalJspFile); if (portalJspFile.exists() && !portalJspBackupFile.exists()) { FileUtil.copyFile(portalJspFile, portalJspBackupFile); } } else { portalJsp = CustomJspRegistryUtil.getCustomJspFileName(contextId, portalJsp); } FileUtil.write( portalWebDir + portalJsp, getCustomJspInputStream(customJspBag.getURLContainer(), customJsp)); } if (!customJspGlobal) { CustomJspRegistryUtil.registerServletContextName(contextId, contextName); } }
protected void installExt(ServletContext servletContext, ClassLoader portletClassLoader) throws Exception { String servletContextName = servletContext.getServletContextName(); String globalLibDir = PortalUtil.getGlobalLibDir(); String portalWebDir = PortalUtil.getPortalWebDir(); String portalLibDir = PortalUtil.getPortalLibDir(); String pluginWebDir = WebDirDetector.getRootDir(portletClassLoader); copyJar(servletContext, globalLibDir, "ext-service"); copyJar(servletContext, portalLibDir, "ext-impl"); copyJar(servletContext, portalLibDir, "ext-util-bridges"); copyJar(servletContext, portalLibDir, "ext-util-java"); copyJar(servletContext, portalLibDir, "ext-util-taglib"); mergeWebXml(portalWebDir, pluginWebDir); CopyTask.copyDirectory( pluginWebDir + "WEB-INF/ext-web/docroot", portalWebDir, StringPool.BLANK, "**/WEB-INF/web.xml", true, false); FileUtil.copyFile( pluginWebDir + "WEB-INF/ext-" + servletContextName + ".xml", portalWebDir + "WEB-INF/ext-" + servletContextName + ".xml"); ExtRegistry.registerExt(servletContext); }