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
ADataChannelimplementation that accesses a remote server via a ClientConnection.- Since:
- 1.2
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanchannelEventsEnabledprotected ClientConnectionconnectionprotected GraphDiffCompressordiffCompressorprotected EntityResolverentityResolverprotected EventManagereventManager-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientConnectiongetConnection()EntityResolvergetEntityResolver()Returns EntityResolver obtained from the server.EventManagergetEventManager()booleanisChannelEventsEnabled()QueryResponseonQuery(ObjectContext context, Query query)GraphDiffonSync(ObjectContext originatingContext, GraphDiff changes, int syncType)protected <T> Tsend(ClientMessage message, Class<T> resultClass)Sends a message via connector, getting a result as an instance of a specific class.protected booleansetupRemoteChannelListener()Starts up an EventBridge to listen for remote updates.
-
-
-
Field Detail
-
connection
protected ClientConnection connection
-
eventManager
protected EventManager eventManager
-
entityResolver
protected EntityResolver entityResolver
-
channelEventsEnabled
protected boolean channelEventsEnabled
-
diffCompressor
protected GraphDiffCompressor diffCompressor
-
-
Constructor Detail
-
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 Detail
-
getConnection
public ClientConnection getConnection()
- Since:
- 3.1
-
isChannelEventsEnabled
public boolean isChannelEventsEnabled()
- Since:
- 3.1
-
getEventManager
public EventManager getEventManager()
- Specified by:
getEventManagerin interfaceDataChannel
-
onQuery
public QueryResponse onQuery(ObjectContext context, Query query)
- Specified by:
onQueryin interfaceDataChannel
-
onSync
public GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType)
- Specified by:
onSyncin interfaceDataChannel
-
getEntityResolver
public EntityResolver 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:
getEntityResolverin interfaceDataChannel
-
setupRemoteChannelListener
protected boolean setupRemoteChannelListener() throws CayenneRuntimeExceptionStarts 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
protected <T> T send(ClientMessage message, Class<T> resultClass)
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.
-
-