properties = new ArrayList<Property>();
}
@Override
public synchronized void start(final StartContext context) throws StartException {
final Handler handler;
final ModuleLoader moduleLoader = Module.forClass(CustomHandlerService.class).getModuleLoader();
final ModuleIdentifier id = ModuleIdentifier.create(moduleName);
try {
final Class<?> handlerClass = Class.forName(className, false, moduleLoader.loadModule(id).getClassLoader());
if (Handler.class.isAssignableFrom(handlerClass)) {
handler = (Handler) handlerClass.newInstance();
} else {
throw MESSAGES.invalidType(className, Handler.class);
}
} catch (ClassNotFoundException e) {
throw MESSAGES.classNotFound(e, className);
} catch (ModuleLoadException e) {
throw MESSAGES.cannotLoadModule(e, moduleName);
} catch (InstantiationException e) {
throw MESSAGES.cannotInstantiateClass(e, className);
} catch (IllegalAccessException e) {
throw MESSAGES.cannotAccessClass(e, className);
}
if (filter != null) handler.setFilter(filter);
formatterSpec.apply(handler);
if (level != null) handler.setLevel(level);
try {
handler.setEncoding(encoding);
} catch (UnsupportedEncodingException e) {
throw new StartException(e);
}
// Set the properties
setProperties(handler, properties);