brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [3/4] brooklyn-server git commit: Use boolean Options correctly in ItemLister
Date Wed, 15 Mar 2017 13:07:37 GMT
Use boolean Options correctly in ItemLister

Replaces list-objects' --catalog-only and --ignore-impls arguments with
--all-classes and --include-impls respectively.

ItemLister defined a few options as booleans whose default was true.
Airline treats boolean options as having zero arity and whose existence
implies truth.

Also removes the default from all other boolean options to make it
clearer that the value is set by Airline.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/116de91e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/116de91e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/116de91e

Branch: refs/heads/master
Commit: 116de91e2f2ae86aa61c4f398a3354231e5f2985
Parents: 3bb2b2b
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Mon Mar 13 13:29:31 2017 +0000
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Mon Mar 13 13:29:31 2017 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/cli/AbstractMain.java   |  4 ++--
 .../org/apache/brooklyn/cli/CloudExplorer.java  |  2 +-
 .../org/apache/brooklyn/cli/ItemLister.java     | 20 ++++++++++--------
 .../main/java/org/apache/brooklyn/cli/Main.java | 22 ++++++++++----------
 4 files changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/116de91e/server-cli/src/main/java/org/apache/brooklyn/cli/AbstractMain.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/AbstractMain.java b/server-cli/src/main/java/org/apache/brooklyn/cli/AbstractMain.java
