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$ ($Author$)
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_POSSIBLE_CSRF, 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 workspace)
          Get a an AccessManager for logical entities.
 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 workspaceName)
          Get hierarchy manager initialized for this user.
 javax.jcr.Session getJCRSession(String workspaceName)
           
 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 workspaceName)
          Get QueryManager created for this user on the specified repository.
 JCRSessionStrategy getRepositoryStrategy()
           
 Subject getSubject()
           
 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. jcr sessions).
 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(JCRSessionStrategy 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.


getSubject

public Subject getSubject()

getAttributeStrategy

public AttributeStrategy getAttributeStrategy()

setAttributeStrategy

public void setAttributeStrategy(AttributeStrategy strategy)

getRepositoryStrategy

public JCRSessionStrategy getRepositoryStrategy()

setRepositoryStrategy

public void setRepositoryStrategy(JCRSessionStrategy 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 workspace)
Description copied from interface: Context
Get a an AccessManager for logical entities. The accesses to the repository are handled by the repository itself.


getJCRSession

public javax.jcr.Session getJCRSession(String workspaceName)
                                throws javax.jcr.LoginException,
                                       javax.jcr.RepositoryException
Throws:
javax.jcr.LoginException
javax.jcr.RepositoryException

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 workspaceName)
Description copied from interface: Context
Get hierarchy manager initialized for this user.

Returns:
hierarchy manager

getQueryManager

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


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–2014 Magnolia International Ltd.. All rights reserved.