Search in sources :

Example 1 with JettyHttpROPConnector

use of org.apache.cayenne.rop.http.JettyHttpROPConnector in project cayenne by apache.

the class JettyHttpClientConnectionProvider method createJettyHttpRopConnector.

protected JettyHttpROPConnector createJettyHttpRopConnector() {
    String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY);
    if (url == null) {
        throw new ConfigurationException("No property defined for '%s', can't initialize connection", ClientConstants.ROP_SERVICE_URL_PROPERTY);
    }
    String username = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY);
    long readTimeout = runtimeProperties.getLong(ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY, -1L);
    HttpClient httpClient = initJettyHttpClient();
    addBasicAuthentication(httpClient, url, username);
    JettyHttpROPConnector result = new JettyHttpROPConnector(httpClient, url, username);
    if (readTimeout > 0) {
        result.setReadTimeout(readTimeout);
    }
    return result;
}
Also used : ConfigurationException(org.apache.cayenne.ConfigurationException) HttpClient(org.eclipse.jetty.client.HttpClient) JettyHttpROPConnector(org.apache.cayenne.rop.http.JettyHttpROPConnector)

Example 2 with JettyHttpROPConnector

use of org.apache.cayenne.rop.http.JettyHttpROPConnector in project cayenne by apache.

the class JettyHttpClientConnectionProvider method get.

@Override
public ClientConnection get() throws DIRuntimeException {
    String sharedSession = runtimeProperties.get(ClientConstants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
    JettyHttpROPConnector ropConnector = createJettyHttpRopConnector();
    ProxyRemoteService remoteService = new ProxyRemoteService(serializationService, ropConnector);
    HttpClientConnection clientConnection = new HttpClientConnection(remoteService, sharedSession);
    ropConnector.setClientConnection(clientConnection);
    return clientConnection;
}
Also used : JettyHttpROPConnector(org.apache.cayenne.rop.http.JettyHttpROPConnector)

Aggregations

JettyHttpROPConnector (org.apache.cayenne.rop.http.JettyHttpROPConnector)2 ConfigurationException (org.apache.cayenne.ConfigurationException)1 HttpClient (org.eclipse.jetty.client.HttpClient)1