Search in sources :

Example 81 with CayenneRuntimeException

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);
    }
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HttpClientTransportOverHTTP2(org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2) HttpClient(org.eclipse.jetty.client.HttpClient) HTTP2Client(org.eclipse.jetty.http2.client.HTTP2Client) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException)

Example 82 with CayenneRuntimeException

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);
    }
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HttpClientTransportOverHTTP2(org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2) HttpClient(org.eclipse.jetty.client.HttpClient) HTTP2Client(org.eclipse.jetty.http2.client.HTTP2Client) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) ServletException(javax.servlet.ServletException) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException)

Example 83 with CayenneRuntimeException

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);
    }
}
Also used : Serializable(java.io.Serializable) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) ClientMessage(org.apache.cayenne.remote.ClientMessage) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException)

Example 84 with CayenneRuntimeException

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.");
    }
}
Also used : CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException)

Example 85 with CayenneRuntimeException

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
    }
}
Also used : NoPkTestEntity(org.apache.cayenne.testdo.no_pk.NoPkTestEntity) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) List(java.util.List) Test(org.junit.Test)

Aggregations

CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)168 Test (org.junit.Test)25 DbAttribute (org.apache.cayenne.map.DbAttribute)21 DataMap (org.apache.cayenne.map.DataMap)19 ObjectId (org.apache.cayenne.ObjectId)18 ObjEntity (org.apache.cayenne.map.ObjEntity)18 Persistent (org.apache.cayenne.Persistent)17 Expression (org.apache.cayenne.exp.Expression)17 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)17 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 DbEntity (org.apache.cayenne.map.DbEntity)14 IOException (java.io.IOException)13 List (java.util.List)12 ObjRelationship (org.apache.cayenne.map.ObjRelationship)12 DbRelationship (org.apache.cayenne.map.DbRelationship)10 DateTestEntity (org.apache.cayenne.testdo.date_time.DateTestEntity)10 File (java.io.File)9 Connection (java.sql.Connection)9 SQLException (java.sql.SQLException)9