Class Application

java.lang.Object
ortus.boxlang.runtime.application.Application

public class Application extends Object
I represent an Application in BoxLang
  • Field Details

    • cacheService

      protected CacheService cacheService
      The cache service helper
  • Constructor Details

    • Application

      public Application(Key name)
      Constructor
      Parameters:
      name - The name of the application
  • Method Details

    • getClassLoaders

      public Map<String,DynamicClassLoader> getClassLoaders()
      Get the application's class loaders
      Returns:
      The class loader map
    • hasClassLoader

      public boolean hasClassLoader(String loaderKey)
      Verify if the class loader exists by cache key
      Parameters:
      loaderKey - The key of the class loader
    • getClassLoader

      public DynamicClassLoader getClassLoader(String loaderKey)
      Get a class loader by cache key
      Parameters:
      loaderKey - The key of the class loader
      Returns:
      The class loader
    • getClassLoaderCount

      public long getClassLoaderCount()
      Count how many class loaders we have loaded
    • startupClassLoaderPaths

      public void startupClassLoaderPaths(RequestBoxContext requestContext)
      Startup the class loader paths from the this.javaSettings.loadPaths
      Parameters:
      requestContext - The request context
    • getStartingListener

      public BaseApplicationListener getStartingListener()
      Get starting listener
      Returns:
      The starting listener
    • start

      public Application start(IBoxContext context)
      Start the application if not already started. The sequence of events is: 1. The application start times are recorded and the application is marked as started 2. The application listener is set 3. The class loader paths are set 4. The session storage is set 5. The application is announced to the interceptor service (onApplicationStart) 6. The application listener is called (onApplicationStart)
      Parameters:
      context - The context starting up the application
      Returns:
      The started application
    • startupAppCaches

      public void startupAppCaches(RequestBoxContext requestContext)
      Startup the application caches if any are defined in the settings of the Application.bx
       this.caches = {
          myCache = {
                      provider = "memory",
                      properties = {
                              // Cache properties
                              maxObjects = 1000,
                              // Default timeout
                              defaultTimeout = 3600,
                              // Default last access timeout
                              defaultLastAccessTimeout = 3600,
                              // Eviction policy
                              evictionPolicy = "LRU"
                 }
         }
       }
       
      Parameters:
      requestContext - The request context
    • startupAppSchedulers

      public void startupAppSchedulers(RequestBoxContext requestContext)
      Startup the application schedulers if any are defined in the settings of the Application.bx
       this.schedulers = [ "path.to.Scheduler", "another.Scheduler" ]
       
      Parameters:
      requestContext - The request context
    • buildAppCacheKey

      public Key buildAppCacheKey(Key cacheName)
      Build a cache key for the application
      Parameters:
      cacheName - The name of the cache
      Returns:
      The cache key for the application
    • getOrCreateSession

      public Session getOrCreateSession(Key ID, RequestBoxContext context)
      Get a session by ID for this application, creating if neccessary if not found
      Parameters:
      ID - The ID of the session
      context - The context of the request that is creating/getting the session
      Returns:
      The session object
    • getSessionCount

      public long getSessionCount()
      How many sessions are currently tracked
    • getSessionsCache

      public ICacheProvider getSessionsCache()
      Return the sessions cache object
      Returns:
    • getApplicationScope

      public ApplicationScope getApplicationScope()
      Get the scope for this application
      Returns:
      The scope
    • getName

      public Key getName()
      Get the name of this application
      Returns:
      The name
    • getStartTime

      public Instant getStartTime()
      Get the start time of the application
      Returns:
      the application start time, or null if not started
    • isExpired

      public boolean isExpired()
      Has this application expired. We look at the application start time and the application timeout to determine if it has expired
      Returns:
      True if the application has expired, false otherwise
    • hasStarted

      public boolean hasStarted()
      Check if the application is running
      Returns:
      True if the application is running
    • restart

      public void restart(IBoxContext context)
      Restart this application
    • shutdown

      public void shutdown(boolean force)
      Shutdown this application
      Parameters:
      force - If true, forces the shutdown of the scheduler