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 - dev@tchemit.fr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultChainedWriterEngine.ModelFileWriterEntryType
-
Field Summary
Fields Modifier and Type Field Description protected Set<ChainedFileWriter>availableWritersavailable writers corresponding to the given configurationprotected ChainedFileWriterConfigurationconfigurationshared configurationprotected List<ChainedFileWriter>selectedWritersselected 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 voidcheckInit(String method)voidclear()clean all internal statesbooleancontainsWriter(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 givenuniverseof writers which accept the givenmodelType.Set<ChainedFileWriter>getAvailableWriters()ChainedFileWriterConfigurationgetConfiguration()ChainedFileWriterDatagetData(ChainedFileWriter writer)Obtain the universe of files to react by the givenwriterassociated with each (distinct).List<ChainedFileWriter>getSelectedWriters()ChainedFileWritergetWriterForInclude(Set<ChainedFileWriter> universe, String include, String modelType)Filter the givenuniverseof writers which accept the givenmodelTypeandinclude.ChainedFileWritergetWriterForInputProtocol(Set<ChainedFileWriter> universe, String inputProtocol, String modelType)Filter the givenuniverseof writers which accept the givenmodelTypeandinputProtocol.protected voidgrabFiles(File extractDirectory, FileGrabber grabber, Map<String,Set<String>> entries, ChainedFileWriterData result)voidinit(ChainedFileWriterConfiguration configuration)voidregisterInclude(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:
getSelectedWritersin interfaceChainedWriterEngine- Returns:
- the list of selected writers after having registred some inputs.
-
containsWriter
public boolean containsWriter(String inputProtocol)
Description copied from interface:ChainedWriterEngineTests if there is a selected writer using the given input protocol.- Specified by:
containsWriterin interfaceChainedWriterEngine- Parameters:
inputProtocol- the inputProtocol to test- Returns:
trueif there is a selected writer using this input protocol- See Also:
ChainedFileWriter.getInputProtocol(),ChainedWriterEngine.getSelectedWriters()
-
getAvailableWriters
public Set<ChainedFileWriter> getAvailableWriters()
- Specified by:
getAvailableWritersin interfaceChainedWriterEngine- Returns:
- the set of all available writers discovered at runtime
-
registerInclude
public void registerInclude(String include)
Description copied from interface:ChainedWriterEngineRegister in engine a new input source. this method will detects writers to register and chain them if necessary.- Specified by:
registerIncludein interfaceChainedWriterEngine- Parameters:
include- the new include to digest
-
clear
public void clear()
Description copied from interface:ChainedWriterEngineclean all internal states- Specified by:
clearin interfaceChainedWriterEngine
-
init
public void init(ChainedFileWriterConfiguration configuration)
- Specified by:
initin interfaceChainedWriterEngine
-
filterWriterForModelType
public Set<ChainedFileWriter> filterWriterForModelType(Map<String,ChainedFileWriter> universe, String modelType)
Description copied from interface:ChainedWriterEngineFilter the givenuniverseof writers which accept the givenmodelType.- Specified by:
filterWriterForModelTypein 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:ChainedWriterEngineFilter the givenuniverseof writers which accept the givenmodelTypeandinputProtocol.- Specified by:
getWriterForInputProtocolin 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:ChainedWriterEngineFilter the givenuniverseof writers which accept the givenmodelTypeandinclude. The include can have several forms :- Specified by:
getWriterForIncludein 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:ChainedWriterEngineObtain the universe of files to react by the givenwriterassociated 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:
getDatain 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
-
-