1 package org.jmage; 2 3 import org.apache.log4j.Priority; 4 5 6 /*** 7 * Creates ApplicationContext from System properties. 8 */ 9 public class SystemApplicationContext extends ApplicationContext { 10 private static final String INITIALIZATION_EXCEPTION = "unable to initialize jmage application context, cause: "; 11 private static final String INITIALIZATION_SUCCESS = " initialized ApplicationContext with system properties"; 12 13 /*** 14 * Use getContext instead. 15 */ 16 protected SystemApplicationContext() { 17 super(); 18 } 19 20 /*** 21 * Create an XmlApplicationContext instance. 22 * 23 * @return the applicationContext 24 */ 25 public static ApplicationContext getContext(ApplicationContext context) { 26 if (context == null) { 27 context = new SystemApplicationContext(); 28 } 29 30 try { 31 context.properties.putAll(System.getProperties()); 32 if (log.isInfoEnabled()) log.info(INITIALIZATION_SUCCESS); 33 } catch (Exception e) { 34 if (log.isEnabledFor(Priority.WARN)) log.warn(INITIALIZATION_EXCEPTION + e.getMessage()); 35 } 36 37 return context; 38 } 39 }