Package org.faktorips.runtime
Class ClassloaderRuntimeRepository
- java.lang.Object
-
- org.faktorips.runtime.internal.AbstractRuntimeRepository
-
- org.faktorips.runtime.internal.AbstractCachingRuntimeRepository
-
- org.faktorips.runtime.internal.AbstractTocBasedRuntimeRepository
-
- org.faktorips.runtime.internal.AbstractClassLoadingRuntimeRepository
-
- org.faktorips.runtime.ClassloaderRuntimeRepository
-
- All Implemented Interfaces:
IRuntimeRepository
public class ClassloaderRuntimeRepository extends AbstractClassLoadingRuntimeRepository
A runtime repository that loads the resources by callingClassLoader.getResourceAsStream(String)- Author:
- Jan Ortmann
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringREPOSITORY_XML_ELEMENTName of the xml element representing the product component registry.static java.lang.StringTABLE_OF_CONTENTS_FILEThe default name of the file describing the registry's contents.
-
Constructor Summary
Constructors Constructor Description ClassloaderRuntimeRepository(java.lang.ClassLoader cl, java.lang.String basePackage)Creates a new repository that loads its contents from the given classloader and the given package.ClassloaderRuntimeRepository(java.lang.ClassLoader cl, java.lang.String basePackage, java.lang.String pathToToc)Creates a new repository that loads its contents from the given classloader and the given package and toc resource using the default document builder.ClassloaderRuntimeRepository(java.lang.ClassLoader cl, java.lang.String basePackage, java.lang.String pathToToc, ICacheFactory cacheFactory)Creates a new repository that loads its contents from the given classloader and the given package using the given xml document builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClassloaderRuntimeRepositorycreate(java.lang.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 ClassloaderRuntimeRepositorycreate(java.lang.String tocResource, java.lang.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 ClassloaderRuntimeRepositorycreate(java.lang.String tocResource, java.lang.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 ClassloaderRuntimeRepositorycreate(java.lang.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 javax.xml.parsers.DocumentBuildergetDocumentBuilder()protected <T> org.w3c.dom.ElementgetDocumentElement(CustomTocEntryObject<T> tocEntry)This method returns the xml element of the product component identified by the tocEntryprotected org.w3c.dom.ElementgetDocumentElement(GenerationTocEntry tocEntry)This method returns the xml element of the product component generation identified by the tocEntryprotected org.w3c.dom.ElementgetDocumentElement(ProductCmptTocEntry tocEntry)This method returns the xml element of the product component identified by the tocEntryprotected org.w3c.dom.ElementgetDocumentElement(TestCaseTocEntry tocEntry)This method returns the xml element of the test case identified by the tocEntryprotected java.lang.StringgetProductComponentGenerationImplClass(GenerationTocEntry tocEntry)This method returns the name of the product component generation implementation class identified by the tocEntry.protected java.io.InputStreamgetXmlAsStream(EnumContentTocEntry tocEntry)Returns the XML data for the specified tocEntry asInputStreamprotected java.io.InputStreamgetXmlAsStream(TableContentTocEntry tocEntry)Returns the XML data for the specified tocEntry asInputStreambooleanisModifiable()Returnstrueif the repository's content is modifiable.protected ReadonlyTableOfContentsloadTableOfContents()-
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, getAllEnumClasses, 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, getAllEnumClasses, getAllIpsTestCases, getAllModelTypeImplementationClasses, getAllProductComponentIds, getAllProductComponents, getAllProductComponents, getAllProductComponents, getAllReferencedRepositories, getAllTables, getCustomRuntimeObject, getDirectlyReferencedRepositories, getEnumValue, getEnumValue, getEnumValueLookupService, getEnumValues, getEnumValuesDefinedInType, getExistingEnumValue, getExistingProductComponent, getExistingProductComponentGeneration, getFormulaEvaluatorFactory, getIpsTest, getIpsTest, getIpsTestCase, getIpsTestCase, getIpsTestCasesStartingWith, getIpsTestSuite, getIpsTestSuite, getLatestProductComponentGeneration, getModelType, getModelType, getModelType, getName, getNextProductComponentGeneration, getNumberOfProductComponentGenerations, getPreviousProductComponentGeneration, getProductComponent, getProductComponent, getProductComponentGeneration, getProductComponentGenerations, getRuntimeRepositoryLookup, getTable, getTable, newJAXBContext, newJAXBContext, removeEnumValueLookupService, setFormulaEvaluatorFactory, setRuntimeRepositoryLookup, toString
-
-
-
-
Field Detail
-
REPOSITORY_XML_ELEMENT
public static final java.lang.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 java.lang.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(java.lang.ClassLoader cl, java.lang.String basePackage)Creates a new repository that loads its contents from the given classloader and the given package. Uses the default toc resource name. Uses the default document builder available viaDocumentBuilderFactory.newInstance()to parse the xml files.- Throws:
java.lang.NullPointerException- if cl or basePackage arenull.java.lang.IllegalArgumentException- if the basePackage does not contain the table of contents file.java.lang.RuntimeException- if the registry's table of contents file can't be read.- See Also:
TABLE_OF_CONTENTS_FILE
-
ClassloaderRuntimeRepository
public ClassloaderRuntimeRepository(java.lang.ClassLoader cl, java.lang.String basePackage, java.lang.String pathToToc)Creates a new repository that loads its 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:
java.lang.NullPointerException- if any argument isnull.java.lang.IllegalArgumentException- if the basePackage does not contain the table of contents file.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
ClassloaderRuntimeRepository
public ClassloaderRuntimeRepository(java.lang.ClassLoader cl, java.lang.String basePackage, java.lang.String pathToToc, ICacheFactory cacheFactory)Creates a new repository that loads its 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:
java.lang.NullPointerException- if any argument isnull.java.lang.IllegalArgumentException- if the basePackage does not contain the table of contents file.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
-
Method Detail
-
create
public static final ClassloaderRuntimeRepository create(java.lang.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:
java.lang.NullPointerException- if any argument isnull.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
create
public static final ClassloaderRuntimeRepository create(java.lang.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:
java.lang.NullPointerException- if any argument isnull.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
create
public static final ClassloaderRuntimeRepository create(java.lang.String tocResource, java.lang.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:
java.lang.NullPointerException- if any argument isnull.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
create
public static final ClassloaderRuntimeRepository create(java.lang.String tocResource, java.lang.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:
java.lang.NullPointerException- if any argument isnull.java.lang.RuntimeException- if the registry's table of contents file can't be read.
-
getDocumentBuilder
protected javax.xml.parsers.DocumentBuilder getDocumentBuilder()
-
loadTableOfContents
protected ReadonlyTableOfContents loadTableOfContents()
- Specified by:
loadTableOfContentsin classAbstractTocBasedRuntimeRepository
-
getProductComponentGenerationImplClass
protected java.lang.String getProductComponentGenerationImplClass(GenerationTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryThis 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:
getProductComponentGenerationImplClassin classAbstractClassLoadingRuntimeRepository
-
getDocumentElement
protected org.w3c.dom.Element getDocumentElement(ProductCmptTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryThis method returns the xml element of the product component identified by the tocEntry- Specified by:
getDocumentElementin classAbstractClassLoadingRuntimeRepository
-
getDocumentElement
protected org.w3c.dom.Element getDocumentElement(GenerationTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryThis method returns the xml element of the product component generation identified by the tocEntry- Specified by:
getDocumentElementin classAbstractClassLoadingRuntimeRepository
-
getDocumentElement
protected org.w3c.dom.Element getDocumentElement(TestCaseTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryThis method returns the xml element of the test case identified by the tocEntry- Specified by:
getDocumentElementin classAbstractClassLoadingRuntimeRepository
-
getXmlAsStream
protected java.io.InputStream getXmlAsStream(EnumContentTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryReturns the XML data for the specified tocEntry asInputStream- Specified by:
getXmlAsStreamin classAbstractClassLoadingRuntimeRepository- 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:IRuntimeRepositoryReturnstrueif 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 programmatically. Returnsfalseotherwise.
-
getXmlAsStream
protected java.io.InputStream getXmlAsStream(TableContentTocEntry tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryReturns the XML data for the specified tocEntry asInputStream- Specified by:
getXmlAsStreamin classAbstractClassLoadingRuntimeRepository- Parameters:
tocEntry- Specifying the requested TableContent- Returns:
- An InputStream containing the XML data - should not return null!
-
getDocumentElement
protected <T> org.w3c.dom.Element getDocumentElement(CustomTocEntryObject<T> tocEntry)
Description copied from class:AbstractClassLoadingRuntimeRepositoryThis method returns the xml element of the product component identified by the tocEntry- Specified by:
getDocumentElementin classAbstractClassLoadingRuntimeRepository
-
-