]> git.argeo.org Git - lgpl/argeo-commons.git/blob - OsgiBootUtils.java
acc0302e62b2178690052f192946edf36f277da5
[lgpl/argeo-commons.git] / 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 /** Utilities, mostly related to logging. */
20 public class OsgiBootUtils {
21
22 public static void info(Object obj) {
23 System.out.println("# OSGiBOOT # " + obj);
24 }
25
26 public static void debug(Object obj) {
27 System.out.println("# OSGiBOOT DBG # " + obj);
28 }
29
30 public static void warn(Object obj) {
31 System.out.println("# OSGiBOOT WARN # " + obj);
32 // Because of a weird bug under Windows when starting it in a forked VM
33 // if (System.getProperty("os.name").contains("Windows"))
34 // System.out.println("# WARN " + obj);
35 // else
36 // System.err.println("# WARN " + obj);
37 }
38
39 /**
40 * Gets a property value
41 *
42 * @return null when defaultValue is ""
43 */
44 public static String getProperty(String name, String defaultValue) {
45 final String value;
46 if (defaultValue != null)
47 value = System.getProperty(name, defaultValue);
48 else
49 value = System.getProperty(name);
50
51 if (value == null || value.equals(""))
52 return null;
53 else
54 return value;
55 }
56
57 public static String getProperty(String name) {
58 return getProperty(name, null);
59 }
60
61 }