repositoryfactory.java
来自「这是linux下ssl vpn的实现程序」· Java 代码 · 共 47 行
JAVA
47 行
package com.sslexplorer.boot;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Factory class to get an instance of the configure {@link com.sslexplorer.boot.Repository}.
* <p>
* If the repository has already been created then the same instance will be
* returned.
* <p>
* The repository implementation to use is determined by the value of
* the <i>sslexplorer.repositoryClass</i> system property that should contain
* the full qualified class name to use.
*
* @author Lee David Painter <a href="mailto: lee@3sp.com"><lee@3sp.com></a>
* @version $Revision: 1.2 $
* @see com.sslexplorer.boot.LocalRepository
*/
public class RepositoryFactory {
static Repository instance;
static Log log = LogFactory.getLog(RepositoryFactory.class);
/**
* Get an instance of the configured repository.
*
* @return repository
* @throws IOException if the repository could not be created for some reason
*/
public static Repository getRepository() {
if (instance != null)
return instance;
try {
if (System.getProperty("sslexplorer.repositoryClass") != null) {
instance = (Repository) Class.forName(System.getProperty("sslexplorer.repositoryClass")).newInstance();
} else
instance = new LocalRepository();
} catch (Exception e) {
log.error("Failed to initialize repository", e);
return null;
}
return instance;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?