/** * Invoke given producer task and gather errors. * <p/> * After the task is complete all gathered errors are logged. No exception is thrown * even if there is a fatal error present in the list of errors. * * @param producer producer task to be invoked. * @return the result produced by the task. */ public static <T> T process(final Producer<T> producer) { return process(producer, false); }
/** * Invoke given producer task and gather messages. * <p/> * After the task is complete all gathered errors are logged. If there is a fatal error * present in the list of errors an {@link ErrorMessagesException exception} is thrown. * * @param producer producer task to be invoked. * @return the result produced by the task. */ public static <T> T processWithException(final Producer<T> producer) { return process(producer, true); }
/** * Invoke given producer task and gather errors. * <p/> * After the task is complete all gathered errors are logged. No exception is thrown * even if there is a fatal error present in the list of errors. * * @param producer producer task to be invoked. * @return the result produced by the task. */ public static <T> T process(final Producer<T> producer) { return process(producer, false); }
/** * Invoke given producer task and gather messages. * <p/> * After the task is complete all gathered errors are logged. If there is a fatal error * present in the list of errors an {@link ErrorMessagesException exception} is thrown. * * @param producer producer task to be invoked. * @return the result produced by the task. */ public static <T> T processWithException(final Producer<T> producer) { return process(producer, true); }
/** * Invoke given callable task and gather messages. * <p/> * After the task is complete all gathered errors are logged. Any exception thrown * by the throwable is re-thrown. * * @param task callable task to be invoked. * @return the result produced by the task. * @throws Exception exception thrown by the task. */ public static <T> T process(final Callable<T> task) throws Exception { return process(task, true); }
private void validateResource(final ResourceModelComponent component) { Errors.process(new Runnable() { @Override public void run() { final ComponentModelValidator validator = new ComponentModelValidator(valueSuppliers, messageBodyWorkers); validator.validate(component); if (Errors.fatalIssuesFound() && !ignoreValidationErrors) { throw new ModelValidationException(LocalizationMessages.ERROR_VALIDATION_SUBRESOURCE(), ModelErrors .getErrorsAsResourceModelIssues()); } } }); }
private void validateResource(final ResourceModelComponent component) { Errors.process(new Runnable() { @Override public void run() { final ComponentModelValidator validator = new ComponentModelValidator(valueSuppliers, messageBodyWorkers); validator.validate(component); if (Errors.fatalIssuesFound() && !ignoreValidationErrors) { throw new ModelValidationException(LocalizationMessages.ERROR_VALIDATION_SUBRESOURCE(), ModelErrors .getErrorsAsResourceModelIssues()); } } }); }
/** * Invoke given callable task and gather messages. * <p/> * After the task is complete all gathered errors are logged. Any exception thrown * by the throwable is re-thrown. * * @param task callable task to be invoked. * @return the result produced by the task. * @throws Exception exception thrown by the task. */ public static <T> T process(final Callable<T> task) throws Exception { return process(task, true); }
/** * Invoke given task and gather messages. * <p/> * After the task is complete all gathered errors are logged. No exception is thrown * even if there is a fatal error present in the list of errors. * * @param task task to be invoked. */ public static void process(final Runnable task) { process(new Producer<Void>() { @Override public Void call() { task.run(); return null; } }, false); }
/** * Invoke given task and gather messages. * <p/> * After the task is complete all gathered errors are logged. If there is a fatal error * present in the list of errors an {@link ErrorMessagesException exception} is thrown. * * @param task task to be invoked. */ public static void processWithException(final Runnable task) { process(new Producer<Void>() { @Override public Void call() { task.run(); return null; } }, true); }
/** * Invoke given task and gather messages. * <p/> * After the task is complete all gathered errors are logged. If there is a fatal error * present in the list of errors an {@link ErrorMessagesException exception} is thrown. * * @param task task to be invoked. */ public static void processWithException(final Runnable task) { process(new Producer<Void>() { @Override public Void call() { task.run(); return null; } }, true); }
/** * Invoke given task and gather messages. * <p/> * After the task is complete all gathered errors are logged. No exception is thrown * even if there is a fatal error present in the list of errors. * * @param task task to be invoked. */ public static void process(final Runnable task) { process(new Producer<Void>() { @Override public Void call() { task.run(); return null; } }, false); }
/** * The validate method validates a component and adds possible * issues found to it's list. The list of issues could be then retrieved * via getIssueList method. * * @param component resource model component. */ public void validate(final ResourceModelComponent component) { Errors.process(new Runnable() { @Override public void run() { Errors.mark(); validateWithErrors(component); issueList.addAll(ModelErrors.getErrorsAsResourceModelIssues(true)); Errors.unmark(); } }); }
/** * The validate method validates a component and adds possible * issues found to it's list. The list of issues could be then retrieved * via getIssueList method. * * @param component resource model component. */ public void validate(final ResourceModelComponent component) { Errors.process(new Runnable() { @Override public void run() { Errors.mark(); validateWithErrors(component); issueList.addAll(ModelErrors.getErrorsAsResourceModelIssues(true)); Errors.unmark(); } }); }
private static <T> T process(final Producer<T> task, final boolean throwException) { try { return process((Callable<T>) task, throwException); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } }
private static <T> T process(final Producer<T> task, final boolean throwException) { try { return process((Callable<T>) task, throwException); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Runs the {@link Runnable task} in the request scope initialized from the * {@link RequestContext scope context}. The {@link RequestContext * scope context} is NOT released by the method (this must be done explicitly). The * current thread might be already in any request scope and in that case the scope * will be changed to the scope defined by the {@link RequestContext scope * instance}. At the end of the method the request scope is returned to its original * state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. */ public void runInScope(RequestContext context, Runnable task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); Errors.process(task); } finally { release(context); resume(oldContext); } }
/** * Runs the {@link org.glassfish.jersey.internal.util.Producer task} in the request scope initialized * from the {@link RequestContext scope context}. * The {@link RequestContext scope context} is NOT released by the method (this * must be done explicitly). The current thread might be already in any request scope * and in that case the scope will be changed to the scope defined by the * {@link RequestContext scope context}. At the end of the method the request * scope is returned to its original state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task} */ public <T> T runInScope(RequestContext context, Producer<T> task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }
/** * Runs the {@link org.glassfish.jersey.internal.util.Producer task} in the request scope initialized * from the {@link RequestContext scope context}. * The {@link RequestContext scope context} is NOT released by the method (this * must be done explicitly). The current thread might be already in any request scope * and in that case the scope will be changed to the scope defined by the * {@link RequestContext scope context}. At the end of the method the request * scope is returned to its original state. * * @param context The request scope context from which the request scope will be initialized. * @param task Task to be executed. * @param <T> {@code task} result type. * @return result returned by the {@code task} */ public <T> T runInScope(RequestContext context, Producer<T> task) { final RequestContext oldContext = retrieveCurrent(); try { activate(context.getReference(), oldContext); return Errors.process(task); } finally { release(context); resume(oldContext); } }
@Override public void onFailure(final ErrorInformation error) throws MultiException { final String msg; switch (error.getErrorType()) { case FAILURE_TO_REIFY: msg = LocalizationMessages.HK_2_REIFICATION_ERROR( error.getDescriptor().getImplementation(), printStackTrace(error.getAssociatedException())); break; default: msg = LocalizationMessages.HK_2_UNKNOWN_ERROR(printStackTrace(error.getAssociatedException())); break; } try { Errors.warning(error.getInjectee(), msg); } catch (IllegalStateException ex) { Errors.process(new Runnable() { @Override public void run() { Errors.warning(this, LocalizationMessages.HK_2_FAILURE_OUTSIDE_ERROR_SCOPE()); Errors.warning(error.getInjectee(), msg); } }); } }