org.faktorips.runtime
Class ClassloaderRuntimeRepository

java.lang.Object
  extended by org.faktorips.runtime.internal.AbstractRuntimeRepository
      extended by org.faktorips.runtime.internal.AbstractCachingRuntimeRepository
          extended by org.faktorips.runtime.internal.AbstractTocBasedRuntimeRepository
              extended by org.faktorips.runtime.internal.AbstractClassLoadingRuntimeRepository
                  extended by org.faktorips.runtime.ClassloaderRuntimeRepository
All Implemented Interfaces:
IRuntimeRepository

public class ClassloaderRuntimeRepository
extends AbstractClassLoadingRuntimeRepository

A runtime repository that loads the resources by calling ClassLoader.getResourceAsStream(String)

Author:
Jan Ortmann

Field Summary
static String REPOSITORY_XML_ELEMENT
          Name of the xml element representing the product component registry.
static String TABLE_OF_CONTENTS_FILE
          The default name of the file describing the registry's contents.
 
Constructor Summary
ClassloaderRuntimeRepository(ClassLoader cl, String basePackage)
          Creates a new repository that loads it's contents from the given classloader and the given package.
ClassloaderRuntimeRepository(ClassLoader cl, String basePackage, String pathToToc)
          Creates a new repository that loads it's contents from the given classloader and the given package and toc resource using the default document builder.
ClassloaderRuntimeRepository(ClassLoader cl, String basePackage, String pathToToc, ICacheFactory cacheFactory)
          Creates a new repository that loads it's contents from the given classloader and the given package using the given xml document builder.
 
Method Summary
static ClassloaderRuntimeRepository create(String tocResource)
          Creates a new repository that loads it's contents from the given toc resource using this class' classloader and the default xml document builder to parse the xml data.
static ClassloaderRuntimeRepository create(String tocResource, ClassLoader cl)
          Creates a new repository that loads it's contents from the given toc resource and classloader using the default document builder to parse the xml data.
static ClassloaderRuntimeRepository create(String tocResource, ClassLoader cl, ICacheFactory cacheFactory)
          Creates a new repository that loads it's contents from the given toc resource and classloader using the default document builder to parse the xml data.
static ClassloaderRuntimeRepository create(String tocResource, ICacheFactory cacheFactory)
          Creates a new repository that loads it's contents from the given toc resource using this class' classloader and the default xml document builder to parse the xml data.
protected  DocumentBuilder getDocumentBuilder()
           
protected
<T> Element
getDocumentElement(CustomTocEntryObject<T> tocEntry)
          This method returns the xml element of the product component identified by the tocEntry
protected  Element getDocumentElement(GenerationTocEntry tocEntry)
          This method returns the xml element of the product component generation identified by the tocEntry
protected  Element getDocumentElement(ProductCmptTocEntry tocEntry)
          This method returns the xml element of the product component identified by the tocEntry
protected  Element getDocumentElement(TestCaseTocEntry tocEntry)
          This method returns the xml element of the test case identified by the tocEntry
protected  String getProductComponentGenerationImplClass(GenerationTocEntry tocEntry)
          This method returns the name of the product component generation implementation class identified by the tocEntry.
protected  InputStream getXmlAsStream(EnumContentTocEntry tocEntry)
          Returns the XML data for the specified tocEntry as InputStream
protected  InputStream getXmlAsStream(TableContentTocEntry tocEntry)
          Returns the XML data for the specified tocEntry as InputStream
 boolean isModifiable()
          Returns true if the repository's content is modifiable.
protected  ReadonlyTableOfContents loadTableOfContents()
           
 
Methods inherited from class org.faktorips.runtime.internal.AbstractClassLoadingRuntimeRepository
createCustomObject, createEnumValues, createProductCmpt, createProductCmptGeneration, createProductComponentGenerationInstance, createProductComponentInstance, createTable, createTestCase, getAllProductComponentsInternal, getClassLoader, getProductVariantHelper, initClRepositoryObject
 
Methods inherited from class org.faktorips.runtime.internal.AbstractTocBasedRuntimeRepository
createEnumXmlAdapter, getAllIpsTestCases, getAllModelTypeImplementationClasses, getAllProductComponentIds, getAllProductComponents, getAllProductComponents, getAllTables, getClass, getIpsTestCaseInternal, getIpsTestCasesStartingWith, getLatestProductComponentGenerationInternal, getNextProductComponentGenerationInternal, getNotCachedCustomObject, getNotCachedEnumValues, getNotCachedEnumXmlAdapter, getNotCachedProductComponent, getNotCachedProductComponentGeneration, getNotCachedTable, getNumberOfProductComponentGenerationsInternal, getPreviousProductComponentGenerationInternal, getProductComponentGenerationInternal, getProductComponentGenerations, getProductComponentInternal, getTableInternal, getTableOfContents, initialize
 
