Skip to content

Commit

Permalink
GEODE-1025: Removing bundled SDG and special handling of spring jars
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
upthewaterspout committed Apr 7, 2016
1 parent 22906e0 commit 4c2d309
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 236 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 9 additions & 17 deletions geode-assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,47 +311,6 @@ public void testGemFireCoreClasspath() throws IOException {
assertJarFileManifestClassPath(coreDependenciesJar, expectedJarDependencies);
}

@Test
public void testGetSpringJars() {
List<String> 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<String> 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());
Expand All @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions geode-assembly/src/test/resources/expected_jars.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

7 changes: 2 additions & 5 deletions geode-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> SPRING_JAR_NAME_PREFIXES;

static {
Set<String> 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 {
Expand Down Expand Up @@ -1143,48 +1117,16 @@ protected String getLocatorClasspath(final boolean includeSystemClasspath, final
}

protected String getServerClasspath(final boolean includeSystemClasspath,
final boolean includeSpringDependencies,
final String userClasspath)
{
List<String> 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<String> getSpringJars() {
File gemfireHomeDirectory= new File(GEMFIRE_HOME);

assertArgument(gemfireHomeDirectory.isDirectory(),
"Please set the GEMFIRE environment variable to the product installation directory.");

List<String> 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");
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions geode-rebalancer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion geode-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 :(
Expand Down
2 changes: 0 additions & 2 deletions gradle/dependency-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c2d309

Please sign in to comment.