01: /*
02: * Copyright 2004,2005 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.wso2.esb.util;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: /**
22: * Caches the getHibernateConfig for a particular database
23: */
24:
25: public final class HibernateConfigCache {
26: private static final Map hibernateConfigMap = new HashMap();
27:
28: public static HibernateConfig getHibernateConfig(
29: String hbConfigKey, String conFigFileName) {
30: HibernateConfig hbConfig;
31: Object obj = hibernateConfigMap.get(hbConfigKey);
32: if (obj == null) {
33: hbConfig = new HibernateConfig(conFigFileName);
34: hibernateConfigMap.put(hbConfigKey, hbConfig);
35: } else {
36: hbConfig = (HibernateConfig) obj;
37: }
38: return hbConfig;
39: }
40:
41: public static void clearCache() {
42: if (!hibernateConfigMap.isEmpty()) {
43: hibernateConfigMap.clear();
44: }
45: }
46: }
|