info.magnolia.context
Class AbstractContext

java.lang.Object
  extended by info.magnolia.context.AbstractContext
All Implemented Interfaces:
java.io.Serializable, java.util.Map, org.apache.commons.chain.Context
Direct Known Subclasses:
AbstractMapBasedContext, AbstractSystemContext, ContextDecorator, UserContextImpl

public abstract class AbstractContext
extends java.lang.Object
implements Context, java.io.Serializable

Default implementation of the Context interface.

Version:
$Revision: 36506 $ ($Author: had $)
Author:
Philipp Bracher
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  java.util.Locale locale
          The locale for this context.
 
Fields inherited from interface info.magnolia.context.Context
APPLICATION_SCOPE, ATTRIBUTE_COMMENT, ATTRIBUTE_EXCEPTION, ATTRIBUTE_MESSAGE, ATTRIBUTE_PATH, ATTRIBUTE_RECURSIVE, ATTRIBUTE_REPOSITORY, ATTRIBUTE_UUID, ATTRIBUTE_VERSION, ATTRIBUTE_VERSION_MAP, LOCAL_SCOPE, SESSION_SCOPE
 
Constructor Summary
AbstractContext()
           
 
Method Summary
 void clear()
          
 boolean containsKey(java.lang.Object arg0)
          
 boolean containsValue(java.lang.Object value)
          This implementation is very slow!
 java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
          
 java.lang.Object get(java.lang.Object key)
          
 AccessManager getAccessManager(java.lang.String repositoryId)
          Get access manager for the specified repository on default workspace.
 AccessManager getAccessManager(java.lang.String repositoryId, java.lang.String workspaceId)
          Get access manager for the specified repository on the specified workspace.
 java.lang.Object getAttribute(java.lang.String name)
          Get the attribute value.
 java.lang.Object getAttribute(java.lang.String name, int scope)
          Get attribute value.
 java.util.Map<java.lang.String,java.lang.Object> getAttributes()
          Merge the scopes maps.
 java.util.Map<java.lang.String,java.lang.Object> getAttributes(int scope)
          Get a map of a attributes set in the scope.
 AttributeStrategy getAttributeStrategy()
           
 HierarchyManager getHierarchyManager(java.lang.String repositoryId)
          Get hierarchy manager initialized for this user.
 HierarchyManager getHierarchyManager(java.lang.String repositoryId, java.lang.String workspaceId)
          Get hierarchy manager initialized for this user.
 java.util.Locale getLocale()
          If not yet set try to get the locale of the user.
 Messages getMessages()
          TODO: This duplicates methods from MessagesManager : remove either.
 Messages getMessages(java.lang.String basename)
          TODO: This duplicates methods from MessagesManager : remove either.
 QueryManager getQueryManager(java.lang.String repositoryId)
          Get QueryManager created for this user on the specified repository.
 QueryManager getQueryManager(java.lang.String repositoryId, java.lang.String workspaceId)
          Get QueryManager created for this user on the specified repository and workspace.
 RepositoryAcquiringStrategy getRepositoryStrategy()
           
 User getUser()
          If this is not a UserContext this method will very likely return the system user.
 boolean isEmpty()
          
 java.util.Set<java.lang.String> keySet()
          
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          
 void putAll(java.util.Map map)
          
 void release()
          Release any resource used by this Context (e.g.
 java.lang.Object remove(java.lang.Object key)
          
 void removeAttribute(java.lang.String name, int scope)
          Remove an attribute.
 void setAttribute(java.lang.String name, java.lang.Object value, int scope)
          Set attribute value, scope of the attribute is defined.
 void setAttributeStrategy(AttributeStrategy strategy)
           
 void setLocale(java.util.Locale locale)
           
 void setRepositoryStrategy(RepositoryAcquiringStrategy strategy)
           
 int size()
          
 java.util.Collection<java.lang.Object> values()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

locale

protected java.util.Locale locale
The locale for this context.

Constructor Detail

AbstractContext

public AbstractContext()
Method Detail

getUser

public User getUser()
Description copied from interface: Context
If this is not a UserContext this method will very likely return the system user.


getAttributeStrategy

public AttributeStrategy getAttributeStrategy()

setAttributeStrategy

public void setAttributeStrategy(AttributeStrategy strategy)

getRepositoryStrategy

public RepositoryAcquiringStrategy getRepositoryStrategy()

setRepositoryStrategy

public void setRepositoryStrategy(RepositoryAcquiringStrategy strategy)

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Description copied from interface: Context
Get attribute value.

Parameters:
name - to which value is associated to
scope - the scope (request, session, application)
Returns:
attribute value

getAttributes

public java.util.Map<java.lang.String,java.lang.Object> getAttributes(int scope)
Description copied from interface: Context
Get a map of a attributes set in the scope.

Returns:
the map

removeAttribute

public void removeAttribute(java.lang.String name,
                            int scope)
Description copied from interface: Context
Remove an attribute.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value,
                         int scope)
