verinec.data.repository
Class RepositoryFactory

java.lang.Object
  extended by verinec.data.repository.RepositoryFactory

public class RepositoryFactory
extends Object

Factory for repositories. To choose the implementation class, the system property verinec.data.repository.implementation is read. If this is not set, a FileRepository is created as default.

Version:
$Revision: 394 $
Author:
david.buchmann at unifr.ch

Constructor Summary
RepositoryFactory()
           
 
Method Summary
static IVerinecRepository createRepository(String name)
          Instantiate a repository for an existing project or create a new one if there is no project with this name.
private static Class getImpl()
          Determine the class to instantiate for the IRepository.
static String[] getProjectNames()
          Returns an array of all available projects in the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryFactory

public RepositoryFactory()
Method Detail

getImpl

private static Class getImpl()
                      throws VerinecException
Determine the class to instantiate for the IRepository. First looks at the verinec.data.repository.implementation system property. If this is not found, returns FileRepository.class.

Returns:
A RepositoryFactory class
Throws:
VerinecException - if the class can not be loaded.

createRepository

public static IVerinecRepository createRepository(String name)
                                           throws VerinecException
Instantiate a repository for an existing project or create a new one if there is no project with this name.

The factory relies on the implementation of IVerinecRepository to have a constructor with one String parameter, the repository name.

Parameters:
name - Name of the project to open or create, may not be null or empty String.
Returns:
An instance of the default implementation for the project name.
Throws:
VerinecException - If repository can not be instantiated.

getProjectNames

public static String[] getProjectNames()
                                throws VerinecException
Returns an array of all available projects in the repository. If the implementation has the static method sgetProjectNames, that method is called to get the list. Otherwise an repository instance named dummy is created to call getProjectNames on it.

Returns:
Names of all projects that can be opened with the default repository implementation.
Throws:
VerinecException - if the repository throws an error while retreiving the project names.

Copyright © 2005 Verinec, DIUF