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(String... servletContextNames) 

Source Link

Usage

From source file:com.liferay.calendar.servlet.CalendarServletContextListener.java

License:Open Source License

@Override
protected void doPortalInit() throws Exception {
    _messageListener = new HotDeployMessageListener(ClpSerializer.getServletContextName()) {

        @Override//  ww w . j ava 2 s. co m
        protected void onDeploy(Message message) throws Exception {
            if (!PortletPropsValues.CALENDAR_SYNC_CALEVENTS_ON_STARTUP) {
                return;
            }

            StopWatch stopWatch = null;

            if (_log.isInfoEnabled()) {
                stopWatch = new StopWatch();

                stopWatch.start();
            }

            CalendarImporterLocalServiceUtil.importCalEvents();

            if (_log.isInfoEnabled()) {
                StringBundler sb = new StringBundler(6);

                sb.append("Calendar events synchronization takes ");
                sb.append(stopWatch.getTime());
                sb.append(" ms. Set the property ");
                sb.append("\"calendar.sync.calevents.on.startup\" ");
                sb.append("to \"false\" to disable calendar events ");
                sb.append("synchronization.");

                _log.info(sb.toString());
            }
        }

    };

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