Package org.apache.velocity.example
Class DBContext
java.lang.Object
org.apache.velocity.context.AbstractContext
org.apache.velocity.example.DBContext
- All Implemented Interfaces:
org.apache.velocity.context.Context
,org.apache.velocity.context.InternalEventContext
public class DBContext
extends org.apache.velocity.context.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$
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.velocity.app.event.EventCartridge
attachEventCartridge
(org.apache.velocity.app.event.EventCartridge arg0) int
org.apache.velocity.runtime.resource.Resource
org.apache.velocity.app.event.EventCartridge
List
<org.apache.velocity.Template> String[]
String[]
org.apache.velocity.util.introspection.IntrospectionCacheData
void
boolean
Not implementing.internalGet
(String key) retrieves a serialized object from the db and returns the living instance to the caller.String[]
Not implementing.internalPut
(String key, Object value) Serializes and stores an object in the database.internalRemove
(String key) Not implementing.void
void
void
pushCurrentMacroName
(String arg0) void
void
setCurrentResource
(org.apache.velocity.runtime.resource.Resource arg0) void
setMacroLibraries
(List<org.apache.velocity.Template> arg0) private void
setup()
Methods inherited from class org.apache.velocity.context.AbstractContext
containsKey, get, getChainedContext, getKeys, put, remove
-
Field Details
-
conn
Connection conn
-
-
Constructor Details
-
DBContext
public DBContext() -
DBContext
public DBContext(org.apache.velocity.context.Context inner)
-
-
Method Details
-
internalGet
retrieves a serialized object from the db and returns the living instance to the caller.- Specified by:
internalGet
in classorg.apache.velocity.context.AbstractContext
-
internalPut
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 classorg.apache.velocity.context.AbstractContext
-
internalContainsKey
Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."- Specified by:
internalContainsKey
in classorg.apache.velocity.context.AbstractContext
-
internalGetKeys
Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."- Specified by:
internalGetKeys
in classorg.apache.velocity.context.AbstractContext
-
internalRemove
Not implementing. Not required for Velocity core operation, so not bothering. As we say above : "very fragile, crappy code..."- Specified by:
internalRemove
in classorg.apache.velocity.context.AbstractContext
-
setup
private void setup() -
pushCurrentTemplateName
-
popCurrentTemplateName
public void popCurrentTemplateName() -
getCurrentTemplateName
-
getTemplateNameStack
-
pushCurrentMacroName
-
popCurrentMacroName
public void popCurrentMacroName() -
getCurrentMacroName
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth() -
getMacroNameStack
-
icacheGet
-
icachePut
public void icachePut(Object arg0, org.apache.velocity.util.introspection.IntrospectionCacheData arg1) -
setCurrentResource
public void setCurrentResource(org.apache.velocity.runtime.resource.Resource arg0) -
getCurrentResource
public org.apache.velocity.runtime.resource.Resource getCurrentResource() -
setMacroLibraries
-
getMacroLibraries
-
attachEventCartridge
public org.apache.velocity.app.event.EventCartridge attachEventCartridge(org.apache.velocity.app.event.EventCartridge arg0) - Specified by:
attachEventCartridge
in interfaceorg.apache.velocity.context.InternalEventContext
-
getEventCartridge
public org.apache.velocity.app.event.EventCartridge getEventCartridge()- Specified by:
getEventCartridge
in interfaceorg.apache.velocity.context.InternalEventContext
-