org.apache.cayenne.intercept
Class DataChannelCallbackInterceptor
java.lang.Object
org.apache.cayenne.intercept.DataChannelDecorator
org.apache.cayenne.intercept.DataChannelCallbackInterceptor
- All Implemented Interfaces:
- DataChannel
public class DataChannelCallbackInterceptor
- extends DataChannelDecorator
Implements JPA-compliant "PreUpdate", "PostUpdate", "PostPersist", "PostRemove",
"PostLoad" callbacks for the DataChannel operations.
Depending on how callbacks are
registered, they are invoked either on persistent object instances directly or on an
instance of an arbitrary listener class. Signature of a callback method of a persistent
object is "void method()"
, while for a non-persistent listener it is
"void method(Object)"
. Note that this interceptor does not apply
"PreRemove" and "PrePersist" callbacks during "onSync", assuming that a child
ObjectContext did that already. It is often used in conjunction with
ObjectContextCallbackInterceptor
that adds those callbacks.
- Since:
- 3.0
- Author:
- Andrus Adamchik
- See Also:
ObjectContextCallbackInterceptor
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
callbackRegistry
protected LifecycleCallbackRegistry callbackRegistry
contextCallbacksEnabled
protected boolean contextCallbacksEnabled
DataChannelCallbackInterceptor
public DataChannelCallbackInterceptor()
setChannel
public void setChannel(DataChannel channel)
- Overrides:
setChannel
in class DataChannelDecorator
isEmpty
protected boolean isEmpty()
onQuery
public QueryResponse onQuery(ObjectContext originatingContext,
Query query)
- Description copied from interface:
DataChannel
- Executes a query, using provided context to register persistent objects
if query returns any objects.
- Specified by:
onQuery
in interface DataChannel
- Overrides:
onQuery
in class DataChannelDecorator
- Parameters:
originatingContext
- an ObjectContext that originated the query, used to
register result objects.
- Returns:
- a generic response object that encapsulates result of the execution.
onSync
public GraphDiff onSync(ObjectContext originatingContext,
GraphDiff changes,
int syncType)
- Description copied from interface:
DataChannel
- Processes synchronization request from a child ObjectContext, returning a GraphDiff
that describes changes to objects made on the receiving end as a result of
syncronization.
- Specified by:
onSync
in interface DataChannel
- Overrides:
onSync
in class DataChannelDecorator
- Parameters:
originatingContext
- an ObjectContext that initiated the sync. Can be null.changes
- diff from the context that initiated the sync.syncType
- One of DataChannel.FLUSH_NOCASCADE_SYNC
, DataChannel.FLUSH_CASCADE_SYNC
,
DataChannel.ROLLBACK_CASCADE_SYNC
.
isContextCallbacksEnabled
public boolean isContextCallbacksEnabled()
- Returns whether "PrePersist" and "PreRemove" callbacks should be executed during
sync. By default this is false, as they are executed by the parent ObjectContext.
This can be changed by calling
setContextCallbacksEnabled(boolean)
.
setContextCallbacksEnabled
public void setContextCallbacksEnabled(boolean contextCallbacksEnabled)
getCallbackRegistry
public LifecycleCallbackRegistry getCallbackRegistry()
Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.