| ShardUtil.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.kernel.dao.shard;
16
17 import javax.sql.DataSource;
18
19 /**
20 * <a href="ShardUtil.java.html"><b><i>View Source</i></b></a>
21 *
22 * @author Alexander Chow
23 */
24 public class ShardUtil {
25
26 public static String getCurrentShardName() {
27 if (_shard != null) {
28 return _shard.getCurrentShardName();
29 }
30
31 return null;
32 }
33
34 public static DataSource getDataSource() {
35 if (_shard != null) {
36 return _shard.getDataSource();
37 }
38
39 return null;
40 }
41
42 public static boolean isEnabled() {
43 if (_shard != null) {
44 return _shard.isEnabled();
45 }
46
47 return false;
48 }
49
50 public static String popCompanyService() {
51 String value = null;
52
53 if (_shard != null) {
54 value = _shard.popCompanyService();
55 }
56
57 return value;
58 }
59
60 public static void pushCompanyService(long companyId) {
61 if (_shard != null) {
62 _shard.pushCompanyService(companyId);
63 }
64 }
65
66 public static void pushCompanyService(String shardName) {
67 if (_shard != null) {
68 _shard.pushCompanyService(shardName);
69 }
70 }
71
72 public void setShard(Shard shard) {
73 _shard = shard;
74 }
75
76 private static Shard _shard;
77
78 }