⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyconfigurablefactory.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// Copyright (C) 2003-@year@, Leo Mekenkamp. All rights reserved.//// $Id: PropertyConfigurableFactory.java,v 1.1 2004/01/01 20:29:29 leomekenkamp Exp $package org.ozoneDB.core.storage;import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;import java.util.Properties;import org.ozoneDB.core.ConfigurationException;/** * * @author <a href="mailto:leoATmekenkampD0Tcom">Leo Mekenkamp (mind the anti sp@m)</a> * @version $Id: PropertyConfigurableFactory.java,v 1.1 2004/01/01 20:29:29 leomekenkamp Exp $ */public class PropertyConfigurableFactory {        private PropertyConfigurableFactory() {    }    public static PropertyConfigurable create(Class assignableFrom, Properties properties, String propertyName) {        String className = properties.getProperty(propertyName);        if (className == null) {            throw new ConfigurationException("could not find property: '" + propertyName + "'");        }        try {            Class classType = Class.forName(className);            if (!PropertyConfigurable.class.isAssignableFrom(classType)) {                throw new ConfigurationException(className + " should implement " + PropertyConfigurable.class);            }            if (!assignableFrom.isAssignableFrom(classType)) {                throw new ConfigurationException(className + " should implement " + assignableFrom);            }            Constructor constructor = classType.getConstructor(new Class[] {Properties.class, String.class});            PropertyConfigurable result = (PropertyConfigurable) constructor.newInstance(new Object[] {properties, propertyName});            return result;        } catch (ClassNotFoundException e) {            throw new ConfigurationException(e);        } catch (NoSuchMethodException e) {            throw new ConfigurationException(className + " does not follow PropertyConfigurable constructor contract", e);        } catch (InstantiationException e) {            throw new ConfigurationException(e);        } catch (IllegalAccessException e) {            throw new ConfigurationException(e);        } catch (InvocationTargetException e) {            throw new ConfigurationException(e);        }    }    }         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -