This project has retired. For details please refer to its
Attic page.
StoreManagerFactory xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
2021import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
22import org.apache.commons.logging.Log;
23import org.apache.commons.logging.LogFactory;
2425/**26 * create objects that are stored in a persistent store27 *28 * @author Jens29 */30publicclassStoreManagerFactory {
3132privatestaticfinal Log log = LogFactory.getLog(StoreManagerFactory.class);
3334privateStoreManagerFactory() {
35 }
3637publicstaticStoreManager createInstance(String className) {
3839 Class<?> clazz = null;
40try {
41 clazz = Class.forName(className);
42 } catch (ClassNotFoundException e) {
43 String msg = "Failed to create StoredObjectCreator, class " + className + " does not exist.";
44 log.error(msg, e);
45 e.printStackTrace();
46thrownew RuntimeException(msg, e);
47 }
4849 Object obj = null;
50try {
51 obj = clazz.newInstance();
52 } catch (InstantiationException e) {
53 log.error("Failed to create StoredObjectCreator from class " + className, e);
54 e.printStackTrace();
55 } catch (IllegalAccessException e) {
56 log.error("Failed to create StoredObjectCreator from class " + className, e);
57 e.printStackTrace();
58 }
5960if (obj instanceof StoreManager) {
61return (StoreManager) obj;
62 } else {
63 log.error("Failed to create StoredObjectCreator, class " + className
64 + " does not implement interface StoredObjectCreator");
65returnnull;
66 }
67 }
6869 }