Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle ADF Share
11g Release 1 (11.1.1)

E10686-03


oracle.adf.share
Class ADFContext

java.lang.Object
  extended by oracle.adf.share.ADFContext

Direct Known Subclasses:
DefaultContext, DefaultNamedContext, ServletADFContext

public abstract class ADFContext
extends java.lang.Object

The execution context for an ADF application


Field Summary
static java.lang.String ADF_PROPERTY_NS
           
static java.lang.String ADF_SESSIONDEF_PACKAGES
           
static java.lang.String APPLICATION_DATA_KEY
           
static java.lang.String APPLICATION_DATA_SEP
           
protected static java.lang.String APPLICATION_NAME_SCOPE_KEY
           
static java.lang.String APPLICATION_SCOPE
           
static java.lang.String APPLICATION_UID
           
static java.lang.String ATTRIBUTE_FORMATTER_MAP_KEY
           
static java.lang.String CONNECTIONS_RESOURCE
           
static java.lang.String MDS_CC_VALUES_FOR_EDIT
           
static java.lang.String MDS_PARTITION_APPID
           
static java.lang.String MDS_SESSION_OPTIONS_FACTORY
           
static java.lang.String NAMED_CONTEXT_ENV
           
static java.lang.String PERSDEF_BASE_PACKAGE
           
static java.lang.String REQUEST_SCOPE
           
static java.lang.String SESSION_SCOPE
           
static java.lang.String SESSIONDEF_BASE_PACKAGE
           
static int TYPE_GENERIC
           
static int TYPE_HTTP
           
static int TYPE_NAMED
           
static int TYPE_PORTLET
           
static java.lang.String USE_ROLE_BASED_CUST_CLASS
           
static java.lang.String USER_CUST_CLASSES
           
static java.lang.String VIEW_SCOPE
           

 

Constructor Summary
protected ADFContext()
           

 

Method Summary
 void clearCachedLocale()
          Clears the cached locale for the context and it's Enviroment (if any).
 java.util.Map createScope(java.lang.String name)
          May be implemented by custom ADFContext classes to create a scope for the specfied name.
protected  java.util.Map<java.lang.String,java.lang.Object> createScope(java.lang.String name, boolean concurrent)
           
protected  java.util.Map<java.lang.String,java.lang.Object> findApplicationScopeMap()
           
 java.util.Map<java.lang.String,java.lang.Object> findScope(java.lang.String name)
          Retrieve a scope from the ADFContext.
static ADFContext get(java.lang.String name)
          This method will be used by callers that have already associated a named context using registerNamedContext method.
 java.lang.String getADFApplicationUID()
          This method will help to get application UID for the JPS unqiue map name to resolve BUG5985198
 ADFConfig getADFConfig()
          Gets the ADF configuration Object used by current thread.
 ADFConfigEx getADFConfigEx()
           
 java.lang.String getADFContextProperty(java.lang.String propName)
          This method will help find all ADFContext nodes in adf-config.xml and return property value based on the name
 java.util.Map<java.lang.String,java.lang.Object> getADFFacesViewScopeMap()
           
 ADFSettings getADFSettings()
          Gets the ADF Settings Object used by current thread.
 ADFConfig getApplication()
          Deprecated. Use getADFConfig() instead.
 java.lang.String getApplicationName()
          Gets the Application Name.
 java.util.Map<java.lang.String,java.lang.Object> getApplicationScope()
          A convenience method for the standard applicationScope.
protected  java.lang.Object getApplicationScopekey()
          The application scope as defined by the ADFContext environment in which the application is being used.
protected  java.util.Map<java.lang.String,java.lang.Object> getApplicationScopeMap()
           
 javax.naming.Context getConfigSecurityContext()
          Gets the security context for the current thread
 javax.naming.Context getConnectionsContext()
          Convenience for accessing the adf jndi context, for managing adf connection definitions.
abstract  int getContextType()
          Returns a type for the context instance.
static ADFContext getCurrent()
          Gets the ADF context for the current thread
protected  java.lang.String getDeployedAppName()
          This method should be overriden in sublclasses so that the appropriate application name is returned.
 java.lang.String getEnterpriseId()
           
 Environment getEnvironment()
           
 ADFExpressionEvaluator getExpressionEvaluator()
           
 java.util.Locale getLocale()
           
protected  ADFContextMDSConfigHelper getMDSConfigHelper()
           
 java.lang.Object getMDSInstanceAsObject()
           
 java.lang.String getMDSLogin()
           
 java.lang.Object getMDSSessionAsObject()
          Get the MDS session associated with this context.
 java.util.Map getRequestScope()
          A convenience method for the standard requestScope.
 java.util.Map<java.lang.String,java.lang.Object> getScope(java.lang.String name)
          Retrieve a scope from the ADFContext.
 java.util.Set getScopeNames()
          Returns the names of all the scopes that are supported by the current ADFContext.
 SecurityContext getSecurityContext()
          Gets the security context for the current thread
 java.util.List getSessionDefPackages()
           
 java.util.Map getSessionScope()
          A convenience method for the standard sessionScope.
 java.lang.Object getSkipLevelIdentifier()
          To be used by DataControls and Bindings to identify a particular slot as skipped in the keypath datastructure.
 java.util.Map getStateManager(java.lang.String scopeName, java.util.Hashtable env)
          Returns a StateManagerScopeAdapter for the specified scope.
static java.lang.Object getThreadLocalValue(java.lang.Object key)
           
 java.net.URL getURL()
          This method can be overridden by subclasses that have a specific instance of adf-config.xml document associated with it.
 javax.servlet.jsp.el.VariableResolver getVariableResolver()
          Returns a variable resolver for this context.
 java.util.Map<java.lang.String,java.lang.Object> getViewScope()
          This method delegates the supporting technology such as Faces or Trinidad to provide the installed View Scope.
static boolean hasCurrent()
          Check if the thread local already has ADFContext set.
 boolean hasEnvironment()
           
 boolean hasMDSSession()
          Determine if there is a MDS session associated with this context
 boolean hasSecurityContext()
          Determine if there is a SecurityContext associated with this context
 boolean hasSession()
          Checks the environment to see if this ADFContext references a native session.
static ADFContext initADFContext(java.lang.Object context, java.lang.Object session, java.lang.Object request, java.lang.Object response)
          Initializes the ADFContext for the environment of the specified context.
 boolean isDesignTime()
          This method will try to determine if the operating environment is Design Time.
 boolean isHttpContext()
          Returns true if the ADFContext is running in an http container.
 boolean isJEE()
          Returns true if executed in a JEE Container.
static boolean isNamedContextRegistered(java.lang.String name)
          This method can be used to check if a NamedContext already exists for the provided name.
protected abstract  Environment loadEnvironment()
           
protected  SecurityContext loadSecurityContext()
           
protected  void putApplicationScopeMap(java.util.Map<java.lang.String,java.lang.Object> scope)
          The application scope as defined by the ADFContext environment in which the application is being used.
 void putScope(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> scope)
          Add a scope to the ADFContext.
static void registerNamedContext(java.lang.String name, java.net.URL url)
           
static void registerNamedContext(java.lang.String name, java.net.URL url, java.lang.Class implClass)
          This method provides the ability to create a named ADFContext by specifying the url of the adf-config.xml file from which this ADFContext will provide the callers configuration information.
 void releaseMDSInstance()
           
 void releaseMDSSession()
          Provides api for releasing the MDS session
 void removeAsCurrent()
          Disassociates this context from the current thread.
 java.util.Map<java.lang.String,java.lang.Object> removeScope(java.lang.String name)
          Remove a scope from the ADFContext.
static java.lang.Object removeThreadLocalValue(java.lang.Object key)
           
static void resetADFContext(ADFContext ctx)
          Restore the ADFContext to the value before initADFContext was invoked.
 void setAsCurrent()
          Sets up this context as the current context.
 void setEnterpriseId(java.lang.String eid)
           
 void setExpressionEvaluator(ADFExpressionEvaluator expressionEvaluator)
           
 void setLocale(java.util.Locale locale)
          Set a locale for the context.
 void setMDSLogin(java.lang.String loginStr)
           
 void setSecurityContext(SecurityContext ctx)
          Internal: Applications should not use this method.
static void setThreadLocalValue(java.lang.Object key, java.lang.Object value)
           
 void setVariableResolver(javax.servlet.jsp.el.VariableResolver variableResolver)
           
static void unregisterNamedContext(java.lang.String name)
           

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

TYPE_GENERIC

public static final int TYPE_GENERIC
See Also:
Constant Field Values

TYPE_HTTP

public static final int TYPE_HTTP
See Also:
Constant Field Values

TYPE_PORTLET

public static final int TYPE_PORTLET
See Also:
Constant Field Values

TYPE_NAMED

public static final int TYPE_NAMED
See Also:
Constant Field Values

MDS_PARTITION_APPID

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

MDS_SESSION_OPTIONS_FACTORY

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

SESSION_SCOPE

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

REQUEST_SCOPE

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

APPLICATION_SCOPE

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

VIEW_SCOPE

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

SESSIONDEF_BASE_PACKAGE

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

PERSDEF_BASE_PACKAGE

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

NAMED_CONTEXT_ENV

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

USE_ROLE_BASED_CUST_CLASS

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

USER_CUST_CLASSES

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

ADF_SESSIONDEF_PACKAGES

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

MDS_CC_VALUES_FOR_EDIT

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

APPLICATION_DATA_KEY

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

APPLICATION_DATA_SEP

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

APPLICATION_NAME_SCOPE_KEY

protected static final java.lang.String APPLICATION_NAME_SCOPE_KEY
See Also:
Constant Field Values

CONNECTIONS_RESOURCE

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

ADF_PROPERTY_NS

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

APPLICATION_UID

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

ATTRIBUTE_FORMATTER_MAP_KEY

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

Constructor Detail

ADFContext

protected ADFContext()

Method Detail

loadEnvironment

protected abstract Environment loadEnvironment()

putScope

public void putScope(java.lang.String name,
                     java.util.Map<java.lang.String,java.lang.Object> scope)
Add a scope to the ADFContext.

Scopes may be used by ADF applications to store application state. For example, the following code could be used to store an application state in the sessionScope:

Map sessionScope = ADFContext.getCurrent().getSessionScope().put(<stateId>, <state>);

ADF supports three standard scopes: applicationScope, sessionScope, and requestScope. The lifecycles of these scopes are defined in the ADFScopes documentation and may depend upon the ADFContext's environment. For example, the lifecycle of the sessionScope may be different in a servlet container than it would be in an EJB container or in a java application.

This method may be used by applications that wish to define custom scopes. If an application has defined a custom scope then it is the application's responsibility to manage the lifecycle of that custom scope.

Please note that a custom scope's lifecycle cannot exceed that of the ADFContext itself -- once the ADFContext goes out of scope then all custom scopes will also go out of scope. Applications that require a custom scope with a lifecycle greater than the ADFContext's must manage those custom scopes elsewhere and associate them with each ADFContext object as it comes into scope.

For example, in a servlet container the ADFContext has request level scope -- once request processing ends the ADFContext object will go out of scope. However, the sessionScope must have a scope that spans multiple requests. ADF solves this issue by associating the session scope to the ADFContext each time the ADFContext is created.

Parameters:
name - the name of the scope. Scope names should implement the pattern <scopeType>Scope. The session, request, and application scope types are reserved for use by ADF and should not be used by applications.
scope - the scope implementation. All scope implementations must implement the java.util.Map interface.

isDesignTime

public boolean isDesignTime()
This method will try to determine if the operating environment is Design Time.

getScope

public java.util.Map<java.lang.String,java.lang.Object> getScope(java.lang.String name)
Retrieve a scope from the ADFContext.

See putScope(String,Map) for more information about scopes.

Parameters:
name - the scope name.
Returns:
the scope implementation.

findScope

public java.util.Map<java.lang.String,java.lang.Object> findScope(java.lang.String name)
Retrieve a scope from the ADFContext. This will not create the scope if it does not exist.
Parameters:
name - the scope name.
Returns:
the scope implementation. null if the scope is not found.

getApplicationScopekey

protected java.lang.Object getApplicationScopekey()
The application scope as defined by the ADFContext environment in which the application is being used. For instance the ApplicationScope is the ServletContextListener in case of a web application.
Returns:
the key that defines the application scope.

putApplicationScopeMap

protected void putApplicationScopeMap(java.util.Map<java.lang.String,java.lang.Object> scope)
The application scope as defined by the ADFContext environment in which the application is being used. This should be overriden to manage the lifecycle as defined in that ADFContext. The aim of this method is to cache the application scope, this may not be necessary in a ServletEnvironment.
Parameters:
scope - - The application scope.

getApplicationScopeMap

protected java.util.Map<java.lang.String,java.lang.Object> getApplicationScopeMap()

findApplicationScopeMap

protected java.util.Map<java.lang.String,java.lang.Object> findApplicationScopeMap()

getViewScope

public java.util.Map<java.lang.String,java.lang.Object> getViewScope()
This method delegates the supporting technology such as Faces or Trinidad to provide the installed View Scope. No default implementation is provided, if there is no supporting technology is available an exception will be thrown.

getADFFacesViewScopeMap

public java.util.Map<java.lang.String,java.lang.Object> getADFFacesViewScopeMap()

createScope

public java.util.Map createScope(java.lang.String name)
May be implemented by custom ADFContext classes to create a scope for the specfied name.

getScope(String) will invoke this method if the specified scope has not already been associated with the current ADFContext. The new scope will be associated with the context until removed or until the context is destroyed.


createScope

protected java.util.Map<java.lang.String,java.lang.Object> createScope(java.lang.String name,
                                                                       boolean concurrent)

removeScope

public java.util.Map<java.lang.String,java.lang.Object> removeScope(java.lang.String name)
Remove a scope from the ADFContext.

See putScope(String,Map) for more information about scopes.

Parameters:
name - the scope name.
Returns:
the scope implementation. null if the scope is not found.

getScopeNames

public java.util.Set getScopeNames()
Returns the names of all the scopes that are supported by the current ADFContext.

See putScope(String,Map) for more information about scopes. returns a set of scope names.


getApplicationScope

public java.util.Map<java.lang.String,java.lang.Object> getApplicationScope()
A convenience method for the standard applicationScope. This method name uses JavaBean naming patterns so that it may be used by JavaBean toolsets.

Equivalent to invoking getScope(APPLICATION_SCOPE).

Returns:
the standard application scope.

getSessionScope

public java.util.Map getSessionScope()
A convenience method for the standard sessionScope. This method name uses JavaBean naming patterns so that it may be used by JavaBean toolsets.

Equivalent to invoking getScope(SESSION_SCOPE).

Returns:
the standard session scope.

getRequestScope

public java.util.Map getRequestScope()
A convenience method for the standard requestScope. This method name uses JavaBean naming patterns so that it may be used by JavaBean toolsets.

Equivalent to invoking getScope(REQUEST_SCOPE).

Returns:
the standard request scope.

getApplication

public ADFConfig getApplication()
Deprecated. Use getADFConfig() instead.
Gets the ADF configuration Object used by current thread.

getADFConfig

public ADFConfig getADFConfig()
Gets the ADF configuration Object used by current thread.

getEnterpriseId

public java.lang.String getEnterpriseId()

setEnterpriseId

public void setEnterpriseId(java.lang.String eid)

getADFConfigEx

public ADFConfigEx getADFConfigEx()

getADFSettings

public ADFSettings getADFSettings()
Gets the ADF Settings Object used by current thread.

getSecurityContext

public SecurityContext getSecurityContext()
Gets the security context for the current thread

hasSecurityContext

public boolean hasSecurityContext()
Determine if there is a SecurityContext associated with this context
Returns:
True if a Security Context was created for this context, otherwise false

getConnectionsContext

public javax.naming.Context getConnectionsContext()
                                           throws javax.naming.NamingException
Convenience for accessing the adf jndi context, for managing adf connection definitions.
Throws:
javax.naming.NamingException

hasCurrent

public static boolean hasCurrent()
Check if the thread local already has ADFContext set.

getCurrent

public static ADFContext getCurrent()
Gets the ADF context for the current thread

getADFContextProperty

public java.lang.String getADFContextProperty(java.lang.String propName)
This method will help find all ADFContext nodes in adf-config.xml and return property value based on the name
Parameters:
propName - the property name, like "adfAppUID"
Returns:

getADFApplicationUID

public java.lang.String getADFApplicationUID()
This method will help to get application UID for the JPS unqiue map name to resolve BUG5985198
Returns:

registerNamedContext

public static void registerNamedContext(java.lang.String name,
                                        java.net.URL url,
                                        java.lang.Class implClass)
                                 throws javax.naming.NameAlreadyBoundException
