Navigation Menu

Skip to content

Commit

Permalink
GRAILS-10024 also need AggregatePersistenceContextInterceptor to impl…
Browse files Browse the repository at this point in the history
…ement ParticipatingInterceptor
  • Loading branch information
burtbeckwith committed Apr 24, 2013
1 parent 177cd42 commit f044d2e
Showing 1 changed file with 22 additions and 1 deletion.
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.codehaus.groovy.grails.commons.GrailsDomainClassProperty;
import org.codehaus.groovy.grails.support.ParticipatingInterceptor;
import org.codehaus.groovy.grails.support.PersistenceContextInterceptor;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.InitializingBean;
Expand All @@ -28,7 +29,7 @@
/**
* @author Burt Beckwith
*/
public class AggregatePersistenceContextInterceptor implements PersistenceContextInterceptor, InitializingBean, ApplicationContextAware {
public class AggregatePersistenceContextInterceptor implements ParticipatingInterceptor, InitializingBean, ApplicationContextAware {

private List<PersistenceContextInterceptor> interceptors = new ArrayList<PersistenceContextInterceptor>();
private List<String> dataSourceNames = new ArrayList<String>();
Expand Down Expand Up @@ -94,6 +95,26 @@ public void setReadWrite() {
}
}

public void setParticipate(boolean flag) {
for (PersistenceContextInterceptor interceptor : interceptors) {
if (interceptor instanceof ParticipatingInterceptor) {
((ParticipatingInterceptor)interceptor).setParticipate(flag);
}
}
}

public boolean getParticipate() {
for (PersistenceContextInterceptor interceptor : interceptors) {
if (interceptor instanceof ParticipatingInterceptor) {
if (((ParticipatingInterceptor)interceptor).getParticipate()) {
// true at least one is true
return true;
}
}
}
return false;
}

/**
* Dependency injection for the datasource names.
* @param names the names
Expand Down

0 comments on commit f044d2e

Please sign in to comment.