changeset 2457:b31a0e847618

Remove boilerplate bind/unbind code. Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-September/020926.html
author Jie Kang <jkang@redhat.com>
date Fri, 16 Sep 2016 12:20:00 -0400
parents 8c3134195c82
children f75865e1da9a
files dependency-tool/command/src/main/java/com/redhat/thermostat/tools/dependency/DependencyAnalyzerCommand.java platform/core/src/main/java/com/redhat/thermostat/platform/internal/command/PlatformCommand.java platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplication.java platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplicationProvider.java platform/swing/core/src/main/java/com/redhat/thermostat/platform/swing/SwingWorkbench.java thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplication.java thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplicationProvider.java thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/internal/ThermostatWorkbenchProvider.java vm-byteman/common/src/main/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanDAOImpl.java web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/WebStorageLauncherCommand.java
diffstat 10 files changed, 11 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/dependency-tool/command/src/main/java/com/redhat/thermostat/tools/dependency/DependencyAnalyzerCommand.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/dependency-tool/command/src/main/java/com/redhat/thermostat/tools/dependency/DependencyAnalyzerCommand.java	Fri Sep 16 12:20:00 2016 -0400
@@ -81,17 +81,9 @@
 
     private PathProcessorHandler handler;
 
-    @Reference(bind = "bindCommonPaths", unbind = "unbindCommonPaths")
+    @Reference
     private CommonPaths paths;
 
