Class JESTContext
- java.lang.Object
- 
- org.apache.openjpa.persistence.jest.JESTContext
 
- 
- All Implemented Interfaces:
- JPAServletContext
 
 public class JESTContext extends java.lang.Object implements JPAServletContext An operational context combines apersistence contextand a HTTP execution context expressed as arequestandresponse.
 This contextparsesthe HTTP request URL to identity the command and thenexecutesit.- Author:
- Pinaki Poddar
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected static PrototypeFactory<java.lang.String,JESTCommand>_cfstatic Localizer_locprotected Log_logprotected MetaDataRepository_reposstatic java.lang.StringCONTEXT_ROOTstatic java.lang.StringJEST_TEMPLATEstatic charQUERY_SEPARATOR
 - 
Constructor SummaryConstructors Constructor Description JESTContext(java.lang.String unit, OpenJPAEntityManagerFactory emf, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()Executes the request.static java.lang.StringgetAction(java.lang.String path)Gets the action from the given path.OpenJPAEntityManagergetPersistenceContext()Gets the persistence context.java.lang.StringgetPersistenceUnitName()Gets the name of the persistence unit.javax.servlet.http.HttpServletRequestgetRequest()Gets the request.java.lang.StringgetRequestURI()Get the requested URI.javax.servlet.http.HttpServletResponsegetResponse()Gets the response.voidlog(short level, java.lang.String message)Logging message.ClassMetaDataresolve(java.lang.String alias)Resolve the given alias to meta-data of the persistent type.
 
- 
- 
- 
Field Detail- 
_reposprotected MetaDataRepository _repos 
 - 
_logprotected Log _log 
 - 
_cfprotected static PrototypeFactory<java.lang.String,JESTCommand> _cf 
 - 
_locpublic static final Localizer _loc 
 - 
QUERY_SEPARATORpublic static final char QUERY_SEPARATOR - See Also:
- Constant Field Values
 
 - 
CONTEXT_ROOTpublic static final java.lang.String CONTEXT_ROOT - See Also:
- Constant Field Values
 
 - 
JEST_TEMPLATEpublic static final java.lang.String JEST_TEMPLATE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
JESTContextpublic JESTContext(java.lang.String unit, OpenJPAEntityManagerFactory emf, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
 
- 
 - 
Method Detail- 
getPersistenceUnitNamepublic java.lang.String getPersistenceUnitName() Gets the name of the persistence unit.- Specified by:
- getPersistenceUnitNamein interface- JPAServletContext
 
 - 
getPersistenceContextpublic OpenJPAEntityManager getPersistenceContext() Gets the persistence context. The persistence context is lazily constructed because all commands may not need it.- Specified by:
- getPersistenceContextin interface- JPAServletContext
 
 - 
getRequestpublic javax.servlet.http.HttpServletRequest getRequest() Gets the request.- Specified by:
- getRequestin interface- JPAServletContext
 
 - 
getRequestURIpublic java.lang.String getRequestURI() Description copied from interface:JPAServletContextGet the requested URI.- Specified by:
- getRequestURIin interface- JPAServletContext
 
 - 
getResponsepublic javax.servlet.http.HttpServletResponse getResponse() Gets the response.- Specified by:
- getResponsein interface- JPAServletContext
 
 - 
executepublic void execute() throws java.lang.ExceptionExecutes the request.
 Execution starts with parsing therequest 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 entirerequestfor requisite qualifiers and arguments and if the parse is successful then the command is executed in this context.
 If path is null, or no command is registered for the action or the command can not parse the request, then a last ditch attempt is made to find a resource. This fallback lookup is important because the response can contain hyperlinks to stylesheets or scripts. The browser will resolve such hyperlinks relative to the original response.
 For example, let the original request URL be:
 http://host:port/demo/jest/find?type=Actor&Robert
 The response to this request is a HTML page that contained a hyperlink tojest.cssstylesheet in its <head> section.
 <link ref="jest.css" .....>
 The browser will resolve the hyperlink by sending back another request as
 http://host:port/demo/jest/find/jest.css- Throws:
- java.lang.Exception
 
 - 
getActionpublic static java.lang.String getAction(java.lang.String path) Gets the action from the given path.- Parameters:
- path- a string
- Returns:
- if null, returns context root i.e. '/'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.
 
 - 
resolvepublic ClassMetaData resolve(java.lang.String alias) Description copied from interface:JPAServletContextResolve the given alias to meta-data of the persistent type.- Specified by:
- resolvein interface- JPAServletContext
- Parameters:
- 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.
- Returns:
- meta-data for the given name.
 
 - 
logpublic void log(short level, java.lang.String message)Description copied from interface:JPAServletContextLogging message.- Specified by:
- login interface- JPAServletContext
- Parameters:
- level- OpenJPA defined- log levels. Invalid levels will print the message on console.
- message- a printable message.
 
 
- 
 
-