jmrun
Class JMRun

java.lang.Object
  |
  +--jmrun.JMRun

public class JMRun
extends java.lang.Object

Provides:

There is a jmrun.dll file that must be activated within your system. There are several ways to do it: You can use method settleDllDestination for automation of this process


Method Summary
static void execParam(java.lang.String cmdLine)
          Runs command in "cmdLine"
static boolean execWait(java.lang.String cmdLine, java.lang.String syncPath, boolean autoFileNameFlag, long waitTime, long sleepTime)
          Runs application from "cmdLine" with file synchronization. execWait creates synchronization file, starts "cmdLine" command and waits till termination of this command, which is syncronized by means of existence of syncronization file.
static boolean execWaitPref(java.lang.String cmdLine, java.lang.String syncKey, boolean autoKeyNameSuffixFlag, long waitTime, long sleepTime)
          Runs application from "cmdLine" with Java Preferences synchronization. execWaitPref sets synchronization preference flag, starts "cmdLine" command and waits till termination of this command, which is syncronized by means of existence of syncronization preference flag.
static boolean isSetPrefStr(java.lang.String key)
          Checks if preferences key value is set to "1" returns true, else returns false
static void main(java.lang.String[] args)
          This is a dual-purpose method: 1.
static void resetPrefFlag(java.lang.String key)
          Removes preferences key
static void setPrefFlag(java.lang.String key)
          Sets preferences key value to "1"
static boolean settleDllDestination(java.lang.String sourcePath, java.lang.String destPath, java.lang.String destPathSuffix, java.lang.String dllFileName)
          Checks for availability of the dllFileName in destPath folder.
static void start(java.lang.String scriptFileName)
          Runs commands from script file where each line is a separate command string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

execParam

public static void execParam(java.lang.String cmdLine)
Runs command in "cmdLine"

Parameters:
cmdLine - command string

start

public static void start(java.lang.String scriptFileName)
Runs commands from script file where each line is a separate command string

Parameters:
scriptFileName - file name with command lines; if line starts with "//" or "rem" or ";", or line is empty - these commands are ignored

settleDllDestination

public static boolean settleDllDestination(java.lang.String sourcePath,
                                           java.lang.String destPath,
                                           java.lang.String destPathSuffix,
                                           java.lang.String dllFileName)
Checks for availability of the dllFileName in destPath folder. If dllFileName is not present it is copied from sourcePath folder.

Parameters:
sourcePath - path to folder where .dll file is located, if it is null this path will be assumed as "<user.dir>/../lib"
destPath - path to folder where .dll file should be copied to, if it is null this path will be assumed as "<java.home>"
destPathSuffix - suffix to destPath path, may be null
dllFileName - .dll filename without path
Returns:
boolean indicating the result; true - if dllFileName was present in destPath folder, or was successfuly copied to destPath folder, otherwise - false. Examples:
  • settleDllDestination( null, null, "/bin", "jmrun.dll" ) - if jmrun.dll file is absent in <java.home>/bin, <user.dir>/../lib/jmrun.dll will be copied to <java.home>/bin/jmrun.dll
  • settleDllDestination( "./bin", "./dll", null, "jmrun.dll" ) - if jmrun.dll file is absent in ./bin, ./bin/jmrun.dll will be copied to ./dll/jmrun.dll
  • settleDllDestination( "./bin", "./", "dll", "jmrun.dll" ) - if jmrun.dll file is absent in ./bin, ./bin/jmrun.dll will be copied to ./dll/jmrun.dll

execWait

public static boolean execWait(java.lang.String cmdLine,
                               java.lang.String syncPath,
                               boolean autoFileNameFlag,
                               long waitTime,
                               long sleepTime)
Runs application from "cmdLine" with file synchronization. execWait creates synchronization file, starts "cmdLine" command and waits till termination of this command, which is syncronized by means of existence of syncronization file. Afterwards this syncronization file is deleted. The called application's logic must delete syncronization file before it terminates. The called application gets synchronization file name as it's last string argument.

Parameters:
cmdLine - command
syncPath - path ( if autoFileNameFlag is true ) or filename ( if autoFileNameFlag is false ) of synchronization file, if syncPath is null, syncPath = ".\sync.tmp"
autoFileNameFlag -
  • if autoFileNameFlag is true - synchronization file is generated with filename in "HH_mm_ss.SSS" format
  • if autoFileNameFlag is false - file syncPath is generated
waitTime - synchronization wait time. If execution time of the called application is more than waitTime, execWait deletes the synchronization file and continues its workflow.
sleepTime - cycle check time of synchronization file existence
Returns:
boolean indicating whether the execution time of the called application was within waitTime;

isSetPrefStr

public static boolean isSetPrefStr(java.lang.String key)
Checks if preferences key value is set to "1" returns true, else returns false

Parameters:
key - preference key name
Returns:
boolean indicating the result;

setPrefFlag

public static void setPrefFlag(java.lang.String key)
Sets preferences key value to "1"

Parameters:
key - preference key name

resetPrefFlag

public static void resetPrefFlag(java.lang.String key)
Removes preferences key

Parameters:
key - preference key name

execWaitPref

public static boolean execWaitPref(java.lang.String cmdLine,
                                   java.lang.String syncKey,
                                   boolean autoKeyNameSuffixFlag,
                                   long waitTime,
                                   long sleepTime)
Runs application from "cmdLine" with Java Preferences synchronization. execWaitPref sets synchronization preference flag, starts "cmdLine" command and waits till termination of this command, which is syncronized by means of existence of syncronization preference flag. Afterwards this syncronization preference flag is removed. The called application's logic must remove syncronization preference flag before it terminates. The called application gets synchronization preference flag keyName as it's last string argument.

Parameters:
cmdLine - command
syncKey - preferences key name, if syncKey is null, or "", syncKey = "syncKey"
autoKeyNameSuffixFlag -
  • if autoKeyNameSuffixFlag is true - syncKey = syncKey + "/HH_mm_ss.SSS"
  • if autoKeyNameSuffixFlag is false - syncKey = syncKey
waitTime - synchronization wait time. If execution time of the called application is more than waitTime, execWait removes the synchronization preference flag and continues its workflow.
sleepTime - cycle check time of synchronization preference flag existence
Returns:
boolean indicating whether the execution time of the called application was within waitTime;

main

public static void main(java.lang.String[] args)
This is a dual-purpose method:

1. Starts JMRun launcher from command line. Example1: javaw -cp <classpath> jmrun.JMRun [<scriptfile>]

2. Could be used to remove synchronization preference flag, i.e. be called from .cmd or .bat files. Example2: javaw -cp <classpath> jmrun.JMRun -rpf:<synchronization preference flag name>

Parameters:
args - command line arguments
  • if args is null the function #1 is started, <scriptfile> = "./jmrun.cfg"
  • if !args[0].startsWith( "-rpf:" ) the function #1 is started, <scriptfile> = args[0]
  • if args[0].startsWith( "-rpf:" ) the function #2 is started