Skip to content

Commit

Permalink
WFLY-2522 Change the way SFSB's are removed, so that the actual remov…
Browse files Browse the repository at this point in the history
…e happens in the synchronization interceptor
  • Loading branch information
stuartwdouglas committed Jan 31, 2014
1 parent c90fffd commit db643ef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 107 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.jboss.as.ee.component.ComponentView;
import org.jboss.as.ejb3.cache.Cache;
import org.jboss.as.ejb3.cache.StatefulObjectFactory;
import org.jboss.as.ejb3.cache.TransactionAwareObjectFactory;
import org.jboss.as.ejb3.component.DefaultAccessTimeoutService;
import org.jboss.as.ejb3.component.EJBBusinessMethod;
import org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation;
Expand Down Expand Up @@ -149,7 +148,10 @@ protected StatefulSessionComponentInstance constructComponentInstance(ManagedRef

@Override
public void destroyInstance(StatefulSessionComponentInstance instance) {
instance.destroy();
instance.setRemoved(true);
if(!instance.isSynchronizationRegistered()) {
instance.destroy();
}
}

@Override
Expand Down Expand Up @@ -297,7 +299,7 @@ public void start() {

super.start();

this.cache = this.cacheFactory.getValue().createCache(this, new TransactionAwareObjectFactory<>(this, this.getTransactionManager()), this);
this.cache = this.cacheFactory.getValue().createCache(this, this, this);
this.cache.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class StatefulSessionComponentInstance extends SessionBeanComponentInstan
* The thread based lock for the stateful bean
*/
private final Object threadLock = new Object();
private boolean removed = false;

boolean isSynchronizationRegistered() {
return synchronizationRegistered;
Expand Down Expand Up @@ -145,6 +146,8 @@ protected void postActivate() {
this.execute(postActivate, null);
}



public void discard() {
if (!isDiscarded()) {
super.discard();
Expand Down Expand Up @@ -210,4 +213,12 @@ public Transaction getTransaction() {
public void setTransaction(Transaction transaction) {
this.transaction = transaction;
}

void setRemoved(boolean removed) {
this.removed = removed;
}

boolean isRemoved() {
return removed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,26 @@ public void beforeCompletion() {

@Override
public void afterCompletion(int status) {
boolean committed = status == Status.STATUS_COMMITTED;
try {
if (ROOT_LOGGER.isTraceEnabled()) {
ROOT_LOGGER.trace("After completion callback invoked on Transaction synchronization: " + this +
" of stateful component instance: " + statefulSessionComponentInstance);
}
if (!statefulSessionComponentInstance.isDiscarded()) {
statefulSessionComponentInstance.afterCompletion(status == Status.STATUS_COMMITTED);
statefulSessionComponentInstance.afterCompletion(committed);
}
} catch (Throwable t) {
handleThrowable(t);
}
if(statefulSessionComponentInstance.isRemoved() && !statefulSessionComponentInstance.isDiscarded()) {
try {
statefulSessionComponentInstance.destroy();
} catch (Throwable t) {
handleThrowable(t);
}
}

// tx has completed, so mark the SFSB instance as no longer in use
statefulSessionComponentInstance.getLock().pushOwner(lockOwner);
try {
Expand Down

0 comments on commit db643ef

Please sign in to comment.