public static Properties toProperties(ResourceConfiguration conf) { Properties prop = conf.toProperties(); prop.setProperty( KIE_RESOURCE_CONF_CLASS, conf.getClass().getName() ); return prop; }
public static ResourceConfiguration fromProperties(Properties prop) { String className = prop.getProperty( KIE_RESOURCE_CONF_CLASS ); try { // not sure how to get the proper classloader here, but the resource configurations // should be accessible from the current classloader ClassLoader cl = ResourceConfiguration.class.getClassLoader(); Class<ResourceConfiguration> confClass = (Class<ResourceConfiguration>) cl.loadClass(className); ResourceConfiguration conf = confClass.newInstance(); conf.fromProperties( prop ); return conf; } catch ( Exception e ) { logger.error( "Error loading resource configuration from properties", e ); } return null; }