|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openqa.selenium.server.BrowserSessionFactory
public class BrowserSessionFactory
Manages browser sessions, their creation, and their closure.
Maintains a cache of unused and available browser sessions in case the server is reusing sessions. Also manages the creation and finalization of all browser sessions.
| Nested Class Summary | |
|---|---|
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. |
| Field Summary | |
|---|---|
protected java.util.Set<BrowserSessionFactory.BrowserSessionInfo> |
activeSessions
|
protected java.util.Set<BrowserSessionFactory.BrowserSessionInfo> |
availableSessions
|
| Constructor Summary | |
|---|---|
|
BrowserSessionFactory(BrowserLauncherFactory blf)
|
protected |
BrowserSessionFactory(BrowserLauncherFactory blf,
long cleanupInterval,
long maxIdleSessionTime,
boolean doCleanup)
Constructor for testing purposes. |
| Method Summary | |
|---|---|
protected void |
addToAvailableSessions(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
for testing only |
protected BrowserSessionFactory.BrowserSessionInfo |
createNewRemoteSession(java.lang.String browserString,
java.lang.String startURL,
java.lang.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,
java.lang.String sessionId,
RemoteControlConfiguration configuration)
Ends a browser session, using SeleniumServer static fields to populate parameters. |
protected void |
endBrowserSession(boolean forceClose,
java.lang.String sessionId,
RemoteControlConfiguration configuration,
boolean ensureClean)
Ends a browser session. |
void |
endBrowserSession(java.lang.String sessionId,
RemoteControlConfiguration configuration)
Ends a browser session, using SeleniumServer static fields to populate parameters. |
protected BrowserSessionFactory.BrowserSessionInfo |
getNewBrowserSession(java.lang.String browserString,
java.lang.String startURL,
java.lang.String extensionJs,
Capabilities browserConfigurations,
boolean useCached,
boolean ensureClean,
RemoteControlConfiguration configuration)
Gets a new browser session |
BrowserSessionFactory.BrowserSessionInfo |
getNewBrowserSession(java.lang.String browserString,
java.lang.String startURL,
java.lang.String extensionJs,
Capabilities browserConfigurations,
RemoteControlConfiguration configuration)
Gets a new browser session, using the SeleniumServer static fields to populate parameters. |
protected FrameGroupCommandQueueSet |
getQueueSet(java.lang.String sessionId)
Isolated dependency |
protected BrowserSessionFactory.BrowserSessionInfo |
grabAvailableSession(java.lang.String browserString,
java.lang.String baseUrl)
Retrieves an available, unused session from the cache. |
protected boolean |
hasActiveSession(java.lang.String sessionId)
for testing only |
protected boolean |
hasAvailableSession(java.lang.String sessionId)
for testing only |
protected BrowserSessionFactory.BrowserSessionInfo |
lookupInfoByBrowserAndUrl(java.lang.String browserString,
java.lang.String baseUrl,
java.util.Set<BrowserSessionFactory.BrowserSessionInfo> set)
Looks up a session in the named set by browser string and base URL |
protected BrowserSessionFactory.BrowserSessionInfo |
lookupInfoBySessionId(java.lang.String sessionId,
java.util.Set<BrowserSessionFactory.BrowserSessionInfo> set)
Looks up a session in the named set by session id |
protected FrameGroupCommandQueueSet |
makeQueueSet(java.lang.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). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.util.Set<BrowserSessionFactory.BrowserSessionInfo> availableSessions
protected final java.util.Set<BrowserSessionFactory.BrowserSessionInfo> activeSessions
| Constructor Detail |
|---|
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.| Method Detail |
|---|
public BrowserSessionFactory.BrowserSessionInfo getNewBrowserSession(java.lang.String browserString,
java.lang.String startURL,
java.lang.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(java.lang.String browserString,
java.lang.String startURL,
java.lang.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.
RemoteCommandExceptionprotected void endAllBrowserSessions(RemoteControlConfiguration configuration)
public void endBrowserSession(java.lang.String sessionId,
RemoteControlConfiguration configuration)
sessionId - the id of the session to be endedconfiguration - Remote Control configuration. Cannot be null.
public void endBrowserSession(boolean forceClose,
java.lang.String sessionId,
RemoteControlConfiguration configuration)
sessionId - the id of the session to be endedconfiguration - Remote Control configuration. Cannot be null.
protected void endBrowserSession(boolean forceClose,
java.lang.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(java.lang.String browserString,
java.lang.String baseUrl)
browserString - the necessary browser for a suitable sessionbaseUrl - the necessary baseUrl for a suitable session
protected FrameGroupCommandQueueSet makeQueueSet(java.lang.String sessionId,
int port,
RemoteControlConfiguration configuration)
sessionId - port - configuration -
protected FrameGroupCommandQueueSet getQueueSet(java.lang.String sessionId)
sessionId -
protected BrowserSessionFactory.BrowserSessionInfo createNewRemoteSession(java.lang.String browserString,
java.lang.String startURL,
java.lang.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 required
RemoteCommandException - 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(java.lang.String sessionId,
java.util.Set<BrowserSessionFactory.BrowserSessionInfo> set)
sessionId - the session id to findset - the Set to inspect
protected BrowserSessionFactory.BrowserSessionInfo lookupInfoByBrowserAndUrl(java.lang.String browserString,
java.lang.String baseUrl,
java.util.Set<BrowserSessionFactory.BrowserSessionInfo> set)
browserString - the browser string to matchbaseUrl - the base URL to match.set - the Set to inspect
protected void removeIdleAvailableSessions()
protected boolean hasActiveSession(java.lang.String sessionId)
protected boolean hasAvailableSession(java.lang.String sessionId)
protected void addToAvailableSessions(BrowserSessionFactory.BrowserSessionInfo sessionInfo)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||