changeset 2325:230095d08aeb

Back out incorrect 'storage-populator -c' patch Revision 52d7d3d03fa7 was an accidental push of an old, incomplete version of the intended patch. Reviewed-by: jaziz Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-June/019105.html
author Andrew Azores <aazores@redhat.com>
date Wed, 01 Jun 2016 16:30:42 -0400
parents 6521ebfe69cd
children f3e9a2a84291
files dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/StoragePopulatorCommand.java dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/internal/Activator.java dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/internal/StoragePopulatorCompleterService.java
diffstat 3 files changed, 7 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/StoragePopulatorCommand.java	Wed Jun 01 13:45:36 2016 -0400
+++ b/dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/StoragePopulatorCommand.java	Wed Jun 01 16:30:42 2016 -0400
@@ -70,8 +70,6 @@
 
 public class StoragePopulatorCommand extends AbstractCommand {
 
-    public static final String COMMAND_NAME = "storage-populator";
-
     private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
     private static final Logger logger = LoggingUtils.getLogger(StoragePopulatorCommand.class);
 
@@ -193,12 +191,8 @@
      * Package-private to allow overriding for testing.
      */
     File getConfigFile(Arguments args) {
-        return new File(getConfigFileDirectoryPath(paths) + args.getArgument(CONFIG_FILE_NAME));
-    }
-
-    public static String getConfigFileDirectoryPath(CommonPaths paths) {
-        return paths.getSystemPluginConfigurationDirectory().getAbsolutePath() +
-                "/storage-populator/";
+        return new File(paths.getSystemPluginConfigurationDirectory().getAbsolutePath() +
+                    "/storage-populator/" + args.getArgument(CONFIG_FILE_NAME));
     }
 
     /**
--- a/dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/internal/Activator.java	Wed Jun 01 13:45:36 2016 -0400
+++ b/dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/internal/Activator.java	Wed Jun 01 16:30:42 2016 -0400
@@ -39,7 +39,6 @@
 import java.util.Hashtable;
 import java.util.Map;
 
-import com.redhat.thermostat.common.cli.CompleterService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -52,20 +51,13 @@
 import com.redhat.thermostat.storage.dao.VmInfoDAO;
 import com.redhat.thermostat.storage.populator.StoragePopulatorCommand;
 import com.redhat.thermostat.thread.dao.ThreadDao;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
 public class Activator implements BundleActivator {
 
-    private MultipleServiceTracker cmdDepsTracker;
-    private ServiceTracker completerDepsTracker;
-    private ServiceRegistration completerRegistration;
+    private MultipleServiceTracker tracker;
 
     @Override
-    @SuppressWarnings("unchecked")
-    public void start(final BundleContext context) throws Exception {
+    public void start(BundleContext context) throws Exception {
 
         final StoragePopulatorCommand command = new StoragePopulatorCommand();
         Hashtable<String,String> properties = new Hashtable<>();
@@ -81,7 +73,7 @@
                 ThreadDao.class,
         };
 
-        cmdDepsTracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() {
+        tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() {
 
             @Override
             public void dependenciesAvailable(Map<String, Object> services) {
@@ -106,37 +98,12 @@
                 command.setServicesUnavailable();
             }
         });
-        cmdDepsTracker.open();
-
-        final StoragePopulatorCompleterService completerService = new StoragePopulatorCompleterService();
-        completerDepsTracker = new ServiceTracker(context, CommonPaths.class, new ServiceTrackerCustomizer() {
-            @Override
-            public Object addingService(ServiceReference serviceReference) {
-                CommonPaths paths = (CommonPaths) context.getService(serviceReference);
-                completerService.setCommonPaths(paths);
-                completerRegistration = context.registerService(CompleterService.class.getName(), completerService, null);
-                return context.getService(serviceReference);
-            }
-
-            @Override
-            public void modifiedService(ServiceReference serviceReference, Object o) {
-            }
-
-            @Override
-            public void removedService(ServiceReference serviceReference, Object o) {
-                completerService.setCommonPaths(null);
-            }
-        });
-        completerDepsTracker.open();
+        tracker.open();
     }
 
     @Override
     public void stop(BundleContext context) throws Exception {
-        cmdDepsTracker.close();
-        completerDepsTracker.close();
-        if (completerRegistration != null) {
-            completerRegistration.unregister();
-        }
+        tracker.close();
     }
 
 }
--- a/dev/storage-populator/command/src/main/java/com/redhat/thermostat/storage/populator/internal/StoragePopulatorCompleterService.java	Wed Jun 01 13:45:36 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright 2012-2016 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.storage.populator.internal;
-
-import com.redhat.thermostat.common.cli.AbstractCompleterService;
-import com.redhat.thermostat.common.cli.CliCommandOption;
-import com.redhat.thermostat.common.cli.CompletionFinderTabCompleter;
-import com.redhat.thermostat.common.cli.DirectoryContentsCompletionFinder;
-import com.redhat.thermostat.common.cli.TabCompleter;
-import com.redhat.thermostat.shared.config.CommonPaths;
-import com.redhat.thermostat.storage.populator.StoragePopulatorCommand;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-public class StoragePopulatorCompleterService extends AbstractCompleterService {
-
-    static final CliCommandOption CONFIG_OPTION = new CliCommandOption("c", "config", true, "the json config file to use", true);
-
-    @Override
-    public Set<String> getCommands() {
-        return Collections.singleton(StoragePopulatorCommand.COMMAND_NAME);
-    }
-
-    @Override
-    public Map<CliCommandOption, ? extends TabCompleter> getOptionCompleters() {
-        if (!dependencyServices.hasService(CommonPaths.class)) {
-            return Collections.emptyMap();
-        }
-        CommonPaths paths = dependencyServices.getService(CommonPaths.class);
-        String directoryPath = StoragePopulatorCommand.getConfigFileDirectoryPath(paths);
-        File directory = new File(directoryPath);
-        CompletionFinderTabCompleter completer = new CompletionFinderTabCompleter(new DirectoryContentsCompletionFinder(directory));
-        return Collections.singletonMap(CONFIG_OPTION, completer);
-    }
-
-    public void setCommonPaths(CommonPaths paths) {
-        setService(CommonPaths.class, paths);
-    }
-
-}