public class BrowserSessionFactory extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BrowserSessionFactory.BrowserSessionInfo
Collection class to hold the objects associated with a browser session.
|
protected class |
BrowserSessionFactory.CleanupTask
TimerTask that looks for unused sessions in the availableSessions collection.
|
Modifier and Type | Field and Description |
---|---|
protected Set<BrowserSessionFactory.BrowserSessionInfo> |
activeSessions |
protected Set<BrowserSessionFactory.BrowserSessionInfo> |
availableSessions |
Modifier | Constructor and Description |
---|---|
|
BrowserSessionFactory(BrowserLauncherFactory blf) |
protected |
BrowserSessionFactory(BrowserLauncherFactory blf,
long cleanupInterval,
long maxIdleSessionTime,
boolean doCleanup)
Constructor for testing purposes.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addToAvailableSessions(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
for testing only
|
protected BrowserSessionFactory.BrowserSessionInfo |
createNewRemoteSession(String browserString,
String startURL,
String extensionJs,
Capabilities browserConfiguration,
boolean ensureClean,
RemoteControlConfiguration configuration)
Creates and tries to open a new session.
|
protected void |
deregisterExternalSession(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
Removes a previously registered external browser session from the list of active sessions.
|
protected void |
endAllBrowserSessions(RemoteControlConfiguration configuration)
Ends all browser sessions.
|
void |
endBrowserSession(boolean forceClose,
String sessionId,
RemoteControlConfiguration configuration)
Ends a browser session, using SeleniumServer static fields to populate parameters.
|
protected void |
endBrowserSession(boolean forceClose,
String sessionId,
RemoteControlConfiguration configuration,
boolean ensureClean)
Ends a browser session.
|
void |
endBrowserSession(String sessionId,
RemoteControlConfiguration configuration)
Ends a browser session, using SeleniumServer static fields to populate parameters.
|
protected BrowserSessionFactory.BrowserSessionInfo |
getNewBrowserSession(String browserString,
String startURL,
String extensionJs,
Capabilities browserConfigurations,
boolean useCached,
boolean ensureClean,
RemoteControlConfiguration configuration)
Gets a new browser session
|
BrowserSessionFactory.BrowserSessionInfo |
getNewBrowserSession(String browserString,
String startURL,
String extensionJs,
Capabilities browserConfigurations,
RemoteControlConfiguration configuration)
Gets a new browser session, using the SeleniumServer static fields to populate parameters.
|
protected FrameGroupCommandQueueSet |
getQueueSet(String sessionId)
Isolated dependency
|
protected BrowserSessionFactory.BrowserSessionInfo |
grabAvailableSession(String browserString,
String baseUrl)
Retrieves an available, unused session from the cache.
|
protected boolean |
hasActiveSession(String sessionId)
for testing only
|
protected boolean |
hasAvailableSession(String sessionId)
for testing only
|
protected BrowserSessionFactory.BrowserSessionInfo |
lookupInfoByBrowserAndUrl(String browserString,
String baseUrl,
Set<BrowserSessionFactory.BrowserSessionInfo> set)
Looks up a session in the named set by browser string and base URL
|
protected BrowserSessionFactory.BrowserSessionInfo |
lookupInfoBySessionId(String sessionId,
Set<BrowserSessionFactory.BrowserSessionInfo> set)
Looks up a session in the named set by session id
|
protected FrameGroupCommandQueueSet |
makeQueueSet(String sessionId,
int port,
RemoteControlConfiguration configuration)
Isolated dependency
|
protected boolean |
registerExternalSession(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
Adds a browser session that was not created by this factory to the set of active sessions.
|
protected void |
removeIdleAvailableSessions() |
protected void |
shutdownBrowserAndClearSessionData(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
Shuts down this browser session's launcher and clears out its session data (if session is not
null).
|
protected final Set<BrowserSessionFactory.BrowserSessionInfo> availableSessions
protected final Set<BrowserSessionFactory.BrowserSessionInfo> activeSessions
public BrowserSessionFactory(BrowserLauncherFactory blf)
protected BrowserSessionFactory(BrowserLauncherFactory blf, long cleanupInterval, long maxIdleSessionTime, boolean doCleanup)
blf
- an injected BrowserLauncherFactory.cleanupInterval
- the time between idle available session cleaning sweeps.maxIdleSessionTime
- the max time in ms for an available session to be idle.doCleanup
- whether or not the idle session cleanup thread should run.public BrowserSessionFactory.BrowserSessionInfo getNewBrowserSession(String browserString, String startURL, String extensionJs, Capabilities browserConfigurations, RemoteControlConfiguration configuration) throws RemoteCommandException
browserString
- startURL
- extensionJs
- per-session user extension Javascriptconfiguration
- Remote Control configuration. Cannot be null.RemoteCommandException
protected BrowserSessionFactory.BrowserSessionInfo getNewBrowserSession(String browserString, String startURL, String extensionJs, Capabilities browserConfigurations, boolean useCached, boolean ensureClean, RemoteControlConfiguration configuration) throws RemoteCommandException
browserString
- startURL
- extensionJs
- per-session user extension Javascriptconfiguration
- Remote Control configuration. Cannot be null.useCached
- if a cached session should be used if one is availableensureClean
- if a clean session (e.g. no previous cookies) is required.RemoteCommandException
protected void endAllBrowserSessions(RemoteControlConfiguration configuration)
public void endBrowserSession(String sessionId, RemoteControlConfiguration configuration)
sessionId
- the id of the session to be endedconfiguration
- Remote Control configuration. Cannot be null.public void endBrowserSession(boolean forceClose, String sessionId, RemoteControlConfiguration configuration)
sessionId
- the id of the session to be endedconfiguration
- Remote Control configuration. Cannot be null.protected void endBrowserSession(boolean forceClose, String sessionId, RemoteControlConfiguration configuration, boolean ensureClean)
sessionId
- the id of the session to be endedconfiguration
- Remote Control configuration. Cannot be null.ensureClean
- if clean sessions (e.g. no leftover cookies) are required.protected void shutdownBrowserAndClearSessionData(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
sessionInfo
- the browser session to end.protected BrowserSessionFactory.BrowserSessionInfo grabAvailableSession(String browserString, String baseUrl)
browserString
- the necessary browser for a suitable sessionbaseUrl
- the necessary baseUrl for a suitable sessionprotected FrameGroupCommandQueueSet makeQueueSet(String sessionId, int port, RemoteControlConfiguration configuration)
sessionId
- port
- configuration
- protected FrameGroupCommandQueueSet getQueueSet(String sessionId)
sessionId
- protected BrowserSessionFactory.BrowserSessionInfo createNewRemoteSession(String browserString, String startURL, String extensionJs, Capabilities browserConfiguration, boolean ensureClean, RemoteControlConfiguration configuration) throws RemoteCommandException
browserString
- startURL
- extensionJs
- configuration
- Remote Control configuration. Cannot be null.ensureClean
- if a clean session is requiredRemoteCommandException
- if the browser failed to launch and request work in the required
amount of time.protected boolean registerExternalSession(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
sessionInfo
- the session info to register.protected void deregisterExternalSession(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
sessionInfo
- the session to remove.protected BrowserSessionFactory.BrowserSessionInfo lookupInfoBySessionId(String sessionId, Set<BrowserSessionFactory.BrowserSessionInfo> set)
sessionId
- the session id to findset
- the Set to inspectprotected BrowserSessionFactory.BrowserSessionInfo lookupInfoByBrowserAndUrl(String browserString, String baseUrl, Set<BrowserSessionFactory.BrowserSessionInfo> set)
browserString
- the browser string to matchbaseUrl
- the base URL to match.set
- the Set to inspectprotected void removeIdleAvailableSessions()
protected boolean hasActiveSession(String sessionId)
protected boolean hasAvailableSession(String sessionId)
protected void addToAvailableSessions(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
Copyright © 2013. All rights reserved.