Methods inherited from class org.faktorips.runtime.internal.AbstractCachingRuntimeRepository
getAllInternalEnumXmlAdapters, getCustomRuntimeObjectInternal, getEnumValuesInternal, getProductComponentGenerationInternal, getProductComponentInternal, getTableInternal, initCaches
 
Methods inherited from class org.faktorips.runtime.internal.AbstractRuntimeRepository
addDirectlyReferencedRepository, addEnumValueLookupService, getAllIpsTestCases, getAllModelTypeImplementationClasses, getAllProductComponentIds, getAllProductComponents, getAllProductComponents, getAllProductComponents, getAllReferencedRepositories, getAllTables, getCustomRuntimeObject, getDirectlyReferencedRepositories, getEnumValue, getEnumValue, getEnumValueLookupService, getEnumValues, getEnumValuesDefinedInType, getExistingProductComponent, getExistingProductComponentGeneration, getFormulaEvaluatorFactory, getIpsTest, getIpsTest, getIpsTestCase, getIpsTestCase, getIpsTestCasesStartingWith, getIpsTestSuite, getIpsTestSuite, getLatestProductComponentGeneration, getModelType, getModelType, getModelType, getModelType, getName, getNextProductComponentGeneration, getNumberOfProductComponentGenerations, getPreviousProductComponentGeneration, getProductComponent, getProductComponent, getProductComponentGeneration, getProductComponentGenerations, getRuntimeRepositoryLookup, getTable, getTable, newJAXBContext, newJAXBContext, removeEnumValueLookupService, setFormulaEvaluatorFactory, setRuntimeRepositoryLookup, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REPOSITORY_XML_ELEMENT

public static final String REPOSITORY_XML_ELEMENT
Name of the xml element representing the product component registry.

See Also:
Constant Field Values

TABLE_OF_CONTENTS_FILE

public static final String TABLE_OF_CONTENTS_FILE
The default name of the file describing the registry's contents.

See Also:
Constant Field Values
Constructor Detail

ClassloaderRuntimeRepository

public ClassloaderRuntimeRepository(ClassLoader cl,
                                    String basePackage)
Creates a new repository that loads it's contents from the given classloader and the given package. Uses the default toc resource name. Uses the default document builder available via DocumentBuilderFactory.newInstance() to parse the xml files.

Throws:
NullPointerException - if cl or basePackage are null.
IllegalArgumentException - if the basePackage does not contain the table of contents file.
RuntimeException - if the registry's table of contents file can't be read.
See Also:
TABLE_OF_CONTENTS_FILE

ClassloaderRuntimeRepository

public ClassloaderRuntimeRepository(ClassLoader cl,
                                    String basePackage,
                                    String pathToToc)
Creates a new repository that loads it's contents from the given classloader and the given package and toc resource using the default document builder.

Parameters:
cl - The classloader to use.
basePackage - The name of the base package that contains the data.
pathToToc - Path from the base package to the resource containing the toc, e.g. "faktorips-repository-toc.xml" or "motor/motor-repository-toc.xml"
Throws:
NullPointerException - if any argument is null.
IllegalArgumentException - if the basePackage does not contain the table of contents file.
RuntimeException - if the registry's table of contents file can't be read.

ClassloaderRuntimeRepository

public ClassloaderRuntimeRepository(ClassLoader cl,
                                    String basePackage,
                                    String pathToToc,
                                    ICacheFactory cacheFactory)
Creates a new repository that loads it's contents from the given classloader and the given package using the given xml document builder.

Parameters:
cl - The classloader to use.
basePackage - The name of the base package that contains the data.
pathToToc - Path from the base package to the resource containing the toc, e.g. "faktorips-repository-toc.xml" or "motor/motor-repository-toc.xml"
Throws:
NullPointerException - if any argument is null.
IllegalArgumentException - if the basePackage does not contain the table of contents file.
RuntimeException - if the registry's table of contents file can't be read.
Method Detail

create

public static final ClassloaderRuntimeRepository create(String tocResource)
Creates a new repository that loads it's contents from the given toc resource using this class' classloader and the default xml document builder to parse the xml data.

