Permalink
Browse files

Upgrade to Spring 3

  • Loading branch information...
1 parent 954ca02 commit 57db3ea3fd7ef187eb450874ff9ec17cdd2f8236 @graemerocher graemerocher committed Jul 14, 2009
Showing with 62 additions and 81 deletions.
  1. BIN grails/lib/aopalliance-1.0.jar
  2. BIN grails/lib/hsqldb-1.8.0.10.jar
  3. BIN grails/lib/org.springframework.aop-3.0.0.CI-325.jar
  4. BIN grails/lib/org.springframework.asm-3.0.0.CI-325.jar
  5. BIN grails/lib/org.springframework.aspects-3.0.0.CI-325.jar
  6. BIN grails/lib/org.springframework.beans-3.0.0.CI-325.jar
  7. BIN grails/lib/org.springframework.context-3.0.0.CI-325.jar
  8. BIN grails/lib/org.springframework.context.support-3.0.0.CI-325.jar
  9. BIN grails/lib/org.springframework.core-3.0.0.CI-325.jar
  10. BIN grails/lib/org.springframework.expression-3.0.0.CI-325.jar
  11. BIN grails/lib/org.springframework.instrument-3.0.0.CI-325.jar
  12. BIN grails/lib/org.springframework.instrument.classloading-3.0.0.CI-325.jar
  13. BIN grails/lib/org.springframework.integration-tests-3.0.0.CI-325.jar
  14. BIN grails/lib/org.springframework.jdbc-3.0.0.CI-325.jar
  15. BIN grails/lib/org.springframework.jms-3.0.0.CI-325.jar
  16. BIN grails/lib/org.springframework.orm-3.0.0.CI-325.jar
  17. BIN grails/lib/org.springframework.oxm-3.0.0.CI-325.jar
  18. BIN grails/lib/org.springframework.test-3.0.0.CI-325.jar
  19. BIN grails/lib/org.springframework.transaction-3.0.0.CI-325.jar
  20. BIN grails/lib/org.springframework.web-3.0.0.CI-325.jar
  21. BIN grails/lib/org.springframework.web.servlet-3.0.0.CI-325.jar
  22. +0 −1 grails/scripts/_GrailsWar.groovy
  23. +1 −1 grails/src/java/grails/util/BuildSettings.groovy
  24. +1 −4 grails/src/java/org/codehaus/groovy/grails/plugins/CoreGrailsPlugin.groovy
  25. +5 −2 grails/src/java/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPlugin.groovy
  26. +2 −8 grails/src/java/org/codehaus/groovy/grails/plugins/orm/hibernate/HibernatePluginSupport.groovy
  27. +35 −17 grails/src/java/org/codehaus/groovy/grails/support/MockApplicationContext.java
  28. +0 −34 grails/src/java/org/codehaus/groovy/grails/web/context/GrailsContextLoaderServlet.java
  29. +9 −5 grails/src/test/grails/spring/BeanBuilderTests.groovy
  30. +5 −4 grails/src/test/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfiguratorTests.java
  31. +0 −1 grails/src/test/org/codehaus/groovy/grails/orm/hibernate/ExecuteUpdateTests.groovy
  32. +0 −1 grails/src/test/org/codehaus/groovy/grails/plugins/CoreGrailsPluginTests.groovy
  33. +1 −1 grails/src/test/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPluginTests.groovy
  34. +3 −2 grails/src/test/org/codehaus/groovy/grails/web/pages/ext/jsp/GroovyPageWithJSPTagsTests.groovy
