@Override public synchronized void setFormatterSpec(final AbstractFormatterSpec formatterSpec) { this.formatterSpec = formatterSpec; final AsyncHandler handler = value; if (handler != null) { formatterSpec.apply(handler); } }
public synchronized void start(final StartContext context) throws StartException { final AsyncHandler handler = new AsyncHandler(queueLength); value = handler; formatterSpec.apply(handler); handler.setOverflowAction(overflowAction); handler.setAutoFlush(autoflush); if (filter != null) handler.setFilter(filter); try { handler.setEncoding(encoding); } catch (UnsupportedEncodingException e) { throw new StartException(e); } Handler[] handlers = new Handler[subhandlers.size()]; for (int i = 0, subhandlersSize = subhandlers.size(); i < subhandlersSize; i++) { handlers[i] = subhandlers.get(i).getValue(); } handler.setHandlers(handlers); if (level != null) handler.setLevel(level); }
@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 new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName())); } } catch (ClassNotFoundException e) { throw new StartException(e); } catch (ModuleLoadException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } catch (InstantiationException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } catch (IllegalAccessException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } formatterSpec.apply(handler); if (level != null) handler.setLevel(level); try { handler.setEncoding(encoding); } catch (UnsupportedEncodingException e) { throw new StartException(e); } value = handler; }