Author: nickarls
Date: 2008-11-24 05:30:52 -0500 (Mon, 24 Nov 2008)
New Revision: 360
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
Log:
minor. brough back for deferEvent for readability
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-11-24
10:27:52 UTC (rev 359)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/event/EventManager.java 2008-11-24
10:30:52 UTC (rev 360)
@@ -48,7 +48,8 @@
private final Map<Class<?>,
CopyOnWriteArrayList<EventObserver<?>>> registeredObservers;
private ManagerImpl manager;
// TODO: can we do this?
- @Resource TransactionManager transactionManager;
+ @Resource
+ TransactionManager transactionManager;
/**
* Initializes a new instance of the EventManager. This includes looking up
@@ -81,7 +82,6 @@
}
}
-
/**
* Resolves the list of observers to be notified for a given event and
* optional event bindings.
@@ -104,7 +104,8 @@
return interestedObservers;
}
- private boolean isTransactionActive() {
+ private boolean isTransactionActive()
+ {
try
{
// TODO: Check NPE conditions;
@@ -113,9 +114,9 @@
catch (SystemException e)
{
return false;
- }
+ }
}
-
+
/**
* Notifies each observer immediately of the event unless a transaction is
* currently in progress, in which case a deferred event is created and
@@ -129,16 +130,24 @@
{
for (Observer<T> observer : observers)
{
- if (isTransactionActive() && ((ObserverImpl<?>)
observer).isTransactional()) {
- TransactionListener transactionListener =
manager.getInstanceByType(TransactionListener.class);
- DeferredEventNotification<T> deferredEvent = new
DeferredEventNotification<T>(event, observer);
- transactionListener.registerSynhronization(deferredEvent);
- } else {
+ if (isTransactionActive() && ((ObserverImpl<?>)
observer).isTransactional())
+ {
+ deferEvent(event, observer);
+ }
+ else
+ {
observer.notify(event);
}
}
}
+ private <T> void deferEvent(T event, Observer<T> observer)
+ {
+ TransactionListener transactionListener =
manager.getInstanceByType(TransactionListener.class);
+ DeferredEventNotification<T> deferredEvent = new
DeferredEventNotification<T>(event, observer);
+ transactionListener.registerSynhronization(deferredEvent);
+ }
+
/**
* Removes an observer from the event bus.
*
Show replies by date