-    protected void bindCommonPaths(CommonPaths paths) {
-        this.paths = paths;
-    }
-
-    protected void unbindCommonPaths(CommonPaths paths) {
-        this.paths = null;
-    }
-
     @Activate
     public void activate() {
         File systemPluginRoot = paths.getSystemPluginRoot();
--- a/platform/core/src/main/java/com/redhat/thermostat/platform/internal/command/PlatformCommand.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/platform/core/src/main/java/com/redhat/thermostat/platform/internal/command/PlatformCommand.java	Fri Sep 16 12:20:00 2016 -0400
@@ -63,10 +63,10 @@
     
     static final String NAME = "platform";
 
-    @Reference(bind = "bindCommonPaths", unbind = "unbindCommonPaths")
+    @Reference
     private CommonPaths paths;
 
-    @Reference(bind = "bindApplicationService", unbind = "unbindApplicationService")
+    @Reference
     private ApplicationService appService;
     
     private ConfigurationManager manager;
@@ -76,22 +76,6 @@
     
     public PlatformCommand() {}
 
-    protected void bindCommonPaths(CommonPaths paths) {
-        this.paths = paths;
-    }
-    
-    protected void unbindCommonPaths(CommonPaths paths) {
-        this.paths = null;
-    }
-
-    protected void bindApplicationService(ApplicationService service) {
-        this.appService = service;
-    }
-    
-    protected void unbindApplicationService(ApplicationService service) {
-        this.appService = null;
-    }
-    
     @Activate
     protected void activate() throws CommandException {
 
--- a/platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplication.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplication.java	Fri Sep 16 12:20:00 2016 -0400
@@ -54,14 +54,6 @@
     @Reference()
     private ApplicationService applicationService;
 
-    protected void bindApplicationService(ApplicationService applicationService) {
-        this.applicationService = applicationService;
-    }
-
-    protected void unbindApplicationService(ApplicationService applicationService) {
-        this.applicationService = null;
-    }
-    
     private SwingPlatform platform;
     
     @Activate
--- a/platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplicationProvider.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/platform/swing/core/src/main/java/com/redhat/thermostat/platform/application/swing/core/SwingApplicationProvider.java	Fri Sep 16 12:20:00 2016 -0400
@@ -58,22 +58,6 @@
     @Reference
     private SwingWorkbench workbench;
 
-    protected void bindWorkbench(SwingWorkbench workbench) {
-        this.workbench = workbench;
-    }
-
-    protected void unbindWorkbench(SwingWorkbench workbench) {
-        this.workbench = null;
-    }
-
-    protected void bindApplication(SwingApplication application) {
-        this.application = application;
-    }
-
-    protected void unbindApplication(SwingApplication application) {
-        this.application = null;
-    }
-
     @Override
     public Application getApplication() {
         return application;
--- a/platform/swing/core/src/main/java/com/redhat/thermostat/platform/swing/SwingWorkbench.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/platform/swing/core/src/main/java/com/redhat/thermostat/platform/swing/SwingWorkbench.java	Fri Sep 16 12:20:00 2016 -0400
@@ -57,16 +57,9 @@
     private WorkbenchView view;
     private WorkbenchController controller;
 
-    @Reference(bind = "bindPlatformShutdown", unbind = "unbindPlatformShutdown")
+    @Reference()
     private PlatformShutdown shutdown;
 
-    private void bindPlatformShutdown(PlatformShutdown shutdown) {
-        this.shutdown = shutdown;
-    }
-
-    private void unbindPlatformShutdown(PlatformShutdown shutdown) {
-        this.shutdown = shutdown;
-    }
 
     @Activate
     private void activate() {
--- a/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplication.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplication.java	Fri Sep 16 12:20:00 2016 -0400
@@ -53,28 +53,12 @@
 @Service(ThermostatGUIApplication.class)
 public class ThermostatGUIApplication extends SwingApplication {
 
-    @Reference(bind = "bindWorkbench", unbind = "unbindWorkbench")
+    @Reference
     private SwingWorkbench workbench;
 
-    protected void bindWorkbench(SwingWorkbench workbench) {
-        this.workbench = workbench;
-    }
-
-    protected void unbindWorkbench(SwingWorkbench workbench) {
-        this.workbench = null;
-    }
-
-    @Reference(bind = "bindApplicationService", unbind = "unbindApplicationService")
+    @Reference
     private ApplicationService applicationService;
 
-    protected void bindApplicationService(ApplicationService applicationService) {
-        this.applicationService = applicationService;
-    }
-
-    protected void unbindApplicationService(ApplicationService applicationService) {
-        this.applicationService = null;
-    }
-
     @Activate
     private void activate() {
         init(applicationService);
--- a/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplicationProvider.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/ThermostatGUIApplicationProvider.java	Fri Sep 16 12:20:00 2016 -0400
@@ -54,28 +54,12 @@
 @Service(ApplicationProvider.class)
 public class ThermostatGUIApplicationProvider extends SwingApplicationProvider {
 
-    @Reference(bind = "bindApplication", unbind = "unbindApplication")
+    @Reference
     private ThermostatGUIApplication application;
 
-    @Reference(bind = "bindWorkbench", unbind = "unbindWorkbench")
+    @Reference
     private SwingWorkbench workbench;
 
-    protected void bindWorkbench(SwingWorkbench workbench) {
-        this.workbench = workbench;
-    }
-
-    protected void unbindWorkbench(SwingWorkbench workbench) {
-        this.workbench = null;
-    }
-
-    protected void bindApplication(ThermostatGUIApplication application) {
-        this.application = application;
-    }
-
-    protected void unbindApplication(ThermostatGUIApplication application) {
-        this.application = null;
-    }
-
     @Override
     public Application getApplication() {
         return application;
--- a/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/internal/ThermostatWorkbenchProvider.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/thermostat-gui/core/src/main/java/com/redhat/thermostat/application/gui/internal/ThermostatWorkbenchProvider.java	Fri Sep 16 12:20:00 2016 -0400
@@ -55,39 +55,15 @@
 @Service({ ThermostatWorkbenchProvider.class, MVCProvider.class })
 public class ThermostatWorkbenchProvider implements MVCProvider {
 
-    @Reference(bind = "bindCommonPaths", unbind = "unbindCommonPaths")
+    @Reference
     private CommonPaths paths;
 
-    @Reference(bind = "bindWorkbench", unbind = "unbindWorkbench")
+    @Reference
     private SwingWorkbench workbench;
 
-    @Reference(bind = "bindThermostatGUI", unbind = "unbindThermostatGUI")
+    @Reference
     private ThermostatGUI thermostatGUI;
 
-    protected void bindCommonPaths(CommonPaths paths) {
-        this.paths = paths;
-    }
-
-    protected void unbindCommonPaths(CommonPaths paths) {
-        this.paths = null;
-    }
-
-    protected void bindWorkbench(SwingWorkbench workbench) {
-        this.workbench = workbench;
-    }
-
-    protected void unbindWorkbench(SwingWorkbench workbench) {
-        this.workbench = null;
-    }
-
-    protected void bindThermostatGUI(ThermostatGUI thermostatGUI) {
-        this.thermostatGUI = thermostatGUI;
-    }
-
-    protected void unbindThermostatGUI(ThermostatGUI thermostatGUI) {
-        this.thermostatGUI = null;
-    }
-
     private Model model;
     private ThermostatWorkbenchView view;
     private ThermostatWorkbenchController controller;
--- a/vm-byteman/common/src/main/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanDAOImpl.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/vm-byteman/common/src/main/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanDAOImpl.java	Fri Sep 16 12:20:00 2016 -0400
@@ -108,17 +108,9 @@
     }
     
     VmBytemanDAOImpl(Storage storage) {
-        bindStorage(storage);
-    }
-    
-    protected void bindStorage(Storage storage) {
         this.storage = storage;
     }
     
-    protected void unbindStorage(Storage storage) {
-        this.storage = null;
-    }
-    
     @Activate
     private void activate() {
         storage.registerCategory(VM_BYTEMAN_METRICS_CATEGORY);
--- a/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/WebStorageLauncherCommand.java	Fri Sep 16 12:23:31 2016 -0400
+++ b/web/endpoint-plugin/web-service/src/main/java/com/redhat/thermostat/web/endpoint/internal/WebStorageLauncherCommand.java	Fri Sep 16 12:20:00 2016 -0400
@@ -96,38 +96,6 @@
         this.shutdownLatch = shutdownLatch;
     }
 
-    protected void bindCommonPaths(CommonPaths commonPaths) {
-        this.commonPaths = commonPaths;
-    }
-
-    protected void unbindCommonPaths(CommonPaths commonPaths) {
-        this.commonPaths = null;
-    }
-
-    protected void bindLauncher(Launcher launcher) {
-        this.launcher = launcher;
-    }
-
-    protected void unbindLauncher(Launcher launcher) {
-        this.launcher = null;
-    }
-
-    protected void bindSslConfig(SSLConfiguration sslConfig) {
-        this.sslConfig = sslConfig;
-    }
-
-    protected void unbindSslConfig(SSLConfiguration sslConfig) {
-        this.sslConfig = null;
-    }
-
-    protected void bindExitStatus(ExitStatus exitStatus) {
-        this.exitStatus = exitStatus;
-    }
-
-    protected void unbindExitStatus(ExitStatus exitStatus) {
-        this.exitStatus = null;
-    }
-
     @Override
     public void run(CommandContext ctx) throws CommandException {
         // start storage