public class PoolStrategy extends java.lang.Object implements ExecutionStrategy
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 and Description |
---|
PoolStrategy(java.util.Collection<ExecutionStrategy> strategies)
Create the pool.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
This method should be used to:
Close remaining process (if any).
Clean previous executions.
For instance, with the
stay_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 to ExecutionStrategy.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,
java.lang.String exifTool,
java.util.List<java.lang.String> arguments,
OutputHandler handler)
Execute exiftool command.
|
boolean |
isRunning()
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.
|
public PoolStrategy(java.util.Collection<ExecutionStrategy> strategies)
strategies
- Internal strategies.java.lang.NullPointerException
- If strategies
is null
.java.lang.IllegalArgumentException
- If strategies
is empty.public void execute(CommandExecutor executor, java.lang.String exifTool, java.util.List<java.lang.String> arguments, OutputHandler handler) throws java.io.IOException
ExecutionStrategy
execute
in interface ExecutionStrategy
executor
- ExifTool withExecutor.exifTool
- ExifTool withPath.arguments
- Command line arguments.handler
- Handler to read command output.java.io.IOException
- If an error occurred during execution.public boolean isRunning()
ExecutionStrategy
stay_open
flag has been enabled.isRunning
in interface ExecutionStrategy
true
if exiftool
process is currently open, false
otherwise.public boolean isSupported(Version version)
ExecutionStrategy
isSupported
in interface ExecutionStrategy
version
- ExifTool Version.true
if this strategy may be used safely with this specific version, false
otherwise.public void close() throws java.lang.Exception
ExecutionStrategy
stay_open
flag, this method should:
ExecutionStrategy.execute(com.thebuzzmedia.exiftool.process.CommandExecutor, java.lang.String, java.util.List<java.lang.String>, com.thebuzzmedia.exiftool.process.OutputHandler)
is made.close
in interface ExecutionStrategy
close
in interface java.lang.AutoCloseable
java.lang.Exception
- If an error occurred while stopping exiftool client.public void shutdown() throws java.lang.Exception
ExecutionStrategy
shutdown
in interface ExecutionStrategy
java.lang.Exception
- If an error occurred while stopping exiftool client.Copyright © 2019. All Rights Reserved.