Package org.apache.cayenne.remote
Class ClientChannel
- java.lang.Object
-
- org.apache.cayenne.remote.ClientChannel
-
- All Implemented Interfaces:
org.apache.cayenne.DataChannel
public class ClientChannel extends Object implements org.apache.cayenne.DataChannel
ADataChannelimplementation that accesses a remote server via a ClientConnection.- Since:
- 1.2
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanchannelEventsEnabledprotected ClientConnectionconnectionprotected org.apache.cayenne.graph.GraphDiffCompressordiffCompressorprotected org.apache.cayenne.map.EntityResolverentityResolverprotected org.apache.cayenne.event.EventManagereventManager
-
Constructor Summary
Constructors Constructor Description ClientChannel(ClientConnection connection, boolean channelEventsEnabled, org.apache.cayenne.event.EventManager eventManager, boolean remoteEventsOptional)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientConnectiongetConnection()org.apache.cayenne.map.EntityResolvergetEntityResolver()Returns EntityResolver obtained from the server.org.apache.cayenne.event.EventManagergetEventManager()booleanisChannelEventsEnabled()org.apache.cayenne.QueryResponseonQuery(org.apache.cayenne.ObjectContext context, org.apache.cayenne.query.Query query)org.apache.cayenne.graph.GraphDiffonSync(org.apache.cayenne.ObjectContext originatingContext, org.apache.cayenne.graph.GraphDiff changes, int syncType)protected <T> Tsend(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 booleansetupRemoteChannelListener()Starts up an EventBridge to listen for remote updates.
-
-
-
Field Detail
-
connection
protected ClientConnection connection
-
eventManager
protected org.apache.cayenne.event.EventManager eventManager
-
entityResolver
protected org.apache.cayenne.map.EntityResolver entityResolver
-
channelEventsEnabled
protected boolean channelEventsEnabled
-
diffCompressor
protected org.apache.cayenne.graph.GraphDiffCompressor diffCompressor
-
-
Constructor Detail
-
ClientChannel
public ClientChannel(ClientConnection connection, boolean channelEventsEnabled, org.apache.cayenne.event.EventManager eventManager, boolean remoteEventsOptional) throws org.apache.cayenne.CayenneRuntimeException
- Parameters:
remoteEventsOptional- if true, failure to start an EventBridge will not result in an exception.- Throws:
org.apache.cayenne.CayenneRuntimeException- Since:
- 3.0
-
-
Method Detail
-
getConnection
public ClientConnection getConnection()
- Since:
- 3.1
-
isChannelEventsEnabled
public boolean isChannelEventsEnabled()
- Since:
- 3.1
-
getEventManager
public org.apache.cayenne.event.EventManager getEventManager()
- Specified by:
getEventManagerin interfaceorg.apache.cayenne.DataChannel
-
onQuery
public org.apache.cayenne.QueryResponse onQuery(org.apache.cayenne.ObjectContext context, org.apache.cayenne.query.Query query)- Specified by:
onQueryin interfaceorg.apache.cayenne.DataChannel
-
onSync
public org.apache.cayenne.graph.GraphDiff onSync(org.apache.cayenne.ObjectContext originatingContext, org.apache.cayenne.graph.GraphDiff changes, int syncType)- Specified by:
onSyncin interfaceorg.apache.cayenne.DataChannel
-
getEntityResolver
public org.apache.cayenne.map.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 interfaceorg.apache.cayenne.DataChannel
-
setupRemoteChannelListener
protected boolean setupRemoteChannelListener() throws org.apache.cayenne.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:
org.apache.cayenne.CayenneRuntimeException
-
send
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.- Throws:
org.apache.cayenne.CayenneRuntimeException- if an underlying connector exception occurred, or a result is not of expected type.
-
-