From 4c2d3091f86e0fb2fe3c07f459f71bb3bccb48d1 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 4 Apr 2016 11:06:53 -0700 Subject: [PATCH] GEODE-1025: Removing bundled SDG and special handling of spring jars Spring Data Gemfire will no longer be bundled with geode, instead users will be expected to manually add it to the classpath if they want to start with spring. Removing the spring jars from the lib directory, and the special code that automatically adds the spring jars to the classpath when starting with --spring-xml-location. --- build.gradle | 2 - geode-assembly/build.gradle | 26 +++----- .../LauncherLifecycleCommandsDUnitTest.java | 60 ------------------- .../LauncherLifecycleCommandsJUnitTest.java | 46 +------------- .../src/test/resources/expected_jars.txt | 3 - .../spring/spring-gemfire-context.xml | 43 ------------- geode-core/build.gradle | 7 +-- .../commands/LauncherLifecycleCommands.java | 60 +------------------ geode-rebalancer/build.gradle | 1 + geode-web/build.gradle | 7 ++- gradle/dependency-versions.properties | 2 - 11 files changed, 21 insertions(+), 236 deletions(-) delete mode 100644 geode-assembly/src/test/resources/spring/spring-gemfire-context.xml diff --git a/build.gradle b/build.gradle index 890bce3a1a27..4f79eaed184a 100755 --- a/build.gradle +++ b/build.gradle @@ -45,8 +45,6 @@ allprojects { repositories { mavenCentral() maven { url "http://repo.spring.io/release" } - maven { url "http://repo.spring.io/milestone" } - maven { url "http://repo.spring.io/snapshot" } } group = "org.apache.geode" diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle index 7e61d1d9c7ba..207db738930a 100755 --- a/geode-assembly/build.gradle +++ b/geode-assembly/build.gradle @@ -49,19 +49,7 @@ configurations { dependencies { provided project(':geode-core') - bundled ('org.springframework.data:spring-data-commons:' + project.'spring-data-commons.version') { - transitive=false - } - bundled ('org.springframework.data:spring-data-gemfire:' + project.'spring-data-gemfire.version') { - transitive=false - } - bundled ('org.springframework:spring-expression:' + project.'springframework.version') { - transitive=false - } - bundled ('org.springframework:spring-tx:' + project.'springframework.version') { - transitive=false - } - + archives project(':geode-common') archives project(':geode-json') archives project(':geode-joptsimple') @@ -75,6 +63,10 @@ dependencies { testCompile project(':geode-junit') testCompile project(path: ':geode-core', configuration: 'testOutput') + testCompile ('org.springframework:spring-web:' + project.'springframework.version') { + exclude module: 'aopalliance' + exclude module: 'spring-aop' + } testCompile 'org.apache.httpcomponents:httpclient:' + project.'httpclient.version' testCompile 'org.apache.httpcomponents:httpcore:' + project.'httpcore.version' @@ -314,18 +306,18 @@ distributions { from project(":geode-cq").configurations.archives.allArtifacts.files from project(":geode-core").configurations.runtime + from project(":geode-core").configurations.archives.allArtifacts.files + + from project(":geode-lucene").configurations.runtime + from project(":geode-lucene").configurations.archives.allArtifacts.files from configurations.bundled - from project(":geode-core").configurations.archives.allArtifacts.files //These tasks are included as closures (wrapped in {}) because gradle may evaluate //this CopySpec before it evaluates the geode-core build file. from { project(":geode-core").webJar } from { project(":geode-core").raJar } from { project(":geode-core").jcaJar } - - from project(":geode-lucene").configurations.runtime - from project(":geode-lucene").configurations.archives.allArtifacts.files // include this jar from project(":geode-web-api").jar diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java index 11712071c2b3..e41e1187bf9f 100644 --- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java +++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsDUnitTest.java @@ -799,66 +799,6 @@ public String description() { assertEquals(Status.NOT_RESPONDING, locatorState.getStatus()); } - public void test013StartServerWithSpring() { - String pathname = (getClass().getSimpleName() + "_" + getTestMethodName()); - File workingDirectory = new File(pathname); - - assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir()); - - CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_SERVER); - - command.addOption(CliStrings.START_SERVER__NAME, getClass().getSimpleName().concat("_").concat(getTestMethodName())); - command.addOption(CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION, Boolean.FALSE.toString()); - command.addOption(CliStrings.START_SERVER__LOG_LEVEL, "config"); - command.addOption(CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH); - command.addOption(CliStrings.START_SERVER__DISABLE_DEFAULT_SERVER); - command.addOption(CliStrings.START_SERVER__DIR, pathname); - command.addOption(CliStrings.START_SERVER__SPRING_XML_LOCATION, "spring/spring-gemfire-context.xml"); - - CommandResult result = executeCommand(command.toString()); - - assertNotNull(result); - assertEquals(Result.Status.OK, result.getStatus()); - - final ServerLauncher springGemFireServer = new ServerLauncher.Builder().setCommand( - ServerLauncher.Command.STATUS).setWorkingDirectory( - IOUtils.tryGetCanonicalPathElseGetAbsolutePath(workingDirectory)).build(); - - assertNotNull(springGemFireServer); - - ServerState serverState = springGemFireServer.status(); - - assertNotNull(serverState); - assertEquals(Status.ONLINE, serverState.getStatus()); - - //Ensure the member name is what is set through spring - String logFile = serverState.getLogFile(); - assertTrue("Log file name was not configured from spring context: " + logFile, logFile.contains("spring_server.log")); - - // Now that the GemFire Server bootstrapped with Spring started up OK, stop it! - stopServer(springGemFireServer.getWorkingDirectory()); - - WaitCriterion waitCriteria = new WaitCriterion() { - @Override - public boolean done() { - ServerState serverState = springGemFireServer.status(); - return (serverState != null && Status.NOT_RESPONDING.equals(serverState.getStatus())); - } - - @Override - public String description() { - return "wait for the Locator to stop; the Locator will no longer respond after it stops"; - } - }; - - waitForCriterion(waitCriteria, TimeUnit.SECONDS.toMillis(15), TimeUnit.SECONDS.toMillis(5), true); - - serverState = springGemFireServer.status(); - - assertNotNull(serverState); - assertEquals(Status.NOT_RESPONDING, serverState.getStatus()); - } - public void test014GemFireServerJvmProcessTerminatesOnOutOfMemoryError() throws Exception { int ports[] = AvailablePortHelper.getRandomAvailableTCPPorts(2); final int serverPort = ports[0]; diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java index c999cfae8d80..dc89f0362dc9 100755 --- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java +++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java @@ -311,47 +311,6 @@ public void testGemFireCoreClasspath() throws IOException { assertJarFileManifestClassPath(coreDependenciesJar, expectedJarDependencies); } - @Test - public void testGetSpringJars() { - List actualSpringJarPathnames = new LauncherLifecycleCommands().getSpringJars(); - - assertNotNull(actualSpringJarPathnames); - assertEquals(LauncherLifecycleCommands.SPRING_JAR_NAME_PREFIXES.size(), actualSpringJarPathnames.size()); - - int springCoreVersion = -1; - int springDataCommonsVersion = -1; - int springDataGemFireVersion = -1; - - Set expectedSpringJarNames = new HashSet<>(LauncherLifecycleCommands.SPRING_JAR_NAME_PREFIXES); - - assertFalse(expectedSpringJarNames.isEmpty()); - - for (String springJarPathname : actualSpringJarPathnames) { - String springJarName = springJarPathname.substring(springJarPathname.lastIndexOf(File.separator) + 1); - String springJarNamePrefix = springJarName.substring(0, springJarName.lastIndexOf("-")); - - switch (springJarNamePrefix) { - case LauncherLifecycleCommands.SPRING_BEANS_JAR_NAME_PREFIX: - springCoreVersion = Integer.parseInt(StringUtils.getDigitsOnly(springJarName)); - break; - case LauncherLifecycleCommands.SPRING_DATA_COMMONS_JAR_NAME_PREFIX: - springDataCommonsVersion = Integer.parseInt(StringUtils.getDigitsOnly(springJarName)); - break; - case LauncherLifecycleCommands.SPRING_DATA_GEMFIRE_JAR_NAME_PREFIX: - springDataGemFireVersion = Integer.parseInt(StringUtils.getDigitsOnly(springJarName)); - break; - } - - expectedSpringJarNames.remove(springJarNamePrefix); - } - - assertTrue(String.format("Expected empty; but was (%1$s)", expectedSpringJarNames), - expectedSpringJarNames.isEmpty()); - assertEquals(424, springCoreVersion); - assertEquals(191, springDataCommonsVersion); - assertEquals(172, springDataGemFireVersion); - } - @Test public void testGetSystemClasspath() { assertEquals(System.getProperty("java.class.path"), getLauncherLifecycleCommands().getSystemClasspath()); @@ -376,10 +335,9 @@ public void testServerClasspathOrder() { String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator).concat( userClasspath).concat(File.pathSeparator).concat( - LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME).concat(File.pathSeparator).concat( - toPath(launcherCommands.getSpringJars().toArray())); + LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME); - String actualClasspath = launcherCommands.getServerClasspath(false, true, userClasspath); + String actualClasspath = launcherCommands.getServerClasspath(false, userClasspath); assertEquals(expectedClasspath, actualClasspath); } diff --git a/geode-assembly/src/test/resources/expected_jars.txt b/geode-assembly/src/test/resources/expected_jars.txt index a566c4dbbf48..159d1e654f02 100644 --- a/geode-assembly/src/test/resources/expected_jars.txt +++ b/geode-assembly/src/test/resources/expected_jars.txt @@ -61,10 +61,7 @@ spring-aop spring-aspects spring-beans spring-context -spring-context-support spring-core -spring-data-commons -spring-data-gemfire spring-expression spring-hateoas spring-ldap-core diff --git a/geode-assembly/src/test/resources/spring/spring-gemfire-context.xml b/geode-assembly/src/test/resources/spring/spring-gemfire-context.xml deleted file mode 100644 index d6f6df3ab9fc..000000000000 --- a/geode-assembly/src/test/resources/spring/spring-gemfire-context.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - SpringGemFireServerBootstrap - 0 - config - spring_server.log - 0 - - - - - - - diff --git a/geode-core/build.gradle b/geode-core/build.gradle index 1d12be36e297..e91a2d3d4b43 100755 --- a/geode-core/build.gradle +++ b/geode-core/build.gradle @@ -101,11 +101,7 @@ dependencies { compile ('org.eclipse.jetty:jetty-webapp:' + project.'jetty.version') { ext.optional = true } - runtime ('org.springframework:spring-aop:' + project.'springframework.version') { - exclude module: 'aopalliance' - ext.optional = true - } - compile ('org.springframework:spring-webmvc:' + project.'springframework.version') { + provided ('org.springframework:spring-webmvc:' + project.'springframework.version') { exclude module: 'aopalliance' exclude module: 'spring-aop' ext.optional = true @@ -116,6 +112,7 @@ dependencies { exclude module: 'cglib' exclude module: 'guava' exclude module: 'spring-aop' + exclude module: 'spring-context-support' ext.optional = true } compile ('org.xerial.snappy:snappy-java:' + project.'snappy-java.version') { diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java index d9928c5b5172..d73c865c7c25 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java @@ -157,32 +157,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport { protected static final String CORE_DEPENDENCIES_JAR_PATHNAME = IOUtils.appendToPath(GEMFIRE_HOME, "lib", "geode-dependencies.jar"); - protected static final String SPRING_AOP_JAR_NAME_PREFIX = "spring-aop"; - protected static final String SPRING_BEANS_JAR_NAME_PREFIX = "spring-beans"; - protected static final String SPRING_CONTEXT_JAR_NAME_PREFIX = "spring-context"; - protected static final String SPRING_CONTEXT_SUPPORT_JAR_NAME_PREFIX = "spring-context-support"; - protected static final String SPRING_DATA_COMMONS_JAR_NAME_PREFIX = "spring-data-commons"; - protected static final String SPRING_DATA_GEMFIRE_JAR_NAME_PREFIX = "spring-data-gemfire"; - protected static final String SPRING_EXPRESSION_JAR_NAME_PREFIX = "spring-expression"; - protected static final String SPRING_TX_JAR_NAME_PREFIX = "spring-tx"; - - protected static final Set SPRING_JAR_NAME_PREFIXES; - - static { - Set springJarNamePrefixes = new HashSet<>(8); - - springJarNamePrefixes.add(SPRING_AOP_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_BEANS_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_CONTEXT_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_CONTEXT_SUPPORT_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_DATA_COMMONS_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_DATA_GEMFIRE_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_EXPRESSION_JAR_NAME_PREFIX); - springJarNamePrefixes.add(SPRING_TX_JAR_NAME_PREFIX); - - SPRING_JAR_NAME_PREFIXES = Collections.unmodifiableSet(springJarNamePrefixes); - } - protected static boolean isAttachApiAvailable() { if (ATTACH_API_AVAILABLE.get() == null) { try { @@ -1143,48 +1117,16 @@ protected String getLocatorClasspath(final boolean includeSystemClasspath, final } protected String getServerClasspath(final boolean includeSystemClasspath, - final boolean includeSpringDependencies, final String userClasspath) { List jarFilePathnames = new ArrayList<>(); jarFilePathnames.add(CORE_DEPENDENCIES_JAR_PATHNAME); - if (includeSpringDependencies) { - jarFilePathnames.addAll(getSpringJars()); - } - return toClasspath(includeSystemClasspath, jarFilePathnames.toArray(new String[jarFilePathnames.size()]), userClasspath); } - protected List getSpringJars() { - File gemfireHomeDirectory= new File(GEMFIRE_HOME); - - assertArgument(gemfireHomeDirectory.isDirectory(), - "Please set the GEMFIRE environment variable to the product installation directory."); - - List springJarFilePathnames = new ArrayList<>(SPRING_JAR_NAME_PREFIXES.size()); - - for (File jarFile : new File(gemfireHomeDirectory, "lib").listFiles(new FileFilter() { - @Override public boolean accept(final File pathname) { - return (pathname.getName().startsWith("spring-") && pathname.getAbsolutePath().endsWith(".jar")); - } - })) { - String jarFileName = jarFile.getName(); - - if (SPRING_JAR_NAME_PREFIXES.stream().anyMatch(prefix -> jarFileName.startsWith(prefix))) { - springJarFilePathnames.add(jarFile.getAbsolutePath()); - } - } - - assertState(springJarFilePathnames.size() == SPRING_JAR_NAME_PREFIXES.size(), - "Unable to find all the necessary Spring JAR files in $GEMFIRE/lib (%1$s): expected (%2$s); but was (%3$s)", - gemfireHomeDirectory, SPRING_JAR_NAME_PREFIXES, springJarFilePathnames); - - return springJarFilePathnames; - } - protected String getSystemClasspath() { return System.getProperty("java.class.path"); } @@ -1808,7 +1750,7 @@ protected String[] createStartServerCommandLine(final ServerLauncher launcher, commandLine.add("-server"); commandLine.add("-classpath"); commandLine.add(getServerClasspath(Boolean.TRUE.equals(includeSystemClasspath), - launcher.isSpringXmlLocationSpecified(), userClasspath)); + userClasspath)); addCurrentLocators(commandLine, gemfireProperties); addGemFirePropertyFile(commandLine, gemfirePropertiesPathname); diff --git a/geode-rebalancer/build.gradle b/geode-rebalancer/build.gradle index c21dbf1d9f63..b821590cd987 100644 --- a/geode-rebalancer/build.gradle +++ b/geode-rebalancer/build.gradle @@ -23,6 +23,7 @@ dependencies { exclude module: 'c3p0' exclude module: 'slf4j-api' } + compile ('org.springframework:spring-context:' + project.'springframework.version') testCompile project(':geode-junit') // the following test dependencies are needed for mocking cache instance diff --git a/geode-web/build.gradle b/geode-web/build.gradle index a2a3dd12c1ec..5bd1d8949c1b 100755 --- a/geode-web/build.gradle +++ b/geode-web/build.gradle @@ -38,7 +38,12 @@ dependencies { } testCompile 'org.springframework:spring-test:' + project.'springframework.version' - + + testCompile ('org.springframework:spring-webmvc:' + project.'springframework.version') { + exclude module: 'aopalliance' + exclude module: 'spring-aop' + } + provided 'javax.servlet:javax.servlet-api:' + project.'javax.servlet-api.version' // have to use output since we exclude the dependent classes from jar :( diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties index beb2d26ca5bf..18e327eb0cd8 100644 --- a/gradle/dependency-versions.properties +++ b/gradle/dependency-versions.properties @@ -85,8 +85,6 @@ quartz.version = 2.2.1 scala.version = 2.10.0 slf4j-api.version = 1.7.7 snappy-java.version = 1.1.1.6 -spring-data-commons.version = 1.9.1.RELEASE -spring-data-gemfire.version = 1.7.0.APACHE-GEODE-EA-SNAPSHOT spring-hateos.version = 0.16.0.RELEASE spring-shell.version = 1.1.0.RELEASE spring-ldap-core.version = 1.3.2.RELEASE