public class JESTContext extends java.lang.Object implements JPAServletContext
persistence context
and a HTTP execution
context expressed as a request
and response
.
parses
the HTTP request URL to identity the command and then
executes
it.Modifier and Type | Field and Description |
---|---|
protected static PrototypeFactory<java.lang.String,JESTCommand> |
_cf |
static Localizer |
_loc |
protected Log |
_log |
protected MetaDataRepository |
_repos |
static java.lang.String |
CONTEXT_ROOT |
static java.lang.String |
JEST_TEMPLATE |
static char |
QUERY_SEPARATOR |
Constructor and Description |
---|
JESTContext(java.lang.String unit,
OpenJPAEntityManagerFactory emf,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Executes the request.
|
(package private) void |
findResource(java.lang.String rsrc)
A resource is always looked up with respect to this class.
|
static java.lang.String |
getAction(java.lang.String path)
Gets the action from the given path.
|
OpenJPAEntityManager |
getPersistenceContext()
Gets the persistence context.
|
java.lang.String |
getPersistenceUnitName()
Gets the name of the persistence unit.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Gets the request.
|
java.lang.String |
getRequestURI()
Get the requested URI.
|
javax.servlet.http.HttpServletResponse |
getResponse()
Gets the response.
|
(package private) boolean |
isContextRoot(java.lang.String path)
Is this path a context root?
|
(package private) boolean |
isEmpty(java.lang.String s) |
void |
log(short level,
java.lang.String message)
Logging message.
|
ClassMetaData |
resolve(java.lang.String alias)
Resolve the given alias to meta-data of the persistent type.
|
protected MetaDataRepository _repos
protected Log _log
protected static PrototypeFactory<java.lang.String,JESTCommand> _cf
public static final Localizer _loc
public static final char QUERY_SEPARATOR
public static final java.lang.String CONTEXT_ROOT
public static final java.lang.String JEST_TEMPLATE
public JESTContext(java.lang.String unit, OpenJPAEntityManagerFactory emf, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public java.lang.String getPersistenceUnitName()
getPersistenceUnitName
in interface JPAServletContext
public OpenJPAEntityManager getPersistenceContext()
getPersistenceContext
in interface JPAServletContext
public javax.servlet.http.HttpServletRequest getRequest()
getRequest
in interface JPAServletContext
public java.lang.String getRequestURI()
JPAServletContext
getRequestURI
in interface JPAServletContext
public javax.servlet.http.HttpServletResponse getResponse()
getResponse
in interface JPAServletContext
public void execute() throws java.lang.Exception
request path
.
The first path segment is interpreted as action key, and
if a action with the given key is registered then the control is delegated to the command.
The command parses the entire request
for requisite qualifiers and
arguments and if the parse is successful then the command is
executed in this context.
http://host:port/demo/jest/find?type=Actor&Robert
jest.css
stylesheet
in its <head> section.<link ref="jest.css" .....>
http://host:port/demo/jest/find/jest.css
java.lang.Exception
public static java.lang.String getAction(java.lang.String path)
path
- a string'/'
character.
Otherwise, if the path starts with context root, then returns the substring before the
next '/'
character or end of the string, whichever is earlier.
If the path does not start with context root, returns
the substring before the first '/'
character or end of the string, whichever is earlier.public ClassMetaData resolve(java.lang.String alias)
JPAServletContext
resolve
in interface JPAServletContext
alias
- a moniker for the Java type. It can be fully qualified type name or entity name
or simple name of the actual persistent Java class.void findResource(java.lang.String rsrc) throws ProcessingException
rsrc
- ProcessingException
public void log(short level, java.lang.String message)
JPAServletContext
log
in interface JPAServletContext
level
- OpenJPA defined log levels
. Invalid levels will print the message on console.message
- a printable message.boolean isContextRoot(java.lang.String path)
path
- boolean isEmpty(java.lang.String s)
Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.