Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaup, whitespace

  • Loading branch information...
commit 983c0a94bbda41b54efa3a3d0b90a094b6b878b9 1 parent 14a9916
Burt Beckwith authored
Showing with 260 additions and 207 deletions.
  1. +8 −8 grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy
  2. +3 −3 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/DefaultCommandLine.java
  3. +15 −0 grails-core/src/main/groovy/grails/web/UrlConverter.java
  4. +12 −13 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/cfg/ConfigurationHelper.groovy
  5. +2 −2 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/AbstractGrailsPlugin.java
  6. +10 −11 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPlugin.java
  7. +25 −25 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPluginManager.java
  8. +7 −2 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/GrailsPlugin.java
  9. +144 −104 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinder.java
  10. +10 −8 ...ugin-async/src/main/groovy/org/codehaus/groovy/grails/plugins/web/async/ControllersAsyncGrailsPlugin.groovy
  11. +7 −4 grails-plugin-async/src/main/groovy/org/codehaus/groovy/grails/plugins/web/async/GrailsAsyncContext.groovy
  12. +1 −1  ...ls-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/plugins/web/ControllersGrailsPlugin.groovy
  13. +1 −4 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/GroovyPagesGrailsPlugin.groovy
  14. +1 −3 grails-plugin-servlets/src/main/groovy/org/codehaus/groovy/grails/plugins/web/ServletsGrailsPlugin.groovy
  15. +14 −19 grails-web/src/main/groovy/grails/gsp/PageRenderer.groovy