index 64c8e1d..1c0a803 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/AbstractMain.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/AbstractMain.java
@@ -101,10 +101,10 @@ public abstract class AbstractMain {
     public static abstract class BrooklynCommand implements Callable<Void> {
 
         @Option(type = OptionType.GLOBAL, name = { "-v", "--verbose" }, description = "Verbose
mode")
-        public boolean verbose = false;
+        public boolean verbose;
 
         @Option(type = OptionType.GLOBAL, name = { "-q", "--quiet" }, description = "Quiet
mode")
-        public boolean quiet = false;
+        public boolean quiet;
 
         @VisibleForTesting
         protected PrintStream stdout = System.out;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/116de91e/server-cli/src/main/java/org/apache/brooklyn/cli/CloudExplorer.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/CloudExplorer.java b/server-cli/src/main/java/org/apache/brooklyn/cli/CloudExplorer.java
index 24246ef..dae16a4 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/CloudExplorer.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/CloudExplorer.java
@@ -52,7 +52,7 @@ public class CloudExplorer {
 
         @Option(name = { "-y", "--yes" }, title = "auto-confirm",
                 description = CloudExplorerSupport.AUTOCONFIRM_DESC)
-        public boolean autoConfirm = false;
+        public boolean autoConfirm;
 
 
         protected abstract CloudExplorerSupport getExplorer(LocalManagementContext mgmt,
boolean allLocations,

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/116de91e/server-cli/src/main/java/org/apache/brooklyn/cli/ItemLister.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/ItemLister.java b/server-cli/src/main/java/org/apache/brooklyn/cli/ItemLister.java
index 1cd0de0..6e31e53 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/ItemLister.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/ItemLister.java
@@ -99,14 +99,16 @@ public class ItemLister {
         @Option(name = { "--type-regex" }, title = "Regex to restrict the Java types loaded")
         public String typeRegex;
 
-        @Option(name = { "--catalog-only" }, title = "When scanning JAR files, whether to
include only items annotated with @Catalog (default true)")
-        public boolean catalogOnly = true;
+        @Option(name = {"--all-classes"}, description =
+                "When scanning JAR files, whether to include all items rather than only those
annotated with @Catalog")
+        protected boolean allClasses;
 
-        @Option(name = { "--ignore-impls" }, title = "Ignore Entity class implementation
where there is an Entity interface with @ImplementedBy (default true)")
-        public boolean ignoreImpls = true;
+        @Option(name = { "--include-impls" }, description =
+                "Include Entity class implementation where there is an Entity interface with
@ImplementedBy")
+        public boolean includeImpls;
 
-        @Option(name = { "--headings-only" }, title = "Whether to only show name/type, and
not config keys etc")
-        public boolean headingsOnly = false;
+        @Option(name = { "--headings-only" }, description = "Whether to only show name/type,
and not config keys etc")
+        public boolean headingsOnly;
         
         @Option(name = { "--output-folder" }, title = "If supplied, generate HTML pages in
the given folder; otherwise only generates JSON")
         public String outputFolder;
@@ -114,7 +116,7 @@ public class ItemLister {
         @SuppressWarnings("unchecked")
         @Override
         public Void call() throws Exception {
-            Map<String, Object> result = MutableMap.of();
+            Map<String, Object> result;
 
             result = populateDescriptors();
             String json = toJson(result);
@@ -334,12 +336,12 @@ public class ItemLister {
             if (typeRegex != null) {
                 fluent = fluent.filter(ClassFinder.withClassNameMatching(typeRegex));
             }
-            if (catalogOnlyOverride == null ? catalogOnly : catalogOnlyOverride) {
+            if (catalogOnlyOverride == null ? !allClasses : catalogOnlyOverride) {
                 fluent = fluent.filter(ClassFinder.withAnnotation(Catalog.class));
             }
             List<Class<? extends T>> filtered = fluent.toList();
             Collection<Class<? extends T>> result;
-            if (ignoreImpls) {
+            if (!includeImpls) {
                 result = MutableSet.copyOf(filtered);
                 for (Class<? extends T> clazz : filtered) {
                     ImplementedBy implementedBy = clazz.getAnnotation(ImplementedBy.class);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/116de91e/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
index a791520..1863f71 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
@@ -203,7 +203,7 @@ public class Main extends AbstractMain {
 
         @Option(name = { "--noGlobalBrooklynProperties" }, title = "do not use any global
brooklyn.properties file found",
             description = "Do not use the default global brooklyn.properties file found")
-        public boolean noGlobalBrooklynProperties = false;
+        public boolean noGlobalBrooklynProperties;
 
         @Option(name = { "-a", "--app" }, title = "application class or file",
                 description = "The Application to start. " +
@@ -250,11 +250,11 @@ public class Main extends AbstractMain {
 
         @Option(name = { "--https" },
             description = "Launch the web console on https")
-        public boolean useHttps = false;
+        public boolean useHttps;
         
         @Option(name = { "-nc", "--noConsole" },
                 description = "Do not start the web console or REST API")
-        public boolean noConsole = false;
+        public boolean noConsole;
 
         @Option(name = { "-b", "--bindAddress" },
                 description = "Specifies the IP address of the NIC to bind the Brooklyn Management
Console to")
@@ -266,39 +266,39 @@ public class Main extends AbstractMain {
 
         @Option(name = { "--noConsoleSecurity" },
                 description = "Whether to disable authentication and security filters for
the web console (for use when debugging on a secure network or bound to localhost)")
-        public Boolean noConsoleSecurity = false;
+        public boolean noConsoleSecurity;
 
         @Option(name = { "--startupContinueOnWebErrors" },
             description = "Continue on web subsystem failures during startup "
                 + "(default is to abort if the web API fails to start, as management access
is not normally possible)")
-        public boolean startupContinueOnWebErrors = false;
+        public boolean startupContinueOnWebErrors;
 
         @Option(name = { "--startupFailOnPersistenceErrors" },
             description = "Fail on persistence/HA subsystem failures during startup "
                 + "(default is to continue, so errors can be viewed via the API)")
-        public boolean startupFailOnPersistenceErrors = false;
+        public boolean startupFailOnPersistenceErrors;
 
         @Option(name = { "--startupFailOnCatalogErrors" },
             description = "Fail on catalog subsystem failures during startup "
                 + "(default is to continue, so errors can be viewed via the API)")
-        public boolean startupFailOnCatalogErrors = false;
+        public boolean startupFailOnCatalogErrors;
 
         @Option(name = { "--startupFailOnManagedAppsErrors" },
             description = "Fail startup on errors deploying of managed apps specified via
the command line "
                 + "(default is to continue, so errors can be viewed via the API)")
-        public boolean startupFailOnManagedAppsErrors = false;
+        public boolean startupFailOnManagedAppsErrors;
 
         @Beta
         @Option(name = { "--startBrooklynNode" },
                 description = "Start a BrooklynNode entity representing this Brooklyn instance")
-        public boolean startBrooklynNode = false;
+        public boolean startBrooklynNode;
 
         // Note in some cases, you can get java.util.concurrent.RejectedExecutionException
         // if shutdown is not co-ordinated, looks like: {@linktourl https://gist.github.com/47066f72d6f6f79b953e}
         @Beta
         @Option(name = { "-sk", "--stopOnKeyPress" },
                 description = "Shutdown immediately on user text entry after startup (useful
for debugging and demos)")
-        public boolean stopOnKeyPress = false;
+        public boolean stopOnKeyPress;
 
         final static String STOP_WHICH_APPS_ON_SHUTDOWN = "--stopOnShutdown";
         protected final static String STOP_ALL = "all";
@@ -321,7 +321,7 @@ public class Main extends AbstractMain {
         @Option(name = { "--exitAndLeaveAppsRunningAfterStarting" },
                 description = "Once the application to start (from --app) is running exit
the process, leaving any entities running. "
                     + "Can be used in combination with --persist auto --persistenceDir <custom
folder location> to attach to the running app at a later time.")
-        public boolean exitAndLeaveAppsRunningAfterStarting = false;
+        public boolean exitAndLeaveAppsRunningAfterStarting;
 
         final static String PERSIST_OPTION = "--persist";
         protected final static String PERSIST_OPTION_DISABLED = "disabled";


Mime
View raw message