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.util.GetterUtil;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public class HotDeployMessageListener extends BaseMessageListener {
023    
024            public HotDeployMessageListener(String servletContextName) {
025                    _servletContextName = servletContextName;
026            }
027    
028            @Override
029            protected void doReceive(Message message) throws Exception {
030                    String servletContextName = GetterUtil.getString(
031                            message.getString("servletContextName"));
032    
033                    if (!servletContextName.equals(_servletContextName)) {
034                            return;
035                    }
036    
037                    String command = GetterUtil.getString(message.getString("command"));
038    
039                    if (command.equals("deploy")) {
040                            onDeploy();
041                    }
042                    else if (command.equals("undeploy")) {
043                            onUndeploy();
044                    }
045            }
046    
047            protected void onDeploy() throws Exception {
048            }
049    
050            protected void onUndeploy() throws Exception {
051            }
052    
053            private String _servletContextName;
054    
055    }