org.apache.axis2.context
Class AbstractContext

java.lang.Object
  extended by org.apache.axis2.context.AbstractContext
Direct Known Subclasses:
ConfigurationContext, MessageContext, OperationContext, ServiceContext, ServiceGroupContext, SessionContext

public abstract class AbstractContext
extends java.lang.Object

This is the top most level of the Context hierarchy and is a bag of properties.


Field Summary
static java.lang.String COPY_PROPERTIES
          Property used to indicate copying of properties is needed by context.
protected  long lastTouchedTime
           
protected  AbstractContext parent
           
protected  java.util.Map properties
           
 
Constructor Summary
protected AbstractContext()
           
protected AbstractContext(AbstractContext parent)
           
 
Method Summary
 void clearPropertyDifferences()
          Once the clustering mechanism transmits the property differences, it should call this method to avoid retransmitting stuff that has already been sent.
 void flush()
           
 long getLastTouchedTime()
           
 java.lang.Object getLocalProperty(java.lang.String key)
          Retrieves an object given a key.
 AbstractContext getParent()
           
 java.util.Map getProperties()
          Deprecated. Use getPropertyNames(), getProperty(String), setProperty(String, Object) & removeProperty(String)instead.
 java.lang.Object getProperty(java.lang.String key)
          Retrieves an object given a key.
 java.util.Map getPropertyDifferences()
          Get the property differences since the last transmission by the clustering mechanism
 java.util.Iterator getPropertyNames()
          An iterator over a collection of String objects, which are the keys in the properties object.
 java.lang.Object getPropertyNonReplicable(java.lang.String key)
          Retrieves an object given a key.
abstract  ConfigurationContext getRootContext()
           
 boolean isAncestor(AbstractContext context)
           
 void mergeProperties(java.util.Map props)
          This will do a copy of the given properties to the current properties table.
 void removeProperty(java.lang.String key)
          Remove a property.
 void removePropertyNonReplicable(java.lang.String key)
          Remove a property.
 void setLastTouchedTime(long t)
           
 void setNonReplicableProperty(java.lang.String key, java.lang.Object value)
          Store a property in this context.
 void setParent(AbstractContext context)
           
 void setProperties(java.util.Map properties)
          This will set the properties to the context.
 void setProperty(java.lang.String key, java.lang.Object value)
          Store a property in this context
protected  void touch()
          ServiceContext and ServiceGroupContext are not getting automatically garbage collected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPY_PROPERTIES

public static final java.lang.String COPY_PROPERTIES
Property used to indicate copying of properties is needed by context.

See Also:
Constant Field Values

lastTouchedTime

protected long lastTouchedTime

parent

protected transient AbstractContext parent

properties

protected transient java.util.Map properties
Constructor Detail

AbstractContext

protected AbstractContext(AbstractContext parent)

AbstractContext

protected AbstractContext()
Method Detail

getParent

public AbstractContext getParent()
Returns:
Returns the parent of this context.

isAncestor

public boolean isAncestor(AbstractContext context)
Parameters:
context -
Returns:
true if the context is an ancestor

getProperties

public java.util.Map getProperties()
Deprecated. Use getPropertyNames(), getProperty(String), setProperty(String, Object) & removeProperty(String)instead.

Returns:
The properties

getPropertyNames

public java.util.Iterator getPropertyNames()
An iterator over a collection of String objects, which are the keys in the properties object.

Returns:
Iterator over a collection of keys

getProperty

public java.lang.Object getProperty(java.lang.String key)
Retrieves an object given a key.

Parameters:
key - - if not found, will return null
Returns:
Returns the property.

getLocalProperty

public java.lang.Object getLocalProperty(java.lang.String key)
Retrieves an object given a key. Only searches at this level i.e. getLocalProperty on MessageContext does not look in the OperationContext properties map if a local result is not found.

Parameters:
key - - if not found, will return null
Returns:
Returns the property.

getPropertyNonReplicable

public java.lang.Object getPropertyNonReplicable(java.lang.String key)
Retrieves an object given a key. The retrieved property will not be replicated to other nodes in the clustered scenario.

Parameters:
key - - if not found, will return null
Returns:
Returns the property.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Store a property in this context

Parameters:
key -
value -

setNonReplicableProperty

public void setNonReplicableProperty(java.lang.String key,
                                     java.lang.Object value)
Store a property in this context. But these properties should not be replicated when Axis2 is clustered.

Parameters:
key -
value -

removeProperty

public void removeProperty(java.lang.String key)
Remove a property. Only properties at this level will be removed. Properties of the parents cannot be removed using this method.

Parameters:
key -

removePropertyNonReplicable

public void removePropertyNonReplicable(java.lang.String key)
Remove a property. Only properties at this level will be removed. Properties of the parents cannot be removed using this method. The removal of the property will not be replicated when Axis2 is clustered.

Parameters:
key -

getPropertyDifferences

public java.util.Map getPropertyDifferences()
Get the property differences since the last transmission by the clustering mechanism

Returns:
The property differences

clearPropertyDifferences

public void clearPropertyDifferences()
Once the clustering mechanism transmits the property differences, it should call this method to avoid retransmitting stuff that has already been sent.


setParent

public void setParent(AbstractContext context)
Parameters:
context -

setProperties

public void setProperties(java.util.Map properties)
This will set the properties to the context. But in setting that one may need to "copy" all the properties from the source properties to the target properties. To enable this we introduced a property (COPY_PROPERTIES) so that if set to true, this code will copy the whole thing, without just referencing to the source.

Parameters:
properties -

mergeProperties

public void mergeProperties(java.util.Map props)
This will do a copy of the given properties to the current properties table.

Parameters:
props - The table of properties to copy

touch

protected void touch()
ServiceContext and ServiceGroupContext are not getting automatically garbage collected. And there is no specific way for some one to go and make it garbage collectible. So the current solution is to make them time out. So the logic is that, there is a timer task in each and every service group which will check for the last touched time. And if it has not been touched for some time, the timer task will remove it from the memory. The touching logic happens like this. Whenever there is a call to addMessageContext in the operationContext it will go and update operationCOntext -> serviceContext -> serviceGroupContext.


getLastTouchedTime

public long getLastTouchedTime()

setLastTouchedTime

public void setLastTouchedTime(long t)

flush

public void flush()
           throws AxisFault
Throws:
AxisFault

getRootContext

public abstract ConfigurationContext getRootContext()


Copyright © 2007 Apache Web Services Project. All Rights Reserved.