1 22 package org.jboss.util.property.jmx; 23 24 import org.jboss.logging.Logger; 25 26 39 public class SystemPropertyClassValue 40 implements SystemPropertyClassValueMBean 41 { 42 public static final Logger log = Logger.getLogger(SystemPropertyClassValue.class); 43 44 45 protected String property; 46 47 48 protected String className; 49 50 53 public SystemPropertyClassValue() 54 { 55 } 56 57 62 public String getProperty() 63 { 64 return property; 65 } 66 67 72 public void setProperty(String property) 73 { 74 this.property = property; 75 } 76 77 83 public String getClassName() 84 { 85 return className; 86 } 87 88 94 public void setClassName(String className) 95 { 96 this.className = className; 97 } 98 99 104 public void create() 105 { 106 Throwable error = setSystemPropertyClassValue(property, className); 107 if (error != null) 108 log.trace("Error loading class " + className + " property " + property + " not set.", error); 109 } 110 111 119 public static Throwable setSystemPropertyClassValue(String property, String className) 120 { 121 if (property == null || property.trim().length() == 0) 123 throw new IllegalArgumentException ("Null or empty property"); 124 if (className == null || className.trim().length() == 0) 125 throw new IllegalArgumentException ("Null or empty class name"); 126 127 try 129 { 130 Thread.currentThread().getContextClassLoader().loadClass(className); 131 } 132 catch (Throwable problem) 133 { 134 return problem; 135 } 136 137 System.setProperty(property, className); 139 return null; 140 } 141 } 142 | Popular Tags |