net.sf.morph.context
Interface Context

All Known Subinterfaces:
DecoratedContext, DelegatingContext, HierarchicalContext
All Known Implementing Classes:
BaseContext, BaseHierarchicalContext, ContextDecorator, HttpServletContext, JspContext, MapContext, ReflectorHierarchicalContext

public interface Context

A context is an object that can be passed between tiers of an application without exposing the APIs that are particular to any given tier. For example, in a web application the information submitted by a user in an HttpRequest object could be exposed to a business object through the Context interface. This leaves objects in the business tier independent of the servlet API and thus testable outside a Servlet container.

Since:
Nov 19, 2004
Author:
Matt Sgarlata

Method Summary
 java.lang.Object get(java.lang.String propertyName)
          Retrieve the property named propertyName.
 java.lang.String[] getPropertyNames()
          Gets the names of the properties which are currently defined for this context.
 void set(java.lang.String propertyName, java.lang.Object propertyValue)
          Sets propertyName to propertyValue.
 

Method Detail

getPropertyNames

java.lang.String[] getPropertyNames()
                                    throws ContextException
Gets the names of the properties which are currently defined for this context. It will often be an O(n) operation to list all property names in the context, so callers should avoid frequent calls to this method. This method should always include Context#PROPERTY_NAMES_PROPERTY as one of the properties in the returned array.

Returns:
the property names
Throws:
ContextException - if the properties could not be retieved for some reason

get

java.lang.Object get(java.lang.String propertyName)
                     throws ContextException
Retrieve the property named propertyName. The property Context#PROPERTY_NAMES_PROPERTY has special symantics. Unless a value for this property has already been explicitly specified for the context, context.get(PROPERTY_NAMES_PROPERTY) will return the same result as getPropertyNames().

Parameters:
propertyName - the name of the property to be retrieved, if the property has been defined or
null, if the property is not defined
Returns:
the value of the property
Throws:
ContextException - if propertyName is empty or
an error occurrs when accessing the property

set

void set(java.lang.String propertyName,
         java.lang.Object propertyValue)
         throws ContextException
Sets propertyName to propertyValue.

Parameters:
propertyName - the name of the property to set
propertyValue - the new value for the property
Throws:
ContextException - if propertyName is empty or
the property can't be set for some reason


Copyright © 2004-2008.