public class InternalModule extends Object implements MaryModule
Any internal module extending this class will need to implement a constructor calling this class's constructor, and override
process()
in a meaningful way. Care must be taken to make sure the process()
method is thread-seafe.
Example for a subclass:
public class Postlex extends InternalModule { public Postlex() { super("Postlex", MaryDataType.PHONEMISED, MaryDataType.POSTPROCESSED); } public MaryData process(MaryData d) throws Exception { Document doc = d.getDocument(); mtuPostlex(doc); phonologicalRules(doc); MaryData result = new MaryData(outputType()); result.setDocument(doc); return result; } private void mtuPostlex(Document doc) {...} private void phonologicalRules(Document doc) {...} }
Modifier and Type | Field and Description |
---|---|
protected org.apache.log4j.Logger |
logger
The logger instance to be used by this module.
|
protected int |
state |
MODULE_OFFLINE, MODULE_RUNNING
Modifier | Constructor and Description |
---|---|
protected |
InternalModule(String name,
MaryDataType inputType,
MaryDataType outputType,
Locale locale) |
Modifier and Type | Method and Description |
---|---|
MaryDataType |
getInputType() |
Locale |
getLocale()
The locale of this module, i.e.
|
MaryDataType |
getOutputType() |
int |
getState()
Inform about the state of this module.
|
MaryDataType |
inputType()
Deprecated.
|
String |
name()
This module's name, as free text, for example "Tokeniser"
|
MaryDataType |
outputType()
Deprecated.
|
void |
powerOnSelfTest()
Perform a power-on self test by processing some example input data.
|
MaryData |
process(MaryData d)
Perform this module's processing on abstract "MaryData" input
d . |
void |
shutdown()
Allow the module to shut down cleanly.
|
void |
startup()
Allow the module to start up, performing whatever is necessary to become operational.
|
protected int state
protected org.apache.log4j.Logger logger
protected InternalModule(String name, MaryDataType inputType, MaryDataType outputType, Locale locale)
public String name()
MaryModule
name
in interface MaryModule
@Deprecated public MaryDataType inputType()
MaryModule
inputType
in interface MaryModule
public MaryDataType getInputType()
getInputType
in interface MaryModule
@Deprecated public MaryDataType outputType()
MaryModule
outputType
in interface MaryModule
public MaryDataType getOutputType()
getOutputType
in interface MaryModule
public Locale getLocale()
MaryModule
getLocale
in interface MaryModule
public int getState()
MaryModule
getState
in interface MaryModule
public void startup() throws Exception
MaryModule
startup
in interface MaryModule
Exception
- Exceptionpublic void powerOnSelfTest() throws Error
powerOnSelfTest
in interface MaryModule
Error
- if the module does not work properly.public void shutdown()
MaryModule
shutdown
in interface MaryModule
public MaryData process(MaryData d) throws Exception
d
. Subclasses need to make sure that the
process()
method is thread-safe, because in server-mode, it will be called from different threads at the same
time. A sensible way to do this seems to be not to use any global or static variables, or to use them read-only.
process
in interface MaryModule
d
- doutputType()
encapsulating the processing result.
This method just returns its input. Subclasses should override this.
Exception
- ExceptionCopyright © 2000–2016 DFKI GmbH. All rights reserved.