Package org.intermine.web.context
Class InterMineContext
- java.lang.Object
-
- org.intermine.web.context.InterMineContext
-
- All Implemented Interfaces:
Shutdownable
public final class InterMineContext extends java.lang.Object implements Shutdownable
A context object that doesn't require the session. TODO: use injection instead.- Author:
- rns
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
doShutdown()
Send the signal that shutdown is happening - try and release resources.static java.lang.Object
getAttribute(java.lang.String name)
Get the value of a stored attribute.static InterMineAPI
getInterMineAPI()
static java.security.KeyStore
getKeyStore()
static WebConfig
getWebConfig()
static java.util.Properties
getWebProperties()
static void
initialise(InterMineAPI imApi, java.util.Properties webProps, WebConfig wc, ResourceOpener resourceOpener)
Set up the Context with everything it needs.static boolean
queueMessage(MailAction action)
Queue up a message to an emailer.static void
setAttribute(java.lang.String name, java.lang.Object value)
Set an attribute of the context.void
shutdown()
Send the signal that shutdown is happening - try and release resources.
-
-
-
Method Detail
-
initialise
public static void initialise(InterMineAPI imApi, java.util.Properties webProps, WebConfig wc, ResourceOpener resourceOpener)
Set up the Context with everything it needs.- Parameters:
imApi
- The application state.webProps
- The application properties.wc
- The application configuration.resourceOpener
- Something to use to open resources.
-
getInterMineAPI
public static InterMineAPI getInterMineAPI()
- Returns:
- The InterMine state object.
-
getWebConfig
public static WebConfig getWebConfig()
- Returns:
- The structured application configuration.
-
getWebProperties
public static java.util.Properties getWebProperties()
- Returns:
- The configured properties of the application.
-
getAttribute
public static java.lang.Object getAttribute(java.lang.String name)
Get the value of a stored attribute.- Parameters:
name
- The name to look up.- Returns:
- The value of the attribute (may be null).
-
setAttribute
public static void setAttribute(java.lang.String name, java.lang.Object value)
Set an attribute of the context.- Parameters:
name
- The name of teh attribute to store.value
- The value of the attribute to store.
-
queueMessage
public static boolean queueMessage(MailAction action)
Queue up a message to an emailer.- Parameters:
action
- The thing that wants to send an email.- Returns:
- Whether the action was successfully queued up.
-
shutdown
public void shutdown()
Send the signal that shutdown is happening - try and release resources.- Specified by:
shutdown
in interfaceShutdownable
-
doShutdown
public static void doShutdown()
Send the signal that shutdown is happening - try and release resources. This class registers with ShutdownHook on construction, this method is called automatically on JVM shutdown and by InitialiserPlugin which calls ShutdownHook.shutdown() explicitly when a webapp is undeployed.
-
getKeyStore
public static java.security.KeyStore getKeyStore() throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
- Returns:
- A key-store containing the keys we trust.
- Throws:
java.security.KeyStoreException
- If this platform doesn't support JKS.java.security.NoSuchAlgorithmException
- If keys are stored with algos we don't know how to use.java.security.cert.CertificateException
- If the certificate is wonky.java.io.IOException
- If we can't even access the file-system.
-
-