use of org.apache.cayenne.CayenneRuntimeException in project cayenne by apache.
the class JettyHttp2ClientConnectionProvider method initJettyHttpClient.
@Override
protected HttpClient initJettyHttpClient() {
try {
HttpClientTransportOverHTTP2 http2 = new HttpClientTransportOverHTTP2(new HTTP2Client());
boolean useALPN = runtimeProperties.getBoolean(ClientConstants.ROP_SERVICE_USE_ALPN_PROPERTY, false);
http2.setUseALPN(useALPN);
HttpClient httpClient = new HttpClient(http2, new SslContextFactory());
httpClient.start();
return httpClient;
} catch (Exception e) {
throw new CayenneRuntimeException("Exception while starting Jetty HttpClient over HTTP/2.", e);
}
}
use of org.apache.cayenne.CayenneRuntimeException in project cayenne by apache.
the class JettyHttpROPConnectorIT method initJettyHttp2Client.
protected static HttpClient initJettyHttp2Client() {
try {
HttpClientTransportOverHTTP2 http2 = new HttpClientTransportOverHTTP2(new HTTP2Client());
http2.setUseALPN(false);
HttpClient httpClient = new HttpClient(http2, new SslContextFactory());
httpClient.start();
return httpClient;
} catch (Exception e) {
throw new CayenneRuntimeException("Exception while starting Jetty HttpClient over HTTP/2.", e);
}
}
use of org.apache.cayenne.CayenneRuntimeException in project cayenne by apache.
the class LocalConnection method doSendMessage.
/**
* Dispatches a message to an internal handler.
*/
@Override
protected Object doSendMessage(ClientMessage message) throws CayenneRuntimeException {
ClientMessage processedMessage;
try {
switch(serializationPolicy) {
case HESSIAN_SERIALIZATION:
processedMessage = (ClientMessage) HessianUtil.cloneViaClientServerSerialization(message, channel.getEntityResolver());
break;
case JAVA_SERIALIZATION:
processedMessage = Util.cloneViaSerialization(message);
break;
default:
processedMessage = message;
}
} catch (Exception ex) {
throw new CayenneRuntimeException("Error serializing message", ex);
}
Serializable result = (Serializable) DispatchHelper.dispatch(channel, processedMessage);
try {
switch(serializationPolicy) {
case HESSIAN_SERIALIZATION:
return HessianUtil.cloneViaServerClientSerialization(result, channel.getEntityResolver());
case JAVA_SERIALIZATION:
return Util.cloneViaSerialization(result);
default:
return result;
}
} catch (Exception ex) {
throw new CayenneRuntimeException("Error deserializing result", ex);
}
}
use of org.apache.cayenne.CayenneRuntimeException in project cayenne by apache.
the class HttpClientConnection method connect.
protected synchronized void connect() {
if (session != null) {
return;
}
long t0 = System.currentTimeMillis();
// create server session...
try {
this.session = (sharedSessionName != null) ? remoteService.establishSharedSession(sharedSessionName) : remoteService.establishSession();
} catch (Throwable th) {
logger.info(th.getMessage(), th);
throw new CayenneRuntimeException(th.getMessage(), th);
}
if (logger.isInfoEnabled()) {
long time = System.currentTimeMillis() - t0;
logger.info("=== Connected, session: " + session + " - took " + time + " ms.");
}
}
use of org.apache.cayenne.CayenneRuntimeException in project cayenne by apache.
the class DataContextNoPkIT method testNoPkFetchObjects.
@Test
public void testNoPkFetchObjects() throws Exception {
try {
List objects = context.performQuery(new SelectQuery<>(NoPkTestEntity.class));
fail("Query for entity with no primary key must have failed, instead we got " + objects.size() + " rows.");
} catch (CayenneRuntimeException ex) {
// exception expected
}
}
Aggregations