public class ThreadSafeSessionManager extends Object implements SessionManager2
PLAYER_SUPPORTS_GET, PREF_ACCEPT_TIMEOUT, PREF_CONNECT_RETRY_ATTEMPTS, PREF_CONNECT_TIMEOUT, PREF_CONNECT_WAIT_INTERVAL, PREF_CONTEXT_RESPONSE_TIMEOUT, PREF_GETVAR_RESPONSE_TIMEOUT, PREF_HIERARCHICAL_VARIABLES, PREF_INVOKE_GETTERS, PREF_RESPONSE_TIMEOUT, PREF_SETVAR_RESPONSE_TIMEOUT, PREF_SOCKET_TIMEOUT, PREF_SUSPEND_WAIT, PREF_SWFSWD_LOAD_TIMEOUT, PREF_URI_MODIFICATION
Modifier and Type | Method and Description |
---|---|
Session |
accept(IProgress waitReporter)
Blocks until the next available player debug session commences, or until
getPreference(PREF_ACCEPT_TIMEOUT) milliseconds pass. |
Session |
connect(int port,
IProgress waitReporter)
Initiate a debug session by connecting to the specified port.
|
int |
getPreference(String pref)
Return the value of a particular preference item
|
Object |
getSyncObject() |
static Object |
getSyncObject(SessionManager sm) |
boolean |
isConnecting()
Is this object currently connecting to the Debug Player
|
boolean |
isListening()
Is this object currently listening for Debug Player connections
|
Session |
launch(String uri,
AIRLaunchInfo airLaunchInfo,
boolean forDebugging,
IProgress waitReporter,
ILaunchNotification launchNotification)
Launches a Player using the given string as a URI, as defined by RFC2396.
|
Session |
launch(String uri,
AIRLaunchInfo airLaunchInfo,
boolean forDebugging,
IProgress waitReporter,
ILaunchNotification launchNotification,
ILauncher launcher)
Launches the given string as a URI using the ILauncher Instance.
|
Process |
launchForRun(String uri,
AIRLaunchInfo airLaunchInfo,
IProgress waitReporter,
ILaunchNotification launchNotification)
This is, functionally, a clone of the SessionManager.launch() method.
|
Process |
launchForRun(String uri,
AIRLaunchInfo airLaunchInfo,
IProgress waitReporter,
ILaunchNotification launchNotification,
ILauncher launcher)
This is, functionally, a clone of the SessionManager.launch() method.
|
Player |
playerForUri(String uri,
AIRLaunchInfo airLaunchInfo)
Returns information about the Flash player which will be used to run the
given URI.
|
void |
setDebuggerCallbacks(IDebuggerCallbacks debuggerCallbacks)
Tells the session manager to use the specified IDebuggerCallbacks for
performing certain operatios, such as finding the Flash Player and
launching the debug target.
|
void |
setPreference(String pref,
int value)
Set preference for this manager and for subsequent Sessions
that are initiated after this call.
|
void |
setPreference(String pref,
String value)
Set preference for this manager and for subsequent Sessions
that are initiated after this call.
|
void |
startListening()
Listens for Player attempts to open a debug session.
|
void |
stopConnecting()
Stops connecting to the Player for a debug session.
|
void |
stopListening()
Stops listening for new Player attempts to open a debug session.
|
boolean |
supportsLaunch()
Returns whether this platform supports the
launch()
command; that is, whether the debugger can programmatically launch the
Flash player. |
static ThreadSafeSessionManager |
wrap(SessionManager sessionManager)
Wraps a SessionManager inside a ThreadSafeSessionManager.
|
public static ThreadSafeSessionManager wrap(SessionManager sessionManager)
public static Object getSyncObject(SessionManager sm)
public Session accept(IProgress waitReporter) throws IOException
SessionManager
getPreference(PREF_ACCEPT_TIMEOUT)
milliseconds pass.
Before calling launch()
, you must call
startListening()
.
Once a Session is obtained, Session.bind() must be called prior to any other Session method.
accept
in interface SessionManager
waitReporter
- a progress monitor to allow accept() to notify its parent how
long it has been waiting for the Flash player to connect to it.
May be null
if the caller doesn't need to know how
long it's been waiting.IOException
- -
see java.net.ServerSocket.accept()public int getPreference(String pref) throws NullPointerException
SessionManager
getPreference
in interface SessionManager
pref
- preference name, one of the strings listed aboveNullPointerException
- if pref does not existpublic boolean isListening()
SessionManager
isListening
in interface SessionManager
public Session launch(String uri, AIRLaunchInfo airLaunchInfo, boolean forDebugging, IProgress waitReporter, ILaunchNotification launchNotification) throws IOException
SessionManager
For example "http://localhost:8100/flex/my.mxml" or for a local file on Windows, "file://c:/my.swf"
This call will block until a session with the newly launched player is created.
It is the caller's responsibility to ensure that no other thread is
blocking in accept()
, since that thread will gain control
of this session.
Before calling launch()
, you should first call
supportsLaunch()
. If supportsLaunch()
returns false, then you will have to tell the user to manually launch the
Flash player.
Also, before calling launch()
, you must call
startListening()
.
launch
in interface SessionManager
uri
- which will launch a Flash player under running OS. For
Flash/Flex apps, this can point to either a SWF or an HTML
file. For AIR apps, this must point to the application.xml
file for the application.airLaunchInfo
- If trying to launch an AIR application, this argument must be
specified; it gives more information about how to do the
launch. If trying to launch a regular web-based Flash or Flex
application, such as one that will be in a browser or in the
standalone Flash Player, this argument should be
null
.forDebugging
- if true
, then the launch is for the purposes
of debugging. If false
, then the launch is
simply because the user wants to run the movie but not debug
it; in that case, the return value of this function will be
null
.waitReporter
- a progress monitor to allow accept() to notify its parent how
long it has been waiting for the Flash player to connect to
it. May be null
if the caller doesn't need to
know how long it's been waiting.launchNotification
- a notifier to notify the caller about ADL Exit Code.
Main usage is for ADL Exit Code 1 (Successful invocation of an
already running AIR application. ADL exits immediately).
May be null
if no need to listen ADL.
Will only be called if forDebugging is false. (If forDebugging
is true, error conditions are handled by throwing an exception.)
The callback will be called on a different thread.CommandLineException
- if the program that was launched exited unexpectedly. This
will be returned, for example, when launching an AIR
application, if adl exits with an error code.
CommandLineException includes functions to return any error
text that may have been sent to stdout/stderr, and the exit
code of the program.IOException
- see Runtime.exec()public Player playerForUri(String uri, AIRLaunchInfo airLaunchInfo)
SessionManager
playerForUri
in interface SessionManager
uri
- The URI which will be passed to launch()
-- for
example, http://flexserver/mymovie.mxml
or
c:\mymovie.swf
. If launching an AIR app, this
should point to the app's *-app.xml file.airLaunchInfo
- If launching an AIR app, this should, if possible, contain
info about the version of AIR being launched, but it can be
null if you don't have that information. If launching a
web-based app, this should be null.Player
which can be used to determine information about
the player -- for example, whether it is a debugger-enabled
player. Returns null
if the player cannot be
determined. Important: There are valid situations in
which this will return null
public boolean supportsLaunch()
SessionManager
launch()
command; that is, whether the debugger can programmatically launch the
Flash player. If this function returns false, then the debugger will have
to tell the user to manually launch the Flash player.supportsLaunch
in interface SessionManager
launch()
command.public void setPreference(String pref, int value)
SessionManager
setPreference
in interface SessionManager
pref
- preference name, one of the strings listed abovevalue
- value to set for preferencepublic void setPreference(String pref, String value)
SessionManager
setPreference
in interface SessionManager
pref
- preference name, one of the strings listed abovevalue
- value to set for preferencepublic void startListening() throws IOException
SessionManager
accept()
being invoked.startListening
in interface SessionManager
IOException
- if opening the server side socket failspublic void stopListening() throws IOException
SessionManager
accept
to throw SocketExceptions.stopListening
in interface SessionManager
IOException
public void setDebuggerCallbacks(IDebuggerCallbacks debuggerCallbacks)
SessionManager
DefaultDebuggerCallbacks
object.setDebuggerCallbacks
in interface SessionManager
public Session connect(int port, IProgress waitReporter) throws IOException
SessionManager
getPreference(PREF_CONNECT_TIMEOUT)
milliseconds pass.
This work-flow is a reverse of accept()
and suited for
cases where the player is unable to initiate the connection. The
player must be listening on the specified port for an incoming debug
connection. In addition, this function calls bind() on the session
to determine if the handshake was successful so that retry works
correctly even across port-forwards.
Use stopConnecting()
to cancel connect,
isConnecting()
to check if we are currently trying to
connect.
connect
in interface SessionManager
port
- - The port to connect to. See DProtocol.DEBUG_CONNECT_PORT.IOException
- - This may have a wrapped VersionException due to bind()public void stopConnecting() throws IOException
SessionManager
connect
to throw SocketExceptions.stopConnecting
in interface SessionManager
IOException
public boolean isConnecting()
SessionManager
isConnecting
in interface SessionManager
public Process launchForRun(String uri, AIRLaunchInfo airLaunchInfo, IProgress waitReporter, ILaunchNotification launchNotification) throws IOException
SessionManager2
launchForRun
in interface SessionManager2
uri
- which will launch a Flash player under running OS. For
Flash/Flex apps, this can point to either a SWF or an HTML
file. For AIR apps, this must point to the application.xml
file for the application.airLaunchInfo
- If trying to launch an AIR application, this argument must be
specified; it gives more information about how to do the
launch. If trying to launch a regular web-based Flash or Flex
application, such as one that will be in a browser or in the
standalone Flash Player, this argument should be
null
.waitReporter
- a progress monitor to allow accept() to notify its parent how
long it has been waiting for the Flash player to connect to
it. May be null
if the caller doesn't need to
know how long it's been waiting.launchNotification
- a notifier to notify the caller about ADL Exit Code.
Main usage is for ADL Exit Code 1 (Successful invocation of an
already running AIR application. ADL exits immediately).
May be null
if no need to listen ADL.
The callback will be called on a different thread.IOException
- see Runtime.exec()public Process launchForRun(String uri, AIRLaunchInfo airLaunchInfo, IProgress waitReporter, ILaunchNotification launchNotification, ILauncher launcher) throws IOException
SessionManager2
launchForRun
in interface SessionManager2
uri
- which will launch a Flash player under running OS. For
Flash/Flex apps, this can point to either a SWF or an HTML
file. For AIR apps, this must point to the application.xml
file for the application.airLaunchInfo
- If trying to launch an AIR application, this argument must be
specified; it gives more information about how to do the
launch. If trying to launch a regular web-based Flash or Flex
application, such as one that will be in a browser or in the
standalone Flash Player, this argument should be
null
.waitReporter
- a progress monitor to allow accept() to notify its parent how
long it has been waiting for the Flash player to connect to
it. May be null
if the caller doesn't need to
know how long it's been waiting.launchNotification
- a notifier to notify the caller about ADL Exit Code.
Main usage is for ADL Exit Code 1 (Successful invocation of an
already running AIR application. ADL exits immediately).
May be null
if no need to listen ADL.
The callback will be called on a different thread.launcher
- a launcher instance which will be used to launch.IOException
public Session launch(String uri, AIRLaunchInfo airLaunchInfo, boolean forDebugging, IProgress waitReporter, ILaunchNotification launchNotification, ILauncher launcher) throws IOException
SessionManager2
It is the caller's responsibility to ensure that no other thread is
blocking in accept()
, since that thread will gain control
of this session.
Before calling launch()
, you should first call
supportsLaunch()
. If supportsLaunch()
returns false, then you will have to tell the user to manually launch the
Flash player.
Also, before calling launch()
, you must call
startListening()
.
launch
in interface SessionManager2
uri
- which will launch a Flash player under running OS. For
Flash/Flex apps, this can point to either a SWF or an HTML
file. For AIR apps, this must point to the application.xml
file for the application.airLaunchInfo
- If trying to launch an AIR application, this argument must be
specified; it gives more information about how to do the
launch. If trying to launch a regular web-based Flash or Flex
application, such as one that will be in a browser or in the
standalone Flash Player, this argument should be
null
.forDebugging
- if true
, then the launch is for the purposes
of debugging. If false
, then the launch is
simply because the user wants to run the movie but not debug
it; in that case, the return value of this function will be
null
.waitReporter
- a progress monitor to allow accept() to notify its parent how
long it has been waiting for the Flash player to connect to
it. May be null
if the caller doesn't need to
know how long it's been waiting.launchNotification
- a notifier to notify the caller about ADL Exit Code.
Main usage is for ADL Exit Code 1 (Successful invocation of an
already running AIR application. ADL exits immediately).
May be null
if no need to listen ADL.
Will only be called if forDebugging is false. (If forDebugging
is true, error conditions are handled by throwing an exception.)
The callback will be called on a different thread.CommandLineException
- if the program that was launched exited unexpectedly. This
will be returned, for example, when launching an AIR
application, if adl exits with an error code.
CommandLineException includes functions to return any error
text that may have been sent to stdout/stderr, and the exit
code of the program.IOException
- Exception during launch.public final Object getSyncObject()
Copyright © 2016 The Apache Software Foundation. All rights reserved.