Object PulsarContexts

  • All Implemented Interfaces:

    
    public class PulsarContexts
    
                        

    Manages the creation and lifecycle of Pulsar contexts and sessions.

    A Pulsar session provides:

    • Full-featured WebDriver

    • Capture of live web pages into a local WebPage

    • Parsing a WebPage into a lightweight Document

    • Event 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 modeling

    • PulsarContexts: 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static PulsarContext create() Creates and activates a new default context if none is active; otherwise returns the existing active context.
      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.
      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.
      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.
      final static PulsarContext getOrCreate()
      final static PulsarContext getOrCreate(PulsarContext context)
      final static PulsarContext getOrCreate(ApplicationContext applicationContext)
      final static PulsarContext getOrCreate(String contextLocation)
      final static PulsarSession createSession() Creates a PulsarSession using the active context (creating a default context if necessary).
      final static PulsarSession getOrCreateSession() Returns the existing PulsarSession if present, otherwise creates one using the active context (creating a default context if necessary).
      final static Unit await() Waits for all submitted URLs to be processed.
      final static Unit registerClosable(AutoCloseable closable, Integer priority) Registers a closable object with the active context.
      final static Unit shutdown() Closes all created contexts and shuts down Browser4.
      final static Unit close() Closes all created contexts and shuts down Browser4 (alias for shutdown).
      final PulsarContext getActiveContext() The active context (the most recently created context).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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

      • createSession

        @Synchronized() final static PulsarSession createSession()

        Creates a PulsarSession using the active context (creating a default context if necessary).

        Returns:

        The created session

      • getOrCreateSession

        @Synchronized() final static PulsarSession getOrCreateSession()

        Returns the existing PulsarSession if present, otherwise creates one using the active context (creating a default context if necessary).

        Returns:

        The existing or newly created session

      • await

         final static Unit await()

        Waits for all submitted URLs to be processed.

      • 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 implementing AutoCloseable
        priority - The priority for closing order