/** * Gets the config properties in the form of a map where the key is the * property name and the value is property type (as a Class). */ public Map<String, Class> getConfigProperties() { String[] props = delegate.getProperties(); Map<String, Class> map = new HashMap<String, Class>(); for (String prop : props) { if (prop.equals("logWriter")) { continue; } map.put(prop, delegate.getPropertyType(prop)); } return map; }
/** * Gets the config properties in the form of a map where the key is the * property name and the value is property type (as a String not a Class). */ public Map getConfigProperties() { String[] props = delegate.getProperties(); Map map = new HashMap(); for (int i = 0; i < props.length; i++) { String prop = props[i]; if(prop.equals("logWriter")) { continue; } map.put(prop, delegate.getPropertyType(prop)); } return map; }
public void setConfigProperty(String property, Object value) throws Exception { Class cls = delegate.getPropertyType(property); if(value != null && value instanceof String && !cls.getName().equals("java.lang.String")) { if(cls.isPrimitive()) { if(cls.equals(int.class)) { cls = Integer.class; } else if(cls.equals(boolean.class)) { cls = Boolean.class; } else if(cls.equals(float.class)) { cls = Float.class; } else if(cls.equals(double.class)) { cls = Double.class; } else if(cls.equals(long.class)) { cls = Long.class; } else if(cls.equals(short.class)) { cls = Short.class; } else if(cls.equals(byte.class)) { cls = Byte.class; } else if(cls.equals(char.class)) { cls = Character.class; } } Constructor con = cls.getConstructor(new Class[]{String.class}); value = con.newInstance(new Object[]{value}); } kernel.setAttribute(abstractName, property, value); }
public void setConfigProperty(String property, Object value) throws Exception { Class cls = delegate.getPropertyType(property); if(value != null && value instanceof String && !cls.getName().equals("java.lang.String")) { if(cls.isPrimitive()) { if(cls.equals(int.class)) { cls = Integer.class; } else if(cls.equals(boolean.class)) { cls = Boolean.class; } else if(cls.equals(float.class)) { cls = Float.class; } else if(cls.equals(double.class)) { cls = Double.class; } else if(cls.equals(long.class)) { cls = Long.class; } else if(cls.equals(short.class)) { cls = Short.class; } else if(cls.equals(byte.class)) { cls = Byte.class; } else if(cls.equals(char.class)) { cls = Character.class; } } Constructor con = cls.getConstructor(new Class[]{String.class}); value = con.newInstance(new Object[]{value}); } kernel.setAttribute(abstractName, property, value); }