001
014
015 package com.liferay.portal.dao.shard.advice;
016
017 import com.liferay.portal.kernel.dao.shard.ShardUtil;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020
021 import org.aopalliance.intercept.MethodInterceptor;
022 import org.aopalliance.intercept.MethodInvocation;
023
024
029 public class ShardIterativelyAdvice implements MethodInterceptor {
030
031
037 public Object invoke(MethodInvocation methodInvocation) throws Throwable {
038 if (_log.isInfoEnabled()) {
039 _log.info(
040 "Iterating through all shards for " +
041 methodInvocation.toString());
042 }
043
044 for (String shardName : ShardUtil.getAvailableShardNames()) {
045 _shardAdvice.pushCompanyService(shardName);
046
047 try {
048 methodInvocation.proceed();
049 }
050 finally {
051 _shardAdvice.popCompanyService();
052 }
053 }
054
055 return null;
056 }
057
058 public void setShardAdvice(ShardAdvice shardAdvice) {
059 _shardAdvice = shardAdvice;
060 }
061
062 private static Log _log = LogFactoryUtil.getLog(
063 ShardIterativelyAdvice.class);
064
065 private ShardAdvice _shardAdvice;
066
067 }