Skip to content

Commit

Permalink
Reformatting to new formatting guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
LightGuard committed Mar 10, 2011
1 parent eb850cf commit 7a6597d
Show file tree
Hide file tree
Showing 63 changed files with 2,237 additions and 2,544 deletions.
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
* Copyright [2010], Red Hat, Inc., and individual contributors
* Copyright 2011, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
Expand Down Expand Up @@ -32,6 +32,5 @@
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
public @interface CatchResource
{
public @interface CatchResource {
}
277 changes: 129 additions & 148 deletions api/src/main/java/org/jboss/seam/exception/control/CaughtException.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* Copyright 2011, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
Expand All @@ -23,151 +23,132 @@
*
* @param <T> Exception type this event represents
*/
@SuppressWarnings( { "unchecked" })
public class CaughtException<T extends Throwable>
{
/**
* Flow control enum. Used in the dispatcher to determine how to markHandled.
*/
protected enum ExceptionHandlingFlow
{
HANDLED,
MARK_HANDLED,
DROP_CAUSE,
ABORT,
RETHROW,
THROW
}

private final ExceptionStack exceptionStack;
private final T exception;
private boolean unmute;
private ExceptionHandlingFlow flow;
private Throwable throwNewException;
private final boolean breadthFirstTraversal;
private final boolean depthFirstTraversal;
private final boolean markedHandled;

/**
* Initial state constructor.
*
* @param exceptionStack Information about the current exception and cause chain.
* @param breadthFirstTraversal flag indicating the direction of the cause chain traversal
* @param handled flag indicating the exception has already been handled by a previous handler
* @throws IllegalArgumentException if exceptionStack is null
*/
public CaughtException(final ExceptionStack exceptionStack, final boolean breadthFirstTraversal, final boolean handled)
{
if (exceptionStack == null)
{
throw new IllegalArgumentException("null is not valid for exceptionStack");
}

this.exception = (T) exceptionStack.getCurrent();
this.exceptionStack = exceptionStack;
this.breadthFirstTraversal = breadthFirstTraversal;
this.depthFirstTraversal = !breadthFirstTraversal;
this.markedHandled = handled;
this.flow = ExceptionHandlingFlow.MARK_HANDLED;
}

public T getException()
{
return this.exception;
}

/**
* Instructs the dispatcher to abort further processing of handlers.
*/
public void abort()
{
this.flow = ExceptionHandlingFlow.ABORT;
}

/**
* Instructs the dispatcher to rethrow the event exception after handler processing.
*/
public void rethrow()
{
this.flow = ExceptionHandlingFlow.RETHROW;
}

/**
* Instructs the dispatcher to terminate additional handler processing and mark the event as handled.
*/
public void handled()
{
this.flow = ExceptionHandlingFlow.HANDLED;
}

/**
* Default instruction to dispatcher, continues handler processing.
*/
public void markHandled()
{
this.flow = ExceptionHandlingFlow.MARK_HANDLED;
}

/**
* Similar to {@link CaughtException#markHandled()}, but instructs the dispatcher to markHandled to the next element
* in the cause chain without processing additional handlers for this cause chain element.
*/
public void dropCause()
{
this.flow = ExceptionHandlingFlow.DROP_CAUSE;
}

/**
* Instructs the dispatcher to allow this handler to be invoked again.
*/
public void unmute()
{
this.unmute = true;
}

public boolean isBreadthFirstTraversal()
{
return breadthFirstTraversal;
}

public boolean isDepthFirstTraversal()
{
return depthFirstTraversal;
}

protected boolean isUnmute()
{
return this.unmute;
}

public ExceptionStack getExceptionStack()
{
return this.exceptionStack;
}

protected ExceptionHandlingFlow getFlow()
{
return this.flow;
}

public boolean isMarkedHandled()
{
return this.markedHandled;
}

/**
* Rethrow the exception, but use the given exception instead of the original.
*
* @param t Exception to be thrown in place of the original.
*/
public void rethrow(Throwable t)
{
this.throwNewException = t;
this.flow = ExceptionHandlingFlow.THROW;
}

protected Throwable getThrowNewException()
{
return throwNewException;
}
@SuppressWarnings({"unchecked"})
public class CaughtException<T extends Throwable> {
/**
* Flow control enum. Used in the dispatcher to determine how to markHandled.
*/
protected enum ExceptionHandlingFlow {
HANDLED,
MARK_HANDLED,
DROP_CAUSE,
ABORT,
RETHROW,
THROW
}

private final ExceptionStack exceptionStack;
private final T exception;
private boolean unmute;
private ExceptionHandlingFlow flow;
private Throwable throwNewException;
private final boolean breadthFirstTraversal;
private final boolean depthFirstTraversal;
private final boolean markedHandled;

/**
* Initial state constructor.
*
* @param exceptionStack Information about the current exception and cause chain.
* @param breadthFirstTraversal flag indicating the direction of the cause chain traversal
* @param handled flag indicating the exception has already been handled by a previous handler
* @throws IllegalArgumentException if exceptionStack is null
*/
public CaughtException(final ExceptionStack exceptionStack, final boolean breadthFirstTraversal, final boolean handled) {
if (exceptionStack == null) {
throw new IllegalArgumentException("null is not valid for exceptionStack");
}

this.exception = (T) exceptionStack.getCurrent();
this.exceptionStack = exceptionStack;
this.breadthFirstTraversal = breadthFirstTraversal;
this.depthFirstTraversal = !breadthFirstTraversal;
this.markedHandled = handled;
this.flow = ExceptionHandlingFlow.MARK_HANDLED;
}

public T getException() {
return this.exception;
}

/**
* Instructs the dispatcher to abort further processing of handlers.
*/
public void abort() {
this.flow = ExceptionHandlingFlow.ABORT;
}

/**
* Instructs the dispatcher to rethrow the event exception after handler processing.
*/
public void rethrow() {
this.flow = ExceptionHandlingFlow.RETHROW;
}

/**
* Instructs the dispatcher to terminate additional handler processing and mark the event as handled.
*/
public void handled() {
this.flow = ExceptionHandlingFlow.HANDLED;
}

/**
* Default instruction to dispatcher, continues handler processing.
*/
public void markHandled() {
this.flow = ExceptionHandlingFlow.MARK_HANDLED;
}

/**
* Similar to {@link CaughtException#markHandled()}, but instructs the dispatcher to markHandled to the next element
* in the cause chain without processing additional handlers for this cause chain element.
*/
public void dropCause() {
this.flow = ExceptionHandlingFlow.DROP_CAUSE;
}

/**
* Instructs the dispatcher to allow this handler to be invoked again.
*/
public void unmute() {
this.unmute = true;
}

public boolean isBreadthFirstTraversal() {
return breadthFirstTraversal;
}

public boolean isDepthFirstTraversal() {
return depthFirstTraversal;
}

protected boolean isUnmute() {
return this.unmute;
}

public ExceptionStack getExceptionStack() {
return this.exceptionStack;
}

protected ExceptionHandlingFlow getFlow() {
return this.flow;
}

public boolean isMarkedHandled() {
return this.markedHandled;
}

/**
* Rethrow the exception, but use the given exception instead of the original.
*
* @param t Exception to be thrown in place of the original.
*/
public void rethrow(Throwable t) {
this.throwNewException = t;
this.flow = ExceptionHandlingFlow.THROW;
}

protected Throwable getThrowNewException() {
return throwNewException;
}
}
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
* Copyright [2010], Red Hat, Inc., and individual contributors
* Copyright 2011, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
Expand All @@ -16,38 +16,31 @@
*/
package org.jboss.seam.exception.control;

public class ExceptionResponse
{
private Class<? extends Throwable> forType;
private String message;
public class ExceptionResponse {
private Class<? extends Throwable> forType;
private String message;

public ExceptionResponse()
{
}
public ExceptionResponse() {
}

public ExceptionResponse(Class<? extends Throwable> forType, String message)
{
this.forType = forType;
this.message = message;
}
public ExceptionResponse(Class<? extends Throwable> forType, String message) {
this.forType = forType;
this.message = message;
}

public Class<? extends Throwable> getForType()
{
return forType;
}
public Class<? extends Throwable> getForType() {
return forType;
}

public void setForType(Class<? extends Throwable> forType)
{
this.forType = forType;
}
public void setForType(Class<? extends Throwable> forType) {
this.forType = forType;
}

public String getMessage()
{
return message;
}
public String getMessage() {
return message;
}

public void setMessage(String message)
{
this.message = message;
}
public void setMessage(String message) {
this.message = message;
}
}

0 comments on commit 7a6597d

Please sign in to comment.