List of usage examples for com.liferay.portal.kernel.scripting ScriptingUtil clearCache
public static void clearCache(String language) throws ScriptingException
From source file:com.liferay.scriptingexecutor.messaging.ScriptingExecutorHotDeployMessageListener.java
License:Open Source License
@Override protected void onUndeploy(Message message) throws Exception { ServletContext servletContext = ServletContextPool.get(message.getString("servletContextName")); if (servletContext != null) { Properties pluginPackageProperties = getPluginPackageProperties(servletContext); String language = getLanguage(pluginPackageProperties); if (Validator.isNotNull(language)) { ScriptingUtil.clearCache(language); }//from w ww .j a va 2 s .c o m } else { Set<String> supportedLanguages = ScriptingUtil.getSupportedLanguages(); for (String supportedLanguage : supportedLanguages) { ScriptingUtil.clearCache(supportedLanguage); } } }
From source file:com.liferay.scriptingexecutor.servlet.ScriptingExecutorServletContextListener.java
License:Open Source License
@Override protected void doPortalInit() { _messageListener = new HotDeployMessageListener() { @Override/* w w w . j ava2 s .c o m*/ protected void onDeploy(Message message) throws Exception { ServletContext servletContext = ServletContextPool.get(message.getString("servletContextName")); URL url = servletContext.getResource(_SCRIPTS_DIR); if (url == null) { return; } Set<String> supportedLanguages = ScriptingUtil.getSupportedLanguages(); Properties pluginPackageProperties = getPluginPackageProperties(servletContext); String language = getLanguage(pluginPackageProperties); if (!supportedLanguages.contains(language)) { if (_log.isWarnEnabled()) { _log.warn("Unsupported language " + language); } return; } String requiredDeploymentContexts = pluginPackageProperties .getProperty("required-deployment-contexts"); if (Validator.isNull(requiredDeploymentContexts)) { return; } ClassLoader classLoader = ClassLoaderUtil .getAggregatePluginsClassLoader(StringUtil.split(requiredDeploymentContexts), false); executeScripts(servletContext, language, classLoader); } @Override protected void onUndeploy(Message message) throws Exception { ServletContext servletContext = ServletContextPool.get(message.getString("servletContextName")); if (servletContext != null) { Properties pluginPackageProperties = getPluginPackageProperties(servletContext); String language = getLanguage(pluginPackageProperties); ScriptingUtil.clearCache(language); } else { Set<String> supportedLanguages = ScriptingUtil.getSupportedLanguages(); for (String supportedLanguage : supportedLanguages) { ScriptingUtil.clearCache(supportedLanguage); } } } }; MessageBusUtil.registerMessageListener(DestinationNames.HOT_DEPLOY, _messageListener); }