Class PoolStrategy
java.lang.Object
com.thebuzzmedia.exiftool.core.strategies.PoolStrategy
- All Implemented Interfaces:
ExecutionStrategy
,AutoCloseable
Implementation of
ExecutionStrategy
using a pool of
strategies.
Each time {execute(CommandExecutor, String, List, OutputHandler)
method
is called, an internal strategy from the pool is picked and return to the pool once work
is finished.
This strategy should be used in a multithreaded environment, when application need to
extract exif data from images in parallel.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This method should be used to: Close remaining process (if any). Clean previous executions. For instance, with thestay_open
flag, this method should: Close opened process. Stop task used to automatically close process. Once closed, ExifTool should still be able to use this strategy if a call toExecutionStrategy.execute(com.thebuzzmedia.exiftool.process.CommandExecutor, java.lang.String, java.util.List<java.lang.String>, com.thebuzzmedia.exiftool.process.OutputHandler)
is made.void
execute
(CommandExecutor executor, String exifTool, List<String> arguments, OutputHandler handler) Execute exiftool command.boolean
Check if exiftool process is currently running.boolean
isSupported
(Version version) Check if this strategy should is supported with this specific version.void
shutdown()
Shutdown the strategy.
-
Constructor Details
-
PoolStrategy
Create the pool.- Parameters:
strategies
- Internal strategies.- Throws:
NullPointerException
- Ifstrategies
isnull
.IllegalArgumentException
- Ifstrategies
is empty.
-
-
Method Details
-
execute
public void execute(CommandExecutor executor, String exifTool, List<String> arguments, OutputHandler handler) throws IOException Description copied from interface:ExecutionStrategy
Execute exiftool command.- Specified by:
execute
in interfaceExecutionStrategy
- Parameters:
executor
- ExifTool withExecutor.exifTool
- ExifTool withPath.arguments
- Command line arguments.handler
- Handler to read command output.- Throws:
IOException
- If an error occurred during execution.
-
isRunning
public boolean isRunning()Description copied from interface:ExecutionStrategy
Check if exiftool process is currently running. This method is important especially ifstay_open
flag has been enabled.- Specified by:
isRunning
in interfaceExecutionStrategy
- Returns:
true
ifexiftool
process is currently open,false
otherwise.
-
isSupported
Description copied from interface:ExecutionStrategy
Check if this strategy should is supported with this specific version.- Specified by:
isSupported
in interfaceExecutionStrategy
- Parameters:
version
- ExifTool Version.- Returns:
true
if this strategy may be used safely with this specific version,false
otherwise.
-
close
Description copied from interface:ExecutionStrategy
This method should be used to:- Close remaining process (if any).
- Clean previous executions.
stay_open
flag, this method should:- Close opened process.
- Stop task used to automatically close process.
ExecutionStrategy.execute(com.thebuzzmedia.exiftool.process.CommandExecutor, java.lang.String, java.util.List<java.lang.String>, com.thebuzzmedia.exiftool.process.OutputHandler)
is made.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceExecutionStrategy
- Throws:
Exception
- If an error occurred while stopping exiftool client.
-
shutdown
Description copied from interface:ExecutionStrategy
Shutdown the strategy.- Specified by:
shutdown
in interfaceExecutionStrategy
- Throws:
Exception
- If an error occurred while stopping exiftool client.
-