01: /**********************************************************************
02: Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: 2003 Andy Jefferson - introduction of localiser
18: 2004 Andy Jefferson - moved to org.jpox.store
19: 2006 Andy Jefferson - generalised so that can be used for any store
20: ...
21: **********************************************************************/package org.jpox.store;
22:
23: import org.jpox.ObjectManagerFactoryImpl;
24: import org.jpox.ClassLoaderResolver;
25: import org.jpox.util.ClassUtils;
26:
27: /**
28: * Factory for creating StoreManagers.
29: *
30: * @version $Revision: 1.13 $
31: **/
32: public class StoreManagerFactory {
33: /**
34: * Default Constructor.
35: **/
36: private StoreManagerFactory() {
37: // protects this class from been instantiated
38: }
39:
40: /**
41: * Accessor for the StoreManager. Creates an instance of StoreManager if necessary
42: * @param managerClassName Name of the class name for the Store Manager
43: * @param clr the ClassLoaderResolver
44: * @param omf Object Manager Factory
45: * @return The Store Manager.
46: **/
47: public static synchronized StoreManager getStoreManager(
48: String managerClassName, ClassLoaderResolver clr,
49: ObjectManagerFactoryImpl omf) {
50: // Create a new StoreManager of this type
51: // TODO Cache the StoreManagers
52: Class managerCls = clr.classForName(managerClassName,
53: ObjectManagerFactoryImpl.class.getClassLoader());
54: Class[] ctrArgTypes = new Class[] { ClassLoaderResolver.class,
55: ObjectManagerFactoryImpl.class };
56: Object[] ctrArgs = new Object[] { clr, omf };
57: return (StoreManager) ClassUtils.newInstance(managerCls,
58: ctrArgTypes, ctrArgs);
59: }
60: }
|