- 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 Object
Base class for all resources.- Author:
- gonural
-
-
Field Summary
Fields Modifier and Type Field Description static String
APPLICATION_SCHEMA_JSON
static jakarta.ws.rs.core.MediaType
APPLICATION_SCHEMA_JSON_TYPE
protected PersistenceContextFactory
factory
static String
SERVICE_VERSION_FORMAT
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractResource()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PersistenceContextFactory
buildPersistenceContextFactory(ClassLoader loader)
Builds the persistence context factory.protected static Map<String,String>
getMatrixParameters(jakarta.ws.rs.core.UriInfo info, 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 PersistenceContext
getPersistenceContext(String persistenceUnit, String entityType, URI baseURI, String version, Map<String,Object> initializationProperties)
Gets the persistence context.PersistenceContextFactory
getPersistenceFactory()
Gets the persistence factory.PersistenceContextFactory
getPersistenceFactory(ClassLoader loader)
Gets the persistence factory.static Map<String,Object>
getQueryParameters(jakarta.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 String
getRelationshipPartner(Map<String,String> matrixParams, Map<String,Object> queryParams)
Gets the relationship partner.protected static boolean
isValidVersion(String version)
Checks if is valid version.protected String
marshallMetadata(Object metadata, String mediaType)
Marshall metadata.void
setPersistenceFactory(PersistenceContextFactory factory)
Sets the persistence factory.protected void
setRequestUniqueId()
-
-
-
Field Detail
-
SERVICE_VERSION_FORMAT
public static final String SERVICE_VERSION_FORMAT
- See Also:
- Constant Field Values
-
APPLICATION_SCHEMA_JSON
public static final String APPLICATION_SCHEMA_JSON
- See Also:
- Constant Field Values
-
APPLICATION_SCHEMA_JSON_TYPE
public static final jakarta.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(ClassLoader loader)
Gets the persistence factory.- Returns:
- the persistence factory
-
buildPersistenceContextFactory
protected PersistenceContextFactory buildPersistenceContextFactory(ClassLoader loader)
Builds the persistence context factory.- Parameters:
loader
- the loader- Returns:
- the persistence context factory
-
getMatrixParameters
protected static Map<String,String> getMatrixParameters(jakarta.ws.rs.core.UriInfo info, 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 Map<String,Object> getQueryParameters(jakarta.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(String version)
Checks if is valid version.- Parameters:
version
- the version- Returns:
- true, if is valid version
-
getPersistenceContext
protected PersistenceContext getPersistenceContext(String persistenceUnit, String entityType, URI baseURI, String version, Map<String,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 String getRelationshipPartner(Map<String,String> matrixParams, Map<String,Object> queryParams)
Gets the relationship partner.- Parameters:
matrixParams
- the matrix paramsqueryParams
- the query params- Returns:
- the relationship partner
-
marshallMetadata
protected String marshallMetadata(Object metadata, String mediaType) throws jakarta.xml.bind.JAXBException
Marshall metadata.- Parameters:
metadata
- the metadatamediaType
- the media type- Returns:
- the string
- Throws:
jakarta.xml.bind.JAXBException
- the jAXB exception
-
setRequestUniqueId
protected void setRequestUniqueId()
-
-