View
BIN grails/lib/aopalliance-1.0.jar
Binary file not shown.
View
BIN grails/lib/hsqldb-1.8.0.10.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.aop-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.asm-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.aspects-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.beans-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.context-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.context.support-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.core-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.expression-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.instrument-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.instrument.classloading-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.integration-tests-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.jdbc-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.jms-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.orm-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.oxm-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.test-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.transaction-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.web-3.0.0.CI-325.jar
Binary file not shown.
View
BIN grails/lib/org.springframework.web.servlet-3.0.0.CI-325.jar
Binary file not shown.
View
1 grails/scripts/_GrailsWar.groovy
@@ -57,7 +57,6 @@ DEFAULT_DEPS = [
"ivy-*.jar",
"jsr107cache-*.jar",
"sitemesh-*.jar",
- "spring-*.jar",
"org.springframework.*-*.jar",
"jcl-over-slf4j-*.jar",
"slf4j-api-*.jar",
View
2 grails/src/java/grails/util/BuildSettings.groovy
@@ -34,7 +34,7 @@ class BuildSettings {
commons-codec-|commons-collections-|commons-dbcp-|commons-fileupload-|commons-io-|commons-lang-|\
commons-pool-|commons-validator-|dom4j-|ehcache-|ejb3-persistence-|groovy-all-|hsqldb-|ivy-|jcl-over-slf4j-|jdbc2_0-stdext|\
jsr107cache-|jta-|log4j-|ognl-|org\\.springframework\\.\\w+-|oro-|\
-oscache-|sitemesh-|slf4j-api-|slf4j-log4j12-|spring-|xercesImpl-|\
+oscache-|sitemesh-|slf4j-api-|slf4j-log4j12-|xercesImpl-|\
xpp3_min-).*\\.jar"""
static final Pattern JAR_PATTERN = ~/^\S+\.jar$/
View
5 grails/src/java/org/codehaus/groovy/grails/plugins/CoreGrailsPlugin.groovy
@@ -52,14 +52,11 @@ class CoreGrailsPlugin {
targetObject = ref("grailsApplication", true)
targetMethod = "getClassLoader"
}
- classEditor(ClassEditor) {
- classLoader = classLoader
- }
if(Environment.current == Environment.DEVELOPMENT)
shutdownHook(DevelopmentShutdownHook)
customEditors(CustomEditorConfigurer) {
- customEditors = [(java.lang.Class.class):classEditor]
+ customEditors = [(java.lang.Class.name):ClassEditor.name]
}
}
View
7 grails/src/java/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPlugin.groovy
@@ -27,6 +27,7 @@ import org.codehaus.groovy.grails.exceptions.GrailsConfigurationException
import java.sql.SQLException
import java.sql.Driver
import java.sql.DriverManager
+import grails.util.Metadata
/**
* A plug-in that handles the configuration of Hibernate within Grails
@@ -150,8 +151,10 @@ class DataSourceGrailsPlugin {
connection?.close()
}
}
-
- deregisterJDBCDrivers()
+
+ if(Metadata.current.warDeployed) {
+ deregisterJDBCDrivers()
+ }
}
private void deregisterJDBCDrivers() {
View
10 ...s/src/java/org/codehaus/groovy/grails/plugins/orm/hibernate/HibernatePluginSupport.groovy
@@ -329,13 +329,8 @@ Try using Grails' default cache provider: 'org.hibernate.cache.OSCacheProvider'"
private static registerDynamicMethods(GrailsDomainClass dc, GrailsApplication application, ApplicationContext ctx, SessionFactory sessionFactory) {
dc.metaClass.methodMissing = { String name, args ->
-// println "METHOD MISSING $name"
throw new MissingMethodException(name, dc.clazz, args, true)
}
-// dc.metaClass.propertyMissing = { String name ->
-// println "PROPERTY MISSING HERE ! $name"
-//
-// }
addBasicPersistenceMethods(dc, application, ctx)
addQueryMethods(dc, application, ctx)
addTransactionalMethods(dc, application, ctx)
@@ -503,15 +498,14 @@ Try using Grails' default cache provider: 'org.hibernate.cache.OSCacheProvider'"
template.bulkUpdate(query, GrailsClassUtils.collectionToObjectArray(args))
}
metaClass.static.executeUpdate = {String query, Map argMap ->
- template.execute( { session ->
+ template.executeWithNativeSession( { Session session ->
Query queryObject = session.createQuery(query)
SessionFactoryUtils.applyTransactionTimeout(queryObject, template.sessionFactory);
for (entry in argMap) {
queryObject.setParameter(entry.key, entry.value)
}
queryObject.executeUpdate()
- } as HibernateCallback
- , true);
+ } as HibernateCallback);
}
View
52 grails/src/java/org/codehaus/groovy/grails/support/MockApplicationContext.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
+import java.lang.annotation.Annotation;
public class MockApplicationContext extends GroovyObjectSupport implements WebApplicationContext {
@@ -89,7 +90,7 @@ public String getId() {
}
public String getDisplayName() {
- throw new UnsupportedOperationException("Method not supported by implementation");
+ return getId();
}
public long getStartupDate() {
@@ -132,7 +133,7 @@ public int getBeanDefinitionCount() {
return getBeanNamesForType(type);
}
- public Map getBeansOfType(Class type) throws BeansException {
+ public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException {
String[] beanNames = getBeanNamesForType(type);
Map newMap = new HashMap();
for (int i = 0; i < beanNames.length; i++) {
@@ -141,32 +142,49 @@ public Map getBeansOfType(Class type) throws BeansException {
}
return newMap;
- }
+ }
- public Map getBeansOfType(Class type, boolean includePrototypes,
- boolean includeFactoryBeans) throws BeansException {
- String[] beanNames = getBeanNamesForType(type);
- Map newMap = new HashMap();
- for (int i = 0; i < beanNames.length; i++) {
- String beanName = beanNames[i];
- newMap.put(beanName, getBean(beanName));
+ public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException {
+ return getBeansOfType(type);
+ }
+ public <A extends Annotation> A findAnnotationOnBean(String name, Class<A> annotation) {
+ Object o = getBean(name);
+ if(o!=null) {
+ return o.getClass().getAnnotation(annotation);
}
- return newMap;
+ return null;
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotation, boolean b, boolean b1) throws BeansException {
+ return getBeansWithAnnotation(annotation);
+ }
+
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotation) throws BeansException {
+ Map<String, Object> submap = new HashMap<String, Object>();
+ for (Object beanName : beans.keySet()) {
+ Object bean = beans.get(beanName);
+ if(bean!=null&&bean.getClass().getAnnotation(annotation)!=null) {
+ submap.put(beanName.toString(), bean);
+ }
+ }
+ return submap;
}
+
+
public Object getBean(String name) throws BeansException {
if(!beans.containsKey(name))throw new NoSuchBeanDefinitionException(name);
return beans.get(name);
}
- public Object getBean(String name, Class requiredType)
- throws BeansException {
- if(!beans.containsKey(name))throw new NoSuchBeanDefinitionException( name);
- if(requiredType != null && beans.get(name).getClass() != requiredType)throw new NoSuchBeanDefinitionException(name);
+ public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
+ if(!beans.containsKey(name))throw new NoSuchBeanDefinitionException( name);
+ if(requiredType != null && beans.get(name).getClass() != requiredType)throw new NoSuchBeanDefinitionException(name);
+
+ return (T) beans.get(name);
+ }
- return beans.get(name);
- }
public Object getBean(String name, Object[] args) throws BeansException {
return getBean(name);
View
34 grails/src/java/org/codehaus/groovy/grails/web/context/GrailsContextLoaderServlet.java
@@ -1,34 +0,0 @@
-/*
- * Copyright 2008 the original author or authors.
- *
- * 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.web.context;
-
-import org.springframework.web.context.ContextLoaderServlet;
-import org.springframework.web.context.ContextLoader;
-
-/**
- * Grails specific context loader servlet for pre-2.4 servlet containers.
- * Containers that support 2.4 and later should use the
- * {@link org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener}
- * instead.
- */
-public class GrailsContextLoaderServlet extends ContextLoaderServlet {
- /**
- * Creates a new GrailsContextLoader.
- */
- protected ContextLoader createContextLoader() {
- return new GrailsContextLoader();
- }
-}
View
14 grails/src/test/grails/spring/BeanBuilderTests.groovy
@@ -758,11 +758,6 @@ class TestScope implements Scope {
int instanceCount
- public Object get(String name, ObjectFactory objectFactory) {
- instanceCount++
- objectFactory.getObject()
- }
-
public Object remove(String name) {
// do nothing
@@ -775,6 +770,15 @@ class TestScope implements Scope {
return "mock"
}
+ public Object get(String name, ObjectFactory<?> objectFactory) {
+ instanceCount++
+ objectFactory.getObject()
+
+ }
+
+ public Object resolveContextualObject(String s) {
+ return null; // noop
+ }
}
class BirthdayCardSender {
List peopleSentCards = []
View
9 ...ls/src/test/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfiguratorTests.java
@@ -4,11 +4,13 @@
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import junit.framework.TestCase;
-import org.codehaus.groovy.grails.commons.*;
+import org.codehaus.groovy.grails.commons.ConfigurationHolder;
+import org.codehaus.groovy.grails.commons.DefaultGrailsApplication;
+import org.codehaus.groovy.grails.commons.GrailsApplication;
+import org.codehaus.groovy.grails.commons.GrailsDomainClass;
import org.codehaus.groovy.grails.plugins.DefaultGrailsPluginManager;
import org.codehaus.groovy.grails.plugins.DefaultPluginMetaManager;
import org.codehaus.groovy.grails.plugins.PluginMetaManager;
-import org.codehaus.groovy.grails.support.ClassEditor;
import org.codehaus.groovy.grails.support.MockApplicationContext;
import org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver;
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsUrlHandlerMapping;
@@ -71,8 +73,7 @@ public void testConfigure() throws Exception {
// test class editor setup
assertNotNull(ctx);
- assertTrue(ctx.getBean(GrailsRuntimeConfigurator.CLASS_LOADER_BEAN) instanceof GroovyClassLoader );
- assertTrue(ctx.getBean(GrailsRuntimeConfigurator.CLASS_EDITOR_BEAN) instanceof ClassEditor);
+ assertTrue(ctx.getBean(GrailsRuntimeConfigurator.CLASS_LOADER_BEAN) instanceof GroovyClassLoader );
// test exception resolver
GrailsExceptionResolver er = (GrailsExceptionResolver)ctx.getBean(GrailsRuntimeConfigurator.EXCEPTION_HANDLER_BEAN);
View
1 grails/src/test/org/codehaus/groovy/grails/orm/hibernate/ExecuteUpdateTests.groovy
@@ -55,7 +55,6 @@ class Customer {
assertEquals 3, custClass.count()
custClass.executeUpdate("delete from Customer c where c.name=:name", [name:'Fred'])
-
assertEquals 2, custClass.count()
}
View
1 grails/src/test/org/codehaus/groovy/grails/plugins/CoreGrailsPluginTests.groovy
@@ -21,7 +21,6 @@ class CoreGrailsPluginTests extends AbstractGrailsMockTests {
def appCtx = springConfig.getApplicationContext()
- assert appCtx.containsBean("classEditor")
assert appCtx.containsBean("classLoader")
assert appCtx.containsBean("customEditors")
}
View
2 ...src/test/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPluginTests.groovy
@@ -61,7 +61,7 @@ class DataSourceGrailsPluginTests extends AbstractGrailsMockTests {
def appCtx = configurator.configure(ctx.getServletContext())
DataSource dataSource = appCtx.getBean("dataSource")
- assert dataSource
+ assert dataSource
def pluginManager = PluginManagerHolder.currentPluginManager()
View
5 ...s/src/test/org/codehaus/groovy/grails/web/pages/ext/jsp/GroovyPageWithJSPTagsTests.groovy
@@ -24,8 +24,9 @@ class GroovyPageWithJSPTagsTests extends AbstractGrailsTagTests{
def rootLoader = new RootLoader([] as URL[], Thread.currentThread().getContextClassLoader())
def res = new FileSystemResource("lib/standard-2.4.jar")
rootLoader.addURL res.getURL()
- res = resolver.getResources("file:lib/spring-webmvc*.jar")[0]
- rootLoader.addURL res.getURL()
+ resolver.getResources("file:lib/org.springframework.web*.jar").each {
+ rootLoader.addURL it.getURL()
+ }
return rootLoader
}
webRequest.getCurrentRequest().setAttribute(GroovyPagesServlet.SERVLET_INSTANCE, new GroovyPagesServlet())

0 comments on commit 57db3ea

Please sign in to comment.