Minor change to code formatting

This commit is contained in:
Phillip Webb
2013-07-06 14:21:20 -07:00
parent a6341dc0af
commit 764a0a9af8
84 changed files with 391 additions and 214 deletions

View File

@@ -24,14 +24,14 @@ import java.util.ServiceLoader;
import java.util.Set;
/**
* Spring Zero Command Line Interface. This is the main entry-point for the Spring
* Zero command line application. This class will parse input arguments and delegate
* to a suitable {@link Command} implementation based on the first argument.
*
* Spring Zero Command Line Interface. This is the main entry-point for the Spring Zero
* command line application. This class will parse input arguments and delegate to a
* suitable {@link Command} implementation based on the first argument.
*
* <p>
* The '-d' and '--debug' switches are handled by this class, however, most argument
* parsing is left to the {@link Command} implementation.
*
*
* @author Phillip Webb
* @see #main(String...)
* @see SpringZeroCliException
@@ -47,8 +47,7 @@ public class SpringZeroCli {
private List<Command> commands;
/**
* Create a new {@link SpringZeroCli} implementation with the default set of
* commands.
* Create a new {@link SpringZeroCli} implementation with the default set of commands.
*/
public SpringZeroCli() {
setCommands(ServiceLoader.load(CommandFactory.class, getClass().getClassLoader()));
@@ -87,10 +86,12 @@ public class SpringZeroCli {
try {
run(argsWithoutDebugFlags);
return 0;
} catch (NoArgumentsException ex) {
}
catch (NoArgumentsException ex) {
showUsage();
return 1;
} catch (Exception ex) {
}
catch (Exception ex) {
Set<SpringZeroCliException.Option> options = NO_EXCEPTION_OPTIONS;
if (ex instanceof SpringZeroCliException) {
options = ((SpringZeroCliException) ex).getOptions();

View File

@@ -70,8 +70,7 @@ public class SpringZeroCliException extends RuntimeException {
}
/**
* Returns options a set of options that are understood by the
* {@link SpringZeroCli}.
* Returns options a set of options that are understood by the {@link SpringZeroCli}.
*/
public Set<Option> getOptions() {
return Collections.unmodifiableSet(this.options);

View File

@@ -29,7 +29,7 @@ import org.springframework.zero.cli.Command;
/**
* {@link Command} to 'clean' up grapes, removing cached dependencies and forcing a
* download on the next attempt to resolve.
*
*
* @author Dave Syer
*/
public class CleanCommand extends OptionParsingCommand {
@@ -102,7 +102,8 @@ public class CleanCommand extends OptionParsingCommand {
|| group.equals("org.springframework.zero")) {
System.out.println("Deleting: " + file);
FileUtil.forceDelete(file);
} else {
}
else {
for (Object obj : FileUtil.listAll(file, Collections.emptyList())) {
File candidate = (File) obj;
if (candidate.getName().contains("SNAPSHOT")) {
@@ -119,7 +120,8 @@ public class CleanCommand extends OptionParsingCommand {
File parent = root;
if (layout == Layout.IVY) {
parent = new File(parent, group);
} else {
}
else {
for (String path : group.split("\\.")) {
parent = new File(parent, path);
}
@@ -140,7 +142,8 @@ public class CleanCommand extends OptionParsingCommand {
if (dir == null || !new File(dir).exists()) {
dir = userdir;
home = new File(dir, ".groovy");
} else {
}
else {
home = new File(dir);
}
if (dir == null || !new File(dir).exists()) {

View File

@@ -77,7 +77,8 @@ public class OptionHandler {
OutputStream out = new ByteArrayOutputStream();
try {
getParser().printHelpOn(out);
} catch (IOException e) {
}
catch (IOException e) {
return "Help not available";
}
return out.toString();

View File

@@ -91,13 +91,17 @@ public class ScriptCommand implements Command {
private void run(Object main, String[] args) throws Exception {
if (main instanceof Command) {
((Command) main).run(args);
} else if (main instanceof OptionHandler) {
}
else if (main instanceof OptionHandler) {
((OptionHandler) getMain()).run(args);
} else if (main instanceof Closure) {
}
else if (main instanceof Closure) {
((Closure<?>) main).call((Object[]) args);
} else if (main instanceof Runnable) {
}
else if (main instanceof Runnable) {
((Runnable) main).run();
} else if (main instanceof Script) {
}
else if (main instanceof Script) {
Script script = (Script) this.main;
script.setProperty("args", args);
if (this.main instanceof GroovyObjectSupport) {
@@ -135,13 +139,15 @@ public class ScriptCommand implements Command {
if (this.main == null) {
try {
this.main = getMainClass().newInstance();
} catch (Exception e) {
}
catch (Exception e) {
throw new IllegalStateException("Cannot create main class: " + this.name,
e);
}
if (this.main instanceof OptionHandler) {
((OptionHandler) this.main).options();
} else if (this.main instanceof GroovyObjectSupport) {
}
else if (this.main instanceof GroovyObjectSupport) {
GroovyObjectSupport object = (GroovyObjectSupport) this.main;
MetaClass metaClass = object.getMetaClass();
MetaMethod options = metaClass.getMetaMethod("options", null);
@@ -160,9 +166,11 @@ public class ScriptCommand implements Command {
Class<?>[] classes;
try {
classes = compiler.compile(source);
} catch (CompilationFailedException e) {
}
catch (CompilationFailedException e) {
throw new IllegalStateException("Could not compile script", e);
} catch (IOException e) {
}
catch (IOException e) {
throw new IllegalStateException("Could not compile script", e);
}
this.mainClass = classes[0];
@@ -185,18 +193,21 @@ public class ScriptCommand implements Command {
if (url != null) {
if (url.toString().startsWith("file:")) {
file = new File(url.toString().substring("file:".length()));
} else {
}
else {
// probably in JAR file
try {
file = File.createTempFile(name, ".groovy");
file.deleteOnExit();
FileUtil.copy(url, file, null);
} catch (IOException e) {
}
catch (IOException e) {
throw new IllegalStateException(
"Could not create temp file for source: " + name);
}
}
} else {
}
else {
String home = System.getProperty("SPRING_HOME", System.getenv("SPRING_HOME"));
if (home == null) {
home = ".";

View File

@@ -72,7 +72,8 @@ public class DependencyCustomizer {
for (String classname : classNames) {
try {
DependencyCustomizer.this.loader.loadClass(classname);
} catch (Exception e) {
}
catch (Exception e) {
return true;
}
}
@@ -95,7 +96,8 @@ public class DependencyCustomizer {
try {
DependencyCustomizer.this.loader.loadClass(classname);
return false;
} catch (Exception e) {
}
catch (Exception e) {
}
}
return DependencyCustomizer.this.canAdd();
@@ -119,7 +121,8 @@ public class DependencyCustomizer {
return false;
}
return true;
} catch (Exception e) {
}
catch (Exception e) {
}
}
return DependencyCustomizer.this.canAdd();
@@ -143,7 +146,8 @@ public class DependencyCustomizer {
return true;
}
return false;
} catch (Exception e) {
}
catch (Exception e) {
}
}
return DependencyCustomizer.this.canAdd();

View File

@@ -47,13 +47,13 @@ import org.codehaus.groovy.control.customizers.ImportCustomizer;
* <li>{@link CompilerAutoConfiguration} strategies will be read from
* <code>META-INF/services/org.springframework.zero.cli.compiler.CompilerAutoConfiguration</code>
* (per the standard java {@link ServiceLoader} contract) and applied during compilation</li>
*
*
* <li>Multiple classes can be returned if the Groovy source defines more than one Class</li>
*
*
* <li>Generated class files can also be loaded using
* {@link ClassLoader#getResource(String)}</li>
* <ul>
*
*
* @author Phillip Webb
* @author Dave Syer
*/
@@ -88,7 +88,8 @@ public class GroovyCompiler {
for (File file : files) {
if (file.getName().endsWith(".groovy") || file.getName().endsWith(".java")) {
compilables.add(file);
} else {
}
else {
others.add(file);
}
}

View File

@@ -24,7 +24,7 @@ import org.springframework.zero.cli.compiler.DependencyCustomizer;
/**
* {@link CompilerAutoConfiguration} for Spring MVC.
*
*
* @author Dave Syer
* @author Phillip Webb
*/
@@ -58,8 +58,8 @@ public class SpringMvcCompilerAutoConfiguration extends CompilerAutoConfiguratio
imports.addStarImports("org.springframework.web.bind.annotation",
"org.springframework.web.servlet.config.annotation",
"org.springframework.http");
imports.addStaticImport(
"org.springframework.zero.cli.template.GroovyTemplate", "template");
imports.addStaticImport("org.springframework.zero.cli.template.GroovyTemplate",
"template");
}
}

View File

@@ -100,7 +100,8 @@ public class SpringZeroCompilerAutoConfiguration extends CompilerAutoConfigurati
AnnotationNode annotationNode = new AnnotationNode(new ClassNode(
annotationClass));
classNode.addAnnotation(annotationNode);
} catch (ClassNotFoundException e) {
}
catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
}

View File

@@ -92,10 +92,12 @@ public class SpringZeroRunner {
this.fileWatchThread.start();
}
} catch (Exception ex) {
}
catch (Exception ex) {
if (this.fileWatchThread == null) {
throw ex;
} else {
}
else {
ex.printStackTrace();
}
}
@@ -132,7 +134,8 @@ public class SpringZeroRunner {
String[].class);
this.applicationContext = method.invoke(null, this.sources,
SpringZeroRunner.this.args);
} catch (Exception ex) {
}
catch (Exception ex) {
ex.printStackTrace();
}
}
@@ -145,11 +148,14 @@ public class SpringZeroRunner {
try {
Method method = this.applicationContext.getClass().getMethod("close");
method.invoke(this.applicationContext);
} catch (NoSuchMethodException ex) {
}
catch (NoSuchMethodException ex) {
// Not an application context that we can close
} catch (Exception ex) {
}
catch (Exception ex) {
ex.printStackTrace();
} finally {
}
finally {
this.applicationContext = null;
}
}
@@ -186,9 +192,11 @@ public class SpringZeroRunner {
compileAndRun();
}
}
} catch (InterruptedException ex) {
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
} catch (Exception ex) {
}
catch (Exception ex) {
// Swallow, will be reported by compileAndRun
}
}

View File

@@ -48,10 +48,12 @@ public class GroovyTemplate {
Template template;
if (file.exists()) {
template = engine.createTemplate(file);
} else {
}
else {
if (resource != null) {
template = engine.createTemplate(resource);
} else {
}
else {
template = engine.createTemplate(name);
}
}