01: //========================================================================
02: //$Id: SystemProperty.java 661 2006-07-06 10:38:27Z janb $
03: //Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
04: //------------------------------------------------------------------------
05: //Licensed under the Apache License, Version 2.0 (the "License");
06: //you may not use this file except in compliance with the License.
07: //You may obtain a copy of the License at
08: //http://www.apache.org/licenses/LICENSE-2.0
09: //Unless required by applicable law or agreed to in writing, software
10: //distributed under the License is distributed on an "AS IS" BASIS,
11: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: //See the License for the specific language governing permissions and
13: //limitations under the License.
14: //========================================================================
15:
16: package org.mortbay.jetty.plugin.util;
17:
18: /**
19: * SystemProperty
20: *
21: * Provides the ability to set System properties
22: * for the mojo execution. A value will only
23: * be set if it is not set already. That is, if
24: * it was set on the command line or by the system,
25: * it won't be overridden by settings in the
26: * plugin's configuration.
27: *
28: */
29: public class SystemProperty {
30:
31: private String name;
32: private String value;
33:
34: /**
35: * @return Returns the name.
36: */
37: public String getName() {
38: return this .name;
39: }
40:
41: /**
42: * @param name The name to set.
43: */
44: public void setName(String name) {
45: this .name = name;
46: }
47:
48: public String getKey() {
49: return this .name;
50: }
51:
52: public void setKey(String name) {
53: this .name = name;
54: }
55:
56: /**
57: * @return Returns the value.
58: */
59: public String getValue() {
60: return this .value;
61: }
62:
63: /**
64: * @param value The value to set.
65: */
66: public void setValue(String value) {
67: this .value = value;
68: }
69:
70: /** Set a System.property with this value
71: * if it is not already set.
72: * @return
73: */
74: public boolean setIfNotSetAlready() {
75: if (System.getProperty(getName()) == null) {
76: System.setProperty(getName(), (getValue() == null ? ""
77: : getValue()));
78: return true;
79: }
80:
81: return false;
82: }
83:
84: }
|