Class AbstractResource
- java.lang.Object
-
- org.eclipse.persistence.jpa.rs.resources.common.AbstractResource
-
- Direct Known Subclasses:
AbstractEntityResource,AbstractPersistenceResource,AbstractPersistenceUnitResource,AbstractQueryResource,AbstractSingleResultQueryResource,MetadataResource
public abstract class AbstractResource extends java.lang.ObjectBase class for all resources.- Author:
- gonural
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPLICATION_SCHEMA_JSONstatic javax.ws.rs.core.MediaTypeAPPLICATION_SCHEMA_JSON_TYPEprotected PersistenceContextFactoryfactorystatic java.lang.StringSERVICE_VERSION_FORMAT
-
Constructor Summary
Constructors Constructor Description AbstractResource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PersistenceContextFactorybuildPersistenceContextFactory(java.lang.ClassLoader loader)Builds the persistence context factory.protected static java.util.Map<java.lang.String,java.lang.String>getMatrixParameters(javax.ws.rs.core.UriInfo info, java.lang.String segment)Get a map of the matrix parameters associated with the URI path segment of the current request In JPA-RS, things that user sets (such as parameters of named queries, etc.) are treated as matrix parameters List of valid matrix parameters for JPA-RS is defined in MatrixParametersprotected PersistenceContextgetPersistenceContext(java.lang.String persistenceUnit, java.lang.String entityType, java.net.URI baseURI, java.lang.String version, java.util.Map<java.lang.String,java.lang.Object> initializationProperties)Gets the persistence context.PersistenceContextFactorygetPersistenceFactory()Gets the persistence factory.PersistenceContextFactorygetPersistenceFactory(java.lang.ClassLoader loader)Gets the persistence factory.static java.util.Map<java.lang.String,java.lang.Object>getQueryParameters(javax.ws.rs.core.UriInfo info)Get the URI query parameters of the current request In JPA-RS, predefined attributes (such as eclipselink query hints) are treated as query parameters List of valid query parameters for JPA-RS is defined in QueryParametersprotected java.lang.StringgetRelationshipPartner(java.util.Map<java.lang.String,java.lang.String> matrixParams, java.util.Map<java.lang.String,java.lang.Object> queryParams)Gets the relationship partner.protected static booleanisValidVersion(java.lang.String version)Checks if is valid version.protected java.lang.StringmarshallMetadata(java.lang.Object metadata, java.lang.String mediaType)Marshall metadata.voidsetPersistenceFactory(PersistenceContextFactory factory)Sets the persistence factory.protected voidsetRequestUniqueId()
-
-
-
Field Detail
-
SERVICE_VERSION_FORMAT
public static final java.lang.String SERVICE_VERSION_FORMAT
- See Also:
- Constant Field Values
-
APPLICATION_SCHEMA_JSON
public static final java.lang.String APPLICATION_SCHEMA_JSON
- See Also:
- Constant Field Values
-
APPLICATION_SCHEMA_JSON_TYPE
public static final javax.ws.rs.core.MediaType APPLICATION_SCHEMA_JSON_TYPE
-
factory
protected PersistenceContextFactory factory
-
-
Method Detail
-
setPersistenceFactory
public void setPersistenceFactory(PersistenceContextFactory factory)
Sets the persistence factory.- Parameters:
factory- the new persistence factory
-
getPersistenceFactory
public PersistenceContextFactory getPersistenceFactory()
Gets the persistence factory.- Returns:
- the persistence factory
-
getPersistenceFactory
public PersistenceContextFactory getPersistenceFactory(java.lang.ClassLoader loader)
Gets the persistence factory.- Returns:
- the persistence factory
-
buildPersistenceContextFactory
protected PersistenceContextFactory buildPersistenceContextFactory(java.lang.ClassLoader loader)
Builds the persistence context factory.- Parameters:
loader- the loader- Returns:
- the persistence context factory
-
getMatrixParameters
protected static java.util.Map<java.lang.String,java.lang.String> getMatrixParameters(javax.ws.rs.core.UriInfo info, java.lang.String segment)Get a map of the matrix parameters associated with the URI path segment of the current request In JPA-RS, things that user sets (such as parameters of named queries, etc.) are treated as matrix parameters List of valid matrix parameters for JPA-RS is defined in MatrixParameters- Parameters:
info- the infosegment- the segment- Returns:
- the matrix parameters
- See Also:
MatrixParameters
-
getQueryParameters
public static java.util.Map<java.lang.String,java.lang.Object> getQueryParameters(javax.ws.rs.core.UriInfo info)
Get the URI query parameters of the current request In JPA-RS, predefined attributes (such as eclipselink query hints) are treated as query parameters List of valid query parameters for JPA-RS is defined in QueryParameters- Parameters:
info- the info- Returns:
- the query parameters
- See Also:
QueryParameters
-
isValidVersion
protected static boolean isValidVersion(java.lang.String version)
Checks if is valid version.- Parameters:
version- the version- Returns:
- true, if is valid version
-
getPersistenceContext
protected PersistenceContext getPersistenceContext(java.lang.String persistenceUnit, java.lang.String entityType, java.net.URI baseURI, java.lang.String version, java.util.Map<java.lang.String,java.lang.Object> initializationProperties)
Gets the persistence context.- Parameters:
persistenceUnit- the persistence unitbaseURI- the base uriversion- the versioninitializationProperties- the initialization properties- Returns:
- the persistence context
-
getRelationshipPartner
protected java.lang.String getRelationshipPartner(java.util.Map<java.lang.String,java.lang.String> matrixParams, java.util.Map<java.lang.String,java.lang.Object> queryParams)Gets the relationship partner.- Parameters:
matrixParams- the matrix paramsqueryParams- the query params- Returns:
- the relationship partner
-
marshallMetadata
protected java.lang.String marshallMetadata(java.lang.Object metadata, java.lang.String mediaType) throws JAXBExceptionMarshall metadata.- Parameters:
metadata- the metadatamediaType- the media type- Returns:
- the string
- Throws:
JAXBException- the jAXB exception
-
setRequestUniqueId
protected void setRequestUniqueId()
-
-