View Javadoc

1   /*
2    * Copyright 2009, Josh Devins, Jitr.org.
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  
17  package org.jitr.core;
18  
19  import org.apache.commons.lang.Validate;
20  
21  /**
22   * A simple, immutable model containing a complete Jitr runtime configuration.
23   * 
24   * @author Josh Devins (info@joshdevins.net)
25   */
26  public final class ConfigurationModel {
27  
28      private final String baseUri;
29  
30      private final Class<?> containerClass;
31  
32      private final String containerWorkPath;
33  
34      private final String contextPath;
35  
36      private final OperationalMode mode;
37  
38      private final int port;
39  
40      private final String warPath;
41  
42      public ConfigurationModel(final String baseUri, final Class<?> containerClass,
43              final String containerWorkPath, final String contextPath, final OperationalMode mode,
44              final int port, final String warPath) {
45  
46          Validate.notEmpty(baseUri, "Base URI must not be empty.");
47          Validate.notNull(containerClass, "Container class must not be null.");
48          Validate.notNull(containerWorkPath, "Container work path must not be null.");
49          Validate.notEmpty(contextPath, "Context path must not be empty.");
50          Validate.notNull(mode, "Operational mode must not be null.");
51          Validate.notNull(warPath, "War path must not be null.");
52  
53          this.baseUri = baseUri;
54          this.containerClass = containerClass;
55          this.containerWorkPath = containerWorkPath;
56          this.contextPath = contextPath;
57          this.mode = mode;
58          this.port = port;
59          this.warPath = warPath;
60      }
61  
62      public String getBaseUri() {
63          return baseUri;
64      }
65  
66      public Class<?> getContainerClass() {
67          return containerClass;
68      }
69  
70      public String getContainerWorkPath() {
71          return containerWorkPath;
72      }
73  
74      public String getContextPath() {
75          return contextPath;
76      }
77  
78      public OperationalMode getMode() {
79          return mode;
80      }
81  
82      public int getPort() {
83          return port;
84      }
85  
86      public String getWarPath() {
87          return warPath;
88      }
89  }