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

📄 idgeneratorholder.java

📁 根据Scott W. Ambler在1998年写的关于ORM Persistence Layer的详细设计论文的设计思路,Artem Rudoy 开发了一个开源的ORM实现 -- PL(Persist
💻 JAVA
字号:
package pl.sql;

/**
 * This class holds ID generator with it's attributes.
 *
 * @author: Artem Rudoy
 */
class IdGeneratorHolder
{
    private java.util.Properties parameters = null;
    private boolean singleInstance = false;
    private java.lang.Class idGeneratorClass = null;
    private pl.sql.IdGenerator instance = null;

    /**
     * IdGeneratorHolder constructor comment.
     */
    public IdGeneratorHolder(Class idGeneratorClass, java.util.Properties parameters, boolean singleInstance)
    {
        super();

        this.idGeneratorClass = idGeneratorClass;
        this.parameters = parameters;
        this.singleInstance = singleInstance;
    }

    /**
     * Return instance of this ID generator class.
     *
     * @return instance of this ID generator class
     */
    public synchronized pl.sql.IdGenerator getInstance(java.util.Properties additionalParameters) throws pl.PlException
    {
        if(!singleInstance)
            return getNewInstance(additionalParameters);
        else
        {
            if(instance == null)
            {
                instance = getNewInstance(new java.util.Properties());
            }

            return instance;
        }
    }

    /**
     * Return new instance of this ID generator class.
     *
     * @return new instance of this ID generator class
     */
    private pl.sql.IdGenerator getNewInstance(java.util.Properties additionalParameters) throws pl.PlException
    {
        try
        {
            java.util.Properties allParameters = new java.util.Properties();
            allParameters.putAll(parameters);
            allParameters.putAll(additionalParameters);
            pl.sql.IdGenerator idGen = (pl.sql.IdGenerator)idGeneratorClass.newInstance();
            idGen.init(allParameters);
            return idGen;
        }
        catch(pl.PlException e)
        {
            throw e;
        }
        catch(Exception e)
        {
            throw new pl.PlException(e);
        }
    }
}

⌨️ 快捷键说明

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