Package org.corpus_tools.pepper.core
Class ModuleResolverImpl
- java.lang.Object
-
- org.corpus_tools.pepper.core.ModuleResolverImpl
-
- All Implemented Interfaces:
ModuleResolver
public class ModuleResolverImpl extends Object implements ModuleResolver
TheModuleResolverImplrealizes a bridge between the Pepper framework and the OSGi environment. Through OSGi declarative services allPepperModuleno matter ifPepperImporter,PepperExporterorPepperManipulator, all of them are registered in theModuleResolverImpl. The main task of this class is to get a description of aPepperModuleand to resolve a real instance of thatPepperModule.- Author:
- Florian Zipser
-
-
Field Summary
Fields Modifier and Type Field Description protected List<org.osgi.service.component.ComponentFactory>pepperExporterComponentFactoriesTODO make docuprotected org.osgi.service.component.ComponentFactorypepperExporterComponentFactoryThis unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin.protected List<org.osgi.service.component.ComponentFactory>pepperImporterComponentFactoriesTODO make docuprotected org.osgi.service.component.ComponentFactorypepperImporterComponentFactoryThis unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin.protected List<org.osgi.service.component.ComponentFactory>pepperManipulatorComponentFactoriesTODO make docuprotected org.osgi.service.component.ComponentFactorypepperManipulatorComponentFactoryThis unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin.static StringPROP_OSGI_BUNDLESname of system property to determine the locations of OSGi bundles-
Fields inherited from interface org.corpus_tools.pepper.core.ModuleResolver
RESOURCES
-
-
Constructor Summary
Constructors Constructor Description ModuleResolverImpl()TODO make docu
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(org.osgi.service.component.ComponentContext componentContext)Sets theComponentContextof the OSGi environment the bundle was started in.voidaddPepperExporterComponentFactory(org.osgi.service.component.ComponentFactory pepperExporterComponentFactory)This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperExporterComponentFactory to this object.voidaddPepperImporterComponentFactory(org.osgi.service.component.ComponentFactory pepperImporterComponentFactory)This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperImporterComponentFactory to this object.voidaddPepperManipulatorComponentFactory(org.osgi.service.component.ComponentFactory pepperManipulatorComponentFactory)This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperManipulatorComponentFactory to this object.org.osgi.service.component.ComponentContextgetComponentContext()Returns theComponentContextof the OSGi environment the bundle was started in.PepperConfigurationgetConfiguration()Returns the configuration object for this converter object.PepperExportergetPepperExporter(StepDesc stepDesc)Creates an instance ofPepperExporterfor each listedComponentFactoryin list#pepperExporterComponentFactoriesand returns that list.List<org.osgi.service.component.ComponentFactory>getPepperExporterComponentFactories()TODO make docuList<PepperExporter>getPepperExporters()Creates an instance ofPepperExporterfor each listedComponentFactoryin list#pepperExporterComponentFactoriesand returns that list.PepperImportergetPepperImporter(StepDesc stepDesc)Returns aPepperImporterobject matching to the givenImporterParams.List<org.osgi.service.component.ComponentFactory>getPepperImporterComponentFactories()TODO make docuList<PepperImporter>getPepperImporters()Creates an instance ofPepperImporterfor each listedComponentFactoryin list#pepperImporterComponentFactoriesand returns that list.PepperManipulatorgetPepperManipulator(StepDesc stepDesc)Creates an instance ofPepperManipulatorfor each listedComponentFactoryin list#pepperManipulatorComponentFactoriesand returns that list.List<org.osgi.service.component.ComponentFactory>getPepperManipulatorComponentFactories()TODO make docuList<PepperManipulator>getPepperManipulators()Creates an instance ofPepperManipulatorfor each listedComponentFactoryin list#pepperManipulatorComponentFactoriesand returns that list.PepperModulegetPepperModule(StepDesc stepDesc)Returns aPepperModuleobject matching to the givenStepDesc.StringgetStatus()Returns a status description asString.voidremovePepperExporterComponentFactory(org.osgi.service.component.ComponentFactory pepperExporterComponentFactory)TODO make some docuvoidremovePepperImporterComponentFactory(org.osgi.service.component.ComponentFactory pepperImporterComponentFactory)TODO make docuvoidremovePepperManipulatorComponentFactory(org.osgi.service.component.ComponentFactory pepperManipulatorComponentFactory)TODO make docuprotected StringretrieveResourcePathFromBundle(PepperModule module)Retrieves the path, where the bundle is located and extracts the path, where resources are estimatedvoidsetConfiguration(PepperConfiguration pepperConfiguration)Sets the configuration object for this object.protected voidsetResources(PepperModule module)Sets resources to a given PepperModule-object.protected voidsetTemporaries(PepperModule module, int number)Sets a temporary folder for eachPepperModuleto store temporary files if necessary.StringtoString()TODO make docu
-
-
-
Field Detail
-
pepperImporterComponentFactory
protected org.osgi.service.component.ComponentFactory pepperImporterComponentFactory
This unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin. Here it is not possible to use a list as osgi-reference. (this is a workaround)
-
pepperImporterComponentFactories
protected List<org.osgi.service.component.ComponentFactory> pepperImporterComponentFactories
TODO make docu
-
pepperManipulatorComponentFactory
protected org.osgi.service.component.ComponentFactory pepperManipulatorComponentFactory
This unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin. Here it is not possible to use a list as osgi-reference. (this is a workaround)
-
pepperManipulatorComponentFactories
protected List<org.osgi.service.component.ComponentFactory> pepperManipulatorComponentFactories
TODO make docu
-
pepperExporterComponentFactory
protected org.osgi.service.component.ComponentFactory pepperExporterComponentFactory
This unnecessary variable must be initialized, because of restrictions of the maven osgi scr plugin. Here it is not possible to use a list as osgi-reference. (this is a workaround)
-
pepperExporterComponentFactories
protected List<org.osgi.service.component.ComponentFactory> pepperExporterComponentFactories
TODO make docu
-
PROP_OSGI_BUNDLES
public static final String PROP_OSGI_BUNDLES
name of system property to determine the locations of OSGi bundles- See Also:
- Constant Field Values
-
-
Method Detail
-
getComponentContext
public org.osgi.service.component.ComponentContext getComponentContext()
Returns theComponentContextof the OSGi environment the bundle was started in.- Specified by:
getComponentContextin interfaceModuleResolver- Returns:
-
activate
public void activate(org.osgi.service.component.ComponentContext componentContext)
Sets theComponentContextof the OSGi environment the bundle was started in.- Specified by:
activatein interfaceModuleResolver
-
getStatus
public String getStatus()
Returns a status description asString. The returnedStringcontains the number of all availablePepperModuleobjects in a readable format.- Specified by:
getStatusin interfaceModuleResolver- Returns:
Stringrepresentation of allPepperModuleobjects available by thisPepperModuleResolverobject.
-
addPepperImporterComponentFactory
public void addPepperImporterComponentFactory(org.osgi.service.component.ComponentFactory pepperImporterComponentFactory)
This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperImporterComponentFactory to this object. AllComponentFactoryobjects are stored in an internal object#pepperImporterComponentFactories- Specified by:
addPepperImporterComponentFactoryin interfaceModuleResolver
-
removePepperImporterComponentFactory
public void removePepperImporterComponentFactory(org.osgi.service.component.ComponentFactory pepperImporterComponentFactory)
TODO make docu- Specified by:
removePepperImporterComponentFactoryin interfaceModuleResolver
-
getPepperImporterComponentFactories
public List<org.osgi.service.component.ComponentFactory> getPepperImporterComponentFactories()
TODO make docu- Specified by:
getPepperImporterComponentFactoriesin interfaceModuleResolver
-
addPepperManipulatorComponentFactory
public void addPepperManipulatorComponentFactory(org.osgi.service.component.ComponentFactory pepperManipulatorComponentFactory)
This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperManipulatorComponentFactory to this object. AllComponentFactoryobjects are stored in an internal object#pepperManipulatorComponentFactories.- Specified by:
addPepperManipulatorComponentFactoryin interfaceModuleResolver
-
removePepperManipulatorComponentFactory
public void removePepperManipulatorComponentFactory(org.osgi.service.component.ComponentFactory pepperManipulatorComponentFactory)
TODO make docu- Specified by:
removePepperManipulatorComponentFactoryin interfaceModuleResolver
-
getPepperManipulatorComponentFactories
public List<org.osgi.service.component.ComponentFactory> getPepperManipulatorComponentFactories()
TODO make docu- Specified by:
getPepperManipulatorComponentFactoriesin interfaceModuleResolver
-
addPepperExporterComponentFactory
public void addPepperExporterComponentFactory(org.osgi.service.component.ComponentFactory pepperExporterComponentFactory)
This method is called by OSGi framework and adds all registeredComponentFactoryobjects having the name PepperExporterComponentFactory to this object. AllComponentFactoryobjects are stored in the internal object list#pepperExporterComponentFactories.- Specified by:
addPepperExporterComponentFactoryin interfaceModuleResolver- Parameters:
pepperExporterComponentFactory-ComponentFactoryobject to be stored in internal list
-
removePepperExporterComponentFactory
public void removePepperExporterComponentFactory(org.osgi.service.component.ComponentFactory pepperExporterComponentFactory)
TODO make some docu- Specified by:
removePepperExporterComponentFactoryin interfaceModuleResolver
-
getPepperExporterComponentFactories
public List<org.osgi.service.component.ComponentFactory> getPepperExporterComponentFactories()
TODO make docu- Specified by:
getPepperExporterComponentFactoriesin interfaceModuleResolver
-
setResources
protected void setResources(PepperModule module)
Sets resources to a given PepperModule-object. The policy of computing the resource path is the following:- If a system property named SYMBOLIC_NAME_OF_MODULE+
ModuleResolver.RESOURCESis set, thePepperModule.getResources()would be directed the value contained by this property - If environment variable
"pepper.modules.resources" is set,
PepperModule.getResources()would be directed to value of "pepper.modules.resources" /SYMBOLIC_NAME_OF_MODULE - If system property
"pepper.modules.resources" is set,
PepperModule.getResources()would be directed to value of "pepper.modules.resources" /SYMBOLIC_NAME_OF_MODULE - If nothing is set,
PepperModule.getResources()would be directed to a subfolder having the name equal to the symbolic name of the bundle, which is located in the same folder as the bundle is located
- Parameters:
module- - the object for setting resources
- If a system property named SYMBOLIC_NAME_OF_MODULE+
-
retrieveResourcePathFromBundle
protected String retrieveResourcePathFromBundle(PepperModule module)
Retrieves the path, where the bundle is located and extracts the path, where resources are estimated- Returns:
-
setConfiguration
public void setConfiguration(PepperConfiguration pepperConfiguration)
Sets the configuration object for this object.- Specified by:
setConfigurationin interfaceModuleResolver
-
getConfiguration
public PepperConfiguration getConfiguration()
Returns the configuration object for this converter object. If noPepperConfigurationobject was set, an automatic detection of configuration file will be started.- Specified by:
getConfigurationin interfaceModuleResolver- Returns:
- configuration object
-
setTemporaries
protected void setTemporaries(PepperModule module, int number)
Sets a temporary folder for eachPepperModuleto store temporary files if necessary. The general temporary folder could either be given via the propertyPepperConfiguration.PROP_TEMP_FOLDERor if this is not set, resolved by via using the temporary folder provided by the OS.
The specific temporary folder is given by the general temporary folder + a subfolder for the modules name and a subfolder for the number of the instance of the current module.- Parameters:
module- - the object for setting temporariesnumber- - number of module instance
-
getPepperImporters
public List<PepperImporter> getPepperImporters()
Creates an instance ofPepperImporterfor each listedComponentFactoryin list#pepperImporterComponentFactoriesand returns that list. ThisPepperModuleResolverinstance does not store any link to the created object, so it can be used and removed as the caller like. Thus each call creates a new list containing new objects.- Specified by:
getPepperImportersin interfaceModuleResolver- Returns:
- a list of
PepperImporterobjects.
-
getPepperManipulators
public List<PepperManipulator> getPepperManipulators()
Creates an instance ofPepperManipulatorfor each listedComponentFactoryin list#pepperManipulatorComponentFactoriesand returns that list. ThisPepperModuleResolverinstance does not store any link to the created object, so it can be used and removed as the caller like. Thus each call creates a new list containing new objects.- Specified by:
getPepperManipulatorsin interfaceModuleResolver- Returns:
- a list of
PepperManipulatorobjects.
-
getPepperExporters
public List<PepperExporter> getPepperExporters()
Creates an instance ofPepperExporterfor each listedComponentFactoryin list#pepperExporterComponentFactoriesand returns that list. ThisPepperModuleResolverinstance does not store any link to the created object, so it can be used and removed as the caller like. Thus each call creates a new list containing new objects.- Specified by:
getPepperExportersin interfaceModuleResolver- Returns:
- a list of
PepperExporterobjects.
-
getPepperModule
public PepperModule getPepperModule(StepDesc stepDesc)
Returns aPepperModuleobject matching to the givenStepDesc. A new instance of the specificPepperImporterclass is created and returned. No references to the returned object will be stored in thisPepperModuleResolverobject. When calling#getPepperModule(ImporterParams)a new instance ofPepperModuleis created.- Specified by:
getPepperModulein interfaceModuleResolver- Returns:
- a new instance of
PepperModulematching the givenStepDesc
-
getPepperImporter
public PepperImporter getPepperImporter(StepDesc stepDesc)
Returns aPepperImporterobject matching to the givenImporterParams. A new instance of the specificPepperImporterclass is created and returned. No references to the returned object will be stored in thisPepperModuleResolverobject. When calling#getPepperImporter(ImporterParams)a new instance ofPepperImporteris created.- Specified by:
getPepperImporterin interfaceModuleResolver- Returns:
- a new instance of
PepperImportermatching the givenImporterParams
-
getPepperManipulator
public PepperManipulator getPepperManipulator(StepDesc stepDesc)
Creates an instance ofPepperManipulatorfor each listedComponentFactoryin list#pepperManipulatorComponentFactoriesand returns that list. ThisPepperModuleResolverinstance does not store any link to the created object, so it can be used and removed as the caller like. Thus each call creates a new list containing new objects.- Specified by:
getPepperManipulatorin interfaceModuleResolver- Returns:
- a list of
PepperManipulatorobjects.
-
getPepperExporter
public PepperExporter getPepperExporter(StepDesc stepDesc)
Creates an instance ofPepperExporterfor each listedComponentFactoryin list#pepperExporterComponentFactoriesand returns that list. ThisPepperModuleResolverinstance does not store any link to the created object, so it can be used and removed as the caller like. Thus each call creates a new list containing new objects.- Specified by:
getPepperExporterin interfaceModuleResolver- Returns:
- a list of
PepperExporterobjects.
-
-