Browse files

whitespace, misc cleanup

  • Loading branch information...
1 parent 1861a2a commit 27b5b041dd8e1f24f56f9c9589a3d25b28886db7 Burt Beckwith committed Jul 24, 2012
View
8 grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy
@@ -17,10 +17,12 @@ package grails.util
import static grails.build.logging.GrailsConsole.instance as CONSOLE
import grails.build.logging.GrailsConsole
+import groovy.transform.CompileStatic
import java.util.concurrent.ConcurrentHashMap
import java.util.regex.Pattern
+import org.apache.ivy.core.module.descriptor.ExcludeRule
import org.apache.ivy.core.report.ResolveReport
import org.apache.ivy.plugins.repository.TransferEvent
import org.apache.ivy.plugins.repository.TransferListener
@@ -29,12 +31,10 @@ import org.apache.ivy.util.DefaultMessageLogger
import org.apache.ivy.util.Message
import org.codehaus.groovy.grails.cli.support.ClasspathConfigurer
import org.codehaus.groovy.grails.cli.support.OwnerlessClosure
+import org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor
import org.codehaus.groovy.grails.resolve.GrailsCoreDependencies
import org.codehaus.groovy.grails.resolve.IvyDependencyManager
import org.codehaus.groovy.runtime.StackTraceUtils
-import org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor
-import org.apache.ivy.core.module.descriptor.ExcludeRule
-import groovy.transform.CompileStatic
/**
* <p>Represents the project paths and other build settings
@@ -1383,7 +1383,7 @@ class BuildSettings extends AbstractBuildSettings {
def props = config.toProperties()
final forkConfig = getForkConfig()
- if((forkConfig instanceof Map) && forkConfig) {
+ if ((forkConfig instanceof Map) && forkConfig) {
forkSettings = (Map)forkConfig
}
Metadata metadata = Metadata.getCurrent()
View
96 ...-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/fork/ForkedGrailsProcess.groovy
@@ -15,52 +15,49 @@
*/
package org.codehaus.groovy.grails.cli.fork
-import groovy.transform.CompileStatic
-import grails.build.logging.GrailsConsole
-import org.apache.commons.logging.Log
import gant.Gant
+import grails.build.logging.GrailsConsole
import grails.util.BuildSettings
import grails.util.PluginBuildSettings
+import groovy.transform.CompileStatic
+
import java.lang.reflect.Method
+import org.apache.commons.logging.Log
+
/**
* Helper class for kicking off forked JVM processes, helpful in managing the setup and
* execution of the forked process. Subclasses should provided a static void main method.
*
* @author Graeme Rocher
* @since 2.2
*/
-
abstract class ForkedGrailsProcess {
- int maxMemory = 1024;
- int minMemory = 64;
- int maxPerm = 256;
- boolean debug = false;
- File reloadingAgent;
+ int maxMemory = 1024
+ int minMemory = 64
+ int maxPerm = 256
+ boolean debug = false
+ File reloadingAgent
List<String> jvmArgs
@CompileStatic
void configure(Map forkConfig) {
- if(forkConfig instanceof Map) {
-
- final Map<String, Object> runSettings = (Map<String, Object>) forkConfig
- runSettings.each { Map.Entry<String, Object> entry ->
- try {
- ((GroovyObject)this).setProperty(entry.getKey(),entry.getValue())
- } catch (MissingPropertyException e) {
- // ignore
- }
+ final Map<String, Object> runSettings = (Map<String, Object>) forkConfig
+ runSettings.each { Map.Entry<String, Object> entry ->
+ try {
+ ((GroovyObject)this).setProperty(entry.getKey(),entry.getValue())
+ } catch (MissingPropertyException e) {
+ // ignore
}
}
-
}
@CompileStatic
protected void discoverAndSetAgent(ExecutionContext executionContext) {
try {
final agentClass = Thread.currentThread().contextClassLoader.loadClass('com.springsource.loaded.ReloadEventProcessorPlugin')
- setReloadingAgent(ForkedGrailsProcess.findJarFile(agentClass))
+ setReloadingAgent(findJarFile(agentClass))
} catch (e) {
final grailsHome = executionContext.grailsHome
if (grailsHome && grailsHome.exists()) {
@@ -95,22 +92,22 @@ abstract class ForkedGrailsProcess {
}
List<String> cmd = ["java", "-Xmx${maxMemory}M".toString(), "-Xms${minMemory}M".toString(), "-XX:MaxPermSize=${maxPerm}m".toString(),"-Dgrails.fork.active=true", "-Dgrails.build.execution.context=${tempFile.canonicalPath}".toString(), "-cp", cp.toString()]
- if(debug) {
- cmd.addAll( ["-Xdebug","-Xnoagent","-Dgrails.full.stacktrace=true", "-Djava.compiler=NONE", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"] )
+ if (debug) {
+ cmd.addAll(["-Xdebug","-Xnoagent","-Dgrails.full.stacktrace=true", "-Djava.compiler=NONE", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"] )
}
final console = GrailsConsole.getInstance()
- if(console.isVerbose()) {
+ if (console.isVerbose()) {
cmd.add("-Dgrails.verbose=true")
cmd.add("-Dgrails.full.stacktrace=true")
}
- if(console.isStacktrace()) {
+ if (console.isStacktrace()) {
cmd.add("-Dgrails.show.stacktrace=true")
}
- if(reloadingAgent != null) {
+ if (reloadingAgent != null) {
cmd.addAll(["-javaagent:" + reloadingAgent.getCanonicalPath(), "-noverify", "-Dspringloaded=profile=grails"])
}
cmd << getClass().name
- if(jvmArgs) {
+ if (jvmArgs) {
cmd.addAll(jvmArgs)
}
@@ -144,7 +141,7 @@ abstract class ForkedGrailsProcess {
@CompileStatic
ExecutionContext readExecutionContext() {
- String location = System.getProperty("grails.build.execution.context");
+ String location = System.getProperty("grails.build.execution.context")
if (location != null) {
final file = new File(location)
@@ -162,21 +159,20 @@ abstract class ForkedGrailsProcess {
public static List<File> buildMinimalIsolatedClasspath(BuildSettings buildSettings) {
List<File> buildDependencies = []
-
buildDependencies.add findJarFile(GroovySystem)
buildDependencies.add findJarFile(Log)
buildDependencies.add findJarFile(Gant)
List<File> bootstrapJars = []
- for(File f in buildSettings.runtimeDependencies) {
+ for (File f in buildSettings.runtimeDependencies) {
final fileName = f.name
- if( fileName.contains('log4j') ) {
+ if (fileName.contains('log4j') ) {
bootstrapJars.add(f)
}
}
- for(File f in buildSettings.buildDependencies) {
+ for (File f in buildSettings.buildDependencies) {
final fileName = f.name
- if( fileName.contains('grails-bootstrap') ||
+ if (fileName.contains('grails-bootstrap') ||
fileName.contains('slf4j-api') ||
fileName.contains('ivy') ||
fileName.contains('ant') ||
@@ -194,20 +190,18 @@ abstract class ForkedGrailsProcess {
public static File findJarFile(Class targetClass) {
def absolutePath = targetClass.getResource('/' + targetClass.name.replace(".", "/") + ".class").getPath()
final jarPath = absolutePath.substring("file:".length(), absolutePath.lastIndexOf("!"))
- final jarFile = new File(jarPath)
- jarFile
+ new File(jarPath)
}
@CompileStatic
protected URLClassLoader createClassLoader(BuildSettings buildSettings) {
- def urls = buildSettings.runtimeDependencies.collect { File f -> f.toURL() }
- urls.add(buildSettings.classesDir.toURL())
- urls.add(buildSettings.pluginClassesDir.toURL())
- urls.add(buildSettings.pluginBuildClassesDir.toURL())
- urls.add(buildSettings.pluginProvidedClassesDir.toURL())
-
- URLClassLoader classLoader = new URLClassLoader(urls as URL[])
- return classLoader
+ def urls = buildSettings.runtimeDependencies.collect { File f -> f.toURI().toURL() }
+ urls.add(buildSettings.classesDir.toURI().toURL())
+ urls.add(buildSettings.pluginClassesDir.toURI().toURL())
+ urls.add(buildSettings.pluginBuildClassesDir.toURI().toURL())
+ urls.add(buildSettings.pluginProvidedClassesDir.toURI().toURL())
+
+ return new URLClassLoader(urls as URL[])
}
protected void setupReloading(URLClassLoader classLoader, BuildSettings buildSettings) {
@@ -225,13 +219,13 @@ abstract class ForkedGrailsProcess {
protected void initializeLogging(File grailsHome, ClassLoader classLoader) {
try {
- Class<?> cls = classLoader.loadClass("org.apache.log4j.PropertyConfigurator");
+ Class<?> cls = classLoader.loadClass("org.apache.log4j.PropertyConfigurator")
Method configure = cls.getMethod("configure", URL.class)
- configure.setAccessible(true);
- File f = new File(grailsHome.absolutePath + "/scripts/log4j.properties");
- configure.invoke(cls, f.toURI().toURL());
+ configure.setAccessible(true)
+ File f = new File(grailsHome.absolutePath + "/scripts/log4j.properties")
+ configure.invoke(cls, f.toURI().toURL())
} catch (Throwable e) {
- println("Log4j was not found on the classpath and will not be used for command line logging. Cause "+e.getClass().getName()+": " + e.getMessage());
+ println("Log4j was not found on the classpath and will not be used for command line logging. Cause "+e.getClass().getName()+": " + e.getMessage())
}
}
@@ -245,10 +239,8 @@ abstract class ForkedGrailsProcess {
void run() {
def isr = new InputStreamReader(input)
- def br = new BufferedReader(isr)
-
- br.eachLine { String next ->
- if(next) {
+ new BufferedReader(isr).eachLine { String next ->
+ if (next) {
GrailsConsole.getInstance().log(next)
}
}
@@ -257,7 +249,7 @@ abstract class ForkedGrailsProcess {
}
@CompileStatic
-class ExecutionContext implements Serializable{
+class ExecutionContext implements Serializable {
List<File> runtimeDependencies
List<File> buildDependencies
List<File> providedDependencies
View
2 ...-bootstrap/src/main/groovy/org/codehaus/groovy/grails/io/support/GrailsResourceUtils.java
@@ -842,7 +842,7 @@ public static Object instantiateFromFlatConfig(Map<String, Object> flatConfig, S
return forName(className, DefaultResourceLoader.getDefaultClassLoader()).newInstance();
}
- private static Class forName(String className, ClassLoader defaultClassLoader) throws ClassNotFoundException {
+ private static Class<?> forName(String className, ClassLoader defaultClassLoader) throws ClassNotFoundException {
return defaultClassLoader.loadClass(className);
}
}
View
6 ...rc/main/groovy/org/codehaus/groovy/grails/plugins/log4j/web/util/Log4jConfigListener.java
@@ -15,20 +15,18 @@
package org.codehaus.groovy.grails.plugins.log4j.web.util;
import grails.util.Environment;
-import grails.util.GrailsWebUtil;
import groovy.util.ConfigObject;
+import java.lang.reflect.Method;
+
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.LogManager;
import org.apache.log4j.helpers.LogLog;
-import org.codehaus.groovy.grails.exceptions.GrailsConfigurationException;
import org.codehaus.groovy.grails.plugins.exceptions.PluginException;
import org.codehaus.groovy.grails.plugins.log4j.Log4jConfig;
-import java.lang.reflect.Method;
-
/**
* Configures Log4j in WAR deployment using Grails Log4j DSL.
*
View
27 grails-plugin-tomcat/src/main/groovy/org/grails/plugins/tomcat/TomcatServerFactory.groovy
@@ -15,16 +15,16 @@
*/
package org.grails.plugins.tomcat
+import grails.util.BuildSettings
+import grails.util.Environment
import grails.web.container.EmbeddableServer
import grails.web.container.EmbeddableServerFactory
-import org.grails.plugins.tomcat.fork.ForkedTomcatServer
-import org.grails.plugins.tomcat.fork.TomcatExecutionContext
-import org.codehaus.groovy.grails.cli.support.BuildSettingsAware
-import grails.util.BuildSettings
import groovy.transform.CompileStatic
-import grails.util.Environment
-import org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess
+import org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess
+import org.codehaus.groovy.grails.cli.support.BuildSettingsAware
+import org.grails.plugins.tomcat.fork.ForkedTomcatServer
+import org.grails.plugins.tomcat.fork.TomcatExecutionContext
class TomcatServerFactory implements EmbeddableServerFactory,BuildSettingsAware {
@@ -33,12 +33,11 @@ class TomcatServerFactory implements EmbeddableServerFactory,BuildSettingsAware
@CompileStatic
EmbeddableServer createInline(String basedir, String webXml, String contextPath, ClassLoader classLoader) {
final obj = buildSettings?.forkSettings?.get("run")
- if(obj) {
+ if (obj) {
return createForked(contextPath, obj)
}
- else {
- return new InlineExplodedTomcatServer(basedir, webXml, contextPath, classLoader)
- }
+
+ return new InlineExplodedTomcatServer(basedir, webXml, contextPath, classLoader)
}
@CompileStatic
@@ -61,24 +60,22 @@ class TomcatServerFactory implements EmbeddableServerFactory,BuildSettingsAware
ec.resourcesDir = buildSettings.resourcesDir
final forkedTomcat = new ForkedTomcatServer(ec)
- if(forkConfig instanceof Map) {
-
+ if (forkConfig instanceof Map) {
forkedTomcat.configure((Map)forkConfig)
}
+
def tomcatJvmArgs = getTomcatJvmArgs()
- if(tomcatJvmArgs instanceof List) {
+ if (tomcatJvmArgs instanceof List) {
forkedTomcat.jvmArgs = (List<String>)tomcatJvmArgs
}
-
return forkedTomcat
}
private getTomcatJvmArgs() {
buildSettings.config?.grails?.tomcat?.jvmArgs
}
-
@CompileStatic
private List<File> buildMinimalIsolatedClasspath() {
List<File> buildDependencies = ForkedGrailsProcess.buildMinimalIsolatedClasspath(buildSettings)
View
28 ...ls-plugin-tomcat/src/main/groovy/org/grails/plugins/tomcat/fork/ForkedTomcatServer.groovy
@@ -19,14 +19,15 @@ import grails.util.BuildSettings
import grails.util.BuildSettingsHolder
import grails.web.container.EmbeddableServer
import groovy.transform.CompileStatic
+
import org.apache.catalina.Context
+import org.apache.catalina.startup.Tomcat
import org.codehaus.groovy.grails.cli.fork.ExecutionContext
import org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess
import org.codehaus.groovy.grails.io.support.Resource
import org.codehaus.groovy.grails.plugins.GrailsPluginUtils
import org.grails.plugins.tomcat.InlineExplodedTomcatServer
import org.grails.plugins.tomcat.TomcatKillSwitch
-import org.apache.catalina.startup.Tomcat
/**
* An implementation of the Tomcat server that runs in forked mode.
@@ -69,20 +70,16 @@ class ForkedTomcatServer extends ForkedGrailsProcess implements EmbeddableServer
initializeLogging(ec.grailsHome,classLoader)
tomcatRunner = new TomcatRunner("$buildSettings.baseDir/web-app", buildSettings.webXmlLocation.absolutePath, ec.contextPath, classLoader)
- if(ec.securePort > 0) {
+ if (ec.securePort > 0) {
tomcatRunner.startSecure(ec.host, ec.port, ec.securePort)
}
else {
tomcatRunner.start(ec.host, ec.port)
}
-
setupReloading(classLoader, buildSettings)
-
}
-
-
@CompileStatic
void start(String host, int port) {
startSecure(host, port, 0)
@@ -108,7 +105,6 @@ class ForkedTomcatServer extends ForkedGrailsProcess implements EmbeddableServer
System.setProperty(TomcatKillSwitch.TOMCAT_KILL_SWITCH_ACTIVE, "true")
}
-
@CompileStatic
boolean isAvailable(String host, int port) {
try {
@@ -145,15 +141,12 @@ class ForkedTomcatServer extends ForkedGrailsProcess implements EmbeddableServer
@CompileStatic
protected void initialize(Tomcat tomcat) {
final autodeployDir = buildSettings.autodeployDir
- if(autodeployDir.exists()) {
-
+ if (autodeployDir.exists()) {
final wars = autodeployDir.listFiles()
- if(wars != null) {
- for(File f in wars) {
- final fileName = f.name
- if(fileName.endsWith(".war")) {
- tomcat.addWebapp(f.name - '.war', f.absolutePath)
- }
+ for(File f in wars) {
+ final fileName = f.name
+ if (fileName.endsWith(".war")) {
+ tomcat.addWebapp(f.name - '.war', f.absolutePath)
}
}
}
@@ -168,8 +161,8 @@ class ForkedTomcatServer extends ForkedGrailsProcess implements EmbeddableServer
} catch (Throwable e) {
// ignore
}
- if(cls != null) {
+ if (cls != null) {
try {
cls.newInstance().customize(tomcat)
} catch (e) {
@@ -211,10 +204,9 @@ class ForkedTomcatServer extends ForkedGrailsProcess implements EmbeddableServer
}
}
-class TomcatExecutionContext extends ExecutionContext implements Serializable {
+class TomcatExecutionContext extends ExecutionContext {
String contextPath
String host = EmbeddableServer.DEFAULT_HOST
int port = EmbeddableServer.DEFAULT_PORT
int securePort
-
}
View
2 grails-test-suite-uber/src/test/groovy/grails/test/mixin/UrlMappingsTestMixinTests.groovy
@@ -1,11 +1,11 @@
package grails.test.mixin
import grails.test.mixin.web.UrlMappingsUnitTestMixin
+import grails.web.Action
import junit.framework.AssertionFailedError
import junit.framework.ComparisonFailure
import org.junit.Test
-import grails.web.Action
import org.springframework.web.context.WebApplicationContext
/**
View
8 scripts/RunApp.groovy
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess
+
/**
* Gant script that executes Grails using an embedded Jetty server
*
@@ -32,8 +34,8 @@ target('default': "Runs a Grails application") {
else {
runApp()
}
- if(!(grailsServer instanceof org.codehaus.groovy.grails.cli.fork.ForkedGrailsProcess)) {
- watchContext()
- }
+ if (!(grailsServer instanceof ForkedGrailsProcess)) {
+ watchContext()
+ }
}
View
24 scripts/StopApp.groovy
@@ -13,30 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
/**
-* Gant script that stops the running forked Grails application if it is running
-*
-* @author Graeme Rocher
-*
-* @since 2.2
-*/
+ * Stops the forked Grails application if it is running.
+ *
+ * @author Graeme Rocher
+ *
+ * @since 2.2
+ */
includeTargets << grailsScript("_GrailsRun")
target('default': "Stops a forked Grails application") {
depends(checkVersion, configureProxy)
-
+
try {
grailsConsole.updateStatus "Stopping Grails Server..."
def url = "http://${serverHost ?: 'localhost'}:${serverPort+1}"
grailsConsole.verbose "URL to stop server is $url"
new URL(url).getText(connectTimeout: 10000, readTimeout: 10000)
- grailsConsole.updateStatus "Server Stopped"
+ grailsConsole.updateStatus "Server Stopped"
}
catch(e) {
- grailsConsole.updateStatus "Server Stopped"
+ grailsConsole.updateStatus "Server Stopped"
}
-
-}
+}
View
2 scripts/_GrailsRun.groovy
@@ -63,7 +63,7 @@ target(runApp: "Main implementation that executes a Grails application") {
/**
* Runs the application in dev mode over HTTPS.
*/
-target(runAppHttps: "Main implementation that executes a Grails application with an HTTPS listener") {
+target(runAppHttps: "Main implementation that executes a Grails application with an HTTPS listener") {
grailsServer = projectRunner.runAppHttps()
}
View
13 scripts/_PluginDependencies.groovy
@@ -14,18 +14,12 @@
* limitations under the License.
*/
-import grails.util.BuildSettings
-import grails.util.GrailsNameUtils
-import grails.util.GrailsUtil
-import grails.util.PluginBuildSettings
-
-
import org.codehaus.groovy.grails.compiler.support.*
-import org.codehaus.groovy.grails.resolve.IvyDependencyManager
+import org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader
import org.codehaus.groovy.grails.resolve.GrailsRepoResolver
+import org.codehaus.groovy.grails.resolve.IvyDependencyManager
import org.codehaus.groovy.grails.resolve.PluginInstallEngine
-
/**
* Plugin stuff. If included, must be included after "_ClasspathAndEvents".
*
@@ -77,12 +71,11 @@ target(loadPluginsAsync:"Asynchronously loads plugins") {
}
target(loadPlugins:"Loads Grails' plugins") {
- def pluginLoader = new org.codehaus.groovy.grails.project.plugins.GrailsProjectPluginLoader(grailsApp, classLoader, buildSettings, eventListener)
+ def pluginLoader = new GrailsProjectPluginLoader(grailsApp, classLoader, buildSettings, eventListener)
pluginManager = pluginLoader.loadPlugins()
grailsApp = pluginLoader.grailsApplication
}
-
/**
* Runs a script contained within a plugin
*/

0 comments on commit 27b5b04

Please sign in to comment.