Class Para
java.lang.Object
com.erudika.para.core.utils.Para
This is the main Para utility class and entry point.
- Author:
- Alex Bogdanovski [[email protected]]
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidRegisters a new destruction listener.static voidRegisters a new initialization listener.static voidaddIOListener(IOListener iol) Registers a new Para I/O listener.static voidRegisters a new Para I/O listener for listening to search queries.static voidasyncExecute(Runnable runnable) Executes aRunnableasynchronously.static ScheduledFuture<?> asyncExecutePeriodically(Runnable task, long delay, long interval, TimeUnit t) Executes aRunnableat a fixed interval, asynchronously.static RateLimitercreateRateLimiter(int rateLimitPerMin, int rateLimitPerHour) Creates a simple rate limiter.static RateLimitercreateRateLimiter(int rateLimitPerMin, int rateLimitPerHour, int rateLimitPerDay) Creates a simple rate limiter.static voiddestroy()Calls all registered listeners on exit.static CachegetCache()Returns an instance of the core cache class.static ParaConfigReturns the default Para CONF instance.static List<CustomResourceHandler> Try loading externalCustomResourceHandlerclasses.static DAOgetDAO()Returns an instance of the core persistence class.static Set<DestroyListener> Returns a list ofDestroyListener.static EmailerReturns an instance of the core Emailer class.static ExecutorServiceReturns the Para executor service.static FileStoreReturns an instance of the core FileStore class.static Set<InitializeListener> Returns a list ofInitializeListener.static Set<IOListener> Returns a list of I/O listeners (callbacks).static ClassLoaderReturns theURLClassLoaderclassloader for Para.static QueuegetQueue()Returns an instance of the core queue class.static StringThe current Git revision of Para.static ScheduledExecutorServiceReturns the Para scheduled executor service.static SearchReturns an instance of the core search class.static Set<IOListener> Returns a list of I/O listeners for search queries.static StringThe current version of Para.static voidExecutes all initialize listeners and prints logo.static booleanThe health status of the server.Creates a new application and returns the credentials for it.Creates a new application and returns the credentials for it.static voidregisterCoreClasses(Set<Class<? extends ParaObject>> classes) Explicitly registers core classes for reflection.static voidsetHealthy(boolean isHealthy) Sets the health status of the server.setup()Creates the root application and returns the credentials for it.
-
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
Returns an instance of the core persistence class.- Returns:
- an instance of the core persistence class.
- See Also:
-
getSearch
Returns an instance of the core search class.- Returns:
- an instance of the core search class.
- See Also:
-
getCache
Returns an instance of the core cache class.- Returns:
- an instance of the core cache class.
- See Also:
-
getQueue
Returns an instance of the core queue class.- Returns:
- an instance of the core queue class.
- See Also:
-
getFileStore
Returns an instance of the core FileStore class.- Returns:
- an instance of the core FileStore class.
- See Also:
-
getEmailer
Returns an instance of the core Emailer class.- Returns:
- an instance of the core Emailer class.
- See Also:
-
addInitListener
Registers a new initialization listener.- Parameters:
il- the listener
-
getInitListeners
Returns a list ofInitializeListener.- Returns:
- a list of
InitializeListener
-
addDestroyListener
Registers a new destruction listener.- Parameters:
dl- the listener
-
getDestroyListeners
Returns a list ofDestroyListener.- Returns:
- a list of
DestroyListener
-
addIOListener
Registers a new Para I/O listener.- Parameters:
iol- the listener
-
getIOListeners
Returns a list of I/O listeners (callbacks).- Returns:
- the list of registered listeners
-
addSearchQueryListener
Registers a new Para I/O listener for listening to search queries.- Parameters:
iol- the listener
-
getSearchQueryListeners
Returns a list of I/O listeners for search queries.- Returns:
- the list of registered listeners for listening to search queries
-
getExecutorService
Returns the Para executor service.- Returns:
- a fixed thread executor service
-
getScheduledExecutorService
Returns the Para scheduled executor service.- Returns:
- a scheduled executor service
-
isHealthy
public static boolean isHealthy()The health status of the server.- Returns:
- true if healthy.
-
setHealthy
public static void setHealthy(boolean isHealthy) Sets the health status of the server.- Parameters:
isHealthy- status
-
asyncExecute
-
asyncExecutePeriodically
public static ScheduledFuture<?> asyncExecutePeriodically(Runnable task, long delay, long interval, TimeUnit t) Executes aRunnableat a fixed interval, asynchronously.- Parameters:
task- a taskdelay- run afterinterval- run at this interval of timet- time unit- Returns:
- a Future
-
createRateLimiter
Creates a simple rate limiter.- Parameters:
rateLimitPerMin- rate limit per minuterateLimitPerHour- 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 minuterateLimitPerHour- rate limit per hourrateLimitPerDay- rate limit per day- Returns:
- a new rate limiter instance
-
getCustomResourceHandlers
Try loading externalCustomResourceHandlerclasses. These will handle custom API requests. viaServiceLoader.load(java.lang.Class).- Returns:
- a loaded list of ServletContextListener class.
-
getParaClassLoader
Returns theURLClassLoaderclassloader for Para. Used for loading JAR files from 'lib/*.jar'.- Returns:
- a classloader
-
registerCoreClasses
Explicitly registers core classes for reflection.- Parameters:
classes- a list of classes
-
setup
-
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 identifiername- the full name of the appsharedTable- false if the app should have its own tablesharedIndex- 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 identifiername- the full name of the appcreatorid- the id of theUserwho owns this appsharedTable- false if the app should have its own tablesharedIndex- false if the app should have its own index- Returns:
- credentials for the root app
-
getVersion
The current version of Para.- Returns:
- version string, from pom.xml
-
getRevision
-
getConfig
Returns the default Para CONF instance.- Returns:
- the default Para CONF instance.
-