View Javadoc

1   /*
2    *  Copyright 2010 Felix Roethenbacher
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package ch.syabru.nagios.broker.impl;
17  
18  import org.apache.commons.lang.Validate;
19  
20  import ch.syabru.nagios.broker.ExternalCommand;
21  import ch.syabru.nagios.broker.ExternalCommandFactory;
22  
23  /**
24   * Process service check result command factory.
25   *
26   * @author Felix Roethenbacher
27   *
28   */
29  public class ProcessServiceCheckResultCommandFactory
30  implements ExternalCommandFactory
31  {
32      private String hostName;
33      private String serviceDescription;
34      private int returnCode;
35      private String pluginOutput;
36  
37      /**
38       * C'tor.
39       * @param hostName Host name.
40       * @param serviceDescription Service description.
41       * @param returnCode Return code.
42       * @param pluginOutput Plugin output.
43       */
44      public ProcessServiceCheckResultCommandFactory(String hostName,
45              String serviceDescription, int returnCode, String pluginOutput)
46      {
47          Validate.notNull(hostName, "hostName must not be null");
48          Validate.notNull(serviceDescription,
49                  "serviceDescription must not be null");
50          Validate.notNull(returnCode, "returnCode must not be null");
51          Validate.notNull(pluginOutput, "pluginOutput must not be null");
52          this.hostName = hostName;
53          this.serviceDescription = serviceDescription;
54          this.returnCode = returnCode;
55          this.pluginOutput = pluginOutput;
56      }
57  
58      @Override
59      public ExternalCommand createCommand() {
60          return new ProcessServiceCheckResultCommand(
61                  hostName, serviceDescription, returnCode, pluginOutput);
62      }
63  
64  }