|
EclipseLink JPA-RS 2.4.1, build 'v20121003-ad44345' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.persistence.jpa.rs.PersistenceContext
public class PersistenceContext
A wrapper around the JPA and JAXB artifacts used to persist an application. A PersistenceContext provides the capability of using the same persistence unit in JPA to to interact with a Database or other JPA-capable data source and in JAXB to interact with either XML or JSON. A PersistenceContext can wrap either an existing persistence unit (EntityManagerFactory), or it can be used to bootstrap a fully dynamic persistence unit.
Field Summary | |
---|---|
protected java.net.URI |
baseURI
The URI of the Persistence context. |
static java.lang.String |
CHANGE_NOTIFICATION_LISTENER
This internal property is used to save a change listener on the session for later retreival. |
protected org.eclipse.persistence.jaxb.JAXBContext |
context
The JAXBConext used to produce JSON or XML |
protected javax.persistence.EntityManagerFactory |
emf
The EntityManagerFactory used to interact using JPA |
DatabaseEventListenerFactory |
eventListenerFactory
A factory class that will provide listeners for events provided by the database Setting this provides a hook to allow applications that are capable of receiving events from the database to do so. |
static java.lang.String |
JPARS_CONTEXT
|
protected java.lang.String |
name
The name of the persistence context is used to look it up. |
protected TransactionWrapper |
transaction
|
Constructor Summary | |
---|---|
protected |
PersistenceContext()
|
|
PersistenceContext(java.lang.String emfName,
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl emf,
java.net.URI defaultURI)
|
Method Summary | |
---|---|
protected void |
addDynamicXMLMetadataSources(java.util.List<java.lang.Object> metadataSources,
org.eclipse.persistence.sessions.server.Server session)
This method is used to help construct a JAXBContext from an existing EntityManagerFactory. |
void |
create(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.Object entity)
A part of the facade over the JPA API Persist an entity in JPA and commit |
protected org.eclipse.persistence.jaxb.JAXBContext |
createDynamicJAXBContext(org.eclipse.persistence.sessions.server.Server session)
Create a JAXBConext based on the EntityManagerFactory for this PersistenceContext |
protected javax.persistence.EntityManager |
createEntityManager(java.lang.String tenantId)
A part of the facade over the JPA API Create an EntityManager from the EntityManagerFactory wrapped by this persistence context |
protected org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl |
createEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo info,
java.util.Map<java.lang.String,?> properties)
A part of the facade over the JPA API Create an EntityManagerFactory using the given PersistenceUnitInfo and properties |
protected java.util.Map<java.lang.String,java.lang.Object> |
createJAXBProperties(org.eclipse.persistence.sessions.server.Server session)
Build the set of properties used to create the JAXBContext based on the EntityManagerFactory that this PersistenceContext wraps |
void |
delete(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String type,
java.lang.Object id)
A part of the facade over the JPA API Delete the given entity in JPA and commit the changes |
java.lang.Object |
find(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String entityName,
java.lang.Object id)
A part of the facade over the JPA API Find an entity with the given name and id in JPA |
java.lang.Object |
find(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String entityName,
java.lang.Object id,
java.util.Map<java.lang.String,java.lang.Object> properties)
A part of the facade over the JPA API Find an entity with the given name and id in JPA |
java.lang.Object |
find(java.lang.String entityName,
java.lang.Object id)
A part of the facade over the JPA API Find an entity with the given name and id in JPA |
java.lang.Object |
findAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String entityName,
java.lang.Object id,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String attribute)
|
java.net.URI |
getBaseURI()
|
java.lang.Class<?> |
getClass(java.lang.String entityName)
Look-up the given entity name in the EntityManagerFactory and return the class is describes |
org.eclipse.persistence.descriptors.ClassDescriptor |
getDescriptor(java.lang.String entityName)
Lookup the descriptor for the given entity name. |
org.eclipse.persistence.descriptors.ClassDescriptor |
getDescriptorForClass(java.lang.Class clazz)
|
javax.persistence.EntityManagerFactory |
getEmf()
|
org.eclipse.persistence.jaxb.JAXBContext |
getJAXBContext()
|
org.eclipse.persistence.sessions.server.ServerSession |
getJpaSession()
|
java.lang.String |
getName()
|
void |
marshallEntity(java.lang.Object object,
javax.ws.rs.core.MediaType mediaType,
java.io.OutputStream output)
Marshall an entity to either JSON or XML Calling this method, will treat relationships as unfetched in the XML/JSON and marshall them as links rather than attempting to marshall the data in those relationships |
void |
marshallEntity(java.lang.Object object,
javax.ws.rs.core.MediaType mediaType,
java.io.OutputStream output,
boolean sendRelationships)
Marshall an entity to either JSON or XML |
java.lang.Object |
merge(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.Object entity)
A part of the facade over the JPA API Call jpa merge on the given object and commit If the passed object is a list, we will iterate through the list and merge each member |
org.eclipse.persistence.dynamic.DynamicEntity |
newEntity(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String type)
A convenience method to create a new dynamic entity of the given type |
org.eclipse.persistence.dynamic.DynamicEntity |
newEntity(java.lang.String type)
A convenience method to create a new dynamic entity of the given type |
protected void |
postMarshallEntity(java.lang.Object object)
|
protected void |
preMarshallEntity(java.lang.Object object)
Process an entity and add any additional data that needs to be added prior to marshalling This method will both single entities and lists of entities |
protected void |
preMarshallIndividualEntity(java.lang.Object entity)
Add any data required prior to marshalling an entity to XML or JSON In general, this will only affect fields that have been weaved into the object |
java.lang.Object |
query(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String name,
java.util.Map<?,?> parameters)
A part of the facade over the JPA API Run a query with the given name in JPA and return the result |
java.lang.Object |
query(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String name,
java.util.Map<?,?> parameters,
java.util.Map<java.lang.String,?> hints,
boolean returnSingleResult,
boolean executeUpdate)
A part of the facade over the JPA API Run a query with the given name in JPA and return the result |
void |
remove(ChangeListener listener)
Remove a given change listener. |
java.lang.Object |
removeAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String entityName,
java.lang.Object id,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String attribute,
java.lang.Object attributeValue,
java.lang.String partner)
|
protected void |
removeMappingValueFromObject(java.lang.Object object,
java.lang.Object attributeValue,
org.eclipse.persistence.mappings.DatabaseMapping mapping,
org.eclipse.persistence.mappings.DatabaseMapping partner)
|
void |
setBaseURI(java.net.URI baseURI)
|
void |
setEventListenerFactory(DatabaseEventListenerFactory eventListenerFactory)
Static setter for the EVENT_LISTENER_FACTORY Part of the mechanism for plugging in code that can react to database events |
protected void |
setMappingValueInObject(java.lang.Object object,
java.lang.Object attributeValue,
org.eclipse.persistence.mappings.DatabaseMapping mapping,
org.eclipse.persistence.mappings.DatabaseMapping partner)
|
void |
stop()
Stop the current application instance |
java.lang.String |
toString()
|
java.lang.Object |
unmarshalEntity(java.lang.Class type,
javax.ws.rs.core.MediaType acceptedMedia,
java.io.InputStream in)
|
java.lang.Object |
unmarshalEntity(java.lang.String type,
javax.ws.rs.core.MediaType acceptedMedia,
java.io.InputStream in)
|
java.lang.Object |
updateOrAddAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId,
java.lang.String entityName,
java.lang.Object id,
java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String attribute,
java.lang.Object attributeValue,
java.lang.String partner)
|
protected java.lang.Object |
wrap(java.lang.Object entity)
Make adjustements to an unmarshalled entity based on what is found in the weaved fields |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public DatabaseEventListenerFactory eventListenerFactory
public static final java.lang.String CHANGE_NOTIFICATION_LISTENER
public static final java.lang.String JPARS_CONTEXT
protected java.lang.String name
protected javax.persistence.EntityManagerFactory emf
protected org.eclipse.persistence.jaxb.JAXBContext context
protected java.net.URI baseURI
protected TransactionWrapper transaction
Constructor Detail |
---|
protected PersistenceContext()
public PersistenceContext(java.lang.String emfName, org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl emf, java.net.URI defaultURI)
Method Detail |
---|
public void setEventListenerFactory(DatabaseEventListenerFactory eventListenerFactory)
eventListenerFactory
- protected void addDynamicXMLMetadataSources(java.util.List<java.lang.Object> metadataSources, org.eclipse.persistence.sessions.server.Server session)
metadataSources
- persistenceUnitName
- session
- public void create(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.Object entity)
tenantId
- entity
- protected org.eclipse.persistence.jaxb.JAXBContext createDynamicJAXBContext(org.eclipse.persistence.sessions.server.Server session) throws javax.xml.bind.JAXBException, java.io.IOException
session
-
javax.xml.bind.JAXBException
java.io.IOException
protected org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl createEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo info, java.util.Map<java.lang.String,?> properties)
info
- properties
-
protected javax.persistence.EntityManager createEntityManager(java.lang.String tenantId)
tenantId
-
protected java.util.Map<java.lang.String,java.lang.Object> createJAXBProperties(org.eclipse.persistence.sessions.server.Server session) throws java.io.IOException
persistenceUnitName
- session
-
java.io.IOException
public void delete(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String type, java.lang.Object id)
public java.lang.Object find(java.lang.String entityName, java.lang.Object id)
entityName
- id
-
public java.lang.Object find(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String entityName, java.lang.Object id)
tenantId
- entityName
- id
-
public java.lang.Object find(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String entityName, java.lang.Object id, java.util.Map<java.lang.String,java.lang.Object> properties)
tenantId
- entityName
- id
- properties
- - query hints used on the find
public java.lang.Object findAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String entityName, java.lang.Object id, java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String attribute)
public java.lang.Object updateOrAddAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String entityName, java.lang.Object id, java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String attribute, java.lang.Object attributeValue, java.lang.String partner)
public java.lang.Object removeAttribute(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String entityName, java.lang.Object id, java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String attribute, java.lang.Object attributeValue, java.lang.String partner)
protected void removeMappingValueFromObject(java.lang.Object object, java.lang.Object attributeValue, org.eclipse.persistence.mappings.DatabaseMapping mapping, org.eclipse.persistence.mappings.DatabaseMapping partner)
public java.net.URI getBaseURI()
public java.lang.Class<?> getClass(java.lang.String entityName)
entityName
-
public org.eclipse.persistence.sessions.server.ServerSession getJpaSession()
public org.eclipse.persistence.descriptors.ClassDescriptor getDescriptor(java.lang.String entityName)
entityName
-
public org.eclipse.persistence.descriptors.ClassDescriptor getDescriptorForClass(java.lang.Class clazz)
public javax.persistence.EntityManagerFactory getEmf()
public org.eclipse.persistence.jaxb.JAXBContext getJAXBContext()
public java.lang.String getName()
public java.lang.Object merge(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.Object entity)
tenantId
- entity
-
public org.eclipse.persistence.dynamic.DynamicEntity newEntity(java.lang.String type)
type
-
public org.eclipse.persistence.dynamic.DynamicEntity newEntity(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String type)
tenantId
- type
-
public java.lang.Object query(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String name, java.util.Map<?,?> parameters)
name
- parameters
-
public java.lang.Object query(java.util.Map<java.lang.String,java.lang.String> tenantId, java.lang.String name, java.util.Map<?,?> parameters, java.util.Map<java.lang.String,?> hints, boolean returnSingleResult, boolean executeUpdate)
name
- parameters
- hints
- returnSingleResult
-
public void remove(ChangeListener listener)
listener
- public void setBaseURI(java.net.URI baseURI)
protected void setMappingValueInObject(java.lang.Object object, java.lang.Object attributeValue, org.eclipse.persistence.mappings.DatabaseMapping mapping, org.eclipse.persistence.mappings.DatabaseMapping partner)
public void stop()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object unmarshalEntity(java.lang.String type, javax.ws.rs.core.MediaType acceptedMedia, java.io.InputStream in) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
public java.lang.Object unmarshalEntity(java.lang.Class type, javax.ws.rs.core.MediaType acceptedMedia, java.io.InputStream in) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
protected java.lang.Object wrap(java.lang.Object entity)
entity
-
public void marshallEntity(java.lang.Object object, javax.ws.rs.core.MediaType mediaType, java.io.OutputStream output) throws javax.xml.bind.JAXBException
object
- mediaType
- output
-
javax.xml.bind.JAXBException
public void marshallEntity(java.lang.Object object, javax.ws.rs.core.MediaType mediaType, java.io.OutputStream output, boolean sendRelationships) throws javax.xml.bind.JAXBException
object
- mediaType
- output
- sendRelationships
- if this is set to true, relationships will be sent as links instead of sending
the actual objects in the relationships
javax.xml.bind.JAXBException
protected void preMarshallEntity(java.lang.Object object)
object
- protected void preMarshallIndividualEntity(java.lang.Object entity)
entity
- protected void postMarshallEntity(java.lang.Object object)
|
EclipseLink JPA-RS 2.4.1, build 'v20121003-ad44345' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |