1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.scheduler.messaging;
16  
17  import com.liferay.portal.kernel.messaging.Message;
18  import com.liferay.portal.kernel.scheduler.Trigger;
19  
20  import java.io.Serializable;
21  
22  /**
23   * <a href="SchedulerRequest.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Michael C. Han
26   * @author Bruno Farache
27   * @author Brian Wing Shun Chan
28   */
29  public class SchedulerRequest implements Serializable {
30  
31      public static final String COMMAND_REGISTER = "REGISTER";
32  
33      public static final String COMMAND_RETRIEVE = "RETRIEVE";
34  
35      public static final String COMMAND_SHUTDOWN = "SHUTDOWN";
36  
37      public static final String COMMAND_STARTUP = "STARTUP";
38  
39      public static final String COMMAND_UNREGISTER = "UNREGISTER";
40  
41      public static SchedulerRequest createRegisterRequest(
42          Trigger trigger, String description, String destination,
43          Message message) {
44  
45          return new SchedulerRequest(
46              COMMAND_REGISTER, trigger, description, destination, message);
47      }
48  
49      public static SchedulerRequest createRetrieveRequest(Trigger trigger) {
50          return new SchedulerRequest(
51              COMMAND_RETRIEVE, trigger, null, null, null);
52      }
53  
54      public static SchedulerRequest createRetrieveResponseRequest(
55          Trigger trigger, String description, Message message) {
56  
57          return new SchedulerRequest(null, trigger, description, null, message);
58      }
59  
60      public static SchedulerRequest createShutdownRequest() {
61          return new SchedulerRequest(COMMAND_SHUTDOWN, null, null, null, null);
62      }
63  
64      public static SchedulerRequest createStartupRequest() {
65          return new SchedulerRequest(COMMAND_STARTUP, null, null, null, null);
66      }
67  
68      public static SchedulerRequest createUnregisterRequest(Trigger trigger) {
69          return new SchedulerRequest(
70              COMMAND_UNREGISTER, trigger, null, null, null);
71      }
72  
73      public String getCommand() {
74          return _command;
75      }
76  
77      public String getDescription() {
78          return _description;
79      }
80  
81      public String getDestination() {
82          return _destination;
83      }
84  
85      public Message getMessage() {
86          return _message;
87      }
88  
89      public Trigger getTrigger() {
90          return _trigger;
91      }
92  
93      public void setCommand(String command) {
94          _command = command;
95      }
96  
97      public void setDescription(String description) {
98          _description = description;
99      }
100 
101     public void setDestination(String destination) {
102         _destination = destination;
103     }
104 
105     public void setMessage(Message message) {
106         _message = message;
107     }
108 
109     public void setTrigger(Trigger trigger) {
110         _trigger = trigger;
111     }
112 
113     private SchedulerRequest(
114         String command, Trigger trigger, String description, String destination,
115         Message message) {
116 
117         _command = command;
118         _trigger = trigger;
119         _description = description;
120         _destination = destination;
121         _message = message;
122     }
123 
124     private String _command;
125     private String _description;
126     private String _destination;
127     private Message _message;
128     private Trigger _trigger;
129 
130 }