001    /**
002     * Copyright (c) 2000-2010 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 DataSource getDataSource() {
027                    return _shardAdvice.getDataSource();
028            }
029    
030            public boolean isEnabled() {
031                    if (_shardAdvice != null) {
032                            return true;
033                    }
034                    else {
035                            return false;
036                    }
037            }
038    
039            public String popCompanyService() {
040                    String value = null;
041    
042                    if (_shardAdvice != null) {
043                            value = _shardAdvice.popCompanyService();
044                    }
045    
046                    return value;
047            }
048    
049            public void pushCompanyService(long companyId) {
050                    if (_shardAdvice != null) {
051                            _shardAdvice.pushCompanyService(companyId);
052                    }
053            }
054    
055            public void pushCompanyService(String shardName) {
056                    if (_shardAdvice != null) {
057                            _shardAdvice.pushCompanyService(shardName);
058                    }
059            }
060    
061            public void setShardAdvice(ShardAdvice shardAdvice) {
062                    _shardAdvice = shardAdvice;
063            }
064    
065            private static ShardAdvice _shardAdvice;
066    
067    }