001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.dao.shard;
016    
017    import com.liferay.portal.kernel.dao.shard.Shard;
018    
019    import javax.sql.DataSource;
020    
021    /**
022     * @author Alexander Chow
023     */
024    public class ShardImpl implements Shard {
025    
026            public String getCurrentShardName() {
027                    return _shardAdvice.getCurrentShardName();
028            }
029    
030            public DataSource getDataSource() {
031                    return _shardAdvice.getDataSource();
032            }
033    
034            public boolean isEnabled() {
035                    if (_shardAdvice != null) {
036                            return true;
037                    }
038                    else {
039                            return false;
040                    }
041            }
042    
043            public String popCompanyService() {
044                    String value = null;
045    
046                    if (_shardAdvice != null) {
047                            value = _shardAdvice.popCompanyService();
048                    }
049    
050                    return value;
051            }
052    
053            public void pushCompanyService(long companyId) {
054                    if (_shardAdvice != null) {
055                            _shardAdvice.pushCompanyService(companyId);
056                    }
057            }
058    
059            public void pushCompanyService(String shardName) {
060                    if (_shardAdvice != null) {
061                            _shardAdvice.pushCompanyService(shardName);
062                    }
063            }
064    
065            public void setShardAdvice(ShardAdvice shardAdvice) {
066                    _shardAdvice = shardAdvice;
067            }
068    
069            private static ShardAdvice _shardAdvice;
070    
071    }