001    /**
002     * Copyright (c) 2000-2010 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.scheduler.messaging;
016    
017    import com.liferay.portal.kernel.messaging.Message;
018    import com.liferay.portal.kernel.scheduler.Trigger;
019    
020    import java.io.Serializable;
021    
022    /**
023     * @author Michael C. Han
024     * @author Bruno Farache
025     * @author Brian Wing Shun Chan
026     */
027    public class SchedulerRequest implements Serializable {
028    
029            public static final String COMMAND_REGISTER = "REGISTER";
030    
031            public static final String COMMAND_RETRIEVE = "RETRIEVE";
032    
033            public static final String COMMAND_SHUTDOWN = "SHUTDOWN";
034    
035            public static final String COMMAND_STARTUP = "STARTUP";
036    
037            public static final String COMMAND_UNREGISTER = "UNREGISTER";
038    
039            public static SchedulerRequest createRegisterRequest(
040                    Trigger trigger, String description, String destination,
041                    Message message) {
042    
043                    return new SchedulerRequest(
044                            COMMAND_REGISTER, trigger, description, destination, message);
045            }
046    
047            public static SchedulerRequest createRetrieveRequest(Trigger trigger) {
048                    return new SchedulerRequest(
049                            COMMAND_RETRIEVE, trigger, null, null, null);
050            }
051    
052            public static SchedulerRequest createRetrieveResponseRequest(
053                    Trigger trigger, String description, Message message) {
054    
055                    return new SchedulerRequest(null, trigger, description, null, message);
056            }
057    
058            public static SchedulerRequest createShutdownRequest() {
059                    return new SchedulerRequest(COMMAND_SHUTDOWN, null, null, null, null);
060            }
061    
062            public static SchedulerRequest createStartupRequest() {
063                    return new SchedulerRequest(COMMAND_STARTUP, null, null, null, null);
064            }
065    
066            public static SchedulerRequest createUnregisterRequest(Trigger trigger) {
067                    return new SchedulerRequest(
068                            COMMAND_UNREGISTER, trigger, null, null, null);
069            }
070    
071            public String getCommand() {
072                    return _command;
073            }
074    
075            public String getDescription() {
076                    return _description;
077            }
078    
079            public String getDestination() {
080                    return _destination;
081            }
082    
083            public Message getMessage() {
084                    return _message;
085            }
086    
087            public Trigger getTrigger() {
088                    return _trigger;
089            }
090    
091            public void setCommand(String command) {
092                    _command = command;
093            }
094    
095            public void setDescription(String description) {
096                    _description = description;
097            }
098    
099            public void setDestination(String destination) {
100                    _destination = destination;
101            }
102    
103            public void setMessage(Message message) {
104                    _message = message;
105            }
106    
107            public void setTrigger(Trigger trigger) {
108                    _trigger = trigger;
109            }
110    
111            private SchedulerRequest(
112                    String command, Trigger trigger, String description, String destination,
113                    Message message) {
114    
115                    _command = command;
116                    _trigger = trigger;
117                    _description = description;
118                    _destination = destination;
119                    _message = message;
120            }
121    
122            private String _command;
123            private String _description;
124            private String _destination;
125            private Message _message;
126            private Trigger _trigger;
127    
128    }