java.lang.Object
com.erudika.para.core.utils.Para

public final class Para extends Object
This is the main utility class and entry point. Dependency injection is initialized with the provided modules.
Author:
Alex Bogdanovski [[email protected]]
  • Field Details

  • Method Details

    • initialize

      public static void initialize()
      Executes all initialize listeners and prints logo. Call this method first.
    • destroy

      public static void destroy()
      Calls all registered listeners on exit. Call this method last.
    • getDAO

      public static DAO getDAO()
      Returns:
      an instance of the core persistence class.
      See Also:
    • getSearch

      public static Search getSearch()
      Returns:
      an instance of the core search class.
      See Also:
    • getCache

      public static Cache getCache()
      Returns:
      an instance of the core cache class.
      See Also:
    • getQueue

      public static Queue getQueue()
      Returns:
      an instance of the core queue class.
      See Also:
    • getFileStore

      public static FileStore getFileStore()
      Returns:
      an instance of the core FileStore class.
      See Also:
    • addInitListener

      public static void addInitListener(InitializeListener il)
      Registers a new initialization listener.
      Parameters:
      il - the listener
    • getInitListeners

      public static Set<InitializeListener> getInitListeners()
      Returns:
      a list of InitializeListener
    • addDestroyListener

      public static void addDestroyListener(DestroyListener dl)
      Registers a new destruction listener.
      Parameters:
      dl - the listener
    • getDestroyListeners

      public static Set<DestroyListener> getDestroyListeners()
      Returns:
      a list of DestroyListener
    • addIOListener

      public static void addIOListener(IOListener iol)
      Registers a new Para I/O listener.
      Parameters:
      iol - the listener
    • getIOListeners

      public static Set<IOListener> getIOListeners()
      Returns a list of I/O listeners (callbacks).
      Returns:
      the list of registered listeners
    • addSearchQueryListener

      public static void addSearchQueryListener(IOListener iol)
      Registers a new Para I/O listener for listening to search queries.
      Parameters:
      iol - the listener
    • getSearchQueryListeners

      public static Set<IOListener> getSearchQueryListeners()
      Returns a list of I/O listeners for search queries.
      Returns:
      the list of registered listeners for listening to search queries
    • getExecutorService

      public static ExecutorService getExecutorService()
      Returns the Para executor service.
      Returns:
      a fixed thread executor service
    • getScheduledExecutorService

      public static ScheduledExecutorService getScheduledExecutorService()
      Returns the Para scheduled executor service.
      Returns:
      a scheduled executor service
    • asyncExecute

      public static void asyncExecute(Runnable runnable)
      Executes a Runnable asynchronously.
      Parameters:
      runnable - a task
    • asyncExecutePeriodically

      public static ScheduledFuture<?> asyncExecutePeriodically(Runnable task, long delay, long interval, TimeUnit t)
      Executes a Runnable at a fixed interval, asynchronously.
      Parameters:
      task - a task
      delay - run after
      interval - run at this interval of time
      t - time unit
      Returns:
      a Future
    • createRateLimiter

      public static RateLimiter createRateLimiter(int rateLimitPerMin, int rateLimitPerHour)
      Creates a simple rate limiter.
      Parameters:
      rateLimitPerMin - rate limit per minute
      rateLimitPerHour - rate limit per hour
      Returns:
      a new rate limiter instance
    • createRateLimiter

      public static RateLimiter createRateLimiter(int rateLimitPerMin, int rateLimitPerHour, int rateLimitPerDay)
      Creates a simple rate limiter.
      Parameters:
      rateLimitPerMin - rate limit per minute
      rateLimitPerHour - rate limit per hour
      rateLimitPerDay - rate limit per day
      Returns:
      a new rate limiter instance
    • getCustomResourceHandlers

      public static List<CustomResourceHandler> getCustomResourceHandlers()
      Try loading external CustomResourceHandler classes. These will handle custom API requests. via ServiceLoader.load(java.lang.Class).
      Returns:
      a loaded list of ServletContextListener class.
    • getParaClassLoader

      public static ClassLoader getParaClassLoader()
      Returns the URLClassLoader classloader for Para. Used for loading JAR files from 'lib/*.jar'.
      Returns:
      a classloader
    • setup

      public static Map<String,String> setup()
      Creates the root application and returns the credentials for it.
      Returns:
      credentials for the root app
    • newApp

      public static Map<String,String> newApp(String appid, String name, boolean sharedTable, boolean sharedIndex)
      Creates a new application and returns the credentials for it.
      Parameters:
      appid - the app identifier
      name - the full name of the app
      sharedTable - false if the app should have its own table
      sharedIndex - false if the app should have its own index
      Returns:
      credentials for the root app
    • newApp

      public static Map<String,String> newApp(String appid, String name, String creatorid, boolean sharedTable, boolean sharedIndex)
      Creates a new application and returns the credentials for it.
      Parameters:
      appid - the app identifier
      name - the full name of the app
      creatorid - the id of the User who owns this app
      sharedTable - false if the app should have its own table
      sharedIndex - false if the app should have its own index
      Returns:
      credentials for the root app
    • printLogo

      public static void printLogo()
      Prints the Para logo to System.out.
    • getVersion

      public static String getVersion()
      The current version of Para.
      Returns:
      version string, from pom.xml
    • getConfig

      public static ParaConfig getConfig()
      Returns:
      the default Para CONF instance.