]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java
Slightly modify the class to enable easy introduction of sorter on column headers...
[lgpl/argeo-commons.git] / osgi / runtime / org.argeo.osgi.boot / src / main / java / org / argeo / osgi / boot / OsgiBootUtils.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.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.argeo.osgi.boot;
18
19 public class OsgiBootUtils {
20
21 public static void info(Object obj) {
22 System.out.println("# OSGiBOOT # " + obj);
23 }
24
25 public static void debug(Object obj) {
26 System.out.println("# OSGiBOOT DBG # " + obj);
27 }
28
29 public static void warn(Object obj) {
30 System.out.println("# OSGiBOOT WARN # " + obj);
31 // Because of a weird bug under Windows when starting it in a forked VM
32 // if (System.getProperty("os.name").contains("Windows"))
33 // System.out.println("# WARN " + obj);
34 // else
35 // System.err.println("# WARN " + obj);
36 }
37
38 //FIXE: returns null when defaultValue is ""
39 public static String getProperty(String name, String defaultValue) {
40 final String value;
41 if (defaultValue != null)
42 value = System.getProperty(name, defaultValue);
43 else
44 value = System.getProperty(name);
45
46 if (value == null || value.equals(""))
47 return null;
48 else
49 return value;
50 }
51
52 public static String getProperty(String name) {
53 return getProperty(name, null);
54 }
55
56 public static String getPropertyCompat(String name, String oldName) {
57 return getPropertyCompat(name, oldName, null);
58 }
59
60 public static String getPropertyCompat(String name, String oldName,
61 String defaultValue) {
62 String res = null;
63
64 if (defaultValue != null) {
65 res = getProperty(name, defaultValue);
66 if (res.equals(defaultValue)) {
67 res = getProperty(oldName, defaultValue);
68 if (!res.equals(defaultValue))
69 warnDeprecated(name, oldName);
70 }
71 } else {
72 res = getProperty(name, null);
73 if (res == null) {
74 res = getProperty(oldName, null);
75 if (res != null)
76 warnDeprecated(name, oldName);
77 }
78 }
79 return res;
80 }
81
82 public static void warnDeprecated(String name, String oldName) {
83 warn("Property '" + oldName
84 + "' is deprecated and will be removed soon, use '" + name
85 + "' instead.");
86 }
87
88 }