Class DBContext

  • All Implemented Interfaces:
    Context, InternalEventContext

    public class DBContext
    extends AbstractContext
    Example context impl that uses a database to store stuff :) yes, this is silly expects a mysql db test with table CREATE TABLE contextstore ( k varchar(100), val blob ); very fragile, crappy code.... just a demo!
    Version:
    $Id$
    Author:
    Geir Magnusson Jr.
    • Constructor Detail

      • DBContext

        public DBContext()
      • DBContext

        public DBContext​(Context inner)
    • Method Detail

      • internalGet

        public Object internalGet​(String key)
        retrieves a serialized object from the db and returns the living instance to the caller.
        Specified by:
        internalGet in class AbstractContext
        Parameters:
        key - key whose associated value is to be returned
        Returns:
        object stored in the context
      • internalPut

        public Object internalPut​(String key,
                                  Object value)
        Serializes and stores an object in the database. This is really a hokey way to do it, and will cause problems. The right way is to use a prepared statement...
        Specified by:
        internalPut in class AbstractContext
        Parameters:
        key - key with which to associate the value
        value - value to be associated with the key
        Returns:
        previously stored value if exists, or null
      • internalContainsKey

        public boolean internalContainsKey​(String key)
        Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."
        Specified by:
        internalContainsKey in class AbstractContext
        Parameters:
        key - key to test for existence
        Returns:
        true if found, false if not
      • internalGetKeys

        public String[] internalGetKeys()
        Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."
        Specified by:
        internalGetKeys in class AbstractContext
        Returns:
        array of keys
      • internalRemove

        public Object internalRemove​(String key)
        Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."
        Specified by:
        internalRemove in class AbstractContext
        Parameters:
        key - key to remove
        Returns:
        object removed if exists, else null
      • pushCurrentTemplateName

        public void pushCurrentTemplateName​(String s)
        set the current template name on top of stack
        Parameters:
        s - current template name
      • popCurrentTemplateName

        public void popCurrentTemplateName()
        remove the current template name from stack
      • getCurrentTemplateName

        public String getCurrentTemplateName()
        get the current template name
        Returns:
        String current template name
      • getTemplateNameStack

        public String[] getTemplateNameStack()
        get the current template name stack
        Returns:
        String[] with the template name stack contents.
      • pushCurrentMacroName

        public void pushCurrentMacroName​(String s)
        set the current macro name on top of stack
        Parameters:
        s - current macro name
      • popCurrentMacroName

        public void popCurrentMacroName()
        remove the current macro name from stack
      • getCurrentMacroName

        public String getCurrentMacroName()
        get the current macro name
        Returns:
        String current macro name
      • getCurrentMacroCallDepth

        public int getCurrentMacroCallDepth()
        get the current macro call depth
        Returns:
        int current macro call depth
      • getMacroNameStack

        public String[] getMacroNameStack()
        get the current macro name stack
        Returns:
        String[] with the macro name stack contents.
      • icacheGet

        public IntrospectionCacheData icacheGet​(Object key)
        returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
        Parameters:
        key - key to find in cache
        Returns:
        cache object
      • icachePut

        public void icachePut​(Object key,
                              IntrospectionCacheData o)
        places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key
        Parameters:
        key - key
        o - IntrospectionCacheData object to place in cache
      • setCurrentResource

        public void setCurrentResource​(Resource r)
        See Also:
        InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
      • getCurrentResource

        public Resource getCurrentResource()
        See Also:
        InternalHousekeepingContext.getCurrentResource()
      • setMacroLibraries

        public void setMacroLibraries​(List<Template> macroLibraries)
        See Also:
        InternalHousekeepingContext.setMacroLibraries(List)
      • getMacroLibraries

        public List<Template> getMacroLibraries()
        See Also:
        InternalHousekeepingContext.getMacroLibraries()