001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.messaging;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class HotDeployMessageListener extends BaseMessageListener {
025    
026            public HotDeployMessageListener(String servletContextName) {
027                    _servletContextName = servletContextName;
028            }
029    
030            @Override
031            protected void doReceive(Message message) throws Exception {
032                    String servletContextName = GetterUtil.getString(
033                            message.getString("servletContextName"));
034    
035                    if (!servletContextName.equals(_servletContextName)) {
036                            return;
037                    }
038    
039                    String command = GetterUtil.getString(message.getString("command"));
040    
041                    if (command.equals("deploy")) {
042                            onDeploy();
043                    }
044                    else if (command.equals("undeploy")) {
045                            onUndeploy();
046                    }
047            }
048    
049            protected void onDeploy() throws Exception {
050            }
051    
052            protected void onUndeploy() throws Exception {
053            }
054    
055            private static Log _log = LogFactoryUtil.getLog(
056                    HotDeployMessageListener.class);
057    
058            private String _servletContextName;
059    
060    }