View
16 grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy
@@ -1016,7 +1016,7 @@ class BuildSettings extends AbstractBuildSettings {
if (!modified) {
if (configFile?.exists() && metadataFile?.exists()) {
- this.resolveChecksum = ChecksumHelper.computeAsString(configFile, "md5") +
+ resolveChecksum = ChecksumHelper.computeAsString(configFile, "md5") +
ChecksumHelper.computeAsString(metadataFile, "md5")
}
@@ -1047,7 +1047,7 @@ class BuildSettings extends AbstractBuildSettings {
if (compileDeps) {
compileDeps = findAndRemovePluginDependencies("compile", compileDeps, internalPluginCompileDependencies)
if (compileDeps.any({ File f -> !f.exists() })) modified = true
- this.internalCompileDependencies = compileDeps
+ internalCompileDependencies = compileDeps
}else {
modified = true
}
@@ -1055,7 +1055,7 @@ class BuildSettings extends AbstractBuildSettings {
if (runtimeDeps) {
runtimeDeps = findAndRemovePluginDependencies("runtime", runtimeDeps, internalPluginRuntimeDependencies)
if (runtimeDeps.any({ File f -> !f.exists() })) modified = true
- this.internalRuntimeDependencies = runtimeDeps
+ internalRuntimeDependencies = runtimeDeps
}else {
modified = true
}
@@ -1063,7 +1063,7 @@ class BuildSettings extends AbstractBuildSettings {
if (testDeps) {
testDeps = findAndRemovePluginDependencies("test", testDeps, internalPluginTestDependencies)
if (testDeps.any({ File f -> !f.exists() })) modified = true
- this.internalTestDependencies = testDeps
+ internalTestDependencies = testDeps
}else {
modified = true
}
@@ -1071,7 +1071,7 @@ class BuildSettings extends AbstractBuildSettings {
if (buildDeps) {
buildDeps = findAndRemovePluginDependencies("build", buildDeps, internalPluginBuildDependencies)
if (buildDeps.any({ File f -> !f.exists() })) modified = true
- this.internalBuildDependencies = buildDeps
+ internalBuildDependencies = buildDeps
}else {
modified = true
}
@@ -1079,7 +1079,7 @@ class BuildSettings extends AbstractBuildSettings {
if (providedDeps) {
providedDeps = findAndRemovePluginDependencies("provided", providedDeps, internalPluginProvidedDependencies)
if (providedDeps.any({ File f -> !f.exists() })) modified = true
- this.internalProvidedDependencies = providedDeps
+ internalProvidedDependencies = providedDeps
}else {
modified = true
}
@@ -1091,7 +1091,7 @@ class BuildSettings extends AbstractBuildSettings {
}
}
else {
- this.modified = true
+ modified = true
}
if (modified) {
ClasspathConfigurer.cleanResolveCache(this)
@@ -1116,7 +1116,7 @@ class BuildSettings extends AbstractBuildSettings {
}
}
- this.proxySettingsFile = new File("$userHome/.grails/ProxySettings.groovy")
+ proxySettingsFile = new File("$userHome/.grails/ProxySettings.groovy")
if (proxySettingsFile.exists()) {
slurper = createConfigSlurper()
try {
View
6 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/DefaultCommandLine.java
@@ -17,7 +17,7 @@
public class DefaultCommandLine implements CommandLine {
Properties systemProperties = new Properties();
- Map<String, Object> undeclaredOptions = new HashMap<String, Object> ();
+ Map<String, Object> undeclaredOptions = new HashMap<String, Object>();
Map<String, SpecifiedOption> declaredOptions = new HashMap<String, SpecifiedOption>();
List<String> remainingArgs = new ArrayList<String>();
private String environment;
@@ -79,7 +79,7 @@ public boolean isEnvironmentSet() {
}
public void setCommandName(String cmd) {
- if ("refresh-dependencies".equals(cmd)) {
+ if (REFRESH_DEPENDENCIES_ARGUMENT.equals(cmd)) {
addUndeclaredOption(REFRESH_DEPENDENCIES_ARGUMENT);
}
this.commandName = cmd;
@@ -152,7 +152,7 @@ private String remainingArgsToString(String separator) {
}
public void addSystemProperty(String name, String value) {
- if(Environment.KEY.equals(name)) {
+ if (Environment.KEY.equals(name)) {
setEnvironment(value);
}
systemProperties.put(name, value);
View
15 grails-core/src/main/groovy/grails/web/UrlConverter.java
@@ -1,3 +1,18 @@
+/*
+ * 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 grails.web;
public interface UrlConverter {
View
25 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/cfg/ConfigurationHelper.groovy
@@ -60,19 +60,19 @@ class ConfigurationHelper {
ClassLoader classLoader
Integer cacheKey = DEV_CACHE_KEY
- if (application != null) {
+ if (application == null) {
+ classLoader = Thread.currentThread().contextClassLoader
+ }
+ else {
classLoader = application.getClassLoader()
if (Environment.isWarDeployed() || !Environment.isWithinShell()) {
// use unique cache keys for each config based on the application instance
- // this to ensure each application gets a unique config and avoid the scenario
+ // to ensure each application gets a unique config and avoid the scenario
// where applications deployed in a shared library mode (shared jars) share the
// same config
cacheKey = System.identityHashCode(application)
}
}
- else {
- classLoader = Thread.currentThread().contextClassLoader
- }
co = getCachedConfigs().get(cacheKey)
if (co == null) {
@@ -80,22 +80,20 @@ class ConfigurationHelper {
try {
try {
application?.config = new ConfigObject() // set empty config to avoid stack overflow
- Class scriptClass = classLoader.loadClass(GrailsApplication.CONFIG_CLASS)
- co = configSlurper.parse(scriptClass)
+ co = configSlurper.parse(classLoader.loadClass(GrailsApplication.CONFIG_CLASS))
application?.config = co
}
catch (ClassNotFoundException e) {
- LOG.debug "Could not find config class [" + GrailsApplication.CONFIG_CLASS + "]. This is probably " +
- "nothing to worry about, it is not required to have a config: $e.message"
+ LOG.debug "Could not find config class [$GrailsApplication.CONFIG_CLASS]. This is probably " +
+ "nothing to worry about; it is not required to have a config: $e.message"
// ignore, it is ok not to have a configuration file
co = new ConfigObject()
}
try {
- Class dataSourceClass = classLoader.loadClass(GrailsApplication.DATA_SOURCE_CLASS)
- co.merge(configSlurper.parse(dataSourceClass))
+ co.merge(configSlurper.parse(classLoader.loadClass(GrailsApplication.DATA_SOURCE_CLASS)))
}
catch (ClassNotFoundException e) {
- LOG.debug "Cound not find data source class [" + GrailsApplication.DATA_SOURCE_CLASS + "]. This may " +
+ LOG.debug "Cound not find data source class [$GrailsApplication.DATA_SOURCE_CLASS]. This may " +
"be what you are expecting, but will result in Grails loading with an in-memory database"
// ignore
}
@@ -201,7 +199,8 @@ class ConfigurationHelper {
config.merge(newConfig)
}
else if (resource.filename.endsWith('.class')) {
- def configClass = new GroovyClassLoader(configSlurper.classLoader).defineClass(null, stream.bytes)
+ def configClass = new GroovyClassLoader(configSlurper.classLoader).defineClass(
+ null, stream.bytes)
def newConfig = configSlurper.parse(configClass)
config.merge(newConfig)
}
View
4 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/AbstractGrailsPlugin.java
@@ -49,11 +49,11 @@ public void refresh() {
protected boolean isBase = false;
protected String version = "1.0";
protected Map<String, Object> dependencies = new HashMap<String, Object>();
- protected String[] dependencyNames = new String[0];
+ protected String[] dependencyNames = {};
protected Class<?> pluginClass;
protected ApplicationContext applicationContext;
protected GrailsPluginManager manager;
- protected String[] evictionList = new String[0];
+ protected String[] evictionList = {};
/**
* Wrapper Grails class for plugins.
View
21 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPlugin.java
@@ -81,7 +81,6 @@
private static final String PLUGIN_CHANGE_EVENT_SOURCE = "source";
private static final String PLUGIN_CHANGE_EVENT_MANAGER = "manager";
- private static final String PLUGIN_OBSERVE = "observe";
protected static final Log LOG = LogFactory.getLog(DefaultGrailsPlugin.class);
private static final String INCLUDES = "includes";
private static final String EXCLUDES = "excludes";
@@ -90,17 +89,17 @@
private GroovyObject plugin;
protected BeanWrapper pluginBean;
private Closure onChangeListener;
- private Resource[] watchedResources = new Resource[0];
+ private Resource[] watchedResources = {};
private PathMatchingResourcePatternResolver resolver;
private String[] watchedResourcePatternReferences;
- private String[] loadAfterNames = new String[0];
- private String[] loadBeforeNames = new String[0];
+ private String[] loadAfterNames = {};
+ private String[] loadBeforeNames = {};
private String status = STATUS_ENABLED;
private String[] observedPlugins;
private Closure onConfigChangeListener;
private Closure onShutdownListener;
- private Class<?>[] providedArtefacts = new Class[0];
+ private Class<?>[] providedArtefacts = {};
private Map pluginScopes;
private Map pluginEnvs;
private List<String> pluginExcludes = new ArrayList<String>();
@@ -227,9 +226,9 @@ else if (includeExcludeObject instanceof List) {
}
private void evaluateAndAddListOfValues(Map targetMap, List includeExcludeList, boolean include, Closure converter) {
- for (Object scope : includeExcludeList) {
- if (scope instanceof String) {
- final String scopeName = (String) scope;
+ for (Object value : includeExcludeList) {
+ if (value instanceof String) {
+ final String scopeName = (String) value;
evaluateAndAddToIncludeExcludeSet(targetMap, scopeName, include, converter);
}
}
@@ -266,10 +265,10 @@ public DefaultGrailsPlugin(Class<?> pluginClass, GrailsApplication application)
}
private void evaluateObservedPlugins() {
- if (pluginBean.isReadableProperty(PLUGIN_OBSERVE)) {
- Object observeProperty = GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, PLUGIN_OBSERVE);
+ if (pluginBean.isReadableProperty(OBSERVE)) {
+ Object observeProperty = GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, OBSERVE);
if (observeProperty instanceof Collection) {
- Collection observeList = (Collection)observeProperty;
+ Collection observeList = (Collection)observeProperty;
observedPlugins = new String[observeList.size()];
int j = 0;
for (Object anObserveList : observeList) {
View
50 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPluginManager.java
@@ -550,38 +550,38 @@ private void attemptPluginLoad(GrailsPlugin plugin) {
}
private void registerPlugin(GrailsPlugin plugin) {
- if (canRegisterPlugin(plugin)) {
+ if (!canRegisterPlugin(plugin)) {
if (LOG.isInfoEnabled()) {
- LOG.info("Grails plug-in [" + plugin.getName() + "] with version [" + plugin.getVersion() + "] loaded successfully");
+ LOG.info("Grails plugin " + plugin + " is disabled and was not loaded");
}
+ return;
+ }
- if (plugin instanceof ParentApplicationContextAware) {
- ((ParentApplicationContextAware) plugin).setParentApplicationContext(parentCtx);
- }
- plugin.setManager(this);
- String[] evictionNames = plugin.getEvictionNames();
- if (evictionNames.length > 0) {
- delayedEvictions.put(plugin, evictionNames);
- }
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Grails plug-in [" + plugin.getName() + "] with version [" + plugin.getVersion() + "] loaded successfully");
+ }
- String[] observedPlugins = plugin.getObservedPluginNames();
- for (String observedPlugin : observedPlugins) {
- Set<GrailsPlugin> observers = pluginToObserverMap.get(observedPlugin);
- if (observers == null) {
- observers = new HashSet<GrailsPlugin>();
- pluginToObserverMap.put(observedPlugin, observers);
- }
- observers.add(plugin);
- }
- pluginList.add(plugin);
- plugins.put(plugin.getName(), plugin);
- classNameToPluginMap.put(plugin.getPluginClass().getName(), plugin);
+ if (plugin instanceof ParentApplicationContextAware) {
+ ((ParentApplicationContextAware) plugin).setParentApplicationContext(parentCtx);
}
- else {
- if (LOG.isInfoEnabled()) {
- LOG.info("Grails plugin " + plugin + " is disabled and was not loaded");
+ plugin.setManager(this);
+ String[] evictionNames = plugin.getEvictionNames();
+ if (evictionNames.length > 0) {
+ delayedEvictions.put(plugin, evictionNames);
+ }
+
+ String[] observedPlugins = plugin.getObservedPluginNames();
+ for (String observedPlugin : observedPlugins) {
+ Set<GrailsPlugin> observers = pluginToObserverMap.get(observedPlugin);
+ if (observers == null) {
+ observers = new HashSet<GrailsPlugin>();
+ pluginToObserverMap.put(observedPlugin, observers);
}
+ observers.add(plugin);
}
+ pluginList.add(plugin);
+ plugins.put(plugin.getName(), plugin);
+ classNameToPluginMap.put(plugin.getPluginClass().getName(), plugin);
}
protected boolean canRegisterPlugin(GrailsPlugin plugin) {
View
9 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/GrailsPlugin.java
@@ -159,16 +159,21 @@
String PLUGIN_LOAD_AFTER_NAMES = "loadAfter";
/**
- * The field that reperesents the list of resources to exclude from plugin packaging
+ * The field that represents the list of resources to exclude from plugin packaging
*/
String PLUGIN_EXCLUDES = "pluginExcludes";
/**
- * The field that reperesents the list of type filters a plugin provides
+ * The field that represents the list of type filters a plugin provides
*/
String TYPE_FILTERS = "typeFilters";
/**
+ * The field that represents the plugin names that this plugin is observing for changes.
+ */
+ String OBSERVE = "observe";
+
+ /**
* <p>This method is called to allow the plugin to add {@link org.springframework.beans.factory.config.BeanDefinition}s
* to the {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}.</p>
*
View
248 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinder.java
@@ -16,6 +16,22 @@
import grails.util.CollectionUtils;
import groovy.lang.Closure;
+
+import java.lang.reflect.Modifier;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
@@ -30,26 +46,49 @@
import org.codehaus.groovy.grails.orm.hibernate.persister.entity.GroovyAwareSingleTableEntityPersister;
import org.codehaus.groovy.grails.orm.hibernate.validation.UniqueConstraint;
import org.codehaus.groovy.grails.plugins.orm.hibernate.HibernatePluginSupport;
-import org.codehaus.groovy.grails.validation.*;
+import org.codehaus.groovy.grails.validation.ConstrainedProperty;
import org.codehaus.groovy.grails.validation.Constraint;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
-import org.hibernate.cfg.*;
+import org.hibernate.cfg.BinderHelper;
+import org.hibernate.cfg.ImprovedNamingStrategy;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.cfg.NamingStrategy;
+import org.hibernate.cfg.SecondPass;
import org.hibernate.id.PersistentIdentifierGenerator;
-import org.hibernate.mapping.*;
+import org.hibernate.mapping.Backref;
+import org.hibernate.mapping.Bag;
import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.DependantValue;
+import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.IndexBackref;
+import org.hibernate.mapping.IndexedCollection;
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.KeyValue;
+import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.OneToOne;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.Selectable;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
-import org.hibernate.type.*;
+import org.hibernate.mapping.UniqueKey;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.ForeignKeyDirection;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.LongType;
+import org.hibernate.type.StandardBasicTypes;
+import org.hibernate.type.TimestampType;
+import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;
import org.springframework.context.ApplicationContext;
-import java.lang.reflect.Modifier;
-import java.sql.Types;
-import java.util.*;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* Handles the binding Grails domain classes and properties to the Hibernate runtime meta model.
* Based on the HbmBinder code in Hibernate core and influenced by AnnotationsBinder.
@@ -323,8 +362,7 @@ private static void bindMapSecondPass(GrailsDomainClassProperty property, Mappin
}
if (!value.isTypeSpecified()) {
- throw new MappingException("map index element must specify a type: "
- + map.getRole());
+ throw new MappingException("map index element must specify a type: " + map.getRole());
}
map.setIndex(value);
@@ -460,7 +498,7 @@ private static void bindCollectionSecondPass(GrailsDomainClassProperty property,
String associatedClassName = property.getReferencedDomainClass().getFullName();
associatedClass = (PersistentClass) persistentClasses.get(associatedClassName);
- if(associatedClass != null) {
+ if (associatedClass != null) {
collection.setOrderBy(buildOrderByClause(propertyToSortBy.getName(), associatedClass, collection.getRole(), propConfig.getOrder() != null ? propConfig.getOrder() : "asc"));
}
}
@@ -672,7 +710,6 @@ private static boolean isNonPropertyToken(String token) {
return false;
}
-
private static Set<String> buildDiscriminatorSet(GrailsDomainClass domainClass) {
Set<String> theSet = new HashSet<String>();
@@ -690,9 +727,8 @@ private static boolean isNonPropertyToken(String token) {
theSet.add(quote + discriminator + quote);
for (GrailsDomainClass subClass : domainClass.getSubClasses()) {
- Set<String> subSet = buildDiscriminatorSet(subClass);
- theSet.addAll(subSet);
- }
+ theSet.addAll(buildDiscriminatorSet(subClass));
+ }
return theSet;
}
@@ -745,7 +781,7 @@ private static void bindCollectionWithJoinTable(GrailsDomainClassProperty proper
}
if (isEnum) {
- bindEnumType(property, referencedType,element,columnName);
+ bindEnumType(property, referencedType,element,columnName);
}
else {
@@ -805,38 +841,39 @@ private static Column getColumnForSimpleValue(SimpleValue element) {
}
private static String getTypeName(GrailsDomainClassProperty property, PropertyConfig config, Mapping mapping) {
- String typeName = null;
if (config != null && config.getType() != null) {
final Object typeObj = config.getType();
if (typeObj instanceof Class<?>) {
- typeName = ((Class<?>)typeObj).getName();
- }
- else {
- typeName = typeObj.toString();
+ return ((Class<?>)typeObj).getName();
}
+ return typeObj.toString();
}
- else if (mapping != null) {
- typeName = mapping.getTypeName(property.getType());
+
+ if (mapping != null) {
+ return mapping.getTypeName(property.getType());
}
- return typeName;
+
+ return null;
}
private static void bindColumnConfigToColumn(Column column, ColumnConfig columnConfig) {
- if (columnConfig != null) {
- if(columnConfig.getLength() != -1) {
- column.setLength(columnConfig.getLength());
- }
- if(columnConfig.getPrecision() != -1) {
- column.setPrecision(columnConfig.getPrecision());
- }
- if(columnConfig.getScale() != -1) {
- column.setScale(columnConfig.getScale());
- }
- if(columnConfig.getSqlType() != null && !columnConfig.getSqlType().isEmpty()) {
- column.setSqlType(columnConfig.getSqlType());
- }
- column.setUnique(columnConfig.getUnique());
+ if (columnConfig == null) {
+ return;
+ }
+
+ if (columnConfig.getLength() != -1) {
+ column.setLength(columnConfig.getLength());
+ }
+ if (columnConfig.getPrecision() != -1) {
+ column.setPrecision(columnConfig.getPrecision());
}
+ if (columnConfig.getScale() != -1) {
+ column.setScale(columnConfig.getScale());
+ }
+ if (columnConfig.getSqlType() != null && !columnConfig.getSqlType().isEmpty()) {
+ column.setSqlType(columnConfig.getSqlType());
+ }
+ column.setUnique(columnConfig.getUnique());
}
private static boolean hasJoinColumnMapping(PropertyConfig config) {
@@ -868,11 +905,11 @@ private static void bindUnidirectionalOneToManyInverseValues(GrailsDomainClassPr
}
private static void bindCollectionForPropertyConfig(Collection collection, PropertyConfig config) {
- if (config != null) {
- collection.setLazy(config.getLazy());
- } else {
+ if (config == null) {
collection.setLazy(true);
collection.setExtraLazy(false);
+ } else {
+ collection.setLazy(config.getLazy());
}
}
@@ -992,9 +1029,9 @@ private static Property getProperty(PersistentClass associatedClass, String prop
if (associatedClass.getKey() instanceof Component) {
return ((Component) associatedClass.getKey()).getProperty(propertyName);
}
- throw e;
- }
+ throw e;
}
+ }
/**
* Links a bidirectional one-to-many, configuring the inverse side and using a column copy to perform the link
@@ -1007,7 +1044,7 @@ private static Property getProperty(PersistentClass associatedClass, String prop
private static void linkBidirectionalOneToMany(Collection collection, PersistentClass associatedClass, DependantValue key, GrailsDomainClassProperty otherSide) {
collection.setInverse(true);
- // Iterator mappedByColumns = associatedClass.getProperty(otherSide.getName()).getValue().getColumnIterator();
+ // Iterator mappedByColumns = associatedClass.getProperty(otherSide.getName()).getValue().getColumnIterator();
Iterator<?> mappedByColumns = getProperty(associatedClass, otherSide.getName()).getValue().getColumnIterator();
while (mappedByColumns.hasNext()) {
Column column = (Column) mappedByColumns.next();
@@ -1268,9 +1305,9 @@ public static Mapping evaluateMapping(GrailsDomainClass domainClass, Closure<?>
HibernateMappingBuilder builder = new HibernateMappingBuilder(domainClass.getFullName());
GrailsApplication application = domainClass.getGrailsApplication();
ApplicationContext ctx = null;
- if(application != null) {
+ if (application != null) {
ctx = application.getMainContext();
- if(ctx == null) ctx = application.getParentContext();
+ if (ctx == null) ctx = application.getParentContext();
}
Mapping m = null;
@@ -1301,7 +1338,7 @@ public static Mapping evaluateMapping(GrailsDomainClass domainClass, Closure<?>
* @return A Mapping object or null
*/
public static Mapping getMapping(Class<?> theClass) {
- return theClass != null ? MAPPING_CACHE.get(theClass) : null;
+ return theClass == null ? null : MAPPING_CACHE.get(theClass);
}
/**
@@ -1311,7 +1348,7 @@ public static Mapping getMapping(Class<?> theClass) {
* @return A Mapping object or null
*/
public static Mapping getMapping(GrailsDomainClass domainClass) {
- return domainClass != null ? MAPPING_CACHE.get(domainClass.getClazz()) : null;
+ return domainClass == null ? null : MAPPING_CACHE.get(domainClass.getClazz());
}
/**
@@ -1426,7 +1463,7 @@ private static void bindSubClass(GrailsDomainClass sub, PersistentClass parent,
// to perform polymorphic queries
Mapping subMapping = getMapping(sub);
subClass.setDiscriminatorValue(subMapping != null && subMapping.getDiscriminator() != null ? subMapping.getDiscriminator() : sub.getFullName());
- if(subMapping != null) {
+ if (subMapping != null) {
configureDerivedProperties(sub, subMapping);
}
}
@@ -1628,14 +1665,14 @@ private static void bindRootPersistentClassCommonValues(GrailsDomainClass domain
bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);
- if (m != null) {
+ if (m == null) {
+ bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
+ }
+ else {
if (m.getVersioned()) {
bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
}
}
- else {
- bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
- }
root.createPrimaryKey();
@@ -1644,28 +1681,29 @@ private static void bindRootPersistentClassCommonValues(GrailsDomainClass domain
private static void bindIdentity(GrailsDomainClass domainClass, RootClass root, Mappings mappings,
Mapping gormMapping, String sessionFactoryBeanName) {
+
GrailsDomainClassProperty identifierProp = domainClass.getIdentifier();
- if (gormMapping != null) {
- Object id = gormMapping.getIdentity();
- if (id instanceof CompositeIdentity) {
- bindCompositeId(domainClass, root, (CompositeIdentity) id, mappings, sessionFactoryBeanName);
- } else {
- final Identity identity = (Identity) id;
- String propertyName = identity.getName();
- if (propertyName != null) {
- GrailsDomainClassProperty namedIdentityProp = domainClass.getPropertyByName(propertyName);
- if (namedIdentityProp == null) {
- throw new MappingException("Mapping specifies an identifier property name that doesn't exist ["+propertyName+"]");
- }
- if (!namedIdentityProp.equals(identifierProp)) {
- identifierProp = namedIdentityProp;
- }
- }
- bindSimpleId(identifierProp, root, mappings, identity, sessionFactoryBeanName);
- }
+ if (gormMapping == null) {
+ bindSimpleId(identifierProp, root, mappings, null, sessionFactoryBeanName);
+ return;
+ }
+ Object id = gormMapping.getIdentity();
+ if (id instanceof CompositeIdentity) {
+ bindCompositeId(domainClass, root, (CompositeIdentity) id, mappings, sessionFactoryBeanName);
} else {
- bindSimpleId(identifierProp, root, mappings, null, sessionFactoryBeanName);
+ final Identity identity = (Identity) id;
+ String propertyName = identity.getName();
+ if (propertyName != null) {
+ GrailsDomainClassProperty namedIdentityProp = domainClass.getPropertyByName(propertyName);
+ if (namedIdentityProp == null) {
+ throw new MappingException("Mapping specifies an identifier property name that doesn't exist ["+propertyName+"]");
+ }
+ if (!namedIdentityProp.equals(identifierProp)) {
+ identifierProp = namedIdentityProp;
+ }
+ }
+ bindSimpleId(identifierProp, root, mappings, identity, sessionFactoryBeanName);
}
}
@@ -1737,22 +1775,20 @@ protected static void createClassProperties(GrailsDomainClass domainClass, Persi
Class<?> userType = getUserType(currentGrailsProp);
-
if (collectionType != null) {
String typeName = getTypeName(currentGrailsProp, getPropertyConfig(currentGrailsProp),gormMapping);
- if(typeName != null && "serializable".equals(typeName)) {
- value = new SimpleValue(mappings,table);
- bindSimpleValue(typeName, (SimpleValue) value, currentGrailsProp.isOptional(), getColumnNameForPropertyAndPath(currentGrailsProp, EMPTY_PATH, null, sessionFactoryBeanName), mappings);
-
+ if ("serializable".equals(typeName)) {
+ value = new SimpleValue(mappings, table);
+ bindSimpleValue(typeName, (SimpleValue) value, currentGrailsProp.isOptional(),
+ getColumnNameForPropertyAndPath(currentGrailsProp, EMPTY_PATH, null, sessionFactoryBeanName), mappings);
}
else {
// create collection
- Collection collection = collectionType.create(currentGrailsProp, persistentClass, EMPTY_PATH,
- mappings, sessionFactoryBeanName);
+ Collection collection = collectionType.create(currentGrailsProp, persistentClass,
+ EMPTY_PATH, mappings, sessionFactoryBeanName);
mappings.addCollection(collection);
value = collection;
}
-
}
else if (currentGrailsProp.isEnum()) {
value = new SimpleValue(mappings, table);
@@ -1918,7 +1954,7 @@ else if (!"ordinal".equalsIgnoreCase(enumType)) {
private static Class<?> getUserType(GrailsDomainClassProperty currentGrailsProp) {
Class<?> userType = null;
PropertyConfig config = getPropertyConfig(currentGrailsProp);
- Object typeObj = config != null ? config.getType() : null;
+ Object typeObj = config == null ? null : config.getType();
if (typeObj instanceof Class<?>) {
userType = (Class<?>)typeObj;
} else if (typeObj != null) {
@@ -2512,8 +2548,9 @@ private static void bindSimpleValue(GrailsDomainClassProperty grailsProp,
column.setUnique(cc.isUnique());
}
- if (table != null)
+ if (table != null) {
table.addColumn(column);
+ }
simpleValue.addColumn(column);
}
@@ -2522,12 +2559,14 @@ private static void bindSimpleValue(GrailsDomainClassProperty grailsProp,
private static void setTypeForPropertyConfig(GrailsDomainClassProperty grailsProp, SimpleValue simpleValue, PropertyConfig config) {
final String typeName = getTypeName(grailsProp, getPropertyConfig(grailsProp), getMapping(grailsProp.getDomainClass()));
- if (typeName != null) {
+ if (typeName == null) {
+ simpleValue.setTypeName(grailsProp.getType().getName());
+ }
+ else {
simpleValue.setTypeName(typeName);
- if (config != null)
+ if (config != null) {
simpleValue.setTypeParameters(config.getTypeParams());
- } else {
- simpleValue.setTypeName(grailsProp.getType().getName());
+ }
}
}
@@ -2613,7 +2652,7 @@ else if ((property.isManyToOne() || property.isOneToOne()) && property.isCircula
ConstrainedProperty cp = getConstrainedProperty(property);
if (cp != null && cp.hasAppliedConstraint(UniqueConstraint.UNIQUE_CONSTRAINT)) {
Constraint appliedConstraint = cp.getAppliedConstraint(UniqueConstraint.UNIQUE_CONSTRAINT);
- if(appliedConstraint instanceof UniqueConstraint) {
+ if (appliedConstraint instanceof UniqueConstraint) {
UniqueConstraint uc = (UniqueConstraint) appliedConstraint;
if (uc != null && uc.isUnique()) {
if (!uc.isUniqueWithinGroup()) {
@@ -2708,20 +2747,7 @@ private static String getColumnNameForPropertyAndPath(GrailsDomainClassProperty
// First try the column config.
String columnName = null;
- if (cc != null) {
- if (supportsJoinColumnMapping(grailsProp)) {
- PropertyConfig pc = getPropertyConfig(grailsProp);
- if (hasJoinKeyMapping(pc)) {
- columnName = pc.getJoinTable().getKey().getName();
- }
- else {
- columnName = cc.getName();
- }
- }
- else {
- columnName = cc.getName();
- }
- } else {
+ if (cc == null) {
// No column config given, so try to fetch it from the mapping
GrailsDomainClass domainClass = grailsProp.getDomainClass();
Mapping m = getMapping(domainClass.getClazz());
@@ -2736,6 +2762,20 @@ else if (c != null && c.getColumn() != null) {
}
}
}
+ else {
+ if (supportsJoinColumnMapping(grailsProp)) {
+ PropertyConfig pc = getPropertyConfig(grailsProp);
+ if (hasJoinKeyMapping(pc)) {
+ columnName = pc.getJoinTable().getKey().getName();
+ }
+ else {
+ columnName = cc.getName();
+ }
+ }
+ else {
+ columnName = cc.getName();
+ }
+ }
if (columnName == null) {
if (StringHelper.isNotEmpty(path)) {
View
18 ...n-async/src/main/groovy/org/codehaus/groovy/grails/plugins/web/async/ControllersAsyncGrailsPlugin.groovy
@@ -31,14 +31,16 @@ class ControllersAsyncGrailsPlugin {
def version = GrailsUtil.getGrailsVersion()
def doWithDynamicMethods = {
- def original = HttpServletRequest.metaClass.getMetaMethod("startAsync", new Object[0])
- if(original != null) {
- HttpServletRequest.metaClass.startAsync = {->
- def webRequest = GrailsWebRequest.lookup()
- def ctx = request.startAsync(webRequest.currentRequest, webRequest.currentResponse)
- delegate.setAttribute(GrailsApplicationAttributes.ASYNC_STARTED, true)
- return new GrailsAsyncContext(ctx, webRequest)
- }
+ def original = HttpServletRequest.metaClass.getMetaMethod("startAsync", null)
+ if (original == null) {
+ return
+ }
+
+ HttpServletRequest.metaClass.startAsync = {->
+ def webRequest = GrailsWebRequest.lookup()
+ def ctx = request.startAsync(webRequest.currentRequest, webRequest.currentResponse)
+ delegate.setAttribute(GrailsApplicationAttributes.ASYNC_STARTED, true)
+ return new GrailsAsyncContext(ctx, webRequest)
}
}
}
View
11 grails-plugin-async/src/main/groovy/org/codehaus/groovy/grails/plugins/web/async/GrailsAsyncContext.groovy
@@ -35,6 +35,8 @@ import com.opensymphony.sitemesh.webapp.SiteMeshWebAppContext;
*/
class GrailsAsyncContext implements AsyncContext {
+ private static final String PERSISTENCE_INTERCEPTORS = 'org.codehaus.groovy.grails.PERSISTENCE_INTERCEPTORS'
+
@Delegate AsyncContext delegate
GrailsWebRequest originalWebRequest
GroovyPageLayoutFinder groovyPageLayoutFinder
@@ -78,7 +80,7 @@ class GrailsAsyncContext implements AsyncContext {
}
}
- void complete() {
+ void complete() {
if (response instanceof GrailsContentBufferingResponse) {
GrailsContentBufferingResponse bufferingResponse = (GrailsContentBufferingResponse) response
def targetResponse = bufferingResponse.getTargetResponse()
@@ -86,7 +88,8 @@ class GrailsAsyncContext implements AsyncContext {
if (content != null) {
def decorator = groovyPageLayoutFinder?.findLayout(request, content)
if (decorator) {
- decorator.render(content, new SiteMeshWebAppContext(request, targetResponse, request.servletContext))
+ decorator.render content,
+ new SiteMeshWebAppContext(request, targetResponse, request.servletContext)
} else {
content.writeOriginal(targetResponse.getWriter())
}
@@ -97,10 +100,10 @@ class GrailsAsyncContext implements AsyncContext {
protected Collection<PersistenceContextInterceptor> getPersistenceInterceptors(GrailsWebRequest webRequest) {
def servletContext = webRequest.servletContext
- def interceptors = servletContext?.getAttribute("org.codehaus.groovy.grails.PERSISTENCE_INTERCEPTORS")
+ def interceptors = servletContext?.getAttribute(PERSISTENCE_INTERCEPTORS)
if (interceptors == null) {
interceptors = webRequest.applicationContext?.getBeansOfType(PersistenceContextInterceptor)?.values() ?: []
- servletContext.setAttribute("org.codehaus.groovy.grails.PERSISTENCE_INTERCEPTORS", interceptors)
+ servletContext.setAttribute(PERSISTENCE_INTERCEPTORS, interceptors)
}
return interceptors
}
View
2  ...plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/plugins/web/ControllersGrailsPlugin.groovy
@@ -172,7 +172,7 @@ class ControllersGrailsPlugin {
controllerApi.setGspEncoding(gspEnc.toString())
}
- def redirectListeners = ctx.getBeansOfType(RedirectEventListener.class)
+ def redirectListeners = ctx.getBeansOfType(RedirectEventListener)
controllerApi.setRedirectListeners(redirectListeners.values())
Object o = application.getFlatConfig().get(RedirectDynamicMethod.GRAILS_VIEWS_ENABLE_JSESSIONID);
View
5 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/GroovyPagesGrailsPlugin.groovy
@@ -248,10 +248,7 @@ class GroovyPagesGrailsPlugin {
def gspServlet = webXml.servlet.find {it.'servlet-name'?.text() == 'gsp' }
gspServlet.'servlet-class' + {
'init-param' {
- description """
- Allows developers to view the intermediate source code, when they pass
- a spillGroovy argument in the URL.
- """
+ description "Allows developers to view the intermediate source code, when they pass a showSource argument in the URL."
'param-name'('showSource')
'param-value'(1)
}
View
4 grails-plugin-servlets/src/main/groovy/org/codehaus/groovy/grails/plugins/web/ServletsGrailsPlugin.groovy
@@ -15,10 +15,9 @@
*/
package org.codehaus.groovy.grails.plugins.web;
-
import grails.util.GrailsUtil
- /**
+/**
* Adds methods to the Servlet API interfaces to make them more Grailsy. For example all classes
* that implement HttpServletRequest will get new methods that allow access to attributes via
* subscript operator.
@@ -31,7 +30,6 @@ class ServletsGrailsPlugin {
def version = GrailsUtil.getGrailsVersion()
def dependsOn = [core:version]
-
def doWithDynamicMethods = { ctx ->
ServletsGrailsPluginSupport.enhanceServletApi()
}
View
33 grails-web/src/main/groovy/grails/gsp/PageRenderer.groovy
@@ -18,14 +18,20 @@ package grails.gsp
import java.security.Principal
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue
+
+import javax.servlet.AsyncContext
+import javax.servlet.DispatcherType
import javax.servlet.RequestDispatcher
import javax.servlet.ServletContext
import javax.servlet.ServletInputStream
import javax.servlet.ServletOutputStream
+import javax.servlet.ServletRequest
+import javax.servlet.ServletResponse
import javax.servlet.http.Cookie
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.servlet.http.HttpSession
+import javax.servlet.http.Part
import org.apache.commons.collections.iterators.IteratorEnumeration
import org.codehaus.groovy.grails.web.pages.FastStringWriter
import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine
@@ -214,28 +220,23 @@ class PageRenderer implements ApplicationContextAware, ServletContextAware{
boolean isRequestedSessionIdFromUrl() { false }
- @Override
boolean authenticate(HttpServletResponse response) {
return false
}
- @Override
void login(String username, String password) {
// no op
}
- @Override
void logout() {
// no op
}
- @Override
- Collection<javax.servlet.http.Part> getParts() {
- return Collections.emptyList();
+ Collection<Part> getParts() {
+ return Collections.emptyList()
}
- @Override
- javax.servlet.http.Part getPart(String name) {
+ Part getPart(String name) {
return null
}
@@ -343,33 +344,27 @@ class PageRenderer implements ApplicationContextAware, ServletContextAware{
return null //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
- javax.servlet.AsyncContext startAsync() {
+ AsyncContext startAsync() {
return null //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
- javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) {
+ AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) {
return null //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
boolean isAsyncStarted() {
return false //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
boolean isAsyncSupported() {
return false //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
- javax.servlet.AsyncContext getAsyncContext() {
+ AsyncContext getAsyncContext() {
return null //To change body of implemented methods use File | Settings | File Templates.
}
- @Override
- javax.servlet.DispatcherType getDispatcherType() {
+ DispatcherType getDispatcherType() {
return null //To change body of implemented methods use File | Settings | File Templates.
}
}
@@ -457,7 +452,7 @@ class PageRenderer implements ApplicationContextAware, ServletContextAware{
}
Collection<String> getHeaderNames() {
- return Collections.emptyList();
+ return Collections.emptyList()
}
ServletOutputStream getOutputStream() {
Please sign in to comment.
Something went wrong with that request. Please try again.