private static ErrorHandler createErrorHandlerFromString( String errorHandlerClassName, ClassLoaderService classLoaderService) { if ( StringHelper.isEmpty( errorHandlerClassName ) || ErrorHandler.LOG.equals( errorHandlerClassName.trim() ) ) { return getDefault(); } else { Class<?> errorHandlerClass = classLoaderService.classForName( errorHandlerClassName ); return ClassLoaderHelper.instanceFromClass( ErrorHandler.class, errorHandlerClass, "Error Handler" ); } }
private static ErrorHandler createErrorHandlerFromString( String errorHandlerClassName, ClassLoaderService classLoaderService) { if ( StringHelper.isEmpty( errorHandlerClassName ) || ErrorHandler.LOG.equals( errorHandlerClassName.trim() ) ) { return getDefault(); } else { Class<?> errorHandlerClass = classLoaderService.classForName( errorHandlerClassName ); return ClassLoaderHelper.instanceFromClass( ErrorHandler.class, errorHandlerClass, "Error Handler" ); } }
/** * @param searchConfiguration The configuration that may specify an ErrorHandler * @return ErrorHandler specified in the {@link SearchConfiguration} or the default one in case not specified. */ public static ErrorHandler createErrorHandler(SearchConfiguration searchConfiguration) { Object configuredErrorHandler = searchConfiguration.getProperties().get( Environment.ERROR_HANDLER ); if ( configuredErrorHandler == null ) { return getDefault(); } if ( configuredErrorHandler instanceof String ) { return createErrorHandlerFromString( (String) configuredErrorHandler, searchConfiguration.getClassLoaderService() ); } else if ( configuredErrorHandler instanceof ErrorHandler ) { return (ErrorHandler) configuredErrorHandler; } else { throw LoggerFactory.make( MethodHandles.lookup() ).unsupportedErrorHandlerConfigurationValueType( configuredErrorHandler.getClass() ); } }
/** * @param searchConfiguration The configuration that may specify an ErrorHandler * @return ErrorHandler specified in the {@link SearchConfiguration} or the default one in case not specified. */ public static ErrorHandler createErrorHandler(SearchConfiguration searchConfiguration) { Object configuredErrorHandler = searchConfiguration.getProperties().get( Environment.ERROR_HANDLER ); if ( configuredErrorHandler == null ) { return getDefault(); } if ( configuredErrorHandler instanceof String ) { return createErrorHandlerFromString( (String) configuredErrorHandler, searchConfiguration.getClassLoaderService() ); } else if ( configuredErrorHandler instanceof ErrorHandler ) { return (ErrorHandler) configuredErrorHandler; } else { throw LoggerFactory.make().unsupportedErrorHandlerConfigurationValueType( configuredErrorHandler.getClass() ); } }