Description copied from interface: Context
Set attribute value, scope of the attribute is defined.

Parameters:
name - is used as a key
scope - , highest level of scope from which this attribute is visible

getAccessManager

public AccessManager getAccessManager(java.lang.String repositoryId,
                                      java.lang.String workspaceId)
Description copied from interface: Context
Get access manager for the specified repository on the specified workspace.

Returns:
access manager

getHierarchyManager

public HierarchyManager getHierarchyManager(java.lang.String repositoryId,
                                            java.lang.String workspaceId)
Description copied from interface: Context
Get hierarchy manager initialized for this user.

Returns:
hierarchy manager

getQueryManager

public QueryManager getQueryManager(java.lang.String repositoryId,
                                    java.lang.String workspaceId)
Description copied from interface: Context
Get QueryManager created for this user on the specified repository and workspace.

Returns:
query manager

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Get the attribute value.

Parameters:
name - to which value is associated to
Returns:
attribute value

getAttributes

public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Merge the scopes maps.

Returns:
the map

getLocale

public java.util.Locale getLocale()
If not yet set try to get the locale of the user. Else use the locale of the system context.

See Also:
Context.getLocale()

setLocale

public void setLocale(java.util.Locale locale)

getMessages

public Messages getMessages()
TODO: This duplicates methods from MessagesManager : remove either.


getMessages

public Messages getMessages(java.lang.String basename)
TODO: This duplicates methods from MessagesManager : remove either.

Parameters:
basename - name of the bundle TODO: This duplicates methods from MessagesManager : remove either

getHierarchyManager

public HierarchyManager getHierarchyManager(java.lang.String repositoryId)
Description copied from interface: Context
Get hierarchy manager initialized for this user.

Returns:
hierarchy manager

getAccessManager

public AccessManager getAccessManager(java.lang.String repositoryId)
Description copied from interface: Context
Get access manager for the specified repository on default workspace.

Returns:
access manager

getQueryManager

public QueryManager getQueryManager(java.lang.String repositoryId)
Description copied from interface: Context
Get QueryManager created for this user on the specified repository.

Returns:
query manager

get

public java.lang.Object get(java.lang.Object key)

Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

Specified by:
put in interface java.util.Map

clear

public void clear()

Specified by:
clear in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
This implementation is very slow!

Specified by:
containsValue in interface java.util.Map

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()

Specified by:
entrySet in interface java.util.Map

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set<java.lang.String> keySet()

Specified by:
keySet in interface java.util.Map

putAll

public void putAll(java.util.Map map)

Specified by:
putAll in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)

Specified by:
remove in interface java.util.Map

values

public java.util.Collection<java.lang.Object> values()

Specified by:
values in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object arg0)

Specified by:
containsKey in interface java.util.Map

size

public int size()

Specified by:
size in interface java.util.Map

release

public void release()
Release any resource used by this Context (e.g. jcr sessions).



Copyright © 2003-2010 Magnolia International Ltd.. All Rights Reserved.