info.magnolia.context
Class AbstractContext

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

public abstract class AbstractContext
extends Object
implements Context, Serializable

Default implementation of the Context interface.

Version:
$Revision: 41137 $ ($Author: gjoseph $)
Author:
Philipp Bracher
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  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(Object arg0)
          
 boolean containsValue(Object value)
          This implementation is very slow!
 Set<Map.Entry<String,Object>> entrySet()
          
 Object get(Object key)
          
 AccessManager getAccessManager(String repositoryId)
          Get access manager for the specified repository on default workspace.
 AccessManager getAccessManager(String repositoryId, String workspaceId)
          Get access manager for the specified repository on the specified workspace.
 Object getAttribute(String name)
          Get the attribute value.
 Object getAttribute(String name, int scope)
          Get attribute value.
 Map<String,Object> getAttributes()
          Merge the scopes maps.
 Map<String,Object> getAttributes(int scope)
          Get a map of a attributes set in the scope.
 AttributeStrategy getAttributeStrategy()
           
 HierarchyManager getHierarchyManager(String repositoryId)
          Get hierarchy manager initialized for this user.
 HierarchyManager getHierarchyManager(String repositoryId, String workspaceId)
          Get hierarchy manager initialized for this user.
 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(String basename)
          TODO: This duplicates methods from MessagesManager : remove either.
 QueryManager getQueryManager(String repositoryId)
          Get QueryManager created for this user on the specified repository.
 QueryManager getQueryManager(String repositoryId, 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()
          
 Set<String> keySet()
          
 Object put(Object key, Object value)
          
 void putAll(Map map)
          
 void release()
          Release any resource used by this Context (e.g.
 Object remove(Object key)
          
 void removeAttribute(String name, int scope)
          Remove an attribute.
 void setAttribute(String name, Object value, int scope)
          Set attribute value, scope of the attribute is defined.
 void setAttributeStrategy(AttributeStrategy strategy)
           
 void setLocale(Locale locale)
           
 void setRepositoryStrategy(RepositoryAcquiringStrategy strategy)
           
 int size()
          
 Collection<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 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 Object getAttribute(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 Map<String,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(String name,
                            int scope)
Description copied from interface: Context
Remove an attribute.


setAttribute

public void setAttribute(String name,
                         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(String repositoryId,
                                      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(String repositoryId,
                                            String workspaceId)
Description copied from interface: Context
Get hierarchy manager initialized for this user.

Returns:
hierarchy manager

getQueryManager

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

Returns:
query manager

getAttribute

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

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

getAttributes

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

Returns:
the map

getLocale

public 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(Locale locale)

getMessages

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


getMessages

public Messages getMessages(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(String repositoryId)
Description copied from interface: Context
Get hierarchy manager initialized for this user.

Returns:
hierarchy manager

getAccessManager

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

Returns:
access manager

getQueryManager

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

Returns:
query manager

get

public Object get(Object key)

Specified by:
get in interface Map

put

public Object put(Object key,
                  Object value)

Specified by:
put in interface Map

clear

public void clear()

Specified by:
clear in interface Map

containsValue

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

Specified by:
containsValue in interface Map

entrySet

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

Specified by:
entrySet in interface Map

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map

keySet

public Set<String> keySet()

Specified by:
keySet in interface Map

putAll

public void putAll(Map map)

Specified by:
putAll in interface Map

remove

public Object remove(Object key)

Specified by:
remove in interface Map

values

public Collection<Object> values()

Specified by:
values in interface Map

containsKey

public boolean containsKey(Object arg0)

Specified by:
containsKey in interface Map

size

public int size()

Specified by:
size in interface Map

release

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



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