]> git.argeo.org Git - lgpl/argeo-commons.git/blob - OsgiBootUtils.java
2d1f0b4d7ae3f04cdc13ec443ccbb053c754db72
[lgpl/argeo-commons.git] / OsgiBootUtils.java
1 package org.argeo.slc.osgiboot;
2
3 public class OsgiBootUtils {
4
5 public static void info(Object obj) {
6 System.out.println("# OSGiBOOT # " + obj);
7 }
8
9 public static void debug(Object obj) {
10 System.out.println("# OSGiBOOT DBG # " + obj);
11 }
12
13 public static void warn(Object obj) {
14 System.out.println("# OSGiBOOT WARN # " + obj);
15 // Because of a weird bug under Windows when starting it in a forked VM
16 // if (System.getProperty("os.name").contains("Windows"))
17 // System.out.println("# WARN " + obj);
18 // else
19 // System.err.println("# WARN " + obj);
20 }
21
22 //FIXE: returns null when defaultValue is ""
23 public static String getProperty(String name, String defaultValue) {
24 final String value;
25 if (defaultValue != null)
26 value = System.getProperty(name, defaultValue);
27 else
28 value = System.getProperty(name);
29
30 if (value == null || value.equals(""))
31 return null;
32 else
33 return value;
34 }
35
36 public static String getProperty(String name) {
37 return getProperty(name, null);
38 }
39
40 public static String getPropertyCompat(String name, String oldName) {
41 return getPropertyCompat(name, oldName, null);
42 }
43
44 public static String getPropertyCompat(String name, String oldName,
45 String defaultValue) {
46 String res = null;
47
48 if (defaultValue != null) {
49 res = getProperty(name, defaultValue);
50 if (res.equals(defaultValue)) {
51 res = getProperty(oldName, defaultValue);
52 if (!res.equals(defaultValue))
53 warnDeprecated(name, oldName);
54 }
55 } else {
56 res = getProperty(name, null);
57 if (res == null) {
58 res = getProperty(oldName, null);
59 if (res != null)
60 warnDeprecated(name, oldName);
61 }
62 }
63 return res;
64 }
65
66 public static void warnDeprecated(String name, String oldName) {
67 warn("Property '" + oldName
68 + "' is deprecated and will be removed soon, use '" + name
69 + "' instead.");
70 }
71
72 }