public static <T extends Declarable> T newInstance(DeclarableType declarableType, Cache cache) { try { Class<T> loadedClass = (Class<T>) ClassPathLoader.getLatest().forName(declarableType.getClassName()); T declarable = loadedClass.newInstance(); Properties initProperties = new Properties(); for (ParameterType parameter : declarableType.getParameters()) { initProperties.put(parameter.getName(), newInstance(parameter, cache)); } declarable.initialize(cache, initProperties); return declarable; } catch (Exception e) { throw new RuntimeException( "Error instantiating class: <" + declarableType.getClassName() + ">", e); } }
Properties listenerProperties = new Properties(); for (ParameterType p : parameters) { listenerProperties.put(p.getName(), p.getString());