cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [25/30] cayenne git commit: CAY-2377. Cleanup ServerRuntime and ServerRuntimeBuilder
Date Thu, 07 Dec 2017 10:09:54 GMT
CAY-2377. Cleanup ServerRuntime and ServerRuntimeBuilder


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/ad9d9347
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/ad9d9347
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/ad9d9347

Branch: refs/heads/master
Commit: ad9d9347cca4afb3fef3f0f42872dcc8096e9d59
Parents: 72a3a52
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Mon Nov 13 10:45:18 2017 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Wed Nov 15 10:27:48 2017 +0300

----------------------------------------------------------------------
 .../configuration/server/ServerRuntime.java     | 47 --------------------
 .../server/ServerRuntimeBuilder.java            | 12 +----
 .../configuration/server/ServerRuntimeTest.java | 39 ++--------------
 .../unit/di/server/ServerRuntimeProvider.java   |  9 ++--
 docs/doc/src/main/resources/UPGRADE.txt         |  3 ++
 5 files changed, 14 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad9d9347/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntime.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntime.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntime.java
index b8c55f6..4a0f22f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntime.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntime.java
@@ -65,53 +65,6 @@ public class ServerRuntime extends CayenneRuntime {
         return new ServerRuntimeBuilder(name);
     }
 
-    @Deprecated
-    private static Collection<Module> collectModules(final String[] configurationLocations,
Module... extraModules) {
-        Collection<Module> modules = new ArrayList<>();
-        modules.add(new ServerModule());
-
-        if (configurationLocations.length > 0) {
-            modules.add(binder -> {
-                ListBuilder<String> locationsBinder = ServerModule.contributeProjectLocations(binder);
-                for (String c : configurationLocations) {
-                    locationsBinder.add(c);
-                }
-            });
-        }
-
-        if (extraModules != null) {
-            modules.addAll(asList(extraModules));
-        }
-
-        return modules;
-    }
-
-    /**
-     * Creates a server runtime configuring it with a standard set of services
-     * contained in {@link ServerModule}. CayenneServerModule is created with
-     * provided 'configurationLocation'. An optional array of extra modules may
-     * contain service overrides and/or user services.
-     *
-     * @deprecated since 4.0 use {@link ServerRuntime#builder()}.
-     */
-    @Deprecated
-    public ServerRuntime(String configurationLocation, Module... extraModules) {
-        this(collectModules(new String[]{configurationLocation}, extraModules));
-    }
-
-    /**
-     * Creates a server runtime configuring it with a standard set of services
-     * contained in {@link ServerModule}. CayenneServerModule is created with
-     * one or more 'configurationLocations'. An optional array of extra modules
-     * may contain service overrides and/or user services.
-     *
-     * @deprecated since 4.0 use {@link ServerRuntime#builder()}.
-     */
-    @Deprecated
-    public ServerRuntime(String[] configurationLocations, Module... extraModules) {
-        this(collectModules(configurationLocations, extraModules));
-    }
-
     /**
      * Creates a server runtime configuring it with a standard set of services
      * contained in {@link ServerModule}. CayenneServerModule is created with

http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad9d9347/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
index 208eb3b..6bb1742 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilder.java
@@ -61,12 +61,8 @@ public class ServerRuntimeBuilder {
 
     /**
      * Creates an empty builder.
-     *
-     * @deprecated since 4.0.M5 in favor of {@link ServerRuntime#builder()}
      */