This method provides the ability to create a named ADFContext by specifying the url of the adf-config.xml file from which this ADFContext will provide the callers configuration information. This API is typically to be used when using the default ADFContext in the context of a running application is not a choice because of the use of ThreadContext store. An example of usage for this can be at design time, when the application being developed in IDE is not running but needs access to its application specific configuration. It can't use the default ADFContext because it won't be application specific instead it will be specific to IDE, that's where the application can use this method.
Parameters:
name - - The name to be given to this Context.
url - - The string representing the URL to the adf-config.xml file to be associated with this named context.
implClass - - concrete class for the context implementation
Throws:
javax.naming.NameAlreadyBoundException - - thrown if a context with the contextInfos already exists

registerNamedContext

public static void registerNamedContext(java.lang.String name,
                                        java.net.URL url)
                                 throws javax.naming.NameAlreadyBoundException
Throws:
javax.naming.NameAlreadyBoundException

unregisterNamedContext

public static void unregisterNamedContext(java.lang.String name)
Parameters:
name - of the namedContext that is registered with ADFContext Unregister the Named Context if it is registered.

isNamedContextRegistered

public static boolean isNamedContextRegistered(java.lang.String name)
This method can be used to check if a NamedContext already exists for the provided name.
Parameters:
name - of the registered context

get

public static ADFContext get(java.lang.String name)
                      throws java.lang.Exception
This method will be used by callers that have already associated a named context using registerNamedContext method.
Parameters:
name - - The name of the context for which ADFContext is to be returned
Returns:
ADFContext - The ADF Context created for the contextInfos
Throws:
java.lang.Exception - - If a contextInfos for this name was not already created
See Also:
registerNamedContext

getURL

public java.net.URL getURL()
This method can be overridden by subclasses that have a specific instance of adf-config.xml document associated with it. This method will be overridden by Named ADF Context

getApplicationName

public java.lang.String getApplicationName()
Gets the Application Name. This will be over ridden by subclasses that can return a meaningful application name such as in the case of a deployed application.

getDeployedAppName

protected java.lang.String getDeployedAppName()
This method should be overriden in sublclasses so that the appropriate application name is returned. Default is null.
Returns:
the deployed application name.

setAsCurrent

public void setAsCurrent()
Sets up this context as the current context. This is required for multi-threaded environment such as an application server, where a thread pool is used. Should be called to associate this context to the thread retrieved from the pool.

removeAsCurrent

public void removeAsCurrent()
Disassociates this context from the current thread.

setSecurityContext

public void setSecurityContext(SecurityContext ctx)
Internal: Applications should not use this method.

getMDSLogin

public java.lang.String getMDSLogin()

setMDSLogin

public void setMDSLogin(java.lang.String loginStr)

loadSecurityContext

protected SecurityContext loadSecurityContext()

getConfigSecurityContext

public javax.naming.Context getConfigSecurityContext()
                                              throws javax.naming.NamingException
Gets the security context for the current thread
Throws:
javax.naming.NamingException

getLocale

public java.util.Locale getLocale()

setLocale

public void setLocale(java.util.Locale locale)
Set a locale for the context. This locale will only be returned if an environment has not been defined for the ADFContext. The environment may not be defined if the ADFContext is acquired from a java application.

clearCachedLocale

public void clearCachedLocale()
Clears the cached locale for the context and it's Enviroment (if any).

getEnvironment

public final Environment getEnvironment()

hasEnvironment

public boolean hasEnvironment()

getVariableResolver

public javax.servlet.jsp.el.VariableResolver getVariableResolver()
Returns a variable resolver for this context.

The VariableResolver will be used whenever evaluating expressions that will be evaluated by the ADFContext expression evaluator.


setVariableResolver

public void setVariableResolver(javax.servlet.jsp.el.VariableResolver variableResolver)

getExpressionEvaluator

public ADFExpressionEvaluator getExpressionEvaluator()

setExpressionEvaluator

public void setExpressionEvaluator(ADFExpressionEvaluator expressionEvaluator)

getStateManager

public java.util.Map getStateManager(java.lang.String scopeName,
                                     java.util.Hashtable env)
Returns a StateManagerScopeAdapter for the specified scope.

isJEE

public boolean isJEE()
Returns true if executed in a JEE Container.

getContextType

public abstract int getContextType()
Returns a type for the context instance. Current types include: