public void setParser(AutomatedXmlConfigurationParserImpl parser) {
this.parser = parser;
}
public void process(Element e, AbstractConfigurationBean bean) {
CacheLoaderManagerConfig cBean = (CacheLoaderManagerConfig) parser.findAndInstantiateBean(e);
//set attributes of <loaders/>
for (Method m : cBean.getClass().getMethods()) {
boolean setter = m.getName().startsWith("set") && m.getParameterTypes().length == 1;
if (setter) {
parser.reflectAndInvokeAttribute(cBean, m, e);
parser.reflectAndInvokeProperties(cBean, m, e);
}
}
Set<Element> elements = parser.getAllElementsInCoreNS("loader", e);
if (elements.isEmpty())
throw new ConfigurationException("No loader elements found!");
for (Element element : elements) {
String clClass = parser.getAttributeValue(element, "class");
if (!parser.existsAttribute(clClass))
throw new ConfigurationException("Missing 'class' attribute for cache loader configuration");
CacheLoader cl;
CacheLoaderConfig clc;
try {
cl = (CacheLoader) Util.getInstance(clClass);
clc = Util.getInstance(cl.getConfigurationClass());
} catch (Exception ex) {
throw new ConfigurationException("Unable to instantiate cache loader or configuration",ex);
}
clc.setCacheLoaderClassName(clClass);
Element propertiesElement = parser.getSingleElementInCoreNS("properties", element);
if (propertiesElement == null)
throw new ConfigurationException("loader " + clClass + " is missing properties element");
parser.visitElement(element, (AbstractConfigurationBean) clc);
cBean.addCacheLoaderConfig(clc);
}
((Configuration)bean).setCacheLoaderManagerConfig(cBean);
}