Object PulsarContexts
-
- All Implemented Interfaces:
public class PulsarContextsManages the creation and lifecycle of Pulsar contexts and sessions.
A Pulsar session provides:
Full-featured
WebDriverCapture of live web pages into a local
WebPageParsing a
WebPageinto a lightweightDocumentEvent handlers across the WebPage lifecycle
One-line scrapers & full crawler (fetching, parsing, scheduling, priorities, browser pool, plugins)
Basic LLM support for interacting with pages or documents
Additional context types:
SQLContexts: enables X‑SQL for advanced web page modelingPulsarContexts: enables agentic/browser‑based agents (AgenticSession)
This object coordinates the active context, shutdown hooks, and session creation.
Thread‑safety:
All creation and shutdown entry points are synchronized.
-
-
Field Summary
Fields Modifier and Type Field Description private final PulsarContextactiveContextpublic final static PulsarContextsINSTANCE
-
Method Summary
Modifier and Type Method Description final static PulsarContextcreate()Creates and activates a new default context if none is active; otherwise returns the existing active context. final static PulsarContextcreate(PulsarContext context)Activates the given context unless an equivalent active context already exists; in that case the existing one is returned. final PulsarContextcreate(ApplicationContext applicationContext)Creates and activates a new context backed by the provided Spring application context if none compatible is active; otherwise returns the existing active context. final static PulsarContextcreate(String contextLocation)Creates and activates a new context from the given Spring XML location if none compatible is active; otherwise returns the existing active context. final static PulsarContextgetOrCreate()final static PulsarContextgetOrCreate(PulsarContext context)final static PulsarContextgetOrCreate(ApplicationContext applicationContext)final static PulsarContextgetOrCreate(String contextLocation)final static PulsarSessioncreateSession()Creates a PulsarSessionusing the active context (creating a default context if necessary).final static PulsarSessiongetOrCreateSession()Returns the existing PulsarSessionif present, otherwise creates one using the active context (creating a default context if necessary).final static Unitawait()Waits for all submitted URLs to be processed. final static UnitregisterClosable(AutoCloseable closable, Integer priority)Registers a closable object with the active context. final static Unitshutdown()Closes all created contexts and shuts down Browser4. final static Unitclose()Closes all created contexts and shuts down Browser4 (alias for shutdown). final PulsarContextgetActiveContext()The active context (the most recently created context). -
-
Method Detail
-
create
@Synchronized() final static PulsarContext create()
Creates and activates a new default context if none is active; otherwise returns the existing active context.
- Returns:
The active context
-
create
@Synchronized() final static PulsarContext create(PulsarContext context)
Activates the given context unless an equivalent active context already exists; in that case the existing one is returned. Also registers shutdown hooks for both Spring and Pulsar contexts.
- Parameters:
context- The context to activate- Returns:
The active context
-
create
@Synchronized() final PulsarContext create(ApplicationContext applicationContext)
Creates and activates a new context backed by the provided Spring application context if none compatible is active; otherwise returns the existing active context.
- Parameters:
applicationContext- The Spring application context- Returns:
The active context
-
create
@Synchronized() final static PulsarContext create(String contextLocation)
Creates and activates a new context from the given Spring XML location if none compatible is active; otherwise returns the existing active context.
- Parameters:
contextLocation- The classpath location of the Spring XML context- Returns:
The active context
-
getOrCreate
@Synchronized() final static PulsarContext getOrCreate()
-
getOrCreate
@Synchronized() final static PulsarContext getOrCreate(PulsarContext context)
-
getOrCreate
@Synchronized() final static PulsarContext getOrCreate(ApplicationContext applicationContext)
-
getOrCreate
@Synchronized() final static PulsarContext getOrCreate(String contextLocation)
-
createSession
@Synchronized() final static PulsarSession createSession()
Creates a
PulsarSessionusing the active context (creating a default context if necessary).- Returns:
The created session
-
getOrCreateSession
@Synchronized() final static PulsarSession getOrCreateSession()
Returns the existing
PulsarSessionif present, otherwise creates one using the active context (creating a default context if necessary).- Returns:
The existing or newly created session
-
registerClosable
final static Unit registerClosable(AutoCloseable closable, Integer priority)
Registers a closable object with the active context. Note: If a context has not been created yet, this is a no‑op.
- Parameters:
closable- The object implementingAutoCloseablepriority- The priority for closing order
-
shutdown
@Synchronized() final static Unit shutdown()
Closes all created contexts and shuts down Browser4.
-
close
@Synchronized() final static Unit close()
Closes all created contexts and shuts down Browser4 (alias for shutdown).
-
getActiveContext
final PulsarContext getActiveContext()
The active context (the most recently created context).
-
-
-
-