use of org.apache.cayenne.access.ClientServerChannel in project cayenne by apache.
the class ClientServerChannelProvider method get.
public ClientServerChannel get() throws ConfigurationException {
LocalConnection connection = (LocalConnection) clientRuntimeProvider.get().getConnection();
ClientServerDataChannelDecorator channelDecorator = (ClientServerDataChannelDecorator) connection.getChannel();
return (ClientServerChannel) channelDecorator.getDelegate();
}
use of org.apache.cayenne.access.ClientServerChannel in project cayenne by apache.
the class RemoteCayenneCase method createROPContext.
protected CayenneContext createROPContext() {
ClientServerChannel clientServerChannel = new ClientServerChannel(serverContext);
UnitLocalConnection connection = new UnitLocalConnection(clientServerChannel, serializationPolicy);
ClientChannel channel = new ClientChannel(connection, false, // TODO: replace with container managed ClientCase.
new DefaultEventManager(0), false);
CayenneContext context = new CayenneContext(channel, true, true);
context.setQueryCache(new MapQueryCache(10));
return context;
}
use of org.apache.cayenne.access.ClientServerChannel in project cayenne by apache.
the class LocalClientServerChannelProvider method get.
public DataChannel get() throws ConfigurationException {
ObjectContextFactory factory = serverInjector.getInstance(ObjectContextFactory.class);
// TODO: ugly cast
DataContext serverContext = (DataContext) factory.createContext();
return new ClientServerChannel(serverContext);
}
use of org.apache.cayenne.access.ClientServerChannel in project cayenne by apache.
the class ClientLocalRuntimeTest method testGetConnection.
@Test
public void testGetConnection() {
final DataContext serverContext = mock(DataContext.class);
Module serverModule = binder -> binder.bind(ObjectContextFactory.class).toInstance(new ObjectContextFactory() {
public ObjectContext createContext(DataChannel parent) {
return null;
}
public ObjectContext createContext() {
return serverContext;
}
});
ClientRuntime runtime = ClientRuntime.builder().local(DIBootstrap.createInjector(serverModule)).build();
ClientConnection connection = runtime.getConnection();
assertNotNull(connection);
assertTrue(connection instanceof LocalConnection);
LocalConnection localConnection = (LocalConnection) connection;
assertTrue(localConnection.getChannel() instanceof ClientServerChannel);
ClientServerChannel clientServerChannel = (ClientServerChannel) localConnection.getChannel();
assertSame(serverContext, clientServerChannel.getParentChannel());
}
Aggregations