Example usage for com.liferay.portal.kernel.messaging HotDeployMessageListener HotDeployMessageListener

List of usage examples for com.liferay.portal.kernel.messaging HotDeployMessageListener HotDeployMessageListener

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.messaging HotDeployMessageListener HotDeployMessageListener.

Prototype

public HotDeployMessageListener() 

Source Link

Usage

From source file:com.liferay.resourcesimporter.servlet.ResourcesImporterServletContextListener.java

License:Open Source License

protected void doPortalInit() {
    _messageListener = new HotDeployMessageListener() {

        protected void onDeploy(Message message) throws Exception {
            initialize(message);//from  www. java  2s . c om
        }

    };

    MessageBusUtil.registerMessageListener(DestinationNames.HOT_DEPLOY, _messageListener);
}

From source file:com.liferay.scriptingexecutor.servlet.ScriptingExecutorServletContextListener.java

License:Open Source License

@Override
protected void doPortalInit() {
    _messageListener = new HotDeployMessageListener() {

        @Override/*w ww.j a v a2  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);
}