Permalink
Browse files

Initial upgrade to Spring 3.1 M1 with Spring environment profiles int…

…egration, still more work to do on Spring MVC updates
  • Loading branch information...
1 parent 94b392d commit fb53d5bb6172cfb8fd922d35aca7ab5440e4bdb0 @graemerocher graemerocher committed May 13, 2011
View
@@ -15,7 +15,7 @@ apply plugin: 'idea'
grailsVersion = '1.4.0.BUILD-SNAPSHOT'
antVersion = "1.8.2"
antTraxVersion = "1.7.1"
-springVersion = "3.0.5.RELEASE"
+springVersion = "3.1.0.M1"
springLoadedVersion = "0.8.0.BUILD-SNAPSHOT"
ivyVersion = "2.2.0"
gantVersion = "1.9.5"
@@ -82,16 +82,19 @@ public Object doCall() {
// dependencies needed by the Grails build system
+ String springVersion = "3.1.0.M1";
+ String antVersion = "1.8.2";
+ String slf4jVersion = "1.6.1";
ModuleRevisionId[] buildDependencies = {
ModuleRevisionId.newInstance("org.springframework.uaa", "org.springframework.uaa.client", "1.0.1.RELEASE"),
ModuleRevisionId.newInstance("com.google.protobuf", "protobuf-java", "2.3.0"),
ModuleRevisionId.newInstance("com.googlecode.json-simple", "json-simple", "1.1"),
ModuleRevisionId.newInstance("org.bouncycastle", "bcpg-jdk15", "1.45"),
ModuleRevisionId.newInstance("org.bouncycastle", "bcprov-jdk15", "1.45"),
ModuleRevisionId.newInstance("org.tmatesoft.svnkit", "svnkit", "1.3.4"),
- ModuleRevisionId.newInstance("org.apache.ant", "ant", "1.8.2"),
- ModuleRevisionId.newInstance("org.apache.ant", "ant-launcher", "1.8.2"),
- ModuleRevisionId.newInstance("org.apache.ant", "ant-junit", "1.8.2"),
+ ModuleRevisionId.newInstance("org.apache.ant", "ant", antVersion),
+ ModuleRevisionId.newInstance("org.apache.ant", "ant-launcher", antVersion),
+ ModuleRevisionId.newInstance("org.apache.ant", "ant-junit", antVersion),
ModuleRevisionId.newInstance("org.apache.ant", "ant-trax", "1.7.1"),
ModuleRevisionId.newInstance("jline", "jline", "0.9.94"),
ModuleRevisionId.newInstance("org.fusesource.jansi", "jansi", "1.2.1"),
@@ -102,9 +105,9 @@ public Object doCall() {
ModuleRevisionId.newInstance("org.grails", "grails-core", grailsVersion),
ModuleRevisionId.newInstance("org.grails", "grails-resources", grailsVersion),
ModuleRevisionId.newInstance("org.grails", "grails-web", grailsVersion),
- ModuleRevisionId.newInstance("org.slf4j", "slf4j-api", "1.6.1"),
- ModuleRevisionId.newInstance("org.slf4j", "slf4j-log4j12", "1.6.1"),
- ModuleRevisionId.newInstance("org.springframework", "spring-test", "3.0.5.RELEASE"),
+ ModuleRevisionId.newInstance("org.slf4j", "slf4j-api", slf4jVersion),
+ ModuleRevisionId.newInstance("org.slf4j", "slf4j-log4j12", slf4jVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-test", springVersion),
ModuleRevisionId.newInstance("com.googlecode.concurrentlinkedhashmap", "concurrentlinkedhashmap-lru", "1.1_jdk5")
};
registerDependencies(dependencyManager, "build", buildDependencies);
@@ -180,25 +183,25 @@ public Object doCall() {
ModuleRevisionId.newInstance("org.grails", "grails-plugin-mimetypes", grailsVersion),
ModuleRevisionId.newInstance("org.grails", "grails-plugin-url-mappings", grailsVersion),
ModuleRevisionId.newInstance("org.grails", "grails-plugin-validation", grailsVersion),
- ModuleRevisionId.newInstance("org.springframework", "spring-core", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-aop", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-aspects", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-asm", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-beans", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-context", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-context-support", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-expression", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-instrument", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-jdbc", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-jms", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-orm", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-oxm", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-tx", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-web", "3.0.5.RELEASE"),
- ModuleRevisionId.newInstance("org.springframework", "spring-webmvc", "3.0.5.RELEASE"),
+ ModuleRevisionId.newInstance("org.springframework", "spring-core", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-aop", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-aspects", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-asm", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-beans", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-context", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-context-support", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-expression", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-instrument", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-jdbc", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-jms", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-orm", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-oxm", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-tx", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-web", springVersion),
+ ModuleRevisionId.newInstance("org.springframework", "spring-webmvc", springVersion),
ModuleRevisionId.newInstance("org.springframework", "spring-datastore-core", springDatastoreMappingVersion),
ModuleRevisionId.newInstance("org.springframework", "spring-datastore-simple", springDatastoreMappingVersion),
- ModuleRevisionId.newInstance("org.slf4j", "slf4j-api", "1.6.1")
+ ModuleRevisionId.newInstance("org.slf4j", "slf4j-api", slf4jVersion)
};
registerDependencies(dependencyManager, compileTimeDependenciesMethod, compileDependencies);
@@ -208,7 +211,7 @@ public Object doCall() {
ModuleRevisionId.newInstance("junit", "junit", "4.8.1"),
ModuleRevisionId.newInstance("org.grails", "grails-plugin-testing", grailsVersion),
ModuleRevisionId.newInstance("org.grails", "grails-test", grailsVersion),
- ModuleRevisionId.newInstance("org.springframework", "spring-test", "3.0.5.RELEASE")
+ ModuleRevisionId.newInstance("org.springframework", "spring-test", springVersion)
};
registerDependencies(dependencyManager, "test", testDependencies);
@@ -239,9 +242,9 @@ public Object doCall() {
ModuleRevisionId[] loggingDependencies = {
ModuleRevisionId.newInstance("log4j", "log4j", "1.2.16"),
- ModuleRevisionId.newInstance("org.slf4j", "jcl-over-slf4j", "1.6.1"),
- ModuleRevisionId.newInstance("org.slf4j", "jul-to-slf4j", "1.6.1"),
- ModuleRevisionId.newInstance("org.slf4j", "slf4j-log4j12", "1.6.1")
+ ModuleRevisionId.newInstance("org.slf4j", "jcl-over-slf4j", slf4jVersion),
+ ModuleRevisionId.newInstance("org.slf4j", "jul-to-slf4j", slf4jVersion),
+ ModuleRevisionId.newInstance("org.slf4j", "slf4j-log4j12", slf4jVersion)
};
registerDependencies(dependencyManager, runtimeDependenciesMethod, loggingDependencies, "mail", "jms", "jmxtools", "jmxri");
@@ -93,7 +93,7 @@
protected Map<String, ArtefactInfo> artefactInfo = new HashMap<String, ArtefactInfo>();
protected Class<?>[] allArtefactClassesArray;
@SuppressWarnings("rawtypes")
- protected Map applicationMeta = Metadata.getCurrent();
+ protected Metadata applicationMeta = Metadata.getCurrent();
protected Resource[] resources;
protected boolean initialised = false;
protected ConfigObject config;
@@ -824,7 +824,7 @@ public boolean isInitialised() {
}
@SuppressWarnings("rawtypes")
- public Map getMetadata() {
+ public Metadata getMetadata() {
return applicationMeta;
}
@@ -16,14 +16,14 @@
package org.codehaus.groovy.grails.commons;
import grails.util.Environment;
+import grails.util.Metadata;
import groovy.util.ConfigObject;
-
-import java.util.Map;
-
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.Resource;
+import java.util.Map;
+
/**
* <p>The main interface representing a running Grails application. This interface's
* main purpose is to provide a mechanism for analysing the conventions within a Grails
@@ -384,7 +384,7 @@
* @return A read-only Map of data about the application, not environment specific
*/
@SuppressWarnings("rawtypes")
- Map getMetadata();
+ Metadata getMetadata();
/**
* Retrieves an artefact by its logical property name. For example the logical property name of
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 SpringSource
+ *
+ * Licensed 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.codehaus.groovy.grails.commons.env;
+
+import grails.util.Environment;
+import org.codehaus.groovy.grails.commons.GrailsApplication;
+import org.springframework.core.env.PropertySource;
+import org.springframework.web.context.support.DefaultWebEnvironment;
+
+import java.util.Set;
+
+/**
+ * Bridges Grails' existing environment API with the new Spring 3.1 environment profiles API
+ *
+ * @author Graeme Rocher
+ * @since 1.4
+ */
+public class GrailsEnvironment extends DefaultWebEnvironment {
+
+ GrailsApplication grailsApplication;
+
+ public GrailsEnvironment(GrailsApplication grailsApplication) {
+ this.grailsApplication = grailsApplication;
+ getPropertySources().addFirst(new GrailsConfigPropertySource(grailsApplication));
+ }
+
+ @Override
+ protected Set<String> doGetActiveProfiles() {
+ Set<String> activeProfiles = super.doGetActiveProfiles();
+ activeProfiles.add(Environment.getCurrent().getName());
+ return activeProfiles;
+ }
+
+
+ private class GrailsConfigPropertySource extends PropertySource<GrailsApplication> {
+
+ public GrailsConfigPropertySource(GrailsApplication grailsApplication) {
+ super(grailsApplication.getMetadata().getApplicationName(), grailsApplication);
+ }
+
+ @Override
+ public Object getProperty(String key) {
+ return grailsApplication.getFlatConfig().get(key);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit fb53d5b

Please sign in to comment.