Class PoolStrategy
- java.lang.Object
-
- com.thebuzzmedia.exiftool.core.strategies.PoolStrategy
-
- All Implemented Interfaces:
ExecutionStrategy
,AutoCloseable
public class PoolStrategy extends Object implements ExecutionStrategy
Implementation ofExecutionStrategy
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 Constructor Description PoolStrategy(Collection<ExecutionStrategy> strategies)
Create the pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
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.
-
-
-
Constructor Detail
-
PoolStrategy
public PoolStrategy(Collection<ExecutionStrategy> strategies)
Create the pool.- Parameters:
strategies
- Internal strategies.- Throws:
NullPointerException
- Ifstrategies
isnull
.IllegalArgumentException
- Ifstrategies
is empty.
-
-
Method Detail
-
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
public boolean isSupported(Version version)
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
public void close() throws Exception
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
public void shutdown() throws Exception
Description copied from interface:ExecutionStrategy
Shutdown the strategy.- Specified by:
shutdown
in interfaceExecutionStrategy
- Throws:
Exception
- If an error occurred while stopping exiftool client.
-
-