You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2016/12/11 12:48:57 UTC
[2/2] cayenne git commit: CAY-2165 Explicit "contribution" API for
easier expansion of DI collections and maps
CAY-2165 Explicit "contribution" API for easier expansion of DI collections and maps
* splitting ROP constants away from server constants
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/1ace4e72
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/1ace4e72
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/1ace4e72
Branch: refs/heads/master
Commit: 1ace4e728d00a17792db18e258ee08c29fd58d3e
Parents: 50bee84
Author: Andrus Adamchik <an...@objectstyle.com>
Authored: Sun Dec 11 14:49:30 2016 +0300
Committer: Andrus Adamchik <an...@objectstyle.com>
Committed: Sun Dec 11 15:48:24 2016 +0300
----------------------------------------------------------------------
.../rop/JettyHttp2ClientConnectionProvider.java | 6 +-
.../rop/JettyHttpClientConnectionProvider.java | 16 +-
.../rop/client/CayenneContextFactory.java | 4 +-
.../rop/client/ClientChannelProvider.java | 2 +-
.../rop/client/ClientConstants.java | 50 +++
.../rop/HttpClientConnectionProvider.java | 16 +-
.../CayenneContextClientChannelEventsIT.java | 11 +-
.../rop/client/ClientModuleTest.java | 4 +-
.../cayenne/rop/protostuff/RuntimeBase.java | 4 +-
.../apache/cayenne/configuration/Constants.java | 408 ++++++++++---------
.../apache/cayenne/tutorial/Http2Client.java | 14 +-
.../tutorial/persistent/client/Main.java | 8 +-
12 files changed, 313 insertions(+), 230 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttp2ClientConnectionProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttp2ClientConnectionProvider.java b/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttp2ClientConnectionProvider.java
index b1411e9..09bc125 100644
--- a/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttp2ClientConnectionProvider.java
+++ b/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttp2ClientConnectionProvider.java
@@ -20,7 +20,7 @@
package org.apache.cayenne.rop;
import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.di.Provider;
import org.apache.cayenne.remote.ClientConnection;
import org.apache.cayenne.rop.http.JettyHttpROPConnector;
@@ -34,7 +34,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
* {@link org.eclipse.jetty.client.HttpClient} over {@link org.eclipse.jetty.http2.client.HTTP2Client}.
* It works without ALPN by default.
* <p>
- * In order to use it with ALPN you have to set {@link Constants#ROP_SERVICE_USE_ALPN_PROPERTY} to true
+ * In order to use it with ALPN you have to set {@link ClientConstants#ROP_SERVICE_USE_ALPN_PROPERTY} to true
* and provide the alpn-boot-XXX.jar into the bootstrap classpath.
*/
public class JettyHttp2ClientConnectionProvider extends JettyHttpClientConnectionProvider {
@@ -44,7 +44,7 @@ public class JettyHttp2ClientConnectionProvider extends JettyHttpClientConnectio
try {
HttpClientTransportOverHTTP2 http2 = new HttpClientTransportOverHTTP2(new HTTP2Client());
- boolean useALPN = runtimeProperties.getBoolean(Constants.ROP_SERVICE_USE_ALPN_PROPERTY, false);
+ boolean useALPN = runtimeProperties.getBoolean(ClientConstants.ROP_SERVICE_USE_ALPN_PROPERTY, false);
http2.setUseALPN(useALPN);
HttpClient httpClient = new HttpClient(http2, new SslContextFactory());
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttpClientConnectionProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttpClientConnectionProvider.java b/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttpClientConnectionProvider.java
index c430c79..6a616df 100644
--- a/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttpClientConnectionProvider.java
+++ b/cayenne-client-jetty/src/main/java/org/apache/cayenne/rop/JettyHttpClientConnectionProvider.java
@@ -21,8 +21,8 @@ package org.apache.cayenne.rop;
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.configuration.Constants;
import org.apache.cayenne.configuration.RuntimeProperties;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.di.DIRuntimeException;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.di.Provider;
@@ -54,7 +54,7 @@ public class JettyHttpClientConnectionProvider implements Provider<ClientConnect
@Override
public ClientConnection get() throws DIRuntimeException {
String sharedSession = runtimeProperties
- .get(Constants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
+ .get(ClientConstants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
JettyHttpROPConnector ropConnector = createJettyHttpRopConnector();
ProxyRemoteService remoteService = new ProxyRemoteService(serializationService, ropConnector);
@@ -66,16 +66,16 @@ public class JettyHttpClientConnectionProvider implements Provider<ClientConnect
}
protected JettyHttpROPConnector createJettyHttpRopConnector() {
- String url = runtimeProperties.get(Constants.ROP_SERVICE_URL_PROPERTY);
+ String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY);
if (url == null) {
throw new ConfigurationException(
"No property defined for '%s', can't initialize connection",
- Constants.ROP_SERVICE_URL_PROPERTY);
+ ClientConstants.ROP_SERVICE_URL_PROPERTY);
}
- String username = runtimeProperties.get(Constants.ROP_SERVICE_USERNAME_PROPERTY);
+ String username = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY);
long readTimeout = runtimeProperties.getLong(
- Constants.ROP_SERVICE_TIMEOUT_PROPERTY,
+ ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY,
-1L);
HttpClient httpClient = initJettyHttpClient();
@@ -103,8 +103,8 @@ public class JettyHttpClientConnectionProvider implements Provider<ClientConnect
}
protected void addBasicAuthentication(HttpClient httpClient, String url, String username) {
- String password = runtimeProperties.get(Constants.ROP_SERVICE_PASSWORD_PROPERTY);
- String realm = runtimeProperties.get(Constants.ROP_SERVICE_REALM_PROPERTY);
+ String password = runtimeProperties.get(ClientConstants.ROP_SERVICE_PASSWORD_PROPERTY);
+ String realm = runtimeProperties.get(ClientConstants.ROP_SERVICE_REALM_PROPERTY);
if (username != null && password != null) {
if (realm == null && logger.isWarnEnabled()) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/CayenneContextFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/CayenneContextFactory.java b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/CayenneContextFactory.java
index 991e9ab..d90cea0 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/CayenneContextFactory.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/CayenneContextFactory.java
@@ -49,11 +49,11 @@ public class CayenneContextFactory implements ObjectContextFactory {
public ObjectContext createContext(DataChannel parent) {
boolean changeEvents = properties.getBoolean(
- Constants.ROP_CONTEXT_CHANGE_EVENTS_PROPERTY,
+ ClientConstants.ROP_CONTEXT_CHANGE_EVENTS_PROPERTY,
false);
boolean lifecycleEvents = properties.getBoolean(
- Constants.ROP_CONTEXT_LIFECYCLE_EVENTS_PROPERTY,
+ ClientConstants.ROP_CONTEXT_LIFECYCLE_EVENTS_PROPERTY,
false);
CayenneContext context = newInstance(parent, changeEvents, lifecycleEvents);
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientChannelProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientChannelProvider.java b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientChannelProvider.java
index b5bc3e3..7936a1e 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientChannelProvider.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientChannelProvider.java
@@ -42,7 +42,7 @@ public class ClientChannelProvider implements Provider<DataChannel> {
public DataChannel get() throws ConfigurationException {
boolean channelEvents = properties.getBoolean(
- Constants.ROP_CHANNEL_EVENTS_PROPERTY,
+ ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY,
false);
return new ClientChannel(connection, channelEvents, eventManager, channelEvents);
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientConstants.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientConstants.java b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientConstants.java
new file mode 100644
index 0000000..c2c0833
--- /dev/null
+++ b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientConstants.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cayenne.configuration.rop.client;
+
+/**
+ * Defines the names of runtime properties and named collections used in DI modules related to ROP client.
+ *
+ * @since 4.0
+ */
+public class ClientConstants {
+
+ public static final String ROP_SERVICE_URL_PROPERTY = "cayenne.rop.service_url";
+
+ public static final String ROP_SERVICE_USERNAME_PROPERTY = "cayenne.rop.service_username";
+
+ public static final String ROP_SERVICE_PASSWORD_PROPERTY = "cayenne.rop.service_password";
+
+ public static final String ROP_SERVICE_REALM_PROPERTY = "cayenne.rop.service_realm";
+
+ /**
+ * A boolean property that defines whether ALPN should be used. Possible values are "true" or "false".
+ */
+ public static final String ROP_SERVICE_USE_ALPN_PROPERTY = "cayenne.rop.service_use_alpn";
+
+ public static final String ROP_SERVICE_SHARED_SESSION_PROPERTY = "cayenne.rop.shared_session_name";
+
+ public static final String ROP_SERVICE_TIMEOUT_PROPERTY = "cayenne.rop.service_timeout";
+
+ public static final String ROP_CHANNEL_EVENTS_PROPERTY = "cayenne.rop.channel_events";
+
+ public static final String ROP_CONTEXT_CHANGE_EVENTS_PROPERTY = "cayenne.rop.context_change_events";
+
+ public static final String ROP_CONTEXT_LIFECYCLE_EVENTS_PROPERTY = "cayenne.rop.context_lifecycle_events";
+}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/main/java/org/apache/cayenne/rop/HttpClientConnectionProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/HttpClientConnectionProvider.java b/cayenne-client/src/main/java/org/apache/cayenne/rop/HttpClientConnectionProvider.java
index ed4036c..c327de9 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/HttpClientConnectionProvider.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/rop/HttpClientConnectionProvider.java
@@ -19,8 +19,8 @@
package org.apache.cayenne.rop;
import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.configuration.Constants;
import org.apache.cayenne.configuration.RuntimeProperties;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.di.DIRuntimeException;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.di.Provider;
@@ -38,7 +38,7 @@ public class HttpClientConnectionProvider implements Provider<ClientConnection>
@Override
public ClientConnection get() throws DIRuntimeException {
String sharedSession = runtimeProperties
- .get(Constants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
+ .get(ClientConstants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
HttpROPConnector ropConnector = createHttpRopConnector();
ProxyRemoteService remoteService = new ProxyRemoteService(serializationService, ropConnector);
@@ -50,19 +50,17 @@ public class HttpClientConnectionProvider implements Provider<ClientConnection>
}
protected HttpROPConnector createHttpRopConnector() {
- String url = runtimeProperties.get(Constants.ROP_SERVICE_URL_PROPERTY);
+ String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY);
if (url == null) {
throw new ConfigurationException(
"No property defined for '%s', can't initialize HessianConnection",
- Constants.ROP_SERVICE_URL_PROPERTY);
+ ClientConstants.ROP_SERVICE_URL_PROPERTY);
}
- String userName = runtimeProperties.get(Constants.ROP_SERVICE_USERNAME_PROPERTY);
- String password = runtimeProperties.get(Constants.ROP_SERVICE_PASSWORD_PROPERTY);
+ String userName = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY);
+ String password = runtimeProperties.get(ClientConstants.ROP_SERVICE_PASSWORD_PROPERTY);
- long readTimeout = runtimeProperties.getLong(
- Constants.ROP_SERVICE_TIMEOUT_PROPERTY,
- -1L);
+ long readTimeout = runtimeProperties.getLong(ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY, -1L);
HttpROPConnector result = new HttpROPConnector(url, userName, password);
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsIT.java b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsIT.java
index efe5736..891f146 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsIT.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/CayenneContextClientChannelEventsIT.java
@@ -19,7 +19,7 @@
package org.apache.cayenne;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.configuration.rop.client.ClientRuntime;
import org.apache.cayenne.di.Inject;
import org.apache.cayenne.query.ObjectIdQuery;
@@ -36,19 +36,14 @@ import org.apache.cayenne.unit.di.server.UseServerRuntime;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
/**
* Tests peer context synchronization via ClientChannel events.
*/
@UseServerRuntime(CayenneProjects.MULTI_TIER_PROJECT)
@ClientRuntimeProperty({
- Constants.ROP_CHANNEL_EVENTS_PROPERTY, "true"
+ ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY, "true"
})
public class CayenneContextClientChannelEventsIT extends ClientCase {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-client/src/test/java/org/apache/cayenne/configuration/rop/client/ClientModuleTest.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/test/java/org/apache/cayenne/configuration/rop/client/ClientModuleTest.java b/cayenne-client/src/test/java/org/apache/cayenne/configuration/rop/client/ClientModuleTest.java
index 8786ff1..acf77c4 100644
--- a/cayenne-client/src/test/java/org/apache/cayenne/configuration/rop/client/ClientModuleTest.java
+++ b/cayenne-client/src/test/java/org/apache/cayenne/configuration/rop/client/ClientModuleTest.java
@@ -45,7 +45,7 @@ public class ClientModuleTest {
public void testClientConnection() {
Map<String, String> properties = new HashMap<>();
- properties.put(Constants.ROP_SERVICE_URL_PROPERTY, "http://localhost/YuM");
+ properties.put(ClientConstants.ROP_SERVICE_URL_PROPERTY, "http://localhost/YuM");
ClientModule module = new ClientModule(properties);
Injector injector = DIBootstrap.createInjector(module);
@@ -114,7 +114,7 @@ public class ClientModuleTest {
public void testDataChannel_NoChannelEvents() {
Map<String, String> properties = new HashMap<>();
- properties.put(Constants.ROP_CHANNEL_EVENTS_PROPERTY, "true");
+ properties.put(ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY, "true");
ClientModule module = new ClientModule(properties) {
@Override
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/RuntimeBase.java
----------------------------------------------------------------------
diff --git a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/RuntimeBase.java b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/RuntimeBase.java
index f474353..91bd033 100644
--- a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/RuntimeBase.java
+++ b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/RuntimeBase.java
@@ -20,7 +20,7 @@
package org.apache.cayenne.rop.protostuff;
import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.configuration.rop.client.ClientLocalRuntime;
import org.apache.cayenne.configuration.rop.client.ClientRuntime;
import org.apache.cayenne.configuration.rop.client.ProtostuffModule;
@@ -47,7 +47,7 @@ public class RuntimeBase extends ProtostuffProperties {
new CayenneJava8Module());
Map<String, String> properties = new HashMap<>();
- properties.put(Constants.ROP_CHANNEL_EVENTS_PROPERTY, Boolean.TRUE.toString());
+ properties.put(ClientConstants.ROP_CHANNEL_EVENTS_PROPERTY, Boolean.TRUE.toString());
Module module = binder -> binder.bind(ClientConnection.class)
.toProviderInstance(new ProtostuffLocalConnectionProvider());
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/cayenne-server/src/main/java/org/apache/cayenne/configuration/Constants.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/Constants.java b/cayenne-server/src/main/java/org/apache/cayenne/configuration/Constants.java
index 53f3de7..7844d6e 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/Constants.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/Constants.java
@@ -21,67 +21,66 @@ package org.apache.cayenne.configuration;
import org.apache.cayenne.di.Binder;
/**
- * Defines the names of runtime properties and DI collections used in DI modules
- * used to configure server and client runtime.
- *
+ * Defines the names of runtime properties and named collections used in DI modules.
+ *
* @since 3.1
*/
public interface Constants {
- // DI "collections"
-
- /**
- * A DI container key for the Map<String, String> storing properties
- * used by built-in Cayenne service.
- *
- * @see org.apache.cayenne.configuration.server.ServerModule#contributeProperties(Binder).
- */
- public static final String PROPERTIES_MAP = "cayenne.properties";
-
- /**
- * A DI container key for the List<DbAdapterDetector> that contains
- * objects that can discover the type of current database and install the
- * correct DbAdapter in runtime.
- */
- public static final String SERVER_ADAPTER_DETECTORS_LIST = "cayenne.server.adapter_detectors";
-
- /**
- * A DI container key for the List<DataChannelFilter> storing
- * DataDomain filters.
+ // DI "collections"
+
+ /**
+ * A DI container key for the Map<String, String> storing properties
+ * used by built-in Cayenne service.
+ *
+ * @see org.apache.cayenne.configuration.server.ServerModule#contributeProperties(Binder).
+ */
+ public static final String PROPERTIES_MAP = "cayenne.properties";
+
+ /**
+ * A DI container key for the List<DbAdapterDetector> that contains
+ * objects that can discover the type of current database and install the
+ * correct DbAdapter in runtime.
+ */
+ public static final String SERVER_ADAPTER_DETECTORS_LIST = "cayenne.server.adapter_detectors";
+
+ /**
+ * A DI container key for the List<DataChannelFilter> storing
+ * DataDomain filters.
*
* @see org.apache.cayenne.configuration.server.ServerModule#contributeDomainFilters(Binder).
- */
- public static final String SERVER_DOMAIN_FILTERS_LIST = "cayenne.server.domain_filters";
-
- /**
- * A DI container key for the List<String> storing locations of the
- * one of more project configuration files.
- */
- public static final String SERVER_PROJECT_LOCATIONS_LIST = "cayenne.server.project_locations";
-
- /**
- * A DI container key for the List<ExtendedType> storing default
- * adapter-agnostic ExtendedTypes.
- *
- * @see org.apache.cayenne.configuration.server.ServerModule#contributeDefaultTypes(Binder).
- */
- public static final String SERVER_DEFAULT_TYPES_LIST = "cayenne.server.default_types";
-
- /**
- * A DI container key for the List<ExtendedType> storing a
- * user-provided ExtendedTypes.
- *
- * @see org.apache.cayenne.configuration.server.ServerModule#contributeUserTypes(Binder).
- */
- public static final String SERVER_USER_TYPES_LIST = "cayenne.server.user_types";
-
- /**
- * A DI container key for the List<ExtendedTypeFactory> storing
- * default and user-provided ExtendedTypeFactories.
- *
- * @see org.apache.cayenne.configuration.server.ServerModule#contributeTypeFactories(Binder).
- */
- public static final String SERVER_TYPE_FACTORIES_LIST = "cayenne.server.type_factories";
+ */
+ public static final String SERVER_DOMAIN_FILTERS_LIST = "cayenne.server.domain_filters";
+
+ /**
+ * A DI container key for the List<String> storing locations of the
+ * one of more project configuration files.
+ */
+ public static final String SERVER_PROJECT_LOCATIONS_LIST = "cayenne.server.project_locations";
+
+ /**
+ * A DI container key for the List<ExtendedType> storing default
+ * adapter-agnostic ExtendedTypes.
+ *
+ * @see org.apache.cayenne.configuration.server.ServerModule#contributeDefaultTypes(Binder).
+ */
+ public static final String SERVER_DEFAULT_TYPES_LIST = "cayenne.server.default_types";
+
+ /**
+ * A DI container key for the List<ExtendedType> storing a
+ * user-provided ExtendedTypes.
+ *
+ * @see org.apache.cayenne.configuration.server.ServerModule#contributeUserTypes(Binder).
+ */
+ public static final String SERVER_USER_TYPES_LIST = "cayenne.server.user_types";
+
+ /**
+ * A DI container key for the List<ExtendedTypeFactory> storing
+ * default and user-provided ExtendedTypeFactories.
+ *
+ * @see org.apache.cayenne.configuration.server.ServerModule#contributeTypeFactories(Binder).
+ */
+ public static final String SERVER_TYPE_FACTORIES_LIST = "cayenne.server.type_factories";
/**
* A server-side DI container key for binding {@link org.apache.cayenne.resource.ResourceLocator}
@@ -89,139 +88,180 @@ public interface Constants {
public final static String SERVER_RESOURCE_LOCATOR = "cayenne.server.resource_locator";
/**
- * A server-side DI container key for the Map<String, String> storing
- * event bridge properties passed to the ROP client on bootstrap.
- */
- public static final String SERVER_ROP_EVENT_BRIDGE_PROPERTIES_MAP = "cayenne.server.rop_event_bridge_properties";
+ * A server-side DI container key for the Map<String, String> storing
+ * event bridge properties passed to the ROP client on bootstrap.
+ */
+ public static final String SERVER_ROP_EVENT_BRIDGE_PROPERTIES_MAP = "cayenne.server.rop_event_bridge_properties";
+
+ // Runtime properties
+
+ public static final String JDBC_DRIVER_PROPERTY = "cayenne.jdbc.driver";
+
+ public static final String JDBC_URL_PROPERTY = "cayenne.jdbc.url";
+
+ public static final String JDBC_USERNAME_PROPERTY = "cayenne.jdbc.username";
+
+ public static final String JDBC_PASSWORD_PROPERTY = "cayenne.jdbc.password";
+
+ public static final String JDBC_MIN_CONNECTIONS_PROPERTY = "cayenne.jdbc.min_connections";
+
+ public static final String JDBC_MAX_CONNECTIONS_PROPERTY = "cayenne.jdbc.max_connections";
+
+ /**
+ * Defines a maximum time in milliseconds that a connection request could
+ * wait in the connection queue. After this period expires, an exception
+ * will be thrown in the calling method. A value of zero will make the
+ * thread wait until a connection is available with no time out. Defaults to
+ * 20 seconds.
+ *
+ * @since 4.0
+ */
+ public static final String JDBC_MAX_QUEUE_WAIT_TIME = "cayenne.jdbc.max_wait";
+
+ /**
+ * @since 4.0
+ */
+ public static final String JDBC_VALIDATION_QUERY_PROPERTY = "cayenne.jdbc.validation_query";
+
+ /**
+ * An integer property defining the maximum number of entries in the query
+ * cache. Note that not all QueryCache providers may respect this property.
+ * MapQueryCache uses it, but the rest would use alternative configuration
+ * methods.
+ */
+ public static final String QUERY_CACHE_SIZE_PROPERTY = "cayenne.querycache.size";
+
+ /**
+ * An optional name of the runtime DataDomain. If not specified (which is
+ * normally the case), the name is inferred from the configuration name.
+ *
+ * @since 4.0
+ */
+ public static final String SERVER_DOMAIN_NAME_PROPERTY = "cayenne.server.domain.name";
+
+ /**
+ * A boolean property defining whether cross-contexts synchronization is
+ * enabled. Possible values are "true" or "false".
+ */
+ public static final String SERVER_CONTEXTS_SYNC_PROPERTY = "cayenne.server.contexts_sync_strategy";
+
+ /**
+ * A String property that defines how ObjectContexts should retain cached
+ * committed objects. Possible values are "weak", "soft", "hard".
+ */
+ public static final String SERVER_OBJECT_RETAIN_STRATEGY_PROPERTY = "cayenne.server.object_retain_strategy";
+
+ /**
+ * A boolean property that defines whether runtime should use external
+ * transactions. Possible values are "true" or "false".
+ */
+ public static final String SERVER_EXTERNAL_TX_PROPERTY = "cayenne.server.external_tx";
+
+ /**
+ * The name of the {@link org.apache.cayenne.event.EventBridgeFactory} that
+ * is passed from the ROP server to the client. Client would instantiate the
+ * factory to receive events from the server. Note that this property is
+ * stored in {@link #SERVER_ROP_EVENT_BRIDGE_PROPERTIES_MAP}, not
+ * {@link #PROPERTIES_MAP}.
+ */
+ public static final String SERVER_ROP_EVENT_BRIDGE_FACTORY_PROPERTY = "cayenne.server.rop_event_bridge_factory";
+
+ /**
+ * A property that defines a maximum number of ID qualifiers in where clause
+ * of queries that are generated for example in
+ * {@link org.apache.cayenne.access.IncrementalFaultList} or in
+ * DISJOINT_BY_ID prefetch processing. This is needed to avoid where clause
+ * size limitations and memory usage efficiency.
+ */
+ public static final String SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY = "cayenne.server.max_id_qualifier_size";
+
+ /**
+ * Defines a maximum time in milliseconds that a connection request could
+ * wait in the connection queue. After this period expires, an exception
+ * will be thrown in the calling method. A value of zero will make the
+ * thread wait until a connection is available with no time out. Defaults to
+ * 20 seconds.
+ *
+ * @deprecated since 4.0 renamed to {@link #JDBC_MAX_QUEUE_WAIT_TIME}. Property name is preserved.
+ */
+ public static final String SERVER_MAX_QUEUE_WAIT_TIME = JDBC_MAX_QUEUE_WAIT_TIME;
+
+ /**
+ * Defines if database uses case-insensitive collation
+ */
+ public final static String CI_PROPERTY = "cayenne.runtime.db.collation.assume.ci";
+
+ /**
+ * A integer property that enables logging for just long running queries
+ * (rather than all queries). The value is the minimum number of
+ * milliseconds a query must run before is logged. A value less than or
+ * equal to zero (the default) disables this feature.
+ *
+ * @since 4.0
+ */
+ public final static String QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY = "cayenne.server.query_execution_time_logging_threshold";
+
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_URL_PROPERTY = "cayenne.rop.service_url";
- // Runtime properties
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_USERNAME_PROPERTY = "cayenne.rop.service_username";
- public static final String JDBC_DRIVER_PROPERTY = "cayenne.jdbc.driver";
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_PASSWORD_PROPERTY = "cayenne.rop.service_password";
- public static final String JDBC_URL_PROPERTY = "cayenne.jdbc.url";
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_REALM_PROPERTY = "cayenne.rop.service_realm";
- public static final String JDBC_USERNAME_PROPERTY = "cayenne.jdbc.username";
+ /**
+ * A boolean property that defines whether ALPN should be used.
+ * Possible values are "true" or "false".
+ *
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_USE_ALPN_PROPERTY = "cayenne.rop.service_use_alpn";
- public static final String JDBC_PASSWORD_PROPERTY = "cayenne.jdbc.password";
-
- public static final String JDBC_MIN_CONNECTIONS_PROPERTY = "cayenne.jdbc.min_connections";
-
- public static final String JDBC_MAX_CONNECTIONS_PROPERTY = "cayenne.jdbc.max_connections";
-
- /**
- * Defines a maximum time in milliseconds that a connection request could
- * wait in the connection queue. After this period expires, an exception
- * will be thrown in the calling method. A value of zero will make the
- * thread wait until a connection is available with no time out. Defaults to
- * 20 seconds.
- *
- * @since 4.0
- */
- public static final String JDBC_MAX_QUEUE_WAIT_TIME = "cayenne.jdbc.max_wait";
-
- /**
- * @since 4.0
- */
- public static final String JDBC_VALIDATION_QUERY_PROPERTY = "cayenne.jdbc.validation_query";
-
- /**
- * An integer property defining the maximum number of entries in the query
- * cache. Note that not all QueryCache providers may respect this property.
- * MapQueryCache uses it, but the rest would use alternative configuration
- * methods.
- */
- public static final String QUERY_CACHE_SIZE_PROPERTY = "cayenne.querycache.size";
-
- /**
- * An optional name of the runtime DataDomain. If not specified (which is
- * normally the case), the name is inferred from the configuration name.
- *
- * @since 4.0
- */
- public static final String SERVER_DOMAIN_NAME_PROPERTY = "cayenne.server.domain.name";
-
- /**
- * A boolean property defining whether cross-contexts synchronization is
- * enabled. Possible values are "true" or "false".
- */
- public static final String SERVER_CONTEXTS_SYNC_PROPERTY = "cayenne.server.contexts_sync_strategy";
-
- /**
- * A String property that defines how ObjectContexts should retain cached
- * committed objects. Possible values are "weak", "soft", "hard".
- */
- public static final String SERVER_OBJECT_RETAIN_STRATEGY_PROPERTY = "cayenne.server.object_retain_strategy";
-
- /**
- * A boolean property that defines whether runtime should use external
- * transactions. Possible values are "true" or "false".
- */
- public static final String SERVER_EXTERNAL_TX_PROPERTY = "cayenne.server.external_tx";
-
- public static final String ROP_SERVICE_URL_PROPERTY = "cayenne.rop.service_url";
-
- public static final String ROP_SERVICE_USERNAME_PROPERTY = "cayenne.rop.service_username";
-
- public static final String ROP_SERVICE_PASSWORD_PROPERTY = "cayenne.rop.service_password";
-
- public static final String ROP_SERVICE_REALM_PROPERTY = "cayenne.rop.service_realm";
-
- /**
- * A boolean property that defines whether ALPN should be used.
- * Possible values are "true" or "false".
- */
- public static final String ROP_SERVICE_USE_ALPN_PROPERTY = "cayenne.rop.service_use_alpn";
-
- public static final String ROP_SERVICE_SHARED_SESSION_PROPERTY = "cayenne.rop.shared_session_name";
-
- public static final String ROP_SERVICE_TIMEOUT_PROPERTY = "cayenne.rop.service_timeout";
-
- public static final String ROP_CHANNEL_EVENTS_PROPERTY = "cayenne.rop.channel_events";
-
- public static final String ROP_CONTEXT_CHANGE_EVENTS_PROPERTY = "cayenne.rop.context_change_events";
-
- public static final String ROP_CONTEXT_LIFECYCLE_EVENTS_PROPERTY = "cayenne.rop.context_lifecycle_events";
-
- /**
- * The name of the {@link org.apache.cayenne.event.EventBridgeFactory} that
- * is passed from the ROP server to the client. Client would instantiate the
- * factory to receive events from the server. Note that this property is
- * stored in {@link #SERVER_ROP_EVENT_BRIDGE_PROPERTIES_MAP}, not
- * {@link #PROPERTIES_MAP}.
- */
- public static final String SERVER_ROP_EVENT_BRIDGE_FACTORY_PROPERTY = "cayenne.server.rop_event_bridge_factory";
-
- /**
- * A property that defines a maximum number of ID qualifiers in where clause
- * of queries that are generated for example in
- * {@link org.apache.cayenne.access.IncrementalFaultList} or in
- * DISJOINT_BY_ID prefetch processing. This is needed to avoid where clause
- * size limitations and memory usage efficiency.
- */
- public static final String SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY = "cayenne.server.max_id_qualifier_size";
-
- /**
- * Defines a maximum time in milliseconds that a connection request could
- * wait in the connection queue. After this period expires, an exception
- * will be thrown in the calling method. A value of zero will make the
- * thread wait until a connection is available with no time out. Defaults to
- * 20 seconds.
- *
- * @deprecated since 4.0 renamed to {@link #JDBC_MAX_QUEUE_WAIT_TIME}. Property name is preserved.
- */
- public static final String SERVER_MAX_QUEUE_WAIT_TIME = JDBC_MAX_QUEUE_WAIT_TIME;
-
- /** Defines if database uses case-insensitive collation */
- public final static String CI_PROPERTY = "cayenne.runtime.db.collation.assume.ci";
-
- /**
- * A integer property that enables logging for just long running queries
- * (rather than all queries). The value is the minimum number of
- * milliseconds a query must run before is logged. A value less than or
- * equal to zero (the default) disables this feature.
- *
- * @since 4.0
- * */
- public final static String QUERY_EXECUTION_TIME_LOGGING_THRESHOLD_PROPERTY = "cayenne.server.query_execution_time_logging_threshold";
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_SHARED_SESSION_PROPERTY = "cayenne.rop.shared_session_name";
+
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_SERVICE_TIMEOUT_PROPERTY = "cayenne.rop.service_timeout";
+
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_CHANNEL_EVENTS_PROPERTY = "cayenne.rop.channel_events";
+
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_CONTEXT_CHANGE_EVENTS_PROPERTY = "cayenne.rop.context_change_events";
+
+ /**
+ * @deprecated since 4.0 moved to cayenne-client org.apache.cayenne.configuration.rop.client.ClientConstants.
+ */
+ @Deprecated
+ public static final String ROP_CONTEXT_LIFECYCLE_EVENTS_PROPERTY = "cayenne.rop.context_lifecycle_events";
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/tutorials/tutorial-rop-client-http2/src/main/java/org/apache/cayenne/tutorial/Http2Client.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-client-http2/src/main/java/org/apache/cayenne/tutorial/Http2Client.java b/tutorials/tutorial-rop-client-http2/src/main/java/org/apache/cayenne/tutorial/Http2Client.java
index 97b589e..6fb819d 100644
--- a/tutorials/tutorial-rop-client-http2/src/main/java/org/apache/cayenne/tutorial/Http2Client.java
+++ b/tutorials/tutorial-rop-client-http2/src/main/java/org/apache/cayenne/tutorial/Http2Client.java
@@ -20,7 +20,7 @@
package org.apache.cayenne.tutorial;
import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.configuration.rop.client.ClientJettyHttp2Module;
import org.apache.cayenne.configuration.rop.client.ClientRuntime;
import org.apache.cayenne.configuration.rop.client.ProtostuffModule;
@@ -43,7 +43,7 @@ import java.util.Map;
* and {@link JettyHttpROPConnector} initialized by {@link JettyHttp2ClientConnectionProvider}, which is bound
* in {@link ClientJettyHttp2Module}. It works without ALPN by default.
* <p>
- * In order to run it with ALPN, you have to set {@link Constants#ROP_SERVICE_USE_ALPN_PROPERTY} to true
+ * In order to run it with ALPN, you have to set {@link ClientConstants#ROP_SERVICE_USE_ALPN_PROPERTY} to true
* and provide the alpn-boot-XXX.jar into the bootstrap classpath.
*/
public class Http2Client {
@@ -60,11 +60,11 @@ public class Http2Client {
System.setProperty("protostuff.runtime.pojo_schema_on_map_fields", "true");
Map<String, String> properties = new HashMap<>();
- properties.put(Constants.ROP_SERVICE_URL_PROPERTY, "https://localhost:8443/");
- properties.put(Constants.ROP_SERVICE_USE_ALPN_PROPERTY, "false");
- properties.put(Constants.ROP_SERVICE_USERNAME_PROPERTY, "cayenne-user");
- properties.put(Constants.ROP_SERVICE_PASSWORD_PROPERTY, "secret");
- properties.put(Constants.ROP_SERVICE_REALM_PROPERTY, "Cayenne Realm");
+ properties.put(ClientConstants.ROP_SERVICE_URL_PROPERTY, "https://localhost:8443/");
+ properties.put(ClientConstants.ROP_SERVICE_USE_ALPN_PROPERTY, "false");
+ properties.put(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY, "cayenne-user");
+ properties.put(ClientConstants.ROP_SERVICE_PASSWORD_PROPERTY, "secret");
+ properties.put(ClientConstants.ROP_SERVICE_REALM_PROPERTY, "Cayenne Realm");
ClientRuntime runtime = new ClientRuntime(properties,
new ClientJettyHttp2Module(),
http://git-wip-us.apache.org/repos/asf/cayenne/blob/1ace4e72/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
----------------------------------------------------------------------
diff --git a/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java b/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
index ddb00e5..b86852b 100644
--- a/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
+++ b/tutorials/tutorial-rop-client/src/main/java/org/apache/cayenne/tutorial/persistent/client/Main.java
@@ -19,7 +19,7 @@
package org.apache.cayenne.tutorial.persistent.client;
import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.configuration.Constants;
+import org.apache.cayenne.configuration.rop.client.ClientConstants;
import org.apache.cayenne.configuration.rop.client.ClientRuntime;
import org.apache.cayenne.query.ObjectSelect;
@@ -32,9 +32,9 @@ public class Main {
public static void main(String[] args) {
Map<String, String> properties = new HashMap<>();
- properties.put(Constants.ROP_SERVICE_URL_PROPERTY, "http://localhost:8080/tutorial-rop-server/cayenne-service");
- properties.put(Constants.ROP_SERVICE_USERNAME_PROPERTY, "cayenne-user");
- properties.put(Constants.ROP_SERVICE_PASSWORD_PROPERTY, "secret");
+ properties.put(ClientConstants.ROP_SERVICE_URL_PROPERTY, "http://localhost:8080/tutorial-rop-server/cayenne-service");
+ properties.put(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY, "cayenne-user");
+ properties.put(ClientConstants.ROP_SERVICE_PASSWORD_PROPERTY, "secret");
ClientRuntime runtime = new ClientRuntime(properties);