001
014
015 package com.liferay.portal.dao.shard;
016
017 import com.liferay.portal.dao.shard.advice.ShardAdvice;
018 import com.liferay.portal.kernel.dao.shard.Shard;
019 import com.liferay.portal.kernel.util.InfrastructureUtil;
020 import com.liferay.portal.util.PropsValues;
021
022 import javax.sql.DataSource;
023
024
027 public class ShardImpl implements Shard {
028
029 public String[] getAvailableShardNames() {
030 ShardDataSourceTargetSource shardDataSourceTargetSource =
031 (ShardDataSourceTargetSource)
032 InfrastructureUtil.getShardDataSourceTargetSource();
033
034 if (shardDataSourceTargetSource != null) {
035 return shardDataSourceTargetSource.getAvailableShardNames();
036 }
037
038 return null;
039 }
040
041 public String getCurrentShardName() {
042 return _shardAdvice.getCurrentShardName();
043 }
044
045 public DataSource getDataSource() {
046 return _shardAdvice.getDataSource();
047 }
048
049 public String getDefaultShardName() {
050 return PropsValues.SHARD_DEFAULT_NAME;
051 }
052
053 public boolean isEnabled() {
054 if (_shardAdvice != null) {
055 return true;
056 }
057 else {
058 return false;
059 }
060 }
061
062 public String popCompanyService() {
063 String value = null;
064
065 if (_shardAdvice != null) {
066 value = _shardAdvice.popCompanyService();
067 }
068
069 return value;
070 }
071
072 public void pushCompanyService(long companyId) {
073 if (_shardAdvice != null) {
074 _shardAdvice.pushCompanyService(companyId);
075 }
076 }
077
078 public void pushCompanyService(String shardName) {
079 if (_shardAdvice != null) {
080 _shardAdvice.pushCompanyService(shardName);
081 }
082 }
083
084 public void setShardAdvice(ShardAdvice shardAdvice) {
085 _shardAdvice = shardAdvice;
086 }
087
088 private static ShardAdvice _shardAdvice;
089
090 }