|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ca.bc.webarts.tools.AutoUpdateApp
This is a self standing Java application that acts as a middleware application executor. A static method is also available to access the functionality from within existing code.
It executes applications... both native or Java as specified in a Properties file that gets passed to it (via a filename on the commandline). All system output from the executed app is echoed to the System.out (both regular and error output).
Its main purpose is to provide a single entrypoint to execute applications that can be dynamically specified at runtime. This allows a single deployment of this class onto a client and then tell this class what to run.
Features:
Usage:java AutoUpdateApp
<
propertiesFilename
> OR
java -jar AutoUpdateApp.jar
<propertiesFilename
>
The properties file describes the app to execute. It has both required and optional entries as follows:
An Example Properties file might look like:
# NATIVE Remote Application Description property file appType=0 remoteAppURL=file:/c:/progra~1/tn.bat #remoteAppURL=c:\\progra~1\\tn.bat remoteAppDownloadURL= remoteAppAutoDownload=false telnetHost=10.0.0.22 2020
OR
# Java Remote Application Description property file appType=1 remoteAppURL=SimpleExample remoteAppDownloadURL=http://somesite.com/updates/MySimpleExample.jar remoteAppAutoDownload=false remoteAppJvmParameters=-Xmx64m extraParm=myParm1 anotherExtraParm=myParm2OR
# Java Remote Application Description property file appType=1 remoteAppURL=TelnetApp.jar remoteAppDownloadURL=http://somesite.com/updates/TelnetApp.jar remoteAppAutoDownload=true remoteAppJvmClasspath=/usr/local/extraclasses.jar;/usr/moreextraclasses.jar telnetHost=10.0.0.22 2020
Field Summary | |
static java.lang.String |
APPLET_APP
Class Constant specifying that the app to run is a Java Applet |
protected static java.lang.String |
appName_
If you extend this app to change its name;CHANGE THIS AS WELL. |
protected static java.lang.String |
appPropertyFilename_
|
protected static java.lang.String |
appType_
Remote Launch Parm specifying the remote lauch app type.(required) |
protected static boolean |
archiveDownload_
A class var to indicate if the download URL is pointing to an archive file (ie. |
protected static java.lang.String |
archiveFilePath_
The system dependant file path for the downloaded archive file. |
(package private) static java.lang.String |
CLASSPATH
this VM classpath |
protected static java.util.Vector |
cmdLineParms_
A table of strings holding any extra parameter properties that were passed in the properties file. |
protected static boolean |
debug_
|
protected static java.lang.String |
DEFAULT_SAVE_LOCATION
A holder for the directory location to save downloaded apps. |
protected static java.util.Vector |
definedPropertyKeys
A helper Vector that keeps a table of the Defined Properties. |
protected static java.lang.String |
errorMsg_
A class var to record and error message to print out if any of the validation checks on the properties fail. |
protected static java.lang.String |
filePath_
The system dependant file path to execute. |
static java.lang.String |
HTTPURL_APP
Class Constant specifying that the app to run is a URL Locationto view using the native webbrowser. |
static java.lang.String |
JAVA_APP
Class Constant specifying that the app to run is a Java application |
protected static java.lang.String |
jvmClasspath_
Remote Launch Parm specifying the any extra classpath parms to put at the front of the classpath when the calling the jvm. |
protected static java.lang.String |
jvmParameters_
Remote Launch Parm specifying the any extra commandline parms to send directly to the jvm. |
static java.lang.String |
NATIVE_APP
Class Constant specifying that the app to run is a native application |
protected static boolean |
remoteAppAutoDownload_
Remote Launch Parm specifying the flag (boolean string val) that specifies if the RemoteLaunchOperation Operation should query the download server for updated app files. |
protected static java.net.URL |
remoteAppDownloadURL_
Remote Launch Parm specifying the URL of the download for the Remote Launch APP. |
protected static java.net.URL |
remoteAppURL_
Remote Launch Parm specifying the remote lauched application in the form of a URL. |
static java.lang.String |
RMT_APP_AUTODOWNLOAD
Remote Launch Property Key specifying the flag (boolean string value) that specifies if the RemoteLaunchOperation Operation should query the download server for updated app files. |
static java.lang.String |
RMT_APP_DOWNLOADURL
Remote Launch Property Key specifying the URL of the download for the Remote Launch APP. |
static java.lang.String |
RMT_APP_JVM_CLASSPATH
Remote Launch Property Key specifying any parameters that should be added to the FRONT of the classpath when executing a Java App. |
static java.lang.String |
RMT_APP_JVM_PARAMETERS
Remote Launch Property Key specifying any parameters that should go to the JVM when executing a Java App. |
static java.lang.String |
RMT_APP_TYPE
Remote Launch Property Key specifying the remote lauch app type. |
static java.lang.String |
RMT_APP_URL
Remote Launch Property Key specifying the remote lauch URL for the RemoteLaunchOperation.HTTPURL_APP app type. |
protected static boolean |
soFarSoGood_
A class var to track the progress of the various validation checks that are performed. |
protected static java.lang.String |
SYSTEM_FILE_SEPERATOR
A holder for the NA Clients System File Separator. |
Constructor Summary | |
protected |
AutoUpdateApp()
Basic constructor for the application. |
Method Summary | |
protected static boolean |
checkAndUpdateApp(java.net.URL urlToGet)
Checks the specified remoteAppDownloadURL_ to see if there is a newer version of the remoteAppURL_ AND then goes out and updates the app if a newer one is available. |
protected static boolean |
checkForUpdatedApp()
Checks the specified remoteAppDownloadURL_ to see if there is a newer version of the remoteAppURL_. |
protected static java.lang.String |
convertSystemDependantPath(java.net.URL url)
Converts the path component of a URL to the native relative file path. |
protected static void |
dumpOut(java.lang.String s)
Helper method to dump a string to System.out masked by debug_. |
protected static boolean |
ensureTheAppIsAvailable(java.lang.String filePath)
This helper method checks that the specified file exists, if not it downloads it from the download URL. |
protected static int |
execute()
Determines the app type that has been assigned to the class variables and calls the correct helper method that Executes the class defined remote app. |
protected static int |
executeJavaApp(java.lang.String classLocation,
java.util.Vector appParms)
Executes the Specified Java appilcation with the provided commandline parameters. |
protected static int |
executeJavaApp(java.lang.String classLocation,
java.util.Vector jvmParms,
java.util.Vector appParms)
Executes the Specified Java appilcation with the provided JVM parameters and executableApp commandline parameters. |
protected static int |
executeNativeApp(java.lang.String executableLocation,
java.util.Vector appParms)
Executes the Specified Native OS application with the provided commandline parameters. |
protected static java.lang.String |
getFilePathFromClasspath(java.lang.String filename)
Searches the classpath for the specified filename and then returns the full path that is used for it. |
protected static boolean |
initialize(java.util.Properties props)
Initializes the apps vars (based on the passed in properties file) and gets ready to start. |
protected static java.util.Properties |
loadAutoAppPropertiesFile()
Loads the AutoDownload app information from the properties file so this wrapped app can execute. |
protected static java.util.Properties |
loadPropertiesFile(java.lang.String propFilename)
Loads the passed Properties file and returns a Properties object. |
static void |
main(java.lang.String[] args)
The main entry for this app. |
protected static java.net.URL |
parseAppExecutableUrl(java.lang.String value)
Parses a String representation of a URL or absolute file path and converts it into a URL. |
protected static boolean |
parseProperties(java.util.Properties props)
Parses the passed in Properties and pulls out all the name/value pairs and assigns them to the class vars as needed. |
static int |
runApp(java.util.Properties props)
The entry point for running an app defined by the passed in properties. |
protected static boolean |
updateAppFromServer(java.net.URL urlToGet)
Downloads the requested URL and replaces any existing version. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static java.lang.String appName_
protected static java.lang.String appPropertyFilename_
protected static boolean debug_
static final java.lang.String CLASSPATH
public static final java.lang.String NATIVE_APP
public static final java.lang.String JAVA_APP
public static final java.lang.String APPLET_APP
public static final java.lang.String HTTPURL_APP
public static final java.lang.String RMT_APP_TYPE
This is a required property in the supplied properties file.
public static final java.lang.String RMT_APP_URL
This is a required property in the supplied properties file.
public static final java.lang.String RMT_APP_DOWNLOADURL
This is an optional property in the supplied properties file. (default=http://localhost:80/tl1gw)
public static final java.lang.String RMT_APP_AUTODOWNLOAD
This is an optional property in the supplied properties file. (default=true)
public static final java.lang.String RMT_APP_JVM_PARAMETERS
This is an optional property in the supplied properties file. (default="")
public static final java.lang.String RMT_APP_JVM_CLASSPATH
This is an optional property in the supplied properties file. (default="")
A StringTokenizer is used to parse this property value and usessemi colons or colons as delimiters. Note that spaces are NOT used as delimeters so they can be used in the paths.
protected static java.util.Vector definedPropertyKeys
protected static final java.lang.String SYSTEM_FILE_SEPERATOR
protected static final java.lang.String DEFAULT_SAVE_LOCATION
Default = ./RemoteApps/
(or the DOS Equiv.
.\RemoteApps\
).
protected static java.lang.String appType_
protected static java.net.URL remoteAppURL_
It gets assigned from the required property RMT_APP_URL in the supplied properties file.
protected static java.lang.String filePath_
protected static java.lang.String archiveFilePath_
protected static java.net.URL remoteAppDownloadURL_
(default=http://TL1GWServerHost:80/tl1gw)
protected static boolean remoteAppAutoDownload_
(default=true)
protected static java.lang.String jvmParameters_
(default="")
protected static java.lang.String jvmClasspath_
(default="")
A StringTokenizer is used to parse this property value. So commas or a space delimited list of entries will work.
protected static boolean soFarSoGood_
protected static boolean archiveDownload_
This field gets used by the updateAppFromServer method to determine where to save the file.
updateAppFromServer(java.net.URL)
protected static java.lang.String errorMsg_
protected static java.util.Vector cmdLineParms_
Constructor Detail |
protected AutoUpdateApp()
main(java.lang.String[])
,
runApp(java.util.Properties)
Method Detail |
public static int runApp(java.util.Properties props)
This method blocks until the Executed app is complete
props
- the Properties defining the app to run as defined in the main
class description.main(java.lang.String[])
public static void main(java.lang.String[] args)
args
- are the commandline parameters.This app expects ONLY 1
parameter... the absolute file path to the properties file
containing all the info for the Remote App to execute.runApp(java.util.Properties)
protected static boolean initialize(java.util.Properties props)
protected static boolean ensureTheAppIsAvailable(java.lang.String filePath)
protected static java.lang.String getFilePathFromClasspath(java.lang.String filename)
protected static java.lang.String convertSystemDependantPath(java.net.URL url)
the
- url to use to convert.protected static int execute()
protected static java.net.URL parseAppExecutableUrl(java.lang.String value) throws java.net.MalformedURLException
This method is a bit forgiving... if the string is not a correctlty formatted http, ftp, or file URL it will assume it is a file URL and create the returned URL as such.
value
- is the String to convert into a URL.java.net.MalformedURLException
- if the passed in String is not a URLprotected static boolean checkAndUpdateApp(java.net.URL urlToGet)
urlToGet
- is the place to go to get the updated app.executableLocation
- the local place where the new updated app will
go.remoteAppDownloadURL_
,
remoteAppURL_
protected static boolean checkForUpdatedApp()
checkAndUpdateApp
,
remoteAppDownloadURL_
,
remoteAppURL_
protected static boolean updateAppFromServer(java.net.URL urlToGet)
The place for saving this downloaded file is determined based on the archiveDownload_ flag. If archiveDownload_is true then dowloaded file is saved as a new /updated file with its own filename. This is done when an archive file is used as the download that is not the same as the executable name found in the remoteAppURL_ field. For example: if remoteAppURL_ points to com.acterna.SomeClass and the remoteAppDownloadURL_ points to SomeClass.jar we need to save the downloaded file to SomeClass.jar and then assume the commandline parameters will take care of the running/classpath issues.
urlToGet
- is the place to go to get the updated app.executableLocation
- the local place where the new updated app will
go.archiveDownload_
protected static int executeNativeApp(java.lang.String executableLocation, java.util.Vector appParms)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the end of the
commandline that gets executed.StreamGobbler
,
Runtime.getRuntime()
protected static int executeJavaApp(java.lang.String classLocation, java.util.Vector appParms)
executableLocation
- is the path to the executable to runappParms
- and extra commandline parameters to tag onto the end of the
commandline that gets executed.protected static int executeJavaApp(java.lang.String classLocation, java.util.Vector jvmParms, java.util.Vector appParms)
executableLocation
- is the path to the executable to runjvmParms
- holds any cmdline parms to send directly to the jvmappParms
- and extra commandline parameters to tag onto the end of the
commandline that gets executed.protected static boolean parseProperties(java.util.Properties props)
props
- the Properties to parseprotected static void dumpOut(java.lang.String s)
protected static java.util.Properties loadAutoAppPropertiesFile()
protected static java.util.Properties loadPropertiesFile(java.lang.String propFilename)
propFilename
- the filename for the Properties file to parse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |