Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.fluidsynth.api
Class Executive  view Executive download Executive.java

java.lang.Object
  extended byorg.fluidsynth.api.Executive

public class Executive
extends java.lang.Object

This class provides an API for starting, stopping and interacting with fluidsynth.


Nested Class Summary
(package private)  class Executive.ConsoleReader
           
(package private)  class Executive.Ping
           
(package private)  class Executive.Runner
          This class provides the thread body that does the Runtime.exec() of fluidsynth and handles abnormal termination.
(package private) static class Executive.ShutdownHook
          Ensure that we kill the fluidsynth process when the JVM is terminated.
(package private) static class Executive.TestListener
           
 
Field Summary
private  boolean abnormalTermination
           
private static java.lang.StringBuffer consoleOutput
           
private static int DEFAULT_TCP_PORT
           
private static java.lang.String EOR_ECHO
           
private static java.lang.String EOR_ECHO_CMD
           
private static int EOR_ECHO_CMD_LEN
           
private static java.lang.String errorMessage
           
private static Executive instance
           
private static java.util.Set listeners
           
private  int port
           
private  Executive.Runner runner
           
private  java.net.Socket socket
           
private  java.io.BufferedReader socketReader
           
private  java.io.BufferedWriter socketWriter
           
(package private) static boolean startSuccess
           
private static TerminationStatus terminationStatus
           
 
Constructor Summary
private Executive(java.lang.String[] command, int port)
          Use the start(), instance() methods to get an instance of this class.
 
Method Summary
static void addListener(org.fluidsynth.api.event.ExecutiveListener listener)
          Add a termination listener.
private  void ensureConnection()
          Connect to the synth via TCP if we haven't done so already.
private static void fireStarted()
           
private static void fireStopped()
           
static java.lang.String getConsoleOutput()
          Return console output produced by fluidsynth (stdout+stderr).
static java.lang.String getErrorMessage()
          Returns an error message produced by a start failure.
static TerminationStatus getTerminationStatus()
           
static Executive instance()
          Get the active instance of this class.
 java.util.List invoke(java.lang.String command)
          Send a command to fluidsynth and return its output.
static boolean isRunning()
          Return true if the synth is running.
static void main(java.lang.String[] args)
           
static void removeListener(org.fluidsynth.api.event.ExecutiveListener listener)
          Remove a termination listener.
private  void shutdown()
          Do the actual work of terminating the fluidsynth process.
static Executive start()
          Start fluidsynth with some simple default options.
static Executive start(org.fluidsynth.api.settings.Settings settings)
          Start fluidsynth in a sub-process with a command line determined by the user-modified settings in the given Settings object.
static Executive start(java.lang.String[] cmdLineArgs, int port)
          Start fluidsynth with the given command line.
static void stop()
          Terminate the fluidsynth process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TCP_PORT

private static final int DEFAULT_TCP_PORT
See Also:
Constant Field Values

EOR_ECHO

private static final java.lang.String EOR_ECHO
See Also:
Constant Field Values

EOR_ECHO_CMD

private static final java.lang.String EOR_ECHO_CMD
See Also:
Constant Field Values

EOR_ECHO_CMD_LEN

private static final int EOR_ECHO_CMD_LEN

instance

private static Executive instance

consoleOutput

private static java.lang.StringBuffer consoleOutput

errorMessage

private static java.lang.String errorMessage

listeners

private static java.util.Set listeners

terminationStatus

private static TerminationStatus terminationStatus

runner

private Executive.Runner runner

port

private int port

socket

private java.net.Socket socket

socketReader

private java.io.BufferedReader socketReader

socketWriter

private java.io.BufferedWriter socketWriter

abnormalTermination

private boolean abnormalTermination

startSuccess

static boolean startSuccess
Constructor Detail

Executive

private Executive(java.lang.String[] command,
                  int port)
           throws java.lang.IllegalStateException
Use the start(), instance() methods to get an instance of this class.

Method Detail

addListener

public static void addListener(org.fluidsynth.api.event.ExecutiveListener listener)
Add a termination listener.


removeListener

public static void removeListener(org.fluidsynth.api.event.ExecutiveListener listener)
Remove a termination listener.


fireStarted

private static void fireStarted()

fireStopped

private static void fireStopped()

start

public static Executive start()
                       throws java.lang.IllegalStateException
Start fluidsynth with some simple default options. Clients should wait for the start event before issuing commands via invoke(java.lang.String) 55 .


start

public static Executive start(org.fluidsynth.api.settings.Settings settings)
                       throws java.lang.IllegalStateException
Start fluidsynth in a sub-process with a command line determined by the user-modified settings in the given Settings object. Clients should wait for the start event before issuing commands via invoke(java.lang.String) 55 .


start

public static Executive start(java.lang.String[] cmdLineArgs,
                              int port)
                       throws java.lang.IllegalStateException
Start fluidsynth with the given command line. Clients should wait for the start event before issuing commands via invoke(java.lang.String) 55 .


stop

public static void stop()
Terminate the fluidsynth process. Harmless to call this more than once.


instance

public static Executive instance()
Get the active instance of this class. If fluidsynth is not running, this method returns null.


isRunning

public static boolean isRunning()
Return true if the synth is running.


getTerminationStatus

public static TerminationStatus getTerminationStatus()

invoke

public java.util.List invoke(java.lang.String command)
                      throws java.io.IOException,
                             java.lang.IllegalStateException
Send a command to fluidsynth and return its output.


getConsoleOutput

public static java.lang.String getConsoleOutput()
Return console output produced by fluidsynth (stdout+stderr). This method will return the output from the current invocation of the synth, or the previous invocation if the synth is not currently running. Returns null if the synth has never been started.


getErrorMessage

public static java.lang.String getErrorMessage()
Returns an error message produced by a start failure.


shutdown

private void shutdown()
Do the actual work of terminating the fluidsynth process.


ensureConnection

private void ensureConnection()
                       throws java.io.IOException,
                              java.lang.IllegalStateException
Connect to the synth via TCP if we haven't done so already.


main

public static void main(java.lang.String[] args)