Package org.nuiton.eugene.writer
Class DefaultChainedWriterEngine
- java.lang.Object
-
- org.nuiton.eugene.writer.DefaultChainedWriterEngine
-
- All Implemented Interfaces:
ChainedWriterEngine
@Component(role=ChainedWriterEngine.class, hint="default") public class DefaultChainedWriterEngine extends Object implements ChainedWriterEngine
Default implementation of theChainedWriterEngine
. Created: 17 déc. 2009- Since:
- 2.0.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultChainedWriterEngine.ModelFileWriterEntryType
-
Field Summary
Fields Modifier and Type Field Description protected Set<ChainedFileWriter>
availableWriters
available writers corresponding to the given configurationprotected ChainedFileWriterConfiguration
configuration
shared configurationprotected List<ChainedFileWriter>
selectedWriters
selected writers obtain while the register phase.
-
Constructor Summary
Constructors Constructor Description DefaultChainedWriterEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkInit(String method)
void
clear()
clean all internal statesboolean
containsWriter(String inputProtocol)
Tests if there is a selected writer using the given input protocol.Set<ChainedFileWriter>
filterWriterForModelType(Map<String,ChainedFileWriter> universe, String modelType)
Filter the givenuniverse
of writers which accept the givenmodelType
.Set<ChainedFileWriter>
getAvailableWriters()
ChainedFileWriterConfiguration
getConfiguration()
ChainedFileWriterData
getData(ChainedFileWriter writer)
Obtain the universe of files to react by the givenwriter
associated with each (distinct).List<ChainedFileWriter>
getSelectedWriters()
ChainedFileWriter
getWriterForInclude(Set<ChainedFileWriter> universe, String include, String modelType)
Filter the givenuniverse
of writers which accept the givenmodelType
andinclude
.ChainedFileWriter
getWriterForInputProtocol(Set<ChainedFileWriter> universe, String inputProtocol, String modelType)
Filter the givenuniverse
of writers which accept the givenmodelType
andinputProtocol
.protected void
grabFiles(File extractDirectory, FileGrabber grabber, Map<String,Set<String>> entries, ChainedFileWriterData result)
void
init(ChainedFileWriterConfiguration configuration)
void
registerInclude(String include)
Register in engine a new input source.
-
-
-
Field Detail
-
configuration
protected ChainedFileWriterConfiguration configuration
shared configuration
-
availableWriters
protected Set<ChainedFileWriter> availableWriters
available writers corresponding to the given configuration
-
selectedWriters
protected List<ChainedFileWriter> selectedWriters
selected writers obtain while the register phase.
-
-
Method Detail
-
getConfiguration
public ChainedFileWriterConfiguration getConfiguration()
-
getSelectedWriters
public List<ChainedFileWriter> getSelectedWriters()
- Specified by:
getSelectedWriters
in interfaceChainedWriterEngine
- Returns:
- the list of selected writers after having registred some inputs.
-
containsWriter
public boolean containsWriter(String inputProtocol)
Description copied from interface:ChainedWriterEngine
Tests if there is a selected writer using the given input protocol.- Specified by:
containsWriter
in interfaceChainedWriterEngine
- Parameters:
inputProtocol
- the inputProtocol to test- Returns:
true
if there is a selected writer using this input protocol- See Also:
ChainedFileWriter.getInputProtocol()
,ChainedWriterEngine.getSelectedWriters()
-
getAvailableWriters
public Set<ChainedFileWriter> getAvailableWriters()
- Specified by:
getAvailableWriters
in interfaceChainedWriterEngine
- Returns:
- the set of all available writers discovered at runtime
-
registerInclude
public void registerInclude(String include)
Description copied from interface:ChainedWriterEngine
Register in engine a new input source. this method will detects writers to register and chain them if necessary.- Specified by:
registerInclude
in interfaceChainedWriterEngine
- Parameters:
include
- the new include to digest
-
clear
public void clear()
Description copied from interface:ChainedWriterEngine
clean all internal states- Specified by:
clear
in interfaceChainedWriterEngine
-
init
public void init(ChainedFileWriterConfiguration configuration)
- Specified by:
init
in interfaceChainedWriterEngine
-
filterWriterForModelType
public Set<ChainedFileWriter> filterWriterForModelType(Map<String,ChainedFileWriter> universe, String modelType)
Description copied from interface:ChainedWriterEngine
Filter the givenuniverse
of writers which accept the givenmodelType
.- Specified by:
filterWriterForModelType
in interfaceChainedWriterEngine
- Parameters:
universe
- the list of writers to filtermodelType
- the accepted model type- Returns:
- the set of filtered writers
- See Also:
ChainedFileWriter.acceptModel(String)
-
getWriterForInputProtocol
public ChainedFileWriter getWriterForInputProtocol(Set<ChainedFileWriter> universe, String inputProtocol, String modelType)
Description copied from interface:ChainedWriterEngine
Filter the givenuniverse
of writers which accept the givenmodelType
andinputProtocol
.- Specified by:
getWriterForInputProtocol
in interfaceChainedWriterEngine
- Parameters:
universe
- the list of writers to filterinputProtocol
- the accepted input protocolmodelType
- the accepted model type- Returns:
- the set of filtered writers
- See Also:
ChainedFileWriter.acceptModel(String)
,ChainedFileWriter.getInputProtocol()
,ChainedFileWriter.getInputProtocol(String)
-
getWriterForInclude
public ChainedFileWriter getWriterForInclude(Set<ChainedFileWriter> universe, String include, String modelType)
Description copied from interface:ChainedWriterEngine
Filter the givenuniverse
of writers which accept the givenmodelType
andinclude
. The include can have several forms :- Specified by:
getWriterForInclude
in interfaceChainedWriterEngine
- Parameters:
universe
- the list of writers to filterinclude
- the include configurationmodelType
- the accepted model type- Returns:
- the set of filtered writers
- See Also:
ChainedFileWriter.acceptModel(String)
,ChainedFileWriter.getInputProtocol()
,ChainedFileWriter.getInputProtocol(String)
-
getData
public ChainedFileWriterData getData(ChainedFileWriter writer) throws IOException
Description copied from interface:ChainedWriterEngine
Obtain the universe of files to react by the givenwriter
associated with each (distinct). Note: If some files are in class-path (using the classpath: prefix) then they will be extracted to theChainedFileWriterConfiguration.getExtractDirectory()
.- Specified by:
getData
in interfaceChainedWriterEngine
- Parameters:
writer
- the writer to inspect- Returns:
- the universe of files to react for the given writer
- Throws:
IOException
- for any IO pb
-
grabFiles
protected void grabFiles(File extractDirectory, FileGrabber grabber, Map<String,Set<String>> entries, ChainedFileWriterData result) throws IOException
- Throws:
IOException
-
checkInit
protected void checkInit(String method) throws IllegalStateException
- Throws:
IllegalStateException
-
-