Class FileProcessorManager
- java.lang.Object
-
- com.jalios.jcms.ChannelListener
-
- com.jalios.jcms.fileprocessor.processingmanagement.FileProcessorManager
-
- All Implemented Interfaces:
PluginComponent
,JPropertiesListener
,java.lang.Comparable
public class FileProcessorManager extends ChannelListener implements JPropertiesListener
FileProcessor singleton manager class
-
-
Field Summary
-
Fields inherited from class com.jalios.jcms.ChannelListener
order
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ProcessingData data)
Add ProcessingData in the queue for a futur processingvoid
addRunningDataFromScan(java.lang.String repositoryId)
Tell the manager that a scan of a repository is currently beginning and no other scan of the same repository should be done until the first has been totally processed.static FileProcessorManager
getInstance()
ProcessingData
getLastAddedProcessingData()
Retrieve the last ProcessingData instance that was added for processing (ie for which process may still be pending, in progress or completely finished).ProcessingData
getLastFinishedProcessingData()
Retrieve the last ProcessingData instance that WAS processed (ie for which process is finished).ProcessingData
getProcessingData()
Retrieve the next ProcessingData to processe, wait until one is added if none is yet available.java.util.List<ProcessingData>
getProcessingDataQueueCopy()
Retrieve a copy of the Processing queue containing the current ProcessingData being process (first, and all other ProcessingData yet to be processed.void
handleFinalize()
Called when the channel is finalizedvoid
init()
void
initAfterStoreLoad()
Called just after the store has been loaded and the channel has been initialized.static boolean
isEnabled()
Check if the File Processor is enabled.boolean
isProcessingThreadAlive()
Tell if the processing of files is alive (which is expected at all time after JCMS startup, even if FileProcessor is disabled, otherwise a complete restart is required).boolean
isProcessingThreadRunning()
Tell if the processing of files is running (Otherwise, it is stopped, or waiting).boolean
isRunnningDataFromScan(java.lang.String repositoryId)
Indicates if the processing thread currently process a set of data sent by a scan of the repository directory.void
propertiesChange(JProperties properties)
Invoked after properties have been modified in JCMS and save on disk.boolean
queueContains(Repository repository, FileActionComponent.Operation operation, java.io.File file)
Check if the queue contains a ProcessingData matching the specified parameters.-
Methods inherited from class com.jalios.jcms.ChannelListener
compareTo, equals, init, initAfterStartup, initBeforeHibernateFactoryBuild, initBeforeStoreLoad
-
-
-
-
Method Detail
-
getInstance
public static FileProcessorManager getInstance()
-
init
public void init()
-
propertiesChange
public void propertiesChange(JProperties properties)
Description copied from interface:JPropertiesListener
Invoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getProperties
orchannel.getProperty
.- Specified by:
propertiesChange
in interfaceJPropertiesListener
- Parameters:
properties
- the properties which have been submitted to change
-
initAfterStoreLoad
public void initAfterStoreLoad() throws java.lang.Exception
Description copied from class:ChannelListener
Called just after the store has been loaded and the channel has been initialized. If for any reason you want to interrupt JCMS startup, you can throw an exception. The exception's message will be displayed in JCMS status page (to any user!).- Overrides:
initAfterStoreLoad
in classChannelListener
- Throws:
java.lang.Exception
- any exception you may want to throw if a problem occurs needing to interrupt JCMS startup.
-
handleFinalize
public void handleFinalize()
Description copied from class:ChannelListener
Called when the channel is finalized- Overrides:
handleFinalize
in classChannelListener
-
isEnabled
public static boolean isEnabled()
Check if the File Processor is enabled.- Returns:
- true if enabled false otherwise
- Since:
- JCMS-5197
-
isProcessingThreadRunning
public boolean isProcessingThreadRunning()
Tell if the processing of files is running (Otherwise, it is stopped, or waiting).- Returns:
- true if the processing is currently running
-
isProcessingThreadAlive
public boolean isProcessingThreadAlive()
Tell if the processing of files is alive (which is expected at all time after JCMS startup, even if FileProcessor is disabled, otherwise a complete restart is required).- Returns:
- true if the processing is currently not stopped
-
isRunnningDataFromScan
public boolean isRunnningDataFromScan(java.lang.String repositoryId)
Indicates if the processing thread currently process a set of data sent by a scan of the repository directory.- Parameters:
repositoryId
- The id of the given repository- Returns:
- true if a scan of the given repository is already pending or running
-
addRunningDataFromScan
public void addRunningDataFromScan(java.lang.String repositoryId)
Tell the manager that a scan of a repository is currently beginning and no other scan of the same repository should be done until the first has been totally processed.- Parameters:
repositoryId
- the id of the given repository
-
getLastFinishedProcessingData
public ProcessingData getLastFinishedProcessingData()
Retrieve the last ProcessingData instance that WAS processed (ie for which process is finished).- Returns:
- a ProcessingData instance or null if no processing has yet occured.
-
getLastAddedProcessingData
public ProcessingData getLastAddedProcessingData()
Retrieve the last ProcessingData instance that was added for processing (ie for which process may still be pending, in progress or completely finished).- Returns:
- a ProcessingData instance or null if no processing request was ever requestd.
-
add
public void add(ProcessingData data)
Add ProcessingData in the queue for a futur processing- Parameters:
data
- the ProcessingData to be processed
-
getProcessingData
public ProcessingData getProcessingData() throws java.lang.InterruptedException
Retrieve the next ProcessingData to processe, wait until one is added if none is yet available.- Returns:
- the ProcessingData, never return null.
- Throws:
java.lang.InterruptedException
-
getProcessingDataQueueCopy
public java.util.List<ProcessingData> getProcessingDataQueueCopy()
Retrieve a copy of the Processing queue containing the current ProcessingData being process (first, and all other ProcessingData yet to be processed.- Returns:
- a unmodifiable list of ProcessingData, never return null
-
queueContains
public boolean queueContains(Repository repository, FileActionComponent.Operation operation, java.io.File file)
Check if the queue contains a ProcessingData matching the specified parameters.- Parameters:
repository
- a repository that must be matched by the ProcessingData to look for, may be null if at least one of the other parameters is not nulloperation
- an Operation that must be matched by the ProcessingData to look for, may be null if at least one of the other parameters is not nullfile
- a File that must be found in the file set of the ProcessingData to look for, may be null if at least one of the other parameters is not null- Returns:
- true if a match was found, false otherwise
- Throws:
java.lang.IllegalArgumentException
- if no valid parameters were specified- Since:
- jcms-9.0.2 DEVJCMS-1490
-
-