public void init(PluginConfig config, PluginContext context) throws ConfigException {
log.trace("init() start");
module = context.getModuleContext();
ParamConfig param = config.getParamConfig("default-class");
Class dataClass = null;
if (param != null) {
try {
dataClass = module.getClassLoader().loadClass(param.getValue());
} catch (Exception e) {
throw new ConfigException("Could not load data class in " + config.toInlineString(), e);
}
}
String factoryClass = DEFAULT_FACTORY;
param = config.getParamConfig("factory-class");
if (param != null) {
factoryClass = param.getValue();
}
FormFactory factory = null;
try {
factory = (FormFactory)module.getClassLoader().loadClass(factoryClass).newInstance();
} catch (Exception e) {
throw new ConfigException("Could not create form factory in " + config.toInlineString(), e);
}
factory.init(module);
param = config.getParamConfig("config");
if (param == null) {
throw new ConfigException("Missing parameter 'config' in " + config.toInlineString());
}
FormsSupport support = new FormsSupport(module.getClassLoader(), dataClass);
service.init(module, support, factory, param.getValue());
context.setFilterClass("forms", FormsFilter.class);
AccessSupport access = AccessSupport.getInstance(module);
access.put("forms", new FormsAccessor(module));