com.softwareag.cis.plugin.util
Class ApplicationContext

java.lang.Object
  extended by com.softwareag.cis.plugin.util.ApplicationContext
All Implemented Interfaces:
com.softwareag.cis.server.ISessionListener

public class ApplicationContext
extends java.lang.Object
implements com.softwareag.cis.server.ISessionListener

Provide various context information


Field Summary
static java.lang.String INIT_PARAM_GUI_CONFIG_ERROR
           
static java.lang.String INIT_PARAM_I18N
           
static java.lang.String INIT_PARAM_I18N__ID
           
static java.lang.String INIT_PARAM_I18N__RESET
           
static java.lang.String INIT_PARAM_I18N__TEST
           
static java.lang.String INIT_PARAM_INITVIEW
           
static java.lang.String INIT_PARAM_LOCALE
           
static java.lang.String INIT_PARAM_PASSWORD
           
static java.lang.String INIT_PARAM_PLUGIN
           
static java.lang.String INIT_PARAM_REFRESH_CLASSLOADER
           
static java.lang.String INIT_PARAM_STYLE
           
static java.lang.String INIT_PARAM_USER
           
 
Constructor Summary
ApplicationContext(com.softwareag.cis.server.Adapter adapter)
          Create ApplicationContext and store in session context for given adapter
ApplicationContext(java.io.File pluginsDir)
          This constructor of an ApplicationContext is used just for testing outside of a servlet / CAI context
 
Method Summary
 void acceptLogon()
          Due to the connect, some plugins may have been deactivated, e.g. because the CentraSite server had not been active.
 void addTempFile(java.lang.String tempFile)
          Register a temporary file for deletion when the session is terminated.
 void connectAll(com.softwareag.cst.util.security.Credentials credentials, CommonAdapter ca)
          Establish connection for all plug-ins contributing a ConnectionHandler
static java.util.List<java.lang.Object> createExtensionList(com.softwareag.cis.server.Adapter adapter, java.lang.String extptId, java.lang.Class<?> interfac)
          Obtain list of extension implementations for given extension point
 void disconnectAll(CommonAdapter commonAdapter)
          Disconnect all connections
 void displayLoginPage(CommonAdapter commonAdapter, boolean logoff)
           
