Class StayOpenStrategy
- java.lang.Object
-
- com.thebuzzmedia.exiftool.core.strategies.StayOpenStrategy
-
- All Implemented Interfaces:
ExecutionStrategy
,AutoCloseable
public class StayOpenStrategy extends Object implements ExecutionStrategy
Execution strategy that useexiftool
with thestay_open
feature.
-
-
Constructor Summary
Constructors Constructor Description StayOpenStrategy(Scheduler scheduler)
Create strategy.
-
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.protected void
finalize()
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
-
StayOpenStrategy
public StayOpenStrategy(Scheduler scheduler)
Create strategy. Scheduler provided in parameter will be used to clean resources (exiftool process).- Parameters:
scheduler
- Delay between automatic cleanup.
-
-
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.
-
-