-    @Deprecated
-    // TODO remove once we are comfortable with removal of the deprecated API
-    public ServerRuntimeBuilder() {
+    protected ServerRuntimeBuilder() {
         this(null);
     }
 
@@ -74,12 +70,8 @@ public class ServerRuntimeBuilder {
      * Creates a builder with a fixed name of the DataDomain of the resulting
      * ServerRuntime. Specifying explicit name is often needed for consistency
      * in runtimes merged from multiple configs, each having its own name.
-     *
-     * @deprecated since 4.0.M5 in favor of {@link ServerRuntime#builder(String)}
      */
-    @Deprecated
-    // TODO make private once we are comfortable with removal of the deprecated API
-    public ServerRuntimeBuilder(String name) {
+    protected ServerRuntimeBuilder(String name) {
         this.configs = new LinkedHashSet<>();
         this.modules = new ArrayList<>();
         this.name = name;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad9d9347/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeTest.java
index e422a94..2928712 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeTest.java
@@ -37,6 +37,7 @@ import org.junit.Test;
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import static java.util.Arrays.asList;
@@ -73,38 +74,6 @@ public class ServerRuntimeTest {
 
     }
 
-    @Deprecated
-    @Test
-    public void testDefaultConstructor_SingleLocation() {
-        ServerRuntime runtime = new ServerRuntime("xxxx");
-
-        List<String> locations = runtime.getInjector().getInstance(
-                Key.getListOf(String.class, Constants.SERVER_PROJECT_LOCATIONS_LIST));
-
-        assertEquals(Arrays.asList("xxxx"), locations);
-
-        Collection<Module> modules = runtime.getModules();
-        assertEquals(2, modules.size());
-        Module m0 = modules.iterator().next();
-        assertTrue(m0 instanceof ServerModule);
-    }
-
-    @Test
-    @Deprecated
-    public void testDefaultConstructor_MultipleLocations() {
-        ServerRuntime runtime = new ServerRuntime(new String[]{"xxxx", "yyyy"});
-
-        List<String> locations = runtime.getInjector().getInstance(
-                Key.getListOf(String.class, Constants.SERVER_PROJECT_LOCATIONS_LIST));
-
-        assertEquals(Arrays.asList("xxxx", "yyyy"), locations);
-
-        Collection<Module> modules = runtime.getModules();
-        assertEquals(2, modules.size());
-        Module m0 = modules.iterator().next();
-        assertTrue(m0 instanceof ServerModule);
-    }
-
     @Test
     @Deprecated
     public void testConstructor_Modules() {
@@ -125,7 +94,6 @@ public class ServerRuntimeTest {
     }
 
     @Test
-    @Deprecated
     public void testGetDataChannel_CustomModule() {
         final DataChannel channel = new DataChannel() {
 
@@ -148,12 +116,11 @@ public class ServerRuntimeTest {
 
         Module module = binder -> binder.bind(DataChannel.class).toInstance(channel);
 
-        ServerRuntime runtime = new ServerRuntime("Yuis", module);
+        ServerRuntime runtime = new ServerRuntime(Collections.singleton(module));
         assertSame(channel, runtime.getChannel());
     }
 
     @Test
-    @Deprecated
     public void testGetObjectContext_CustomModule() {
         final ObjectContext context = new DataContext();
         final ObjectContextFactory factory = new ObjectContextFactory() {
@@ -169,7 +136,7 @@ public class ServerRuntimeTest {
 
         Module module = binder -> binder.bind(ObjectContextFactory.class).toInstance(factory);
 
-        ServerRuntime runtime = new ServerRuntime("mnYw", module);
+        ServerRuntime runtime = new ServerRuntime(Collections.singleton(module));
         assertSame(context, runtime.newContext());
         assertSame(context, runtime.newContext());
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad9d9347/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerRuntimeProvider.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerRuntimeProvider.java
index 5155cdb..1531f91 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerRuntimeProvider.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/ServerRuntimeProvider.java
@@ -51,7 +51,7 @@ public class ServerRuntimeProvider implements Provider<ServerRuntime>
{
         this.unitDbAdapter = unitDbAdapter;
     }
 
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings("unchecked")
     @Override
     public ServerRuntime get() throws ConfigurationException {
 
@@ -61,9 +61,12 @@ public class ServerRuntimeProvider implements Provider<ServerRuntime>
{
                     + "annotate your test case with @UseServerRuntime");
         }
 
-        Collection<? extends Module> modules = getExtraModules();
+        Collection modules = getExtraModules();
 
-        return new ServerRuntime(configurationLocation, modules.toArray(new Module[modules.size()]));
+        return ServerRuntime.builder()
+                        .addConfig(configurationLocation)
+                        .addModules(modules)
+                        .build();
     }
 
     protected Collection<? extends Module> getExtraModules() {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/ad9d9347/docs/doc/src/main/resources/UPGRADE.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/UPGRADE.txt b/docs/doc/src/main/resources/UPGRADE.txt
index cc3ebc1..23ce6cd 100644
--- a/docs/doc/src/main/resources/UPGRADE.txt
+++ b/docs/doc/src/main/resources/UPGRADE.txt
@@ -266,6 +266,9 @@ UPGRADING TO 4.1.M2
 
       - removed setDataMap from buildQuery() in SQLTemplateDescriptor, SelectQueryDescriptor,
ProcedureQueryDescriptor and EJBQLQueryDescriptor;
       - removed setDataMap from org.apache.cayenne.AbstractQuery and from org.apache.cayenne.query.EJBQLQuery;
+      - removed ServerRuntime(String configurationLocation, Module... extraModules), ServerRuntime(String[]
configurationLocations, Module... extraModules) and
+      Collection<Module> collectModules(final String[] configurationLocations, Module...
extraModules) from org.apache.cayenne.configuration.server.ServerRuntime;
+
 
 UPGRADING TO 4.1.M1
 


Mime
View raw message