Parameters:
tocResource - Path to the resource containing the toc file. E.g. "org/faktorips/sample/internal/faktorips-repository-toc.xml"
Throws:
NullPointerException - if any argument is null.
RuntimeException - if the registry's table of contents file can't be read.

create

public static final ClassloaderRuntimeRepository create(String tocResource,
                                                        ICacheFactory cacheFactory)
Creates a new repository that loads it's contents from the given toc resource using this class' classloader and the default xml document builder to parse the xml data.

Parameters:
tocResource - Path to the resource containing the toc file. E.g. "org/faktorips/sample/internal/faktorips-repository-toc.xml"
cacheFactory - The CacheFactory used to create the cache objects in the repository
Throws:
NullPointerException - if any argument is null.
RuntimeException - if the registry's table of contents file can't be read.

create

public static final ClassloaderRuntimeRepository create(String tocResource,
                                                        ClassLoader cl)
Creates a new repository that loads it's contents from the given toc resource and classloader using the default document builder to parse the xml data.

Parameters:
tocResource - Path to the resource containing the toc file. E.g. "org/faktorips/sample/internal/faktorips-repository-toc.xml"
cl - The classloader to use.
Throws:
NullPointerException - if any argument is null.
RuntimeException - if the registry's table of contents file can't be read.

create

public static final ClassloaderRuntimeRepository create(String tocResource,
                                                        ClassLoader cl,
                                                        ICacheFactory cacheFactory)
Creates a new repository that loads it's contents from the given toc resource and classloader using the default document builder to parse the xml data.

Parameters:
tocResource - Path to the resource containing the toc file. E.g. "org/faktorips/sample/internal/faktorips-repository-toc.xml"
cl - The classloader to use.
cacheFactory - The CacheFactory used to create the cache objects in the repository
Throws:
NullPointerException - if any argument is null.
RuntimeException - if the registry's table of contents file can't be read.

getDocumentBuilder

protected DocumentBuilder getDocumentBuilder()

loadTableOfContents

protected ReadonlyTableOfContents loadTableOfContents()
Specified by:
loadTableOfContents in class AbstractTocBasedRuntimeRepository

getProductComponentGenerationImplClass

protected String getProductComponentGenerationImplClass(GenerationTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
This method returns the name of the product component generation implementation class identified by the tocEntry. This could either be an implementation class using the formula evaluation or an implementation class containing the compiled formulas.

Specified by:
getProductComponentGenerationImplClass in class AbstractClassLoadingRuntimeRepository

getDocumentElement

protected Element getDocumentElement(ProductCmptTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
This method returns the xml element of the product component identified by the tocEntry

Specified by:
getDocumentElement in class AbstractClassLoadingRuntimeRepository

getDocumentElement

protected Element getDocumentElement(GenerationTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
This method returns the xml element of the product component generation identified by the tocEntry

Specified by:
getDocumentElement in class AbstractClassLoadingRuntimeRepository

getDocumentElement

protected Element getDocumentElement(TestCaseTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
This method returns the xml element of the test case identified by the tocEntry

Specified by:
getDocumentElement in class AbstractClassLoadingRuntimeRepository

getXmlAsStream

protected InputStream getXmlAsStream(EnumContentTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
Returns the XML data for the specified tocEntry as InputStream

Specified by:
getXmlAsStream in class AbstractClassLoadingRuntimeRepository
Parameters:
tocEntry - Specifying the requested EnumContent
Returns:
An InputStream containing the XML data - should not return null!

isModifiable

public boolean isModifiable()
Description copied from interface: IRuntimeRepository
Returns true if the repository's content is modifiable. This feature is mainly targeted for writing test cases that need to setup a repository with a test specific content programatically. Returns false otherwise.


getXmlAsStream

protected InputStream getXmlAsStream(TableContentTocEntry tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
Returns the XML data for the specified tocEntry as InputStream

Specified by:
getXmlAsStream in class AbstractClassLoadingRuntimeRepository
Parameters:
tocEntry - Specifying the requested TableContent
Returns:
An InputStream containing the XML data - should not return null!

getDocumentElement

protected <T> Element getDocumentElement(CustomTocEntryObject<T> tocEntry)
Description copied from class: AbstractClassLoadingRuntimeRepository
This method returns the xml element of the product component identified by the tocEntry

Specified by:
getDocumentElement in class AbstractClassLoadingRuntimeRepository


Copyright © 2015. All rights reserved.