static ApplicationContext get(com.softwareag.cis.server.Adapter adapter)
          Get ApplicationContext from session context for given adapter.
 com.softwareag.cst.util.security.Credentials getCredentials()
          Obtain credetials used for most recent attempt to login
 java.lang.String getInitParam(java.lang.String key)
          Get init parameter.
 java.util.Locale getLocale()
           
 javax.security.auth.login.LoginContext getLoginContext()
           
 java.lang.String getParameter(java.lang.String pluginId, java.lang.String name)
          Obtain value of application parameter set via "parameter" extension point
 PlugInRegistry getPlugInRegistry()
          Get the PlugInRegistry.
 PlugIn getPreferredPlugIn(boolean throwExceptionOnError)
          Get preferred plug-in (selected via optional query parameter PLUGIN=
 java.lang.String getQueryString(java.util.Map additionalQueryParms)
          Obtain query parameters passed to servlet when being started
 java.lang.String getQueryString(java.util.Map additionalQueryParms, java.util.List filter)
          Obtain query parameters passed to servlet when being started
 java.lang.String getRequestProtocol()
           
 javax.servlet.ServletContext getServletContext()
          Obtain servlet context for current web app
 javax.servlet.http.HttpServletRequest getServletRequest()
           
 com.softwareag.cis.context.ILookupContext getSessionContext()
          Obtain the Application Designer's session context
 javax.security.auth.Subject getSubject()
           
 java.lang.String getTitle()
          Get title to be used for browser window
 java.io.File getWebAppDir()
          Obtain web app directory of PluggableUI
 java.lang.String getWebAppURL()
           
 void initAll(CommonAdapter ca)
          Initialize all ConnectionHandlers
 void loadLoginPage(CommonAdapter commonAdapter)
          Deprecated. - please use displayLoginPage()
 void notifyConnectedAll(CommonAdapter ba)
          Notify connected to all ConnectionHandlers.
 void reactOnSessionDestroyed()
          Clean-up (connections, temp files) on session destroy.
 void removeInitParam(java.lang.String name)
          Remove init/query parameter e.g. after it has been processed as part of a deep link in order to avoid that it occurs in a secondary deep link.
 void setInitParamMap(com.softwareag.cis.server.Adapter adapter)
          Sets a map of init parameters for the current application context.
 void setLocale(java.util.Locale locale)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INIT_PARAM_USER

public static final java.lang.String INIT_PARAM_USER
See Also:
Constant Field Values

INIT_PARAM_PASSWORD

public static final java.lang.String INIT_PARAM_PASSWORD
See Also:
Constant Field Values

INIT_PARAM_INITVIEW

public static final java.lang.String INIT_PARAM_INITVIEW
See Also:
Constant Field Values

INIT_PARAM_GUI_CONFIG_ERROR

public static final java.lang.String INIT_PARAM_GUI_CONFIG_ERROR
See Also:
Constant Field Values

INIT_PARAM_STYLE

public static final java.lang.String INIT_PARAM_STYLE
See Also:
Constant Field Values

INIT_PARAM_LOCALE

public static final java.lang.String INIT_PARAM_LOCALE
See Also:
Constant Field Values

INIT_PARAM_REFRESH_CLASSLOADER

public static final java.lang.String INIT_PARAM_REFRESH_CLASSLOADER
See Also:
Constant Field Values

INIT_PARAM_I18N

public static final java.lang.String INIT_PARAM_I18N
See Also:
Constant Field Values

INIT_PARAM_I18N__TEST

public static final java.lang.String INIT_PARAM_I18N__TEST
See Also:
Constant Field Values

INIT_PARAM_I18N__RESET

public static final java.lang.String INIT_PARAM_I18N__RESET
See Also:
Constant Field Values

INIT_PARAM_I18N__ID

public static final java.lang.String INIT_PARAM_I18N__ID
See Also:
Constant Field Values

INIT_PARAM_PLUGIN

public static final java.lang.String INIT_PARAM_PLUGIN
See Also:
Constant Field Values
Constructor Detail

ApplicationContext

public ApplicationContext(com.softwareag.cis.server.Adapter adapter)
Create ApplicationContext and store in session context for given adapter


ApplicationContext

public ApplicationContext(java.io.File pluginsDir)
This constructor of an ApplicationContext is used just for testing outside of a servlet / CAI context

Method Detail

getRequestProtocol

public java.lang.String getRequestProtocol()

getSessionContext

public com.softwareag.cis.context.ILookupContext getSessionContext()
Obtain the Application Designer's session context

Returns:
the session-specific lookup context

getPreferredPlugIn

public PlugIn getPreferredPlugIn(boolean throwExceptionOnError)
Get preferred plug-in (selected via optional query parameter PLUGIN=

Parameters:
throwExceptionOnError - if true, an exception shall be thrown, if the id of an unknown plug-in had been given
Returns:
the preferred plug-in. if not set (missing URL parameter) then Control plug-in is returned. If Control plug-in is not available then null is returned.

setInitParamMap

public void setInitParamMap(com.softwareag.cis.server.Adapter adapter)
Sets a map of init parameters for the current application context.

Parameters:
adapter - Used for obtaining init parameters.

getInitParam

public java.lang.String getInitParam(java.lang.String key)
Get init parameter. Backward compatibility if key has plug-in-prefix, try with local name as well.


removeInitParam

public void removeInitParam(java.lang.String name)
Remove init/query parameter e.g. after it has been processed as part of a deep link in order to avoid that it occurs in a secondary deep link.

Parameters:
name - name of init parameter to be removed

getWebAppDir

public java.io.File getWebAppDir()
Obtain web app directory of PluggableUI

Returns:
the File object representing the directory

getWebAppURL

public java.lang.String getWebAppURL()
Returns:
PluggableUI web application URL.

getServletContext

public javax.servlet.ServletContext getServletContext()
Obtain servlet context for current web app

Returns:
the ServletContext

getLocale

public java.util.Locale getLocale()

setLocale

public void setLocale(java.util.Locale locale)

get

public static ApplicationContext get(com.softwareag.cis.server.Adapter adapter)
Get ApplicationContext from session context for given adapter.

Parameters:
adapter - Used to obtain the session context.

getPlugInRegistry

public PlugInRegistry getPlugInRegistry()
Get the PlugInRegistry.

Returns:
the PlugInRegistry

createExtensionList

public static java.util.List<java.lang.Object> createExtensionList(com.softwareag.cis.server.Adapter adapter,
                                                                   java.lang.String extptId,
                                                                   java.lang.Class<?> interfac)
Obtain list of extension implementations for given extension point

Parameters:
adapter - the adapter used to obtain application context and for error reporting
extptId - qualified id of extension point
interfac - the interface or class which must be implemented or extended by all extensions of given extension point
Returns:
the list of extension

initAll

public void initAll(CommonAdapter ca)
             throws java.lang.Exception
Initialize all ConnectionHandlers

Parameters:
ca - The CommonAdapter providing e.g. a session context.
Throws:
java.lang.Exception

connectAll

public void connectAll(com.softwareag.cst.util.security.Credentials credentials,
                       CommonAdapter ca)
                throws java.lang.Exception
Establish connection for all plug-ins contributing a ConnectionHandler

Throws:
java.lang.Exception

acceptLogon

public void acceptLogon()
Due to the connect, some plugins may have been deactivated, e.g. because the CentraSite server had not been active. We do only continue, if one of the following is true: - the "pluggableUI" is the preferred plugin - there is at least one other plug-in left

Throws:
java.lang.IllegalStateException - if the above is not fulfilled.

notifyConnectedAll

public void notifyConnectedAll(CommonAdapter ba)
                        throws java.lang.Exception
Notify connected to all ConnectionHandlers.

Parameters:
ba - the CommonAdapter adapter being active while the connection is being established
Throws:
java.lang.Exception

disconnectAll

public void disconnectAll(CommonAdapter commonAdapter)
Disconnect all connections


displayLoginPage

public void displayLoginPage(CommonAdapter commonAdapter,
                             boolean logoff)

loadLoginPage

public void loadLoginPage(CommonAdapter commonAdapter)
Deprecated. - please use displayLoginPage()


getQueryString

public java.lang.String getQueryString(java.util.Map additionalQueryParms)
Obtain query parameters passed to servlet when being started

Returns:
the query parameters with leading "?" and delimited by '&' and URL encoded

getQueryString

public java.lang.String getQueryString(java.util.Map additionalQueryParms,
                                       java.util.List filter)
Obtain query parameters passed to servlet when being started

Parameters:
filter - List of query param keys to be excluded from the final query string.
Returns:
the query parameters with leading "?" and delimited by '&' and URL encoded

getCredentials

public com.softwareag.cst.util.security.Credentials getCredentials()
Obtain credetials used for most recent attempt to login

Returns:
the Credentials used to establish the current session

getSubject

public javax.security.auth.Subject getSubject()
Returns:
JAAS Subject for current session or null if such is not present (e.g. browse as guest)

getLoginContext

public javax.security.auth.login.LoginContext getLoginContext()

getParameter

public java.lang.String getParameter(java.lang.String pluginId,
                                     java.lang.String name)
Obtain value of application parameter set via "parameter" extension point

Parameters:
name -
Returns:
value of parameter if known or null if unknown

addTempFile

public void addTempFile(java.lang.String tempFile)
Register a temporary file for deletion when the session is terminated.


getServletRequest

public javax.servlet.http.HttpServletRequest getServletRequest()

reactOnSessionDestroyed

public void reactOnSessionDestroyed()
Clean-up (connections, temp files) on session destroy.

Specified by:
reactOnSessionDestroyed in interface com.softwareag.cis.server.ISessionListener
See Also:
ISessionListener.reactOnSessionDestroyed()

getTitle

public java.lang.String getTitle()
Get title to be used for browser window

Returns:
the title - must be localized if applicable