Skip to content

Commit

Permalink
Removed the Status enumeration from the TransactionServices SPI
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3502 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
drallen committed Aug 15, 2009
1 parent 40cec4a commit 8718de6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
32 changes: 32 additions & 0 deletions impl/src/main/java/org/jboss/webbeans/event/Status.java
@@ -0,0 +1,32 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.webbeans.event;

/**
* An enumeration of the possible outcomes for a transaction. This is used
* to keep track of whether an observer wants to see all events regardless of
* the outcome of the transaction or only those transactions which succeed or
* fail.
*
* @author David Allen
*
*/
public enum Status
{
ALL, SUCCESS, FAILURE
}
Expand Up @@ -20,8 +20,6 @@

import javax.transaction.Synchronization;

import org.jboss.webbeans.transaction.spi.TransactionServices;

/**
* A JTA transaction sychronization which wraps a Runnable.
*
Expand All @@ -30,21 +28,21 @@
*/
public class TransactionSynchronizedRunnable implements Synchronization
{
private final TransactionServices.Status desiredStatus;
private final Status desiredStatus;
private final Runnable task;
private final boolean before;

public TransactionSynchronizedRunnable(Runnable task, boolean before)
{
this(task, TransactionServices.Status.ALL, before);
this(task, Status.ALL, before);
}

public TransactionSynchronizedRunnable(Runnable task, TransactionServices.Status desiredStatus)
public TransactionSynchronizedRunnable(Runnable task, Status desiredStatus)
{
this(task, desiredStatus, false); // Status is only applicable after the transaction
}

private TransactionSynchronizedRunnable(Runnable task, TransactionServices.Status desiredStatus, boolean before)
private TransactionSynchronizedRunnable(Runnable task, Status desiredStatus, boolean before)
{
this.task = task;
this.desiredStatus = desiredStatus;
Expand All @@ -58,7 +56,7 @@ private TransactionSynchronizedRunnable(Runnable task, TransactionServices.Statu
*/
public void afterCompletion(int status)
{
if ((desiredStatus == TransactionServices.Status.SUCCESS && status == STATUS_COMMITTED) || (desiredStatus == TransactionServices.Status.FAILURE && status != STATUS_COMMITTED) || (desiredStatus == TransactionServices.Status.ALL))
if ((desiredStatus == Status.SUCCESS && status == STATUS_COMMITTED) || (desiredStatus == Status.FAILURE && status != STATUS_COMMITTED) || (desiredStatus == Status.ALL))
{
task.run();
}
Expand Down
Expand Up @@ -74,21 +74,21 @@ private void deferEvent(T event)
DeferredEventNotification<T> deferredEvent = new DeferredEventNotification<T>(event, this);;

Synchronization synchronization = null;
if (transactionPhase.equals(transactionPhase.BEFORE_COMPLETION))
if (transactionPhase.equals(TransactionPhase.BEFORE_COMPLETION))
{
synchronization = new TransactionSynchronizedRunnable(deferredEvent, true);
}
else if (transactionPhase.equals(transactionPhase.AFTER_COMPLETION))
else if (transactionPhase.equals(TransactionPhase.AFTER_COMPLETION))
{
synchronization = new TransactionSynchronizedRunnable(deferredEvent, false);
}
else if (transactionPhase.equals(transactionPhase.AFTER_SUCCESS))
else if (transactionPhase.equals(TransactionPhase.AFTER_SUCCESS))
{
synchronization = new TransactionSynchronizedRunnable(deferredEvent, TransactionServices.Status.SUCCESS);
synchronization = new TransactionSynchronizedRunnable(deferredEvent, Status.SUCCESS);
}
else if (transactionPhase.equals(transactionPhase.AFTER_FAILURE))
else if (transactionPhase.equals(TransactionPhase.AFTER_FAILURE))
{
synchronization = new TransactionSynchronizedRunnable(deferredEvent, TransactionServices.Status.FAILURE);
synchronization = new TransactionSynchronizedRunnable(deferredEvent, Status.FAILURE);
}
manager.getServices().get(TransactionServices.class).registerSynchronization(synchronization);
}
Expand Down
Expand Up @@ -23,15 +23,6 @@
*/
public interface TransactionServices extends Service
{
/**
* Possible status conditions for a transaction. This can be used by SPI
* providers to keep track for which status an observer is used.
*/
public static enum Status
{
ALL, SUCCESS, FAILURE
}

/**
* Registers a synchronization object with the currently executing
* transaction.
Expand Down

0 comments on commit 8718de6

Please sign in to comment.