]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java
fa3ecc2b10ca2dd99951a9573b24c991bd270143
[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 import java.text.DateFormat;
20 import java.text.SimpleDateFormat;
21 import java.util.Date;
22
23 /** Utilities, mostly related to logging. */
24 public class OsgiBootUtils {
25 /** ISO8601 (as per log4j) and difference to UTC */
26 private static DateFormat dateFormat = new SimpleDateFormat(
27 "yyyy-MM-dd HH:mm:ss,SSS Z");
28
29 public static void info(Object obj) {
30 System.out.println("# OSGiBOOT # " + dateFormat.format(new Date())
31 + " # " + obj);
32 }
33
34 public static void debug(Object obj) {
35 System.out.println("# OSGiBOOT DBG # " + dateFormat.format(new Date())
36 + " # " + obj);
37 }
38
39 public static void warn(Object obj) {
40 System.out.println("# OSGiBOOT WARN # " + dateFormat.format(new Date())
41 + " # " + obj);
42 }
43
44 /**
45 * Gets a property value
46 *
47 * @return null when defaultValue is ""
48 */
49 public static String getProperty(String name, String defaultValue) {
50 final String value;
51 if (defaultValue != null)
52 value = System.getProperty(name, defaultValue);
53 else
54 value = System.getProperty(name);
55
56 if (value == null || value.equals(""))
57 return null;
58 else
59 return value;
60 }
61
62 public static String getProperty(String name) {
63 return getProperty(name, null);
64 }
65
66 }