Package org.marketcetera.strategy
Class StrategyServiceImpl.RunningStrategy
- java.lang.Object
-
- org.marketcetera.strategy.StrategyServiceImpl.RunningStrategy
-
- Enclosing class:
- StrategyServiceImpl
private class StrategyServiceImpl.RunningStrategy extends Object
Tracks a running strategy instance.- Since:
- $Release$
- Version:
- $Id$
- Author:
- Colin DuPlantis
-
-
Field Summary
Fields Modifier and Type Field Description private FilejarFileJAR file that contains the strategy to runprivate URLClassLoadernewClassloaderclass loader used for the strategyprivate org.springframework.context.annotation.AnnotationConfigApplicationContextnewContextnew application context used for the strategyprivate StrategyInstancestrategyInstancestrategy instance associated with the running strategy
-
Constructor Summary
Constructors Modifier Constructor Description privateRunningStrategy(StrategyInstance inStrategyInstance, File inStrategyJar)Create a new RunningStrategy instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringgetMainClassName(File inJarFile)Determines the main class name from the given JAR.private voidstart()Start the strategy.private voidstop()Stop the running strategy.
-
-
-
Field Detail
-
jarFile
private final File jarFile
JAR file that contains the strategy to run
-
strategyInstance
private final StrategyInstance strategyInstance
strategy instance associated with the running strategy
-
newClassloader
private URLClassLoader newClassloader
class loader used for the strategy
-
newContext
private org.springframework.context.annotation.AnnotationConfigApplicationContext newContext
new application context used for the strategy
-
-
Constructor Detail
-
RunningStrategy
private RunningStrategy(StrategyInstance inStrategyInstance, File inStrategyJar)
Create a new RunningStrategy instance.- Parameters:
inStrategyInstance- aStrategyInstancevalueinStrategyJar- aFilevalue
-
-
Method Detail
-
start
private void start() throws ThrowableStart the strategy.- Throws:
Throwable- if an error occurs loading or starting the strategy.
-
stop
private void stop()
Stop the running strategy.
-
getMainClassName
private String getMainClassName(File inJarFile) throws FileNotFoundException, IOException
Determines the main class name from the given JAR.The current implementation optimistically assumes the given File is a JAR and contains a
Main-Classattribute.- Parameters:
inJarFile- aFilevalue- Returns:
- a
Stringvalue ornullif the appropriate attribute cannot be extracted from the given file - Throws:
FileNotFoundException- if the file does not existIOException- if the file could otherwise not be read
-
-