Package org.apache.cayenne.remote
Class ClientChannel
java.lang.Object
org.apache.cayenne.remote.ClientChannel
- All Implemented Interfaces:
DataChannel
public class ClientChannel extends Object implements DataChannel
A
DataChannel
implementation that accesses a remote server
via a ClientConnection.- Since:
- 1.2
-
Field Summary
Fields Modifier and Type Field Description protected boolean
channelEventsEnabled
protected ClientConnection
connection
protected GraphDiffCompressor
diffCompressor
protected EntityResolver
entityResolver
protected EventManager
eventManager
Fields inherited from interface org.apache.cayenne.DataChannel
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC
-
Constructor Summary
Constructors Constructor Description ClientChannel(ClientConnection connection, boolean channelEventsEnabled, EventManager eventManager, boolean remoteEventsOptional)
-
Method Summary
Modifier and Type Method Description ClientConnection
getConnection()
EntityResolver
getEntityResolver()
Returns EntityResolver obtained from the server.EventManager
getEventManager()
Returns an EventManager associated with this channel.boolean
isChannelEventsEnabled()
QueryResponse
onQuery(ObjectContext context, Query query)
Executes a query, using provided context to register persistent objects if query returns any objects.GraphDiff
onSync(ObjectContext originatingContext, GraphDiff changes, int syncType)
Processes synchronization request from a child ObjectContext, returning a GraphDiff that describes changes to objects made on the receiving end as a result of synchronization.protected <T> T
send(org.apache.cayenne.remote.ClientMessage message, Class<T> resultClass)
Sends a message via connector, getting a result as an instance of a specific class.protected boolean
setupRemoteChannelListener()
Starts up an EventBridge to listen for remote updates.
-
Field Details
-
connection
-
eventManager
-
entityResolver
-
channelEventsEnabled
protected boolean channelEventsEnabled -
diffCompressor
-
-
Constructor Details
-
ClientChannel
public ClientChannel(ClientConnection connection, boolean channelEventsEnabled, EventManager eventManager, boolean remoteEventsOptional) throws CayenneRuntimeException- Parameters:
remoteEventsOptional
- if true, failure to start an EventBridge will not result in an exception.- Throws:
CayenneRuntimeException
- Since:
- 3.0
-
-
Method Details
-
getConnection
- Since:
- 3.1
-
isChannelEventsEnabled
public boolean isChannelEventsEnabled()- Since:
- 3.1
-
getEventManager
Description copied from interface:DataChannel
Returns an EventManager associated with this channel. Channel may return null if EventManager is not available for any reason.- Specified by:
getEventManager
in interfaceDataChannel
-
onQuery
Description copied from interface:DataChannel
Executes a query, using provided context to register persistent objects if query returns any objects.- Specified by:
onQuery
in interfaceDataChannel
- Parameters:
context
- an ObjectContext that originated the query, used to register result objects.- Returns:
- a generic response object that encapsulates result of the execution.
-
onSync
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 synchronization.- Specified by:
onSync
in interfaceDataChannel
- Parameters:
originatingContext
- an ObjectContext that initiated the sync. Can be null.changes
- diff from the context that initiated the sync.syncType
- One ofDataChannel.FLUSH_NOCASCADE_SYNC
,DataChannel.FLUSH_CASCADE_SYNC
,DataChannel.ROLLBACK_CASCADE_SYNC
.
-
getEntityResolver
Returns EntityResolver obtained from the server. On first access, this method sends a message to the server to retrieve the EntityResolver. On subsequent calls locally cached resolver is used.- Specified by:
getEntityResolver
in interfaceDataChannel
-
setupRemoteChannelListener
Starts up an EventBridge to listen for remote updates. Returns true if the listener was setup, false if not. False can be returned if the underlying connection doesn't support events of if there is no EventManager available.- Throws:
CayenneRuntimeException
-
send
Sends a message via connector, getting a result as an instance of a specific class.- Throws:
CayenneRuntimeException
- if an underlying connector exception occurred, or a result is not of expected type.
-