public enum ScrapingSessionManager extends java.lang.Enum<ScrapingSessionManager>
Enum Constant and Description |
---|
INSTANCE
The scraping session manager instance
|
Modifier and Type | Field and Description |
---|---|
static org.apache.log4j.Logger |
log |
static int |
MAX_BASIC_EDITION_SCRAPING_SESSIONS |
(package private) java.util.concurrent.atomic.AtomicInteger |
numRunning |
Modifier and Type | Method and Description |
---|---|
ScrapingSession |
addNewScrapingSession(Folder folder)
Adds a blank
ScrapingSession . |
void |
addScrapingSession(ScrapingSession scrapingSession)
Adds a scraping session to be managed.
|
static ScrapingSessionManager |
getInstance()
Returns the manager instance
|
int |
getNumRunnableScrapingSessions()
Gets the number of runnable
ScrapingSession s. |
int |
getNumRunningScrapingSessions()
Gets the number of running
ScrapingSession s. |
int |
getNumRunningScrapingSessions(java.lang.String scrapingSessionName)
Gets the number of named running
ScrapingSession s. |
int |
getNumScrapingSessions()
Gets the number of
ScrapingSession s. |
int |
getNumScrapingSessionsWithName(java.lang.String name)
Gets the number of scraping sessions carrying the given name.
|
ScrapingSession |
getRunningScrapingSession(java.lang.String name)
Gets a running scraping session, based on the name of the scraping session.
|
java.util.List<ScrapingSession> |
getRunningScrapingSessions()
Returns a
HashSet containing running ScrapingSession objects. |
ScrapingSession |
getScrapingSession(int id)
Gets a scraping session, based on the ID of the scraping session.
|
ScrapingSession |
getScrapingSession(java.lang.String name)
Gets a scraping session, based on the name of the scraping session.
|
ScrapingSession |
getScrapingSessionBySequence(int sequence)
Gets a
ScrapingSession based on a sequence, assuming the scraping sessions are sorted alphabetically. |
ScrapingSession |
getScrapingSessionCopy(java.lang.String name)
Gets a copy of an existing scraping session, based on the name of the scraping session.
|
java.util.Date |
getScrapingSessionLastImportTime(java.lang.String scrapeName)
Returns the last time the scrape with the given name was imported, or if it hasn't been imported since the instance was launched (or isn't in the
instance) returns the time the server was launched
|
java.util.Set<ScrapingSession> |
getScrapingSessions()
Returns a set of the current sessions
|
java.util.TreeSet<ScrapingSession> |
getScrapingSessionsAsTreeSet()
Returns a sorted
TreeSet containing the ScrapingSession objects. |
java.util.Iterator<ScrapingSession> |
getScrapingSessionsIterator()
Returns an iterator over the current sessions
|
int |
getSequenceForScrapingSession(ScrapingSession scrapingSession)
Gets the sequence of the given scraping session.
|
void |
hotSwapScrapingSessionsFromDatabase()
Hot swaps scraping sessions from the database.
|
void |
hotSwapScrapingSessionsFromFiles()
Checks for existing scraping sessions in the "import" directory, and if they exist, hot swaps them in.
|
java.lang.Object |
importFromFile(java.io.File file,
Folder folder,
boolean promptForOverwrite)
Imports a file that may either contain a
ScrapingSession or Script . |
java.lang.Object |
importFromReader(java.io.Reader reader,
Folder folder,
boolean promptForOverwrite)
Imports an object pointed to by the given reader that may either contain a
ScrapingSession or Script . |
boolean |
isScrapingSessionRunning(ScrapingSession scrapingSession)
Indicates whether or not the given scraping session is currently running.
|
void |
loadScrapingSessions(ScrapingSessionNotifiable scrapingSessionNotifiable)
Causes the manager to load itself with all available scraping sessions.
|
void |
removeAllScrapingSessions()
Clears all scraping sessions.
|
void |
removeScrapingSession(ScrapingSession scrapingSession)
Removes a
ScrapingSession from the manager. |
void |
runScrapingSession(ScrapingSession session)
Runs or queues to be run a scraping session.
|
void |
save()
Saves all of the scraping sessions held by the manager.
|
void |
scrapingSessionFinished(ScrapingSession scrapingSession)
Performs a few functions that need to take place when a scraping session has finished.
|
java.util.List<GlobalSearchResult> |
searchLastRequestsAndResponses(java.lang.String textToFind,
boolean isCaseSensitive)
Searches the last requests and responses for the given text.
|
void |
setDefaultProxySettingsOnAllScrapingSessions()
Sets all scraping session proxy settings using the default settings.
|
static void |
setMaxConcurrentScrapingSessions(int maxConcurrentScrapingSessions)
Sets the maximum number of concurrent sessions to allow (in basic this is capped)
|
void |
setScrapingSessionNotifiable(ScrapingSession scrapingSession,
ScrapingSessionNotifiable notifiable)
This method gives all scraping sessions (current, running, or runnable) matching the one passed in a reference to the given notifiable.
|
void |
shutdown() |
void |
stopAllRunningScrapingSessions()
Stops all running
ScrapingSession s. |
void |
stopScrapingSessions(java.lang.String name)
Stops any scraping sessions with the given name.
|
static ScrapingSessionManager |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ScrapingSessionManager[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ScrapingSessionManager INSTANCE
public static org.apache.log4j.Logger log
@NotNull java.util.concurrent.atomic.AtomicInteger numRunning
public static final int MAX_BASIC_EDITION_SCRAPING_SESSIONS
public static ScrapingSessionManager[] values()
for (ScrapingSessionManager c : ScrapingSessionManager.values()) System.out.println(c);
public static ScrapingSessionManager valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null@NotNull public static ScrapingSessionManager getInstance()
public static void setMaxConcurrentScrapingSessions(int maxConcurrentScrapingSessions)
maxConcurrentScrapingSessions
- The maximum number of sessions to allowpublic java.util.Set<ScrapingSession> getScrapingSessions()
public java.util.TreeSet<ScrapingSession> getScrapingSessionsAsTreeSet()
TreeSet
containing the ScrapingSession
objects.TreeSet
.public java.util.Iterator<ScrapingSession> getScrapingSessionsIterator()
@Nullable public ScrapingSession getScrapingSessionBySequence(int sequence)
ScrapingSession
based on a sequence, assuming the scraping sessions are sorted alphabetically.sequence
- The sequence corresponding to the desired ScrapingSession
.ScrapingSession
if the sequence is valid. Returns null, otherwise.public int getSequenceForScrapingSession(ScrapingSession scrapingSession)
scrapingSession
- The session to the the sequence forpublic int getNumScrapingSessions()
ScrapingSession
s.public java.util.List<ScrapingSession> getRunningScrapingSessions()
HashSet
containing running ScrapingSession
objects.HashSet
.@Nullable public ScrapingSession getRunningScrapingSession(java.lang.String name)
name
- The name of the desired scraping session.public boolean isScrapingSessionRunning(@NotNull ScrapingSession scrapingSession)
scrapingSession
- The ScrapingSession
.public int getNumRunnableScrapingSessions()
ScrapingSession
s.public int getNumRunningScrapingSessions()
ScrapingSession
s.public int getNumRunningScrapingSessions(@Nullable java.lang.String scrapingSessionName)
ScrapingSession
s.scrapingSessionName
- The name of the scraping session to check.public void addScrapingSession(@Nullable ScrapingSession scrapingSession)
scrapingSession
- The ScrapingSession
.@NotNull public java.util.Date getScrapingSessionLastImportTime(@NotNull java.lang.String scrapeName)
scrapeName
- The name of the scrape to check@NotNull public ScrapingSession addNewScrapingSession(Folder folder)
ScrapingSession
.folder
- The folder that should contain the generated scraping session.public void hotSwapScrapingSessionsFromFiles()
@Nullable public java.lang.Object importFromFile(@NotNull java.io.File file, @Nullable Folder folder, boolean promptForOverwrite) throws java.lang.Exception
ScrapingSession
or Script
.file
- The file to import.folder
- A Folder
to contain the imported object. If this parameter is null, the object will be placed into the root folder.promptForOverwrite
- Indicates whether or not the user should be prompted to overwrite existing objects.ScrapingSession
or Script
.java.lang.Exception
- An exception with a good error message if something goes wrong.public java.lang.Object importFromReader(@NotNull java.io.Reader reader, Folder folder, boolean promptForOverwrite) throws java.lang.Exception
ScrapingSession
or Script
.reader
- A reader pointing to the object to import.folder
- A Folder
to contain the imported object. If this parameter is null, the object will be placed into the root folder.promptForOverwrite
- Indicates whether or not the user should be prompted to overwrite existing objects.ScrapingSession
or Script
.java.lang.Exception
- An exception with a good error message if something goes wrong.public void hotSwapScrapingSessionsFromDatabase()
public void save()
public void scrapingSessionFinished(@Nullable ScrapingSession scrapingSession)
scrapingSession
- The ScrapingSession
that finished.public void stopAllRunningScrapingSessions()
ScrapingSession
s.public void runScrapingSession(@NotNull ScrapingSession session)
session
- The ScrapingSession
.public void stopScrapingSessions(java.lang.String name)
name
- The name of the scraping sessions that should be stopped.@Nullable public ScrapingSession getScrapingSessionCopy(java.lang.String name)
name
- The name of the desired scraping session.@NotNull public java.util.List<GlobalSearchResult> searchLastRequestsAndResponses(java.lang.String textToFind, boolean isCaseSensitive)
textToFind
- The text to search for.isCaseSensitive
- Case sensitive?@Nullable public ScrapingSession getScrapingSession(java.lang.String name)
name
- The name of the desired scraping session.@Nullable public ScrapingSession getScrapingSession(int id)
id
- The ID of the desired scraping session.public int getNumScrapingSessionsWithName(@Nullable java.lang.String name)
name
- The name of the scraping session.public void removeScrapingSession(@NotNull ScrapingSession scrapingSession)
ScrapingSession
from the manager.scrapingSession
- The ScrapingSession
to remove.public void removeAllScrapingSessions()
public void setScrapingSessionNotifiable(@Nullable ScrapingSession scrapingSession, @Nullable ScrapingSessionNotifiable notifiable)
scrapingSession
- The ScrapingSession
to match.notifiable
- The ScrapingSessionNotifiable
object the matching scraping sessions should be given a reference to.public void setDefaultProxySettingsOnAllScrapingSessions()
public void loadScrapingSessions(@Nullable ScrapingSessionNotifiable scrapingSessionNotifiable)
scrapingSessionNotifiable
- The ScrapingSessionNotifiable
to give to the ScrapingSession
s that get created. Note that this parameter
is optional.public void shutdown()