public class PepperModuleImpl extends Object implements PepperModule, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected boolean |
isMultithreaded |
protected org.slf4j.Logger |
logger |
protected ModuleController |
moduleController
the controller object, which acts as bridge between Pepper framework and
Pepper module.
|
protected org.eclipse.emf.common.util.URI |
resources
TODO make docu
|
protected org.corpus_tools.salt.common.SaltProject |
saltProject
Salt project which is processed by module.
|
protected org.corpus_tools.salt.common.SCorpusGraph |
sCorpusGraph
The
SCorpusGraph object which should be processed by this module. |
protected String |
symbolicName
TODO make docu
|
protected org.eclipse.emf.common.util.URI |
temproraries
Deprecated.
|
ENDING_ALL_FILES, ENDING_FOLDER, ENDING_LEAF_FOLDER, ENDING_TAB, ENDING_TXT, ENDING_XML
Modifier | Constructor and Description |
---|---|
protected |
PepperModuleImpl()
Creates a
PepperModule object, which is either a
MODULE_TYPE.IMPORTER , a MODULE_TYPE.MANIPULATOR or a
MODULE_TYPE.EXPORTER . |
protected |
PepperModuleImpl(String name)
Creates a
PepperModule object, which is either a
MODULE_TYPE.IMPORTER , a MODULE_TYPE.MANIPULATOR or a
MODULE_TYPE.EXPORTER . |
Modifier and Type | Method and Description |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext componentContext)
This method is called by OSGi framework and sets the component context,
this class is running in.
|
PepperMapper |
createPepperMapper(org.corpus_tools.salt.graph.Identifier sElementId)
OVERRIDE THIS METHOD FOR CUSTOMIZED MAPPING.
|
void |
done(org.corpus_tools.salt.graph.Identifier id,
DOCUMENT_STATUS result)
This method is called by a
PepperMapperController object to
notify the PepperModule object, that the mapping for this object
is done. |
void |
done(PepperMapperController controller)
This method is called by a
PepperMapperController object to
notify the PepperModule object, that the mapping is done. |
void |
end()
|
org.osgi.service.component.ComponentContext |
getComponentContext()
Returns the
ComponentContext of the OSGi environment the bundle
was started in. |
org.corpus_tools.salt.common.SCorpusGraph |
getCorpusGraph()
Returns the
SCorpusGraph object which is filled, manipulated or
exported by the current module. |
String |
getDesc()
Returns a short description of this module.
|
protected Map<String,DocumentController> |
getDocumentId2DC()
Returns the map relating
Identifier belonging to
SDocument objects to their DocumentController container. |
PepperModuleDesc |
getFingerprint()
Returns a
PepperModuleDesc object, which is a kind of a
fingerprint of this PepperModule . |
protected Map<String,PepperMapperController> |
getMapperControllers()
Returns a threadsafe map of all
PepperMapperController objects
which are connected with a started PepperMapper corresponding to
their |
protected ThreadGroup |
getMapperThreadGroup()
Returns a
ThreadGroup where PepperMapper objects and the
corresponding threads are supposed to run in. |
ModuleController |
getModuleController()
Returns the container and controller object for the current module.
|
MODULE_TYPE |
getModuleType()
Returns the type of this module.
|
String |
getName()
Returns the name of this module.
|
Double |
getProgress()
This method is invoked by the Pepper framework, to get the current total
progress of all
SDocument objects being processed by this module. |
Double |
getProgress(String globalId)
This method is invoked by the Pepper framework, to get the current
progress concerning the
SDocument object corresponding to the
given Identifier in percent. |
PepperModuleProperties |
getProperties()
Returns a
PepperModuleProperties object containing properties to
customize the behavior of this PepperModule . |
org.eclipse.emf.common.util.URI |
getResources()
Returns the path of the folder which might contain resources for a Pepper
module.
|
org.corpus_tools.salt.common.SaltProject |
getSaltProject()
Returns the
SaltProject object, which is filled, manipulated or
exported by the current module. |
SelfTestDesc |
getSelfTestDesc()
This method is called by the Pepper framework to run an integration test
for module.
|
Collection<String> |
getStartProblems()
If
PepperModule.isReadyToStart() has returned false, this method returns a
list of reasons why this module is not ready to start. |
org.eclipse.emf.common.util.URI |
getSupplierContact()
Returns a uri where to find more information about this module and where
to find some contact information to contact the supplier.
|
org.eclipse.emf.common.util.URI |
getSupplierHomepage()
Sets the
URI to the homepage describing the functionality of the
module. |
String |
getSymbolicName()
Returns the symbolic name of this OSGi bundle.
|
org.eclipse.emf.common.util.URI |
getTemproraries()
Deprecated.
|
String |
getVersion()
Returns the version of this module.
|
boolean |
isMultithreaded()
Returns whether this
PepperModule is able to run multithreaded. |
boolean |
isReadyToStart()
This method is called by the pepper framework after initializing this
object and directly before start processing.
|
List<org.corpus_tools.salt.graph.Identifier> |
proposeImportOrder(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)
This method could be overridden, to make a proposal for the import order
of
SDocument objects. |
void |
setCorpusGraph(org.corpus_tools.salt.common.SCorpusGraph newSCorpusGraph)
Sets the
SCorpusGraph object which is filled, manipulated or
exported by the current module. |
void |
setDesc(String desc)
Sets a short description of this module.
|
void |
setIsMultithreaded(boolean isMultithreaded)
Sets whether this
PepperModule is able to run multithreaded. |
protected void |
setMapperThreadGroup(ThreadGroup mapperThreadGroup)
Sets a
ThreadGroup where PepperMapper objects and the
corresponding threads are supposed to run in. |
protected void |
setName(String name)
Sets the name of this
PepperModule . |
void |
setPepperModuleController_basic(ModuleController newModuleController)
Sets the container and controller object for the current module.
|
void |
setPepperModuleController(ModuleController newModuleController)
Sets the container and controller object for the current module.
|
void |
setProperties(PepperModuleProperties properties)
Sets the
PepperModuleProperties object containing properties to
customize the behavior of this PepperModule . |
void |
setResources(org.eclipse.emf.common.util.URI newResources)
Sets the resource folder used by
PepperModule.getResources() . |
void |
setSaltProject(org.corpus_tools.salt.common.SaltProject newSaltProject)
Sets the
SaltProject object, which is filled, manipulated or
exported by the current module. |
void |
setSupplierContact(org.eclipse.emf.common.util.URI supplierContact)
Sets a uri where to find more information about this module and where to
find some contact information to contact the supplier.
|
void |
setSupplierHomepage(org.eclipse.emf.common.util.URI hp)
Returns the
URI to the homepage describing the functionality of
the module. |
void |
setSymbolicName(String newSymbolicName)
Sets the symbolic name of this OSGi bundle.
|
void |
setTemproraries(org.eclipse.emf.common.util.URI newTemproraries)
Deprecated.
|
void |
setVersion(String newVersion)
Sets the version of this module.
|
void |
start()
Starts the conversion process.
|
void |
start(org.corpus_tools.salt.graph.Identifier sElementId)
This method is called by method
start() , if the method was not
overridden by the current class. |
String |
toString()
Returns a string representation of this object.
|
void |
uncaughtException(Thread t,
Throwable e)
Method catches Uncaught exceptions thrown by
PepperMapperImpl
while running as Thread. |
protected org.slf4j.Logger logger
protected org.corpus_tools.salt.common.SaltProject saltProject
protected org.eclipse.emf.common.util.URI resources
@Deprecated protected org.eclipse.emf.common.util.URI temproraries
protected String symbolicName
protected ModuleController moduleController
protected org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph
SCorpusGraph
object which should be processed by this module.protected boolean isMultithreaded
protected PepperModuleImpl()
PepperModule
object, which is either a
MODULE_TYPE.IMPORTER
, a MODULE_TYPE.MANIPULATOR
or a
MODULE_TYPE.EXPORTER
. The name of this module is set to
"MyModule". PepperModuleImpl(String)
and pass a proper name.protected PepperModuleImpl(String name)
PepperModule
object, which is either a
MODULE_TYPE.IMPORTER
, a MODULE_TYPE.MANIPULATOR
or a
MODULE_TYPE.EXPORTER
. The passed name is set as the modules name.public PepperModuleDesc getFingerprint()
PepperModuleDesc
object, which is a kind of a
fingerprint of this PepperModule
. This fingerprint for instance
contains information like the name, the version of this module or
information about the supplier.getFingerprint
in interface PepperModule
public String getName()
getName
in interface PepperModule
protected void setName(String name)
PepperModule
. Note, that a name can
only be set once and not be changed again.name
- name of this module.public String getVersion()
getVersion
in interface PepperModule
public void setVersion(String newVersion)
setVersion
in interface PepperModule
newVersion
- the new value of the 'Version' attribute.public MODULE_TYPE getModuleType()
getModuleType
in interface PepperModule
public String getDesc()
getDesc
in interface PepperModule
public void setDesc(String desc)
setDesc
in interface PepperModule
desc
- a short description of the task of this modulepublic org.eclipse.emf.common.util.URI getSupplierContact()
getSupplierContact
in interface PepperModule
public void setSupplierContact(org.eclipse.emf.common.util.URI supplierContact)
setSupplierContact
in interface PepperModule
public org.eclipse.emf.common.util.URI getSupplierHomepage()
PepperModule
URI
to the homepage describing the functionality of the
module.getSupplierHomepage
in interface PepperModule
URI
to the homepagepublic void setSupplierHomepage(org.eclipse.emf.common.util.URI hp)
PepperModule
URI
to the homepage describing the functionality of
the module.setSupplierHomepage
in interface PepperModule
hp
- URI
to the homepagepublic PepperModuleProperties getProperties()
PepperModuleProperties
object containing properties to
customize the behavior of this PepperModule
.getProperties
in interface PepperModule
public void setProperties(PepperModuleProperties properties)
PepperModuleProperties
object containing properties to
customize the behavior of this PepperModule
. Please make sure,
that this method is called in constructor of your module. If not, a
general PepperModuleProperties
object is created by the pepper
framework and will be initialized. This means, when calling this method
later, all properties for customizing the module will be overridden.setProperties
in interface PepperModule
public org.corpus_tools.salt.common.SaltProject getSaltProject()
SaltProject
object, which is filled, manipulated or
exported by the current module.getSaltProject
in interface PepperModule
public void setSaltProject(org.corpus_tools.salt.common.SaltProject newSaltProject)
SaltProject
object, which is filled, manipulated or
exported by the current module. Note: This method only should be called
by the pepper framework.setSaltProject
in interface PepperModule
newSaltProject
- the new value of the 'Salt Project' attribute.public org.eclipse.emf.common.util.URI getResources()
getResources
in interface PepperModule
public void setResources(org.eclipse.emf.common.util.URI newResources)
PepperModule.getResources()
. This method
should only be invoked by the Pepper framework. The documentation of
PepperModule.getResources()
for more details.setResources
in interface PepperModule
newResources
- path to resource folder@Deprecated public org.eclipse.emf.common.util.URI getTemproraries()
getTemproraries
in interface PepperModule
@Deprecated public void setTemproraries(org.eclipse.emf.common.util.URI newTemproraries)
setTemproraries
in interface PepperModule
public String getSymbolicName()
getSymbolicName
in interface PepperModule
public void setSymbolicName(String newSymbolicName)
PepperModuleImpl
class. If you want to manipulate that method.
make sure to set the symbolic name and make sure, that it is set to the
bundles symbolic name.setSymbolicName
in interface PepperModule
newSymbolicName
- the new value of the 'Symbolic Name' attribute.public org.osgi.service.component.ComponentContext getComponentContext()
ComponentContext
of the OSGi environment the bundle
was started in.getComponentContext
in interface PepperModule
protected void activate(org.osgi.service.component.ComponentContext componentContext)
ComponentContext
object for symbolic name and version and
initializes its values symbolicName
and #version
with
it. When running this class in OSGi context, you do not have to set both
values by hand. With the given architecture, the symbolic name and the
bundle version will be given by pom.xml, via MANIFEST.MF and finally read
by this method. Also sets the internal field storing the
ComponentContext
which can be retrieved via
getComponentContext()
.componentContext
- public Collection<String> getStartProblems()
PepperModule.isReadyToStart()
has returned false, this method returns a
list of reasons why this module is not ready to start.getStartProblems
in interface PepperModule
public boolean isReadyToStart() throws PepperModuleNotReadyException
PepperModuleProperties
, setting temporary files,
resources etc. . returns false or throws an exception in case of
PepperModule
instance is not ready for any reason MODULE_TYPE
is not nullPepperModule.getStartProblems()
.isReadyToStart
in interface PepperModule
PepperModule
instance is not ready for any reason,
true, else.PepperModuleNotReadyException
public ModuleController getModuleController()
ModuleController
object is a kind of communicator between a
PepperModule
and the pepper framework.getModuleController
in interface PepperModule
public void setPepperModuleController(ModuleController newModuleController)
ModuleController
object is a kind of communicator between a
PepperModule
and the pepper framework. Also calls the inverse
method ModuleController.setPepperModule_basic(PepperModule)
.
Note, this method only should be called by pepper framework.setPepperModuleController
in interface PepperModule
newModuleController
- the new value of the 'Pepper Module Controller'
container reference.public void setPepperModuleController_basic(ModuleController newModuleController)
ModuleController
object is a kind of communicator between a
PepperModule
and the pepper framework. Note, this method only
should be called by pepper framework.setPepperModuleController_basic
in interface PepperModule
newModuleController
- the new value of the 'Pepper Module Controller'
container reference.public org.corpus_tools.salt.common.SCorpusGraph getCorpusGraph()
SCorpusGraph
object which is filled, manipulated or
exported by the current module. The SCorpusGraph
object is
contained in the salt project PepperModule.getSaltProject()
.getCorpusGraph
in interface PepperModule
public void setCorpusGraph(org.corpus_tools.salt.common.SCorpusGraph newSCorpusGraph)
SCorpusGraph
object which is filled, manipulated or
exported by the current module. The SCorpusGraph
object is
contained in the salt project PepperModule.getSaltProject()
. Note: This
method only should be called by the pepper framework.setCorpusGraph
in interface PepperModule
newSCorpusGraph
- the new value of the 'SCorpus Graph' attribute.protected Map<String,PepperMapperController> getMapperControllers()
PepperMapperController
objects
which are connected with a started PepperMapper
corresponding to
theirpublic void setIsMultithreaded(boolean isMultithreaded)
PepperModule
is able to run multithreaded. This
method only should be called by the module itself.setIsMultithreaded
in interface PepperModule
public boolean isMultithreaded()
PepperModule
is able to run multithreaded.
The behavior only should be set by the module itself via calling
PepperModule.setIsMultithreaded(boolean)
.isMultithreaded
in interface PepperModule
protected ThreadGroup getMapperThreadGroup()
ThreadGroup
where PepperMapper
objects and the
corresponding threads are supposed to run in.protected void setMapperThreadGroup(ThreadGroup mapperThreadGroup)
ThreadGroup
where PepperMapper
objects and the
corresponding threads are supposed to run in.mapperThreadGroup
- protected Map<String,DocumentController> getDocumentId2DC()
Identifier
belonging to
SDocument
objects to their DocumentController
container.public void start() throws PepperModuleException
PepperModule.start(Identifier)
for each SDocument
and SCorpus
object being contained in the set SCorpusGraph
. This is done in a
multithreaded way by default. Note: When your module should not
run in multithreaded mode, call PepperModule.setIsMultithreaded(boolean)
.start
in interface PepperModule
PepperModuleException
public void done(org.corpus_tools.salt.graph.Identifier id, DOCUMENT_STATUS result)
PepperMapperController
object to
notify the PepperModule
object, that the mapping for this object
is done.done
in interface PepperModule
public void done(PepperMapperController controller)
PepperMapperController
object to
notify the PepperModule
object, that the mapping is done.done
in interface PepperModule
controller
- The object which is done with its jobpublic void start(org.corpus_tools.salt.graph.Identifier sElementId) throws PepperModuleException
start()
, if the method was not
overridden by the current class. If this is not the case, this method
will be called for every document which has to be processed.start
in interface PepperModule
sElementId
- the id value for the current document or corpus to processPepperModuleException
public PepperMapper createPepperMapper(org.corpus_tools.salt.graph.Identifier sElementId)
PepperMapper
object and returns
it. You can here do some additional initialisations. Thinks like setting
the Identifier
of the SDocument
or SCorpus
object
and the URI
resource is done by the framework (or more in detail
in method PepperModule.start()
). The parameter sElementId
, if a
PepperMapper
object should be created in case of the object to
map is either an SDocument
object or an SCorpus
object of
the mapper should be initialized differently. createPepperMapper
in interface PepperModule
sElementId
- Identifier
of the SCorpus
or SDocument
to be processed.PepperMapper
object to do the mapping task for object
connected to given Identifier
public void end() throws PepperModuleException
end
in interface PepperModule
PepperModuleException
public void uncaughtException(Thread t, Throwable e)
PepperMapperImpl
while running as Thread. This method just logs the exception. It is
assumed, that the PepperMapperImpl
itself notifies the Pepper
framework about the unsuccessful process.uncaughtException
in interface Thread.UncaughtExceptionHandler
public Double getProgress(String globalId)
SDocument
object corresponding to the
given Identifier
in percent. A valid value return must be between
0 and 1. PepperModule.start(Identifier)
or PepperModule.start()
, please also override this
method, because it accesses an internal list of all mappers, which
initialized in PepperModule.start(Identifier)
.getProgress
in interface PepperModule
public Double getProgress()
SDocument
objects being processed by this module.
A valid value return must be between 0 and 1. This method can be
overridden by a derived PepperModule
class. If this method is not
overridden, it will return null.getProgress
in interface PepperModule
public List<org.corpus_tools.salt.graph.Identifier> proposeImportOrder(org.corpus_tools.salt.common.SCorpusGraph sCorpusGraph)
SDocument
objects. Overriding this method is useful, in case
of the order matters in the specific mapping of this PepperModule
. In this case a influencing the import order can decrease the processing
time. If you do not want to influence the order, just return an empty
list, or don't override this method. SCorpusGraph
. proposeImportOrder
in interface PepperModule
sCorpusGraph
- the SCorpusGraph
object for which the order could be
proposedSDocument
objectspublic String toString()
public SelfTestDesc getSelfTestDesc()
PepperModule
SelfTestDesc
object needs to
provide an input corpus path and an output corpus path.
When this module is:
SelfTestDesc.getInputCorpusPath()
should contain
the format to be imported. SelfTestDesc.getExpectedCorpusPath()
should contain the expected salt project (for control).SelfTestDesc.getInputCorpusPath()
should
contain a salt project which is the module's input.
SelfTestDesc.getExpectedCorpusPath()
should contain the expected
salt project (for control).SelfTestDesc.getInputCorpusPath()
should contain
a salt project which is the module's input.
SelfTestDesc.getExpectedCorpusPath()
should contain the expected
corpus in output format.return new IntegrationTestDesc(inputPath, outputPath);When this module is an importer or a manipulator the method
SelfTestDesc.compare(SaltProject, SaltProject)
is called to
compare output salt project with expected salt project. When the module
is an exporter the method SelfTestDesc.compare(URI, URI)
is
called to compare the created output folder with an expected one. By
default this method checks whether the file structure and each file is
equal.getSelfTestDesc
in interface PepperModule
Copyright © 2009–2019 Humboldt-Universität zu Berlin, INRIA. All rights reserved.