changeset 810:e5ff501704ab

PR1090: Merge ApplicationContext and ApplicationService reviewed-by: jerboaa, ebaron review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-November/004325.html ApplicationContext and related helper classes removed, functionality moved to ApplicationServiceImpl ApplicationServiceImpl (formerly ApplicationServiceProvider) moved to common-core bundle and registered as service there, rather than in several other places depending on command. Numerous trivial related changes to make everything compatible with the above.
author Jon VanAlten <jon.vanalten@redhat.com>
date Thu, 29 Nov 2012 17:06:15 -0500
parents e5cc3eac6fec
children f3c72548d96e
files agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ApplicationCache.java client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ApplicationService.java client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ContextAction.java client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java client/core/src/test/java/com/redhat/thermostat/client/osgi/service/ApplicationCacheTest.java client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumperService.java client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/HeapDumpDetailsController.java client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/ObjectDetailsController.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpControllerTest.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpDetailsControllerTest.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectDetailsControllerTest.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectRootsControllerTest.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/HeapDumperCommandTest.java client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java client/heapdumper/swing/src/main/java/com/redhat/thermostat/client/heap/swing/Activator.java client/heapdumper/swing/src/test/java/com/redhat/thermostat/client/heap/swing/ServicesAvailableActionTest.java client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsController.java client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsService.java client/memory-stats-panel/core/src/test/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsControllerTest.java client/memory-stats-panel/swing/src/main/java/com/redhat/thermostat/client/stats/memory/swing/MemoryStatsPanelActivator.java client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/GUIClientCommand.java client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ApplicationServiceProvider.java client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/GUIClientCommandTest.java client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ApplicationServiceProviderTest.java client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatController.java client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatService.java client/vmclassstat/core/src/test/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatControllerTest.java client/vmclassstat/swing/src/main/java/com/redhat/thermostat/client/vmclassstat/swing/Activator.java client/vmclassstat/swing/src/test/java/com/redhat/thermostat/client/vmclassstat/swing/ActivatorTest.java common/core/pom.xml common/core/src/main/java/com/redhat/thermostat/common/ApplicationCache.java common/core/src/main/java/com/redhat/thermostat/common/ApplicationService.java common/core/src/main/java/com/redhat/thermostat/common/appctx/ApplicationContext.java common/core/src/main/java/com/redhat/thermostat/common/appctx/ApplicationContextUtil.java common/core/src/main/java/com/redhat/thermostat/common/cli/AppContextSetup.java common/core/src/main/java/com/redhat/thermostat/common/internal/Activator.java common/core/src/main/java/com/redhat/thermostat/common/internal/ApplicationServiceImpl.java common/core/src/main/java/com/redhat/thermostat/test/TestCommandContextFactory.java common/core/src/test/java/com/redhat/thermostat/common/ApplicationCacheTest.java common/core/src/test/java/com/redhat/thermostat/common/appctx/ApplicationContextTest.java common/core/src/test/java/com/redhat/thermostat/common/internal/ApplicationServiceImplTest.java eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuController.java host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/HostCpuControllerTest.java host-cpu/client-swing/src/main/java/com/redhat/thermostat/host/cpu/client/swing/Activator.java host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/ActivatorTest.java host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryController.java host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/HostMemoryControllerTest.java host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/Activator.java host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/ActivatorTest.java host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewController.java host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/HostOverviewControllerTest.java host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/Activator.java host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/ActivatorTest.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadView.java thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableControllerTest.java thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineControllerTest.java thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/osgi/Activator.java tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuController.java vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuControllerTest.java vm-cpu/client-swing/src/main/java/com/redhat/thermostat/vm/cpu/client/swing/Activator.java vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/ActivatorTest.java vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcController.java vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/VmGcControllerTest.java vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/Activator.java vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/ActivatorTest.java vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewController.java vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewControllerTest.java vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/Activator.java vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/ActivatorTest.java
diffstat 108 files changed, 709 insertions(+), 928 deletions(-) [+]
line wrap: on
line diff
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java	Thu Nov 29 17:06:15 2012 -0500
@@ -55,9 +55,6 @@
 import com.redhat.thermostat.backend.BackendService;
 import com.redhat.thermostat.common.Constants;
 import com.redhat.thermostat.common.LaunchException;
-import com.redhat.thermostat.common.ThreadPoolTimerFactory;
-import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -114,8 +111,6 @@
         final Logger logger = LoggingUtils.getLogger(AgentApplication.class);
 
         final DAOFactory daoFactory = daoFactoryCreator.create(configuration);
-        TimerFactory timerFactory = new ThreadPoolTimerFactory(1);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
 
         Connection connection = daoFactory.getConnection();
         ConnectionListener connectionListener = new ConnectionListener() {
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ApplicationCache.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright 2012 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.client.osgi.service;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class ApplicationCache {
-    @SuppressWarnings("rawtypes")
-    private Map cache = new ConcurrentHashMap();
-    
-
-    @SuppressWarnings("unchecked")
-    public void addAttribute(Object key, Object value) {
-        cache.put(key, value);
-    }
-    
-    public Object getAttribute(Object key) {
-        return cache.get(key);
-    }
-}
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ApplicationService.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright 2012 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.client.osgi.service;
-
-import java.util.concurrent.ExecutorService;
-
-public interface ApplicationService {
-
-    ApplicationCache getApplicationCache();
-
-    ExecutorService getApplicationExecutor();
-}
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ContextAction.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/ContextAction.java	Thu Nov 29 17:06:15 2012 -0500
@@ -41,7 +41,7 @@
  * <br /><br />
  * 
  * Each specific subclass defines the selected entry points for the context
- * menues.
+ * menus.
  * <br /><br />
  * 
  * Context actions are executed once the user select the appropriate UI elements
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/SummaryController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,9 +44,9 @@
 import com.redhat.thermostat.client.core.views.BasicView.Action;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 
@@ -59,7 +59,7 @@
 
     private final Timer backgroundUpdateTimer;
 
-    public SummaryController(HostInfoDAO hostInfoDao, VmInfoDAO vmInfoDao, SummaryViewProvider viewProvider) {
+    public SummaryController(ApplicationService appSvc, HostInfoDAO hostInfoDao, VmInfoDAO vmInfoDao, SummaryViewProvider viewProvider) {
 
         this.view = viewProvider.createView();
 
@@ -82,7 +82,7 @@
         hostsDAO = hostInfoDao;
         vmsDAO = vmInfoDao;
 
-        backgroundUpdateTimer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        backgroundUpdateTimer = appSvc.getTimerFactory().createTimer();
         backgroundUpdateTimer.setAction(new Runnable() {
             @Override
             public void run() {
--- a/client/core/src/test/java/com/redhat/thermostat/client/osgi/service/ApplicationCacheTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright 2012 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.client.osgi.service;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ApplicationCacheTest {
-
-    @Test
-    public void verityCache() {
-        ApplicationCache cache = new ApplicationCache();
-        cache.addAttribute("test", "fluff");
-        assertEquals("fluff", cache.getAttribute("test"));
-    }
-}
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/SummaryControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -54,11 +54,10 @@
 import com.redhat.thermostat.client.core.views.SummaryViewProvider;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 
@@ -72,8 +71,6 @@
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-        ApplicationContext ctx = ApplicationContext.getInstance();
 
         // Setup timer
         timer = mock(Timer.class);
@@ -81,7 +78,8 @@
         when(timerFactory.createTimer()).thenReturn(timer);
         ArgumentCaptor<Runnable> actionCaptor = ArgumentCaptor.forClass(Runnable.class);
         doNothing().when(timer).setAction(actionCaptor.capture());
-        ctx.setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // setup dao
         HostInfoDAO hDAO = mock(HostInfoDAO.class);
@@ -98,7 +96,7 @@
         when(viewProvider.createView()).thenReturn(view);
 
         @SuppressWarnings("unused")
-        SummaryController summaryCtrl = new SummaryController(hDAO, vDAO, viewProvider);
+        SummaryController summaryCtrl = new SummaryController(appSvc, hDAO, vDAO, viewProvider);
 
         timerAction = actionCaptor.getValue();
         viewListener = viewArgumentCaptor.getValue();
@@ -110,7 +108,6 @@
         timerAction = null;
         view = null;
         viewListener = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumpController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -50,13 +50,12 @@
 import com.redhat.thermostat.client.heap.chart.OverviewChart;
 import com.redhat.thermostat.client.heap.cli.HeapDumperCommand;
 import com.redhat.thermostat.client.heap.internal.HeapDumpDetailsController;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
@@ -110,7 +109,7 @@
                     translator.localize(LocaleResources.HEAP_CHART_CAPACITY),
                     translator.localize(LocaleResources.HEAP_CHART_USED));
         
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appService.getTimerFactory().createTimer();
         timer.setAction(new HeapOverviewDataCollector());
         
         timer.setInitialDelay(0);
--- a/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumperService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/HeapDumperService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,7 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
--- a/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/HeapDumpDetailsController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/HeapDumpDetailsController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -49,7 +49,7 @@
 import com.redhat.thermostat.client.heap.ObjectDetailsView;
 import com.redhat.thermostat.client.heap.ObjectDetailsViewProvider;
 import com.redhat.thermostat.client.heap.ObjectRootsViewProvider;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.common.utils.LoggingUtils;
--- a/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/ObjectDetailsController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/main/java/com/redhat/thermostat/client/heap/internal/ObjectDetailsController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -47,9 +47,9 @@
 import com.redhat.thermostat.client.heap.ObjectRootsViewProvider;
 import com.redhat.thermostat.client.heap.ObjectDetailsView.ObjectAction;
 import com.redhat.thermostat.client.heap.ObjectDetailsView.ObjectReferenceCallback;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.sun.tools.hat.internal.model.JavaClass;
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -60,14 +60,12 @@
 
 import com.redhat.thermostat.client.heap.HeapView.HeapDumperAction;
 import com.redhat.thermostat.client.heap.cli.HeapDumperCommand;
-import com.redhat.thermostat.client.osgi.service.ApplicationCache;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationCache;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
@@ -105,13 +103,12 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
 
         agentDao = mock(AgentInfoDAO.class);
         heapDao = mock(HeapDAO.class);
         vmDao = mock(VmMemoryStatDAO.class);
+        appService = mock(ApplicationService.class);
 
-        setUpTimers();
         setUpView();
     }
     
@@ -122,7 +119,7 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        when(appService.getTimerFactory()).thenReturn(timerFactory);
     }
     
     private void setUpView() {
@@ -163,8 +160,8 @@
     
     private void createController() {
         ApplicationCache cache = mock(ApplicationCache.class);
-        appService = mock(ApplicationService.class);
         when(appService.getApplicationCache()).thenReturn(cache);
+        setUpTimers();
         VmRef ref = mock(VmRef.class);
         heapDumperCommand = mock(HeapDumperCommand.class);
         controller = new HeapDumpController(agentDao, vmDao, heapDao, ref, appService,
@@ -182,7 +179,7 @@
         histogramProvider = null;
         objectDetailsProvider = null;
         objectRootsProvider = null;
-        ApplicationContextUtil.resetApplicationContext();
+        appService = null;
     }
 
     @Test
@@ -230,7 +227,8 @@
     
     @Test
     public void testOpenDumpCalledWhenPreviousDump() {
-        
+
+        setUpTimers();
         HeapDump dump = mock(HeapDump.class);
         
         HeapInfo info1 = mock(HeapInfo.class);
@@ -245,8 +243,6 @@
         
         ApplicationCache cache = mock(ApplicationCache.class);
         when(cache.getAttribute(any(VmRef.class))).thenReturn(dump);
-        
-        appService = mock(ApplicationService.class);
         when(appService.getApplicationCache()).thenReturn(cache);
         VmRef ref = mock(VmRef.class);
         controller = new HeapDumpController(agentDao, vmDao, heapDao, ref, appService,
@@ -260,6 +256,7 @@
     @Test
     public void testNotOpenDumpCalledWhenNoPreviousDump() {
 
+        setUpTimers();
         HeapInfo info1 = mock(HeapInfo.class);        
         HeapInfo info2 = mock(HeapInfo.class);
         Collection<HeapInfo> infos = new ArrayList<HeapInfo>();
@@ -270,8 +267,7 @@
         
         ApplicationCache cache = mock(ApplicationCache.class);
         when(cache.getAttribute(any(VmRef.class))).thenReturn(null);
-        
-        appService = mock(ApplicationService.class);
+
         when(appService.getApplicationCache()).thenReturn(cache);
         VmRef ref = mock(VmRef.class);
         controller = new HeapDumpController(agentDao, vmDao, heapDao, ref, appService,
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpDetailsControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/HeapDumpDetailsControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -49,8 +49,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.heap.internal.HeapDumpDetailsController;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.redhat.thermostat.common.heap.ObjectHistogram;
 
@@ -64,8 +63,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         viewProvider = mock(HeapDumpDetailsViewProvider.class);
         view = mock(HeapDumpDetailsView.class);
         when(viewProvider.createView()).thenReturn(view);
@@ -89,7 +86,6 @@
         histogramProvider = null;
         objectDetailsProvider = null;
         objectRootsProvider = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectDetailsControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectDetailsControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -62,10 +62,9 @@
 
 import com.redhat.thermostat.client.heap.ObjectDetailsView.ObjectAction;
 import com.redhat.thermostat.client.heap.internal.ObjectDetailsController;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.sun.tools.hat.internal.model.JavaClass;
 import com.sun.tools.hat.internal.model.JavaHeapObject;
@@ -81,8 +80,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         view = mock(ObjectDetailsView.class);
         objectDetailsProvider = mock(ObjectDetailsViewProvider.class);
         when(objectDetailsProvider.createView()).thenReturn(view);
@@ -102,7 +99,6 @@
         view = null;
         objectDetailsProvider = null;
         objectRootsProvider = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectRootsControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/ObjectRootsControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,7 +45,6 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -56,7 +55,6 @@
 import com.redhat.thermostat.client.heap.internal.ObjectRootsController;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.heap.HeapDump;
 import com.sun.tools.hat.internal.model.JavaClass;
 import com.sun.tools.hat.internal.model.JavaHeapObject;
@@ -76,8 +74,6 @@
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         // Set up views
         view = mock(ObjectRootsView.class);
 
@@ -106,11 +102,6 @@
         listener = listenerCaptor.getValue();
     }
 
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
 
     @Test
     public void verifyAddListenersToView() {
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/HeapDumperCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/HeapDumperCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -52,7 +52,6 @@
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.client.command.RequestQueue;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.command.Request;
 import com.redhat.thermostat.common.command.Request.RequestType;
 import com.redhat.thermostat.common.command.RequestResponseListener;
@@ -74,8 +73,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         reqQueue = mock(RequestQueue.class);
         OSGIUtils osgiUtils = mock(OSGIUtils.class);
         when(osgiUtils.getService(RequestQueue.class)).thenReturn(reqQueue);
@@ -103,7 +100,6 @@
         vmRef = null;
         cmd = null;
         reqQueue = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/core/src/test/java/com/redhat/thermostat/client/heap/cli/ListHeapDumpsCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -47,14 +47,11 @@
 import java.util.TimeZone;
 
 import org.apache.commons.cli.Options;
-import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -82,17 +79,6 @@
         TimeZone.setDefault(defaultTimezone);
     }
 
-    @Before
-    public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-
-    }
-
     @Test
     public void verifyBasics() {
         Command command = new ListHeapDumpsCommand();
--- a/client/heapdumper/swing/src/main/java/com/redhat/thermostat/client/heap/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/swing/src/main/java/com/redhat/thermostat/client/heap/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,7 +45,7 @@
 
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.heap.HeapDumperService;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
--- a/client/heapdumper/swing/src/test/java/com/redhat/thermostat/client/heap/swing/ServicesAvailableActionTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/heapdumper/swing/src/test/java/com/redhat/thermostat/client/heap/swing/ServicesAvailableActionTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -49,7 +49,7 @@
 import com.redhat.thermostat.client.heap.HeapDumperService;
 import com.redhat.thermostat.client.heap.swing.Activator;
 import com.redhat.thermostat.client.heap.swing.Activator.ServicesAvailableAction;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.HeapDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
--- a/client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -47,10 +47,10 @@
 import com.redhat.thermostat.client.stats.memory.core.locale.LocaleResources;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -142,8 +142,8 @@
         }
     }
     
-    public MemoryStatsController(final VmMemoryStatDAO vmMemoryStatDao, final VmRef ref,
-                                 MemoryStatsViewProvider viewProvider,
+    public MemoryStatsController(ApplicationService appSvc, final VmMemoryStatDAO vmMemoryStatDao,
+                                 final VmRef ref, MemoryStatsViewProvider viewProvider,
                                  final AgentInfoDAO agentDAO, final GCRequest gcRequest) {
         
         regions = new HashMap<>();
@@ -151,7 +151,7 @@
         vmDao = vmMemoryStatDao;
         view = viewProvider.createView();
         
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appSvc.getTimerFactory().createTimer();
         
         collector = new VMCollector();
         timer.setAction(collector);
--- a/client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/memory-stats-panel/core/src/main/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,6 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -50,11 +51,13 @@
     
     private VmFilter filter = new AlwaysMatchFilter();
 
+    private ApplicationService appSvc;
     private VmMemoryStatDAO vmMemoryStatDao;
     private AgentInfoDAO agentDAO;
     private GCRequest gcRequest;
     
-    public MemoryStatsService(VmMemoryStatDAO vmMemoryStatDao, AgentInfoDAO agentDAO, GCRequest gcRequest) {
+    public MemoryStatsService(ApplicationService appSvc, VmMemoryStatDAO vmMemoryStatDao, AgentInfoDAO agentDAO, GCRequest gcRequest) {
+        this.appSvc = appSvc;
         this.vmMemoryStatDao = vmMemoryStatDao;
         this.gcRequest = gcRequest;
         this.agentDAO = agentDAO;
@@ -63,7 +66,7 @@
     @Override
     public VmInformationServiceController getInformationServiceController(VmRef ref) {
         MemoryStatsViewProvider viewProvider = OSGIUtils.getInstance().getService(MemoryStatsViewProvider.class);
-        return new MemoryStatsController(vmMemoryStatDao, ref, viewProvider, agentDAO, gcRequest);
+        return new MemoryStatsController(appSvc, vmMemoryStatDao, ref, viewProvider, agentDAO, gcRequest);
     }
 
     @Override
--- a/client/memory-stats-panel/core/src/test/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/memory-stats-panel/core/src/test/java/com/redhat/thermostat/client/stats/memory/core/MemoryStatsControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -53,18 +53,16 @@
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -103,7 +101,8 @@
         
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
         
         List<VmMemoryStat> vmInfo = new ArrayList<>();
         
@@ -159,7 +158,7 @@
         agentDAO = mock(AgentInfoDAO.class);
         gcRequest = mock(GCRequest.class);
         
-        controller = new MemoryStatsController(memoryStatDao, ref, viewProvider, agentDAO, gcRequest);
+        controller = new MemoryStatsController(appSvc, memoryStatDao, ref, viewProvider, agentDAO, gcRequest);
         
         viewListener = viewArgumentCaptor.getValue();
         gcActionListener = gcArgumentCaptor.getValue();
@@ -283,9 +282,4 @@
         assertTrue(actual <= expected + 1000);
         assertTrue(actual >= expected - 1000);
     }
-
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
 }
--- a/client/memory-stats-panel/swing/src/main/java/com/redhat/thermostat/client/stats/memory/swing/MemoryStatsPanelActivator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/memory-stats-panel/swing/src/main/java/com/redhat/thermostat/client/stats/memory/swing/MemoryStatsPanelActivator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -43,9 +43,9 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.VmInformationService;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.stats.memory.core.MemoryStatsService;
 import com.redhat.thermostat.client.stats.memory.core.MemoryStatsViewProvider;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.AgentInfoDAO;
@@ -82,8 +82,9 @@
                 VmMemoryStatDAO memoryStatDao = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName());
                 AgentInfoDAO agentDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName());
                 GCRequest gcRequest = (GCRequest) services.get(GCRequest.class.getName());
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
 
-                MemoryStatsService impl = new MemoryStatsService(memoryStatDao, agentDAO, gcRequest);
+                MemoryStatsService impl = new MemoryStatsService(appSvc, memoryStatDao, agentDAO, gcRequest);
                 memoryStatRegistration = context.registerService(VmInformationService.class.getName(), impl , null);
             }
         });
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/GUIClientCommand.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/GUIClientCommand.java	Thu Nov 29 17:06:15 2012 -0500
@@ -39,9 +39,7 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.osgi.service.ContextAction;
-import com.redhat.thermostat.client.swing.internal.osgi.ApplicationServiceProvider;
 import com.redhat.thermostat.client.swing.internal.osgi.ContextActionServiceProvider;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -63,15 +61,11 @@
     
     @Override
     public void run(CommandContext ctx) throws CommandException {
-        ApplicationService service = new ApplicationServiceProvider();
-        
-        context.registerService(ApplicationService.class.getName(), service, null);
         context.registerService(ContextAction.class.getName(), new ContextActionServiceProvider(), null);
         
         // this blocks, everything else needs to be done before
         clientMain.run();
 
-        service.getApplicationExecutor().shutdown();
     }
 
     @Override
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/Main.java	Thu Nov 29 17:06:15 2012 -0500
@@ -51,17 +51,14 @@
 import com.redhat.swing.laf.dolphin.DolphinLookAndFeel;
 import com.redhat.thermostat.client.core.views.ClientConfigurationView;
 import com.redhat.thermostat.client.locale.LocaleResources;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.swing.internal.config.ConnectionConfiguration;
 import com.redhat.thermostat.client.swing.views.ClientConfigurationSwing;
 import com.redhat.thermostat.client.ui.ClientConfigReconnector;
 import com.redhat.thermostat.client.ui.ClientConfigurationController;
 import com.redhat.thermostat.client.ui.MainWindowController;
 import com.redhat.thermostat.client.ui.UiFacadeFactory;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Constants;
-import com.redhat.thermostat.common.ThreadPoolTimerFactory;
-import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.config.ClientPreferences;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.dao.DAOFactoryImpl;
@@ -93,20 +90,18 @@
         StorageProvider connProv = StorageProviderUtil.getStorageProvider(config);
 
         DAOFactory daoFactory = new DAOFactoryImpl(connProv);
-        TimerFactory timerFactory = new ThreadPoolTimerFactory(1);
 
-        init(OSGIUtils.getInstance(), uiFacadeFactory, daoFactory, timerFactory);
+        init(OSGIUtils.getInstance(), uiFacadeFactory, daoFactory);
     }
 
-    Main(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, DAOFactory daoFactory, TimerFactory timerFactory) {
-        init(serviceProvider, uiFacadeFactory, daoFactory, timerFactory);
+    Main(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, DAOFactory daoFactory) {
+        init(serviceProvider, uiFacadeFactory, daoFactory);
     }
 
-    private void init(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, DAOFactory daoFactory, TimerFactory timerFactory) {
+    private void init(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, DAOFactory daoFactory) {
         this.serviceProvider = serviceProvider;
         this.uiFacadeFactory = uiFacadeFactory;
         this.daoFactory = daoFactory;
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
     }
 
     public void run() {
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java	Thu Nov 29 17:06:15 2012 -0500
@@ -71,12 +71,12 @@
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.ApplicationInfo;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.DefaultHostsVMsLoader;
 import com.redhat.thermostat.common.HostsVMsLoader;
 import com.redhat.thermostat.common.ThermostatExtensionRegistry;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.config.ClientPreferences;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -97,6 +97,7 @@
     private final CopyOnWriteArrayList<HostDecorator> hostTreeDecorators = new CopyOnWriteArrayList<>();
     private final CopyOnWriteArrayList<VmDecorator> vmTreeDecorators = new CopyOnWriteArrayList<>();
 
+    private ApplicationService appSvc;
     private Timer backgroundUpdater;
 
     private MainView view;
@@ -162,8 +163,9 @@
 
     private VmInformationControllerProvider vmInfoControllerProvider;
 
-    public MainWindowControllerImpl(UiFacadeFactory facadeFactory, MainView view, RegistryFactory registryFactory, HostInfoDAO hostsDao, VmInfoDAO vmsDAO)
+    public MainWindowControllerImpl(ApplicationService appSvc, UiFacadeFactory facadeFactory, MainView view, RegistryFactory registryFactory, HostInfoDAO hostsDao, VmInfoDAO vmsDAO)
     {
+        this.appSvc = appSvc;
         try {
             vmFilterRegistry = registryFactory.createVmFilterRegistry();
             hostFilterRegistry = registryFactory.createHostFilterRegistry();
@@ -220,8 +222,7 @@
     }
     
     private void initializeTimer() {
-        ApplicationContext ctx = ApplicationContext.getInstance();
-        backgroundUpdater = ctx.getTimerFactory().createTimer();
+        backgroundUpdater = appSvc.getTimerFactory().createTimer();
         backgroundUpdater.setAction(new Runnable() {
             @Override
             public void run() {
@@ -307,7 +308,7 @@
         uninstallListenersAndStopRegistries();
 
         view.hideMainWindow();
-        ApplicationContext.getInstance().getTimerFactory().shutdown();
+        appSvc.getTimerFactory().shutdown();
         shutdownOSGiFramework();
     }
 
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java	Thu Nov 29 17:06:15 2012 -0500
@@ -54,6 +54,7 @@
 import com.redhat.thermostat.client.ui.SummaryController;
 import com.redhat.thermostat.client.ui.UiFacadeFactory;
 import com.redhat.thermostat.client.ui.VmInformationController;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
@@ -69,6 +70,7 @@
     private Collection<VMContextAction> contextAction = new ArrayList<>();
 
     private BundleContext context;
+    private ApplicationService appSvc;
 
     private HostInfoDAO hostInfoDao;
     private VmInfoDAO vmInfoDao;
@@ -78,6 +80,7 @@
     UiFacadeFactoryImpl(OSGIUtils serviceProvider, BundleContext context) {
         this.context = context;
         this.serviceProvider = serviceProvider;
+        appSvc = serviceProvider.getService(ApplicationService.class);
     }
     
     public UiFacadeFactoryImpl(BundleContext context) {
@@ -97,13 +100,13 @@
     public MainWindowController getMainWindow() {
         MainView mainView = new MainWindow();
         RegistryFactory registryFactory = new RegistryFactory(context);
-        return new MainWindowControllerImpl(this, mainView, registryFactory, hostInfoDao, vmInfoDao);
+        return new MainWindowControllerImpl(appSvc, this, mainView, registryFactory, hostInfoDao, vmInfoDao);
     }
 
     @Override
     public SummaryController getSummary() {
         SummaryViewProvider viewProvider = serviceProvider.getService(SummaryViewProvider.class);
-        return new SummaryController(hostInfoDao, vmInfoDao, viewProvider);
+        return new SummaryController(appSvc, hostInfoDao, vmInfoDao, viewProvider);
     }
 
     @Override
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ApplicationServiceProvider.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright 2012 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.client.swing.internal.osgi;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import com.redhat.thermostat.client.osgi.service.ApplicationCache;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
-
-public class ApplicationServiceProvider implements ApplicationService {
-
-    private ApplicationCache cache = new ApplicationCache();
-
-    // NOTE: When merging with ApplicationContext, this could be provided by the same
-    // thread pool that does the timer scheduling. Not sure we want this though,
-    // as scheduled thread pools are always limited in number of threads (could lead to deadlocks
-    // when used carelessly).
-    private ExecutorService executor = Executors.newCachedThreadPool();
-
-    @Override
-    public ApplicationCache getApplicationCache() {
-        return cache;
-    }
-
-    @Override
-    public ExecutorService getApplicationExecutor() {
-        return executor;
-    }
-}
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/GUIClientCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/GUIClientCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -54,8 +54,8 @@
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.osgi.service.ContextAction;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandContextFactory;
 import com.redhat.thermostat.common.cli.CommandException;
@@ -90,7 +90,6 @@
         cmd.run(cmdCtx);
 
         verify(clientMain).run();
-        verify(bCtx).registerService(eq(ApplicationService.class.getName()), isNotNull(), any(Dictionary.class));
         verify(bCtx).registerService(eq(ContextAction.class.getName()), isNotNull(), any(Dictionary.class));
     }
 
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -54,9 +54,9 @@
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.ui.MainWindowController;
 import com.redhat.thermostat.client.ui.UiFacadeFactory;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.dao.DAOFactory;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -111,6 +111,7 @@
         when(daoFactory.getConnection()).thenReturn(connection);
 
         timerFactory = mock(TimerFactory.class);
+        when(appService.getTimerFactory()).thenReturn(timerFactory);
     }
 
     /**
@@ -128,7 +129,7 @@
 
     @Test
     public void verifyRunWaitsForShutdown() throws Exception {
-        Main main = new Main(serviceProvider, uiFactory, daoFactory, timerFactory);
+        Main main = new Main(serviceProvider, uiFactory, daoFactory);
 
         main.run();
 
@@ -139,7 +140,7 @@
 
     @Test
     public void verifyConnectionIsMade() throws Exception {
-        Main main = new Main(serviceProvider, uiFactory, daoFactory, timerFactory);
+        Main main = new Main(serviceProvider, uiFactory, daoFactory);
 
         main.run();
 
@@ -151,7 +152,7 @@
 
     @Test
     public void verifySuccessfulConnectionTriggersMainWindowToBeShown() throws Exception {
-        Main main = new Main(serviceProvider, uiFactory, daoFactory, timerFactory);
+        Main main = new Main(serviceProvider, uiFactory, daoFactory);
 
         main.run();
 
@@ -168,7 +169,7 @@
     @Test
     public void verifySuccessfulConnectionRegistersDAOs() throws Exception {
 
-        Main main = new Main(serviceProvider, uiFactory, daoFactory, timerFactory);
+        Main main = new Main(serviceProvider, uiFactory, daoFactory);
 
         main.run();
 
@@ -186,7 +187,7 @@
     @Test
     public void verifyFailedConnectionTriggersShutdown() throws Exception {
 
-        Main main = new Main(serviceProvider, uiFactory, daoFactory, timerFactory);
+        Main main = new Main(serviceProvider, uiFactory, daoFactory);
 
         main.run();
 
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -75,14 +75,13 @@
 import com.redhat.thermostat.client.ui.VmInformationController;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.HostsVMsLoader;
 import com.redhat.thermostat.common.ThermostatExtensionRegistry;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.ThermostatExtensionRegistry.Action;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
@@ -130,14 +129,13 @@
     @SuppressWarnings({ "unchecked", "rawtypes" }) // ActionListener fluff
     @Before
     public void setUp() throws Exception {
-        ApplicationContextUtil.resetApplicationContext();
-
         // Setup timers
         mainWindowTimer = mock(Timer.class);
         Timer otherTimer = mock(Timer.class); // FIXME needed for SummaryView; remove later
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(mainWindowTimer).thenReturn(otherTimer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when (appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         SummaryController summaryController = mock(SummaryController.class);
 
@@ -182,7 +180,7 @@
 
         setUpVMContextActions();
 
-        controller = new MainWindowControllerImpl(uiFacadeFactory, view, registryFactory, mockHostsDAO, mockVmsDAO);
+        controller = new MainWindowControllerImpl(appSvc, uiFacadeFactory, view, registryFactory, mockHostsDAO, mockVmsDAO);
         l = grabListener.getValue();
         
         hostFiltersListener = grabHostFiltersListener.getValue();
@@ -221,7 +219,6 @@
         mockHostsDAO = null;
         mockVmsDAO = null;
         l = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @SuppressWarnings("unchecked")
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ApplicationServiceProviderTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright 2012 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.client.swing.internal.osgi;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ApplicationServiceProviderTest {
-
-    private ApplicationServiceProvider provider;
-
-    @Before
-    public void setUp() {
-        provider = new ApplicationServiceProvider();
-    }
-
-    @After
-    public void tearDown() {
-        provider = null;
-    }
-
-    @Test
-    public void testCache() {
-        provider.getApplicationCache().addAttribute("test", "fluff");
-        assertEquals("fluff", provider.getApplicationCache().getAttribute("test"));
-    }
-
-    @Test
-    public void testApplicationExecutor() throws Exception {
-        assertNotNull(provider.getApplicationExecutor());
-        final String obj = "test";
-        Future<String> future = provider.getApplicationExecutor().submit(new Callable<String>() {
-
-            @Override
-            public String call() throws Exception {
-                return obj;
-            }
-        });
-        String result = future.get();
-        assertSame(result, obj);
-    }
-}
--- a/client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -46,10 +46,10 @@
 import com.redhat.thermostat.client.vmclassstat.core.locale.LocaleResources;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.locale.Translate;
@@ -58,8 +58,6 @@
 
 public class VmClassStatController implements VmInformationServiceController {
 
-    private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
-
     private class UpdateChartData implements Runnable {
         @Override
         public void run() {
@@ -83,10 +81,10 @@
 
     private volatile long lastSeenTimeStamp = Long.MIN_VALUE;
 
-    public VmClassStatController(VmClassStatDAO vmClassStatDao, VmRef ref, VmClassStatViewProvider viewProvider) {
+    public VmClassStatController(ApplicationService appSvc, VmClassStatDAO vmClassStatDao, VmRef ref, VmClassStatViewProvider viewProvider) {
         this.ref = ref;
         dao = vmClassStatDao;
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appSvc.getTimerFactory().createTimer();
 
         timer.setAction(new UpdateChartData());
         timer.setSchedulingType(SchedulingType.FIXED_RATE);
--- a/client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/vmclassstat/core/src/main/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,6 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -48,16 +49,18 @@
 
     private VmFilter filter = new AlwaysMatchFilter();
 
+    private ApplicationService appSvc;
     private VmClassStatDAO vmClassStatDao;
 
-    public VmClassStatService(VmClassStatDAO vmClassStatDao) {
+    public VmClassStatService(ApplicationService appSvc, VmClassStatDAO vmClassStatDao) {
+        this.appSvc = appSvc;
         this.vmClassStatDao = vmClassStatDao;
     }
     
     @Override
     public VmInformationServiceController getInformationServiceController(VmRef ref) {
         VmClassStatViewProvider viewProvider = OSGIUtils.getInstance().getService(VmClassStatViewProvider.class);
-        return new VmClassStatController(vmClassStatDao, ref, viewProvider);
+        return new VmClassStatController(appSvc, vmClassStatDao, ref, viewProvider);
     }
 
     @Override
--- a/client/vmclassstat/core/src/test/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/vmclassstat/core/src/test/java/com/redhat/thermostat/client/vmclassstat/core/VmClassStatControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -51,9 +51,9 @@
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.storage.model.VmClassStat;
@@ -79,7 +79,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         VmClassStatView view = mock(VmClassStatView.class);
         ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class);
@@ -89,7 +90,7 @@
         when(viewProvider.createView()).thenReturn(view);
 
         @SuppressWarnings("unused")
-        VmClassStatController controller = new VmClassStatController(vmClassStatDAO, ref, viewProvider);
+        VmClassStatController controller = new VmClassStatController(appSvc, vmClassStatDAO, ref, viewProvider);
 
         ActionListener<VmClassStatView.Action> l = viewArgumentCaptor.getValue();
 
--- a/client/vmclassstat/swing/src/main/java/com/redhat/thermostat/client/vmclassstat/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/vmclassstat/swing/src/main/java/com/redhat/thermostat/client/vmclassstat/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,9 +44,9 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.VmInformationService;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatService;
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatViewProvider;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
@@ -71,8 +71,9 @@
             @Override
             public void dependenciesAvailable(Map<String, Object> services) {
                 VmClassStatDAO dao = (VmClassStatDAO) services.get(VmClassStatDAO.class.getName());
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
                 Objects.requireNonNull(dao);
-                VmClassStatService service = new VmClassStatService(dao);
+                VmClassStatService service = new VmClassStatService(appSvc, dao);
                 classStatRegistration = context.registerService(VmInformationService.class.getName(), service, null);
             }
 
--- a/client/vmclassstat/swing/src/test/java/com/redhat/thermostat/client/vmclassstat/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/client/vmclassstat/swing/src/test/java/com/redhat/thermostat/client/vmclassstat/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,9 +44,9 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.VmInformationService;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatService;
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatViewProvider;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
 import com.redhat.thermostat.test.StubBundleContext;
 
--- a/common/core/pom.xml	Thu Nov 29 19:47:42 2012 +0100
+++ b/common/core/pom.xml	Thu Nov 29 17:06:15 2012 -0500
@@ -77,6 +77,7 @@
           <instructions>
             <Bundle-SymbolicName>com.redhat.thermostat.common.core</Bundle-SymbolicName>
             <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor>
+            <Bundle-Activator>com.redhat.thermostat.common.internal.Activator</Bundle-Activator>
             <Export-Package>
               com.redhat.thermostat.common.cli,
               com.redhat.thermostat.common.tools,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/ApplicationCache.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 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.common;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ApplicationCache {
+    @SuppressWarnings("rawtypes")
+    private Map cache = new ConcurrentHashMap();
+    
+
+    @SuppressWarnings("unchecked")
+    public void addAttribute(Object key, Object value) {
+        cache.put(key, value);
+    }
+    
+    public Object getAttribute(Object key) {
+        return cache.get(key);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/ApplicationService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012 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.common;
+
+import java.util.concurrent.ExecutorService;
+
+public interface ApplicationService {
+
+    ApplicationCache getApplicationCache();
+
+    ExecutorService getApplicationExecutor();
+
+    public TimerFactory getTimerFactory();
+
+}
--- a/common/core/src/main/java/com/redhat/thermostat/common/appctx/ApplicationContext.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012 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.common.appctx;
-
-import com.redhat.thermostat.common.TimerFactory;
-
-public class ApplicationContext {
-
-    private static ApplicationContext instance = new ApplicationContext();
-
-    private TimerFactory timerFactory;
-
-    public static ApplicationContext getInstance() {
-        return instance;
-    }
-
-    static void reset() {
-        instance = new ApplicationContext();
-    }
-
-    private ApplicationContext() {
-        // Nothing to do here, just prevent instantiation of this class outside
-        // the factory method.
-    }
-
-    public void setTimerFactory(TimerFactory timerFactory) {
-        this.timerFactory = timerFactory;
-    }
-
-    public TimerFactory getTimerFactory() {
-        return timerFactory;
-    }
-}
--- a/common/core/src/main/java/com/redhat/thermostat/common/appctx/ApplicationContextUtil.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright 2012 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.common.appctx;
-
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-
-public class ApplicationContextUtil {
-
-    /**
-     * This is here to allow tests to reset the ApplicationContext, while
-     * preventing real code the same (ApplicationContext.reset() is package private).
-     *
-     * It is vital that tests call this from their setUp() and tearDown() methods,
-     * to avoid leaking mocks and stuff from test to test.
-     */
-    public static void resetApplicationContext() {
-        ApplicationContext.reset();
-    }
-}
--- a/common/core/src/main/java/com/redhat/thermostat/common/cli/AppContextSetup.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright 2012 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.common.cli;
-
-public interface AppContextSetup {
-
-    void setupAppContext(String dbUrl, String username, String password);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/internal/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 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.common.internal;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import com.redhat.thermostat.common.ApplicationService;
+
+public class Activator implements BundleActivator {
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        ApplicationService service = new ApplicationServiceImpl();
+        context.registerService(ApplicationService.class.getName(), service, null);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        // Nothing to do here.
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/main/java/com/redhat/thermostat/common/internal/ApplicationServiceImpl.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012 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.common.internal;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import com.redhat.thermostat.common.ApplicationCache;
+import com.redhat.thermostat.common.ApplicationService;
+import com.redhat.thermostat.common.ThreadPoolTimerFactory;
+import com.redhat.thermostat.common.TimerFactory;
+
+public class ApplicationServiceImpl implements ApplicationService {
+
+    private ApplicationCache cache = new ApplicationCache();
+
+    // NOTE: When merging with ApplicationContext, this could be provided by the same
+    // thread pool that does the timer scheduling. Not sure we want this though,
+    // as scheduled thread pools are always limited in number of threads (could lead to deadlocks
+    // when used carelessly).
+    private ExecutorService executor = Executors.newCachedThreadPool();
+
+    private TimerFactory timers = new ThreadPoolTimerFactory(1);
+
+    @Override
+    public ApplicationCache getApplicationCache() {
+        return cache;
+    }
+
+    @Override
+    public ExecutorService getApplicationExecutor() {
+        return executor;
+    }
+
+    @Override
+    public TimerFactory getTimerFactory() {
+        return timers;
+    }
+}
--- a/common/core/src/main/java/com/redhat/thermostat/test/TestCommandContextFactory.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/common/core/src/main/java/com/redhat/thermostat/test/TestCommandContextFactory.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,7 +44,6 @@
 
 import org.osgi.framework.BundleContext;
 
-import com.redhat.thermostat.common.cli.AppContextSetup;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandContextFactory;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/test/java/com/redhat/thermostat/common/ApplicationCacheTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2012 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.common;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ApplicationCacheTest {
+
+    @Test
+    public void verityCache() {
+        ApplicationCache cache = new ApplicationCache();
+        cache.addAttribute("test", "fluff");
+        assertEquals("fluff", cache.getAttribute("test"));
+    }
+}
--- a/common/core/src/test/java/com/redhat/thermostat/common/appctx/ApplicationContextTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright 2012 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.common.appctx;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-
-public class ApplicationContextTest {
-
-    @Before
-    public void setUp() {
-        ApplicationContext.reset();
-    }
-
-    @After
-    public void tearDown() {
-        ApplicationContext.reset();
-    }
-
-    @Test
-    public void verifyGetInstanceNotNull() {
-        ApplicationContext ctx = ApplicationContext.getInstance();
-        assertNotNull(ctx);
-    }
-
-    @Test
-    public void  testTimerFactorySetGet() {
-        TimerFactory timerFactory = mock(TimerFactory.class);
-        ApplicationContext ctx = ApplicationContext.getInstance();
-        ctx.setTimerFactory(timerFactory);
-
-        TimerFactory actual1 = ctx.getTimerFactory();
-        assertSame(timerFactory, actual1);
-    }
-
-    @Test
-    public void  verifyTimerFactoryIsNullWhenNotInitialized() {
-        ApplicationContext ctx = ApplicationContext.getInstance();
-
-        TimerFactory actual = ctx.getTimerFactory();
-        assertNull(actual);
-    }
-
-    @Test
-    public void  verifyTimerFactoryStaysSame() {
-        TimerFactory timerFactory = mock(TimerFactory.class);
-        ApplicationContext ctx = ApplicationContext.getInstance();
-        ctx.setTimerFactory(timerFactory);
-
-        ApplicationContext ctx2 = ApplicationContext.getInstance();
-        TimerFactory actual2 = ctx2.getTimerFactory();
-        assertSame(timerFactory, actual2);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/core/src/test/java/com/redhat/thermostat/common/internal/ApplicationServiceImplTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2012 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.common.internal;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.redhat.thermostat.common.internal.ApplicationServiceImpl;
+
+public class ApplicationServiceImplTest {
+
+    private ApplicationServiceImpl provider;
+
+    @Before
+    public void setUp() {
+        provider = new ApplicationServiceImpl();
+    }
+
+    @After
+    public void tearDown() {
+        provider = null;
+    }
+
+    @Test
+    public void testCache() {
+        provider.getApplicationCache().addAttribute("test", "fluff");
+        assertEquals("fluff", provider.getApplicationCache().getAttribute("test"));
+    }
+
+    @Test
+    public void testApplicationExecutor() throws Exception {
+        assertNotNull(provider.getApplicationExecutor());
+        final String obj = "test";
+        Future<String> future = provider.getApplicationExecutor().submit(new Callable<String>() {
+
+            @Override
+            public String call() throws Exception {
+                return obj;
+            }
+        });
+        String result = future.get();
+        assertSame(result, obj);
+    }
+
+    @Test
+    public void testTimerFactory() {
+        assertNotNull(provider.getTimerFactory());
+    }
+}
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF	Thu Nov 29 17:06:15 2012 -0500
@@ -11,7 +11,6 @@
  com.redhat.thermostat.client.osgi.service,
  com.redhat.thermostat.client.ui,
  com.redhat.thermostat.common,
- com.redhat.thermostat.common.appctx,
  com.redhat.thermostat.common.dao,
  com.redhat.thermostat.common.heap,
  com.redhat.thermostat.common.locale,
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,8 +36,11 @@
 
 package com.redhat.thermostat.eclipse.chart.common;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -67,7 +70,9 @@
 
     public HostCpuController createController(HostInfoDAO hostInfoDao,
             CpuStatDAO cpuStatDao, HostRef ref, HostCpuViewProvider viewProvider) {
-        return new HostCpuController(hostInfoDao, cpuStatDao, ref, viewProvider);
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new HostCpuController(appSvc, hostInfoDao, cpuStatDao, ref, viewProvider);
     }
 
 }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,8 +36,11 @@
 
 package com.redhat.thermostat.eclipse.chart.common;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.MemoryStatDAO;
@@ -67,7 +70,9 @@
     public HostMemoryController createController(HostInfoDAO hostInfoDao,
             MemoryStatDAO memoryStatDao, HostRef ref,
             HostMemoryViewProvider viewProvider) {
-        return new HostMemoryController(hostInfoDao, memoryStatDao, ref,
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new HostMemoryController(appSvc, hostInfoDao, memoryStatDao, ref,
                 viewProvider);
     }
 
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,8 +36,11 @@
 
 package com.redhat.thermostat.eclipse.chart.common;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -63,7 +66,9 @@
 
     public VmCpuController createController(VmCpuStatDAO vmCpuStatDao,
             VmRef ref, VmCpuViewProvider viewProvider) {
-        return new VmCpuController(vmCpuStatDao, ref, viewProvider);
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new VmCpuController(appSvc, vmCpuStatDao, ref, viewProvider);
     }
 
 }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,8 +36,11 @@
 
 package com.redhat.thermostat.eclipse.chart.common;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -66,7 +69,9 @@
 
     public VmGcController createController(VmMemoryStatDAO vmMemoryStatDao,
             VmGcStatDAO vmGcStatDao, VmRef ref, VmGcViewProvider viewProvider) {
-        return new VmGcController(vmMemoryStatDao, vmGcStatDao, ref,
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new VmGcController(appSvc, vmMemoryStatDao, vmGcStatDao, ref,
                 viewProvider);
     }
 
--- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF	Thu Nov 29 17:06:15 2012 -0500
@@ -15,7 +15,6 @@
  com.redhat.thermostat.client.ui,
  com.redhat.thermostat.client.vmclassstat.core,
  com.redhat.thermostat.common,
- com.redhat.thermostat.common.appctx,
  com.redhat.thermostat.common.dao,
  com.redhat.thermostat.common.locale,
  com.redhat.thermostat.common.utils,
--- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,10 +36,13 @@
 
 package com.redhat.thermostat.eclipse.chart.vmclassstat;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatController;
 import com.redhat.thermostat.client.vmclassstat.core.VmClassStatViewProvider;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -63,7 +66,9 @@
 
     public VmClassStatController createController(VmClassStatDAO classStatDao,
             VmRef ref, VmClassStatViewProvider viewProvider) {
-        return new VmClassStatController(classStatDao, ref, viewProvider);
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new VmClassStatController(appSvc, classStatDao, ref, viewProvider);
     }
 
 }
--- a/eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF	Thu Nov 29 17:06:15 2012 -0500
@@ -14,7 +14,6 @@
  com.redhat.thermostat.client.ui,
  com.redhat.thermostat.client.vmclassstat.core,
  com.redhat.thermostat.common,
- com.redhat.thermostat.common.appctx,
  com.redhat.thermostat.eclipse,
  com.redhat.thermostat.eclipse.chart.common,
  com.redhat.thermostat.eclipse.chart.vmclassstat,
--- a/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF	Thu Nov 29 17:06:15 2012 -0500
@@ -13,7 +13,6 @@
  com.redhat.thermostat.client.locale,
  com.redhat.thermostat.client.ui,
  com.redhat.thermostat.common,
- com.redhat.thermostat.common.appctx,
  com.redhat.thermostat.common.dao,
  com.redhat.thermostat.common.locale,
  com.redhat.thermostat.common.utils,
--- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,9 +45,6 @@
 import org.osgi.framework.BundleContext;
 
 import com.redhat.thermostat.common.DbService;
-import com.redhat.thermostat.common.ThreadPoolTimerFactory;
-import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.utils.OSGIUtils;
 import com.redhat.thermostat.eclipse.LoggerFacility;
 import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewViewProvider;
@@ -82,10 +79,6 @@
         super.start(context);
         plugin = this;
 
-        // Register a TimerFactory
-        TimerFactory timerFactory = new ThreadPoolTimerFactory(1);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
-
         // Register ViewProvider
         OSGIUtils.getInstance().registerService(HostOverviewViewProvider.class,
                 new SWTHostOverviewViewProvider());
--- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,8 +36,11 @@
 
 package com.redhat.thermostat.eclipse.internal.views;
 
+import java.util.Objects;
+
 import org.eclipse.swt.widgets.Composite;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
@@ -67,7 +70,9 @@
     public HostOverviewController createController(HostRef ref,
             HostInfoDAO hostInfoDAO, NetworkInterfaceInfoDAO networkInfoDAO,
             HostOverviewViewProvider provider) {
-        return new HostOverviewController(hostInfoDAO, networkInfoDAO, ref,
+        ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+        Objects.requireNonNull(appSvc);
+        return new HostOverviewController(appSvc, hostInfoDAO, networkInfoDAO, ref,
                 provider);
     }
 
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,10 +45,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -72,14 +72,14 @@
     private int chartsAdded = 0;
     private long lastSeenTimeStamp = Long.MIN_VALUE;
 
-    public HostCpuController(HostInfoDAO hostInfoDao, CpuStatDAO cpuStatDAO, HostRef ref, HostCpuViewProvider provider) {
+    public HostCpuController(ApplicationService appSvc, HostInfoDAO hostInfoDao, CpuStatDAO cpuStatDAO, HostRef ref, HostCpuViewProvider provider) {
         this.ref = ref;
         view = provider.createView();
         view.clearCpuUsageData();
         this.hostInfoDAO = hostInfoDao;
         this.cpuStatDAO = cpuStatDAO;
 
-        backgroundUpdateTimer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        backgroundUpdateTimer = appSvc.getTimerFactory().createTimer();
         backgroundUpdateTimer.setAction(new Runnable() {
 
             @Override
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -39,6 +39,7 @@
 import com.redhat.thermostat.client.core.HostFilter;
 import com.redhat.thermostat.client.core.HostInformationService;
 import com.redhat.thermostat.client.core.controllers.HostInformationServiceController;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -52,11 +53,13 @@
             return true;
         }
     };
-    
+
+    private ApplicationService appSvc;
     private HostInfoDAO hostInfoDAO;
     private CpuStatDAO cpuStatDAO;
     
-    public HostCpuService(HostInfoDAO hostInfoDAO, CpuStatDAO cpuStatDAO) {
+    public HostCpuService(ApplicationService appSvc, HostInfoDAO hostInfoDAO, CpuStatDAO cpuStatDAO) {
+        this.appSvc = appSvc;
         this.hostInfoDAO = hostInfoDAO;
         this.cpuStatDAO = cpuStatDAO;
     }
@@ -70,7 +73,7 @@
     public HostInformationServiceController getInformationServiceController(
             HostRef ref) {
         HostCpuViewProvider provider = OSGIUtils.getInstance().getService(HostCpuViewProvider.class);
-        return new HostCpuController(hostInfoDAO, cpuStatDAO, ref, provider);
+        return new HostCpuController(appSvc, hostInfoDAO, cpuStatDAO, ref, provider);
     }
 
 }
--- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/HostCpuControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/HostCpuControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -58,11 +58,10 @@
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -89,14 +88,14 @@
     @Before
     public void setUp() {
         // Setup timer.
-        ApplicationContextUtil.resetApplicationContext();
         timer = mock(Timer.class);
         ArgumentCaptor<Runnable> actionCaptor = ArgumentCaptor.forClass(Runnable.class);
         doNothing().when(timer).setAction(actionCaptor.capture());
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // Setup DAOs.
         HostInfo hostInfo = new HostInfo("fluffhost1", "fluffOs1", "fluffKernel1", "fluffCpu1", 12345, 98765);
@@ -116,7 +115,7 @@
         when(viewProvider.createView()).thenReturn(view);
 
         HostRef host = new HostRef("123", "fluffhost");
-        controller = new HostCpuController(hostInfoDAO, cpuStatDAO, host, viewProvider);
+        controller = new HostCpuController(appSvc, hostInfoDAO, cpuStatDAO, host, viewProvider);
 
         timerAction = actionCaptor.getValue();
         viewListener = viewArgumentCaptor.getValue();
@@ -128,7 +127,6 @@
         controller = null;
         view = null;
         timer = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/host-cpu/client-swing/src/main/java/com/redhat/thermostat/host/cpu/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-cpu/client-swing/src/main/java/com/redhat/thermostat/host/cpu/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
@@ -64,6 +65,7 @@
         Class<?>[] deps = new Class<?>[] {
             HostInfoDAO.class,
             CpuStatDAO.class,
+            ApplicationService.class
         };
 
         tracker = new MultipleServiceTracker(context, deps, new Action() {
@@ -74,7 +76,9 @@
                 Objects.requireNonNull(hostInfoDAO);
                 CpuStatDAO cpuStatDAO = (CpuStatDAO) services.get(CpuStatDAO.class.getName());
                 Objects.requireNonNull(cpuStatDAO);
-                HostCpuService service = new HostCpuService(hostInfoDAO, cpuStatDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                Objects.requireNonNull(appSvc);
+                HostCpuService service = new HostCpuService(appSvc, hostInfoDAO, cpuStatDAO);
                 reg = context.registerService(HostInformationService.class.getName(), service, null);
             }
 
--- a/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.CpuStatDAO;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.host.cpu.client.core.HostCpuService;
@@ -76,9 +77,11 @@
         StubBundleContext context = new StubBundleContext();
         HostInfoDAO hostInfoDAO = mock(HostInfoDAO.class);
         CpuStatDAO cpuStatDAO = mock(CpuStatDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(HostInfoDAO.class, hostInfoDAO, null);
         context.registerService(CpuStatDAO.class, cpuStatDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
@@ -89,7 +92,7 @@
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(3, context.getAllServices().size());
+        assertEquals(4, context.getAllServices().size());
     }
 
     @Test
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,10 +45,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.MemoryStatDAO;
@@ -75,7 +75,7 @@
 
     private long lastSeenTimeStamp = Long.MIN_VALUE;
 
-    public HostMemoryController(HostInfoDAO hostInfoDAO, MemoryStatDAO memoryStatDAO, final HostRef ref, HostMemoryViewProvider provider) {
+    public HostMemoryController(ApplicationService appSvc, HostInfoDAO hostInfoDAO, MemoryStatDAO memoryStatDAO, final HostRef ref, HostMemoryViewProvider provider) {
         this.ref = ref;
         this.hostInfoDAO = hostInfoDAO;
         this.memoryStatDAO = memoryStatDAO;
@@ -106,7 +106,7 @@
             }
         });
 
-        backgroundUpdateTimer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        backgroundUpdateTimer = appSvc.getTimerFactory().createTimer();
         backgroundUpdateTimer.setAction(new Runnable() {
             @Override
             public void run() {
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -39,6 +39,7 @@
 import com.redhat.thermostat.client.core.HostFilter;
 import com.redhat.thermostat.client.core.HostInformationService;
 import com.redhat.thermostat.client.core.controllers.HostInformationServiceController;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.MemoryStatDAO;
@@ -52,11 +53,13 @@
             return true;
         }
     };
-    
+
+    private ApplicationService appSvc;
     private HostInfoDAO hostInfoDAO;
     private MemoryStatDAO memoryStatDAO;
     
-    public HostMemoryService(HostInfoDAO hostInfoDAO, MemoryStatDAO memoryStatDAO) {
+    public HostMemoryService(ApplicationService appSvc, HostInfoDAO hostInfoDAO, MemoryStatDAO memoryStatDAO) {
+        this.appSvc = appSvc;
         this.hostInfoDAO = hostInfoDAO;
         this.memoryStatDAO = memoryStatDAO;
     }
@@ -70,7 +73,7 @@
     public HostInformationServiceController getInformationServiceController(
             HostRef ref) {
         HostMemoryViewProvider provider = OSGIUtils.getInstance().getService(HostMemoryViewProvider.class);
-        return new HostMemoryController(hostInfoDAO, memoryStatDAO, ref, provider);
+        return new HostMemoryController(appSvc, hostInfoDAO, memoryStatDAO, ref, provider);
     }
 
 }
--- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/HostMemoryControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/HostMemoryControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -48,16 +48,14 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.MemoryStatDAO;
@@ -69,11 +67,6 @@
 
 public class HostMemoryControllerTest {
 
-    @Before
-    public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
     @SuppressWarnings({ "unchecked", "rawtypes" }) // any(List.class)
     @Test
     public void testUpdate() {
@@ -94,7 +87,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         HostRef ref = mock(HostRef.class);
 
@@ -106,7 +100,7 @@
         when(viewProvider.createView()).thenReturn(view);
 
         @SuppressWarnings("unused")
-        HostMemoryController controller = new HostMemoryController(hostInfoDAO, memoryStatDAO, ref, viewProvider);
+        HostMemoryController controller = new HostMemoryController(appSvc, hostInfoDAO, memoryStatDAO, ref, viewProvider);
 
         ActionListener<HostMemoryView.Action> l = viewArgumentCaptor.getValue();
 
--- a/host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-memory/client-swing/src/main/java/com/redhat/thermostat/host/memory/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
@@ -62,6 +63,7 @@
         context.registerService(HostMemoryViewProvider.class.getName(), viewProvider, null);
 
         Class<?>[] deps = new Class<?>[] {
+            ApplicationService.class,
             HostInfoDAO.class,
             MemoryStatDAO.class,
         };
@@ -74,7 +76,9 @@
                 Objects.requireNonNull(hostInfoDAO);
                 MemoryStatDAO memoryStatDAO = (MemoryStatDAO) services.get(MemoryStatDAO.class.getName());
                 Objects.requireNonNull(memoryStatDAO);
-                HostMemoryService service = new HostMemoryService(hostInfoDAO, memoryStatDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                Objects.requireNonNull(appSvc);
+                HostMemoryService service = new HostMemoryService(appSvc, hostInfoDAO, memoryStatDAO);
                 reg = context.registerService(HostInformationService.class.getName(), service, null);
             }
 
--- a/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.MemoryStatDAO;
 import com.redhat.thermostat.host.memory.client.core.HostMemoryService;
@@ -76,9 +77,11 @@
         StubBundleContext context = new StubBundleContext();
         HostInfoDAO hostInfoDAO = mock(HostInfoDAO.class);
         MemoryStatDAO memoryStatDAO = mock(MemoryStatDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(HostInfoDAO.class, hostInfoDAO, null);
         context.registerService(MemoryStatDAO.class, memoryStatDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
@@ -89,7 +92,7 @@
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(3, context.getAllServices().size());
+        assertEquals(4, context.getAllServices().size());
     }
 
     @Test
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -46,10 +46,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
@@ -71,7 +71,7 @@
 
     private final HostOverviewView view;
 
-    public HostOverviewController(HostInfoDAO hostInfoDAO, NetworkInterfaceInfoDAO networkInfoDAO, final HostRef ref, HostOverviewViewProvider provider) {
+    public HostOverviewController(ApplicationService appSvc, HostInfoDAO hostInfoDAO, NetworkInterfaceInfoDAO networkInfoDAO, final HostRef ref, HostOverviewViewProvider provider) {
         this.hostInfoDAO = hostInfoDAO;
         this.networkInfoDAO = networkInfoDAO;
 
@@ -81,7 +81,7 @@
         networkTableColumnVector.add(translator.localize(LocaleResources.NETWORK_IPV4_COLUMN));
         networkTableColumnVector.add(translator.localize(LocaleResources.NETWORK_IPV6_COLUMN));
 
-        backgroundUpdateTimer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        backgroundUpdateTimer = appSvc.getTimerFactory().createTimer();
         backgroundUpdateTimer.setAction(new Runnable() {
             @Override
             public void run() {
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -39,6 +39,7 @@
 import com.redhat.thermostat.client.core.HostFilter;
 import com.redhat.thermostat.client.core.HostInformationService;
 import com.redhat.thermostat.client.core.controllers.HostInformationServiceController;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
@@ -52,11 +53,13 @@
             return true;
         }
     };
-    
+
+    private ApplicationService appSvc;
     private HostInfoDAO hostInfoDAO;
     private NetworkInterfaceInfoDAO networkInfoDAO;
     
-    public HostOverviewService(HostInfoDAO hostInfoDAO, NetworkInterfaceInfoDAO networkInfoDAO) {
+    public HostOverviewService(ApplicationService appSvc, HostInfoDAO hostInfoDAO, NetworkInterfaceInfoDAO networkInfoDAO) {
+        this.appSvc = appSvc;
         this.hostInfoDAO = hostInfoDAO;
         this.networkInfoDAO = networkInfoDAO;
     }
@@ -70,7 +73,7 @@
     public HostInformationServiceController getInformationServiceController(
             HostRef ref) {
         HostOverviewViewProvider provider = OSGIUtils.getInstance().getService(HostOverviewViewProvider.class);
-        return new HostOverviewController(hostInfoDAO, networkInfoDAO, ref, provider);
+        return new HostOverviewController(appSvc, hostInfoDAO, networkInfoDAO, ref, provider);
     }
 
 }
--- a/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/HostOverviewControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/HostOverviewControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -57,11 +57,10 @@
 import com.redhat.thermostat.client.core.views.BasicView.Action;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
@@ -91,8 +90,6 @@
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         // Setup timer
         timer = mock(Timer.class);
         ArgumentCaptor<Runnable> timerActionCaptor = ArgumentCaptor.forClass(Runnable.class);
@@ -100,7 +97,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // Setup DAOs
         HostInfo hostInfo = new HostInfo(HOST_NAME, OS_NAME, KERNEL_NAME, CPU_MODEL, CPU_COUNT, TOTAL_MEMORY);
@@ -127,17 +125,12 @@
         when(viewProvider.createView()).thenReturn(view);
 
         @SuppressWarnings("unused")
-        HostOverviewController controller = new HostOverviewController(hostInfoDao, networkInfoDao, ref, viewProvider);
+        HostOverviewController controller = new HostOverviewController(appSvc, hostInfoDao, networkInfoDao, ref, viewProvider);
 
         listener = listenerCaptor.getValue();
         timerAction = timerActionCaptor.getValue();
     }
 
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
     @Test
     public void verifyViewIsUpdatedWithData() {
         timerAction.run();
--- a/host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-overview/client-swing/src/main/java/com/redhat/thermostat/host/overview/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
@@ -62,6 +63,7 @@
         context.registerService(HostOverviewViewProvider.class.getName(), viewProvider, null);
 
         Class<?>[] deps = new Class<?>[] {
+            ApplicationService.class,
             HostInfoDAO.class,
             NetworkInterfaceInfoDAO.class,
         };
@@ -75,7 +77,9 @@
                 NetworkInterfaceInfoDAO networkInfoDAO = (NetworkInterfaceInfoDAO) 
                         services.get(NetworkInterfaceInfoDAO.class.getName());
                 Objects.requireNonNull(networkInfoDAO);
-                HostOverviewService service = new HostOverviewService(hostInfoDAO, networkInfoDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                Objects.requireNonNull(appSvc);
+                HostOverviewService service = new HostOverviewService(appSvc, hostInfoDAO, networkInfoDAO);
                 reg = context.registerService(HostInformationService.class.getName(), service, null);
             }
 
--- a/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.HostInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.HostInfoDAO;
 import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
 import com.redhat.thermostat.host.overview.client.core.HostOverviewService;
@@ -76,9 +77,11 @@
         StubBundleContext context = new StubBundleContext();
         HostInfoDAO hostInfoDAO = mock(HostInfoDAO.class);
         NetworkInterfaceInfoDAO networkInfoDAO = mock(NetworkInterfaceInfoDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(HostInfoDAO.class, hostInfoDAO, null);
         context.registerService(NetworkInterfaceInfoDAO.class, networkInfoDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
@@ -89,7 +92,7 @@
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(3, context.getAllServices().size());
+        assertEquals(4, context.getAllServices().size());
     }
 
     @Test
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -90,6 +90,7 @@
     @Override
     public void start(final BundleContext context) throws Exception {
         super.start(context);
+
         tracker = new MultipleServiceTracker(context, new Class[] {OSGiRegistry.class, Keyring.class}, new RegisterLauncherAction(context));
         tracker.open();
     }
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java	Thu Nov 29 17:06:15 2012 -0500
@@ -51,11 +51,10 @@
 import com.redhat.thermostat.bundles.OSGiRegistry;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.ActionNotifier;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.DbService;
 import com.redhat.thermostat.common.DbServiceFactory;
-import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.Version;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandContext;
@@ -68,6 +67,7 @@
 import com.redhat.thermostat.common.tools.ApplicationState;
 import com.redhat.thermostat.common.tools.BasicCommand;
 import com.redhat.thermostat.common.utils.LoggingUtils;
+import com.redhat.thermostat.common.utils.OSGIUtils;
 import com.redhat.thermostat.launcher.CommonCommandOptions;
 import com.redhat.thermostat.launcher.Launcher;
 import com.redhat.thermostat.storage.core.ConnectionException;
@@ -153,10 +153,10 @@
 
     private void shutdown() throws InternalError {
         try {
-            TimerFactory tf = ApplicationContext.getInstance().getTimerFactory();
-            if (tf != null) {
-                tf.shutdown();
-            }
+            ApplicationService appSvc = OSGIUtils.getInstance().getService(ApplicationService.class);
+            appSvc.getApplicationExecutor().shutdown();
+            appSvc.getTimerFactory().shutdown();
+
             context.getBundle(0).stop();
         } catch (BundleException e) {
             throw (InternalError) new InternalError().initCause(e);
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/LauncherTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -50,6 +50,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.concurrent.ExecutorService;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -75,11 +76,10 @@
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.ActionNotifier;
 import com.redhat.thermostat.common.ApplicationInfo;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.DbService;
 import com.redhat.thermostat.common.DbServiceFactory;
 import com.redhat.thermostat.common.Version;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.Arguments;
 import com.redhat.thermostat.common.cli.Command;
 import com.redhat.thermostat.common.cli.CommandContext;
@@ -92,6 +92,7 @@
 import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.common.tools.ApplicationState;
 import com.redhat.thermostat.common.tools.BasicCommand;
+import com.redhat.thermostat.common.utils.OSGIUtils;
 import com.redhat.thermostat.launcher.internal.LauncherImpl.LoggingInitializer;
 import com.redhat.thermostat.test.StubBundleContext;
 import com.redhat.thermostat.test.TestCommandContextFactory;
@@ -101,7 +102,7 @@
 import com.redhat.thermostat.utils.keyring.KeyringProvider;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({FrameworkUtil.class, HelpCommand.class})
+@PrepareForTest({FrameworkUtil.class, HelpCommand.class, OSGIUtils.class})
 public class LauncherTest {
     
     private static String defaultKeyringProvider;
@@ -152,10 +153,6 @@
 
     @Before
     public void setUp() {
-
-        ApplicationContextUtil.resetApplicationContext();
-        timerFactory = new TestTimerFactory();
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
         setupCommandContextFactory();
 
         TestCommand cmd1 = new TestCommand(name1, new TestCmd1());
@@ -238,6 +235,16 @@
         when(bCtx.getService(infosRef)).thenReturn(infos);
         when(FrameworkUtil.getBundle(isA(HelpCommand.class.getClass()))).thenReturn(bundle);
 
+        timerFactory = new TestTimerFactory();
+        ExecutorService exec = mock(ExecutorService.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
+        when(appSvc.getApplicationExecutor()).thenReturn(exec);
+        OSGIUtils osgi = mock(OSGIUtils.class);
+        when(osgi.getService(ApplicationService.class)).thenReturn(appSvc);
+        PowerMockito.mockStatic(OSGIUtils.class);
+        when(OSGIUtils.getInstance()).thenReturn(osgi);
+
         loggingInitializer = mock(LoggingInitializer.class);
         dbServiceFactory = mock(DbServiceFactory.class);
 
@@ -259,7 +266,6 @@
     public void tearDown() {
         ctxFactory = null;
         bundleContext = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadView.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadView.java	Thu Nov 29 17:06:15 2012 -0500
@@ -38,9 +38,9 @@
 
 import com.redhat.thermostat.client.core.views.BasicView;
 import com.redhat.thermostat.client.core.views.UIComponent;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.ActionNotifier;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart;
 
 public abstract class ThreadView extends BasicView implements UIComponent {
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,13 +44,13 @@
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.client.core.views.BasicView.Action;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
+import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.thread.client.common.ThreadTableBean;
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
@@ -69,7 +69,8 @@
     
     private ThreadView view;
     private ThreadCollector collector;
-    
+
+    private ApplicationService appService;
     private Timer timer;
     
     private LivingDaemonThreadDifferenceChart model;
@@ -78,6 +79,7 @@
                                        ThreadCollectorFactory collectorFactory, 
                                        ThreadViewProvider viewFactory)
     {
+        this.appService = appService;
         view = viewFactory.createView();
         view.setApplicationService(appService, ref.getIdString() + "-" + ref.getAgent().getAgentId());
         
@@ -85,7 +87,7 @@
         
         initControllers();
         
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appService.getTimerFactory().createTimer();
         
         timer.setInitialDelay(0);
         timer.setDelay(1000);
@@ -204,14 +206,14 @@
         
         ThreadTableView threadTableView = view.createThreadTableView();
         threadTableView.addThreadSelectionActionListener(new ThreadSelectionActionListener());
+        TimerFactory tf = appService.getTimerFactory();
         CommonController threadTableController =
-                new ThreadTableController(threadTableView, collector,
-                                          ApplicationContext.getInstance().getTimerFactory().createTimer());
+                new ThreadTableController(threadTableView, collector, tf.createTimer());
         threadTableController.initialize();
         
         CommonController threadTimeline =
                 new ThreadTimelineController(view.createThreadTimelineView(), collector,
-                                             ApplicationContext.getInstance().getTimerFactory().createTimer());
+                                             tf.createTimer());
         threadTimeline.initialize();
     }
 }
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -41,7 +41,7 @@
 import com.redhat.thermostat.client.core.controllers.InformationServiceController;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.Ref;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.thread.client.common.ThreadViewProvider;
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -43,7 +43,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.VmInformationService;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.thread.client.common.ThreadViewProvider;
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -42,19 +42,16 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationCache;
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationCache;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.HostRef;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.thread.client.common.ThreadTableBean;
@@ -85,15 +82,10 @@
     
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
+        appService = mock(ApplicationService.class);
         setUpTimers();
         setUpView();
     }
-    
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
 
     private void setUpView() {
         threadCapsView = mock(VMThreadCapabilitiesView.class);
@@ -116,7 +108,7 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        when(appService.getTimerFactory()).thenReturn(timerFactory);
     }
     
     private void setUpListeners() {        
@@ -134,7 +126,6 @@
     
     private void createController() {
         ApplicationCache cache = mock(ApplicationCache.class);
-        appService = mock(ApplicationService.class);
         when(appService.getApplicationCache()).thenReturn(cache);
         
         VmRef ref = mock(VmRef.class);
@@ -181,7 +172,6 @@
         when(collectorFactory.getCollector(ref)).thenReturn(collector);
         
         ApplicationCache cache = mock(ApplicationCache.class);
-        appService = mock(ApplicationService.class);
         when(appService.getApplicationCache()).thenReturn(cache);
                 
         controller = new ThreadInformationController(ref, appService, collectorFactory, viewFactory);
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,7 +40,6 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -48,7 +47,6 @@
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.Timer;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
 import com.redhat.thermostat.thread.client.common.collector.ThreadCollector;
 
@@ -64,7 +62,6 @@
     
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         collector = mock(ThreadCollector.class);
         
         timer = mock(Timer.class);
@@ -74,11 +71,6 @@
         setUpTimers();
     }
     
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-    
     private void setUpTimers() {
         timer = mock(Timer.class);
         timerActionCaptor = ArgumentCaptor.forClass(Runnable.class);
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,7 +40,6 @@
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.anyLong;
 import static org.mockito.Mockito.when;
 
@@ -56,7 +55,6 @@
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
 import com.redhat.thermostat.common.Timer;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
 import com.redhat.thermostat.thread.client.common.ThreadTimelineBean;
 import com.redhat.thermostat.thread.client.common.ThreadTimelineView;
@@ -75,7 +73,6 @@
     
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         collector = mock(ThreadCollector.class);
         
         timer = mock(Timer.class);
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -41,14 +41,12 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView;
 import com.redhat.thermostat.thread.client.common.collector.ThreadCollector;
 import com.redhat.thermostat.thread.model.VMThreadCapabilities;
@@ -63,7 +61,6 @@
     
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         collector = mock(ThreadCollector.class);
         caps = mock(VMThreadCapabilities.class);
         
@@ -72,11 +69,6 @@
         vmThreadCapsView = mock(VMThreadCapabilitiesView.class);
     }
     
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-    
     @Test
     public void testStartVMThreadCapabilities() {
         
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java	Thu Nov 29 17:06:15 2012 -0500
@@ -49,10 +49,10 @@
 import javax.swing.SwingUtilities;
 import javax.swing.SwingWorker;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
 import com.redhat.thermostat.client.swing.SwingComponent;
 import com.redhat.thermostat.client.swing.components.ChartPanel;
 import com.redhat.thermostat.client.ui.ComponentVisibleListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.locale.Translate;
 import com.redhat.thermostat.thread.client.common.ThreadTableBean;
 import com.redhat.thermostat.thread.client.common.ThreadTableView;
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/osgi/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/osgi/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -41,7 +41,7 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
-import com.redhat.thermostat.client.osgi.service.ApplicationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.thread.client.common.ThreadViewProvider;
 import com.redhat.thermostat.thread.client.swing.SwingThreadViewService;
 
--- a/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/tools/src/main/java/com/redhat/thermostat/tools/cli/VMStatCommand.java	Thu Nov 29 17:06:15 2012 -0500
@@ -42,8 +42,8 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.HostVMArguments;
@@ -101,7 +101,8 @@
     private void startContinuousStats(final CommandContext ctx, final VMStatPrinter statPrinter) {
 
         final CountDownLatch latch = new CountDownLatch(1);
-        Timer timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        ApplicationService appSvc = serviceProvider.getService(ApplicationService.class);
+        Timer timer = appSvc.getTimerFactory().createTimer();
         timer.setDelay(1);
         timer.setInitialDelay(1);
         timer.setSchedulingType(Timer.SchedulingType.FIXED_RATE);
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/ConnectCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -60,7 +60,6 @@
 
 import com.redhat.thermostat.common.DbService;
 import com.redhat.thermostat.common.DbServiceFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -83,7 +82,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         setupCommandContextFactory();
 
         dbServiceFactory = mock(DbServiceFactory.class);
@@ -102,7 +100,6 @@
     public void tearDown() {
         cmdCtxFactory = null;
         cmd = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/DisconnectCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -58,7 +58,6 @@
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import com.redhat.thermostat.common.DbService;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.CommandContext;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
@@ -79,7 +78,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         setupCommandContextFactory();
 
         cmd = new DisconnectCommand();
@@ -97,7 +95,6 @@
     public void tearDown() {
         cmdCtxFactory = null;
         cmd = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     @Test
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VMInfoCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -56,7 +56,6 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.DAOException;
@@ -90,7 +89,6 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         setupCommandContextFactory();
 
         vmsDAO = mock(VmInfoDAO.class);
--- a/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/tools/src/test/java/com/redhat/thermostat/tools/cli/VmStatCommandTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -59,9 +59,8 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.cli.CommandException;
 import com.redhat.thermostat.common.cli.SimpleArguments;
 import com.redhat.thermostat.common.dao.HostRef;
@@ -103,9 +102,9 @@
 
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
         timerFactory = new TestTimerFactory();
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
         setupCommandContextFactory();
 
         setupDAOs();
@@ -113,6 +112,7 @@
         OSGIUtils serviceProvider = mock(OSGIUtils.class);
         when(serviceProvider.getServiceAllowNull(VmCpuStatDAO.class)).thenReturn(vmCpuStatDAO);
         when(serviceProvider.getServiceAllowNull(VmMemoryStatDAO.class)).thenReturn(vmMemoryStatDAO);
+        when(serviceProvider.getService(ApplicationService.class)).thenReturn(appSvc);
 
         cmd = new VMStatCommand(serviceProvider);
     }
@@ -123,7 +123,6 @@
         cmdCtxFactory = null;
         cmd = null;
         timerFactory = null;
-        ApplicationContextUtil.resetApplicationContext();
     }
 
     private void setupCommandContextFactory() {
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,10 +45,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.locale.Translate;
@@ -67,10 +67,10 @@
 
     private long lastSeenTimeStamp = Long.MIN_VALUE;
 
-    public VmCpuController(VmCpuStatDAO vmCpuStatDao, VmRef ref, VmCpuViewProvider provider) {
+    public VmCpuController(ApplicationService appSvc, VmCpuStatDAO vmCpuStatDao, VmRef ref, VmCpuViewProvider provider) {
         this.ref = ref;
         dao = vmCpuStatDao;
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appSvc.getTimerFactory().createTimer();
 
         timer.setAction(new Runnable() {
             @Override
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,6 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -47,10 +48,12 @@
 public class VmCpuService implements VmInformationService {
     
     private static final VmFilter FILTER = new AlwaysMatchFilter();
-    
+
+    private ApplicationService appSvc;
     private VmCpuStatDAO vmCpuStatDAO;
     
-    public VmCpuService(VmCpuStatDAO vmCpuStatDAO) {
+    public VmCpuService(ApplicationService appSvc, VmCpuStatDAO vmCpuStatDAO) {
+        this.appSvc = appSvc;
         this.vmCpuStatDAO = vmCpuStatDAO;
     }
 
@@ -58,7 +61,7 @@
     public VmInformationServiceController getInformationServiceController(
             VmRef ref) {
         VmCpuViewProvider provider = OSGIUtils.getInstance().getService(VmCpuViewProvider.class);
-        return new VmCpuController(vmCpuStatDAO, ref, provider);
+        return new VmCpuController(appSvc, vmCpuStatDAO, ref, provider);
     }
 
     @Override
--- a/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -46,16 +46,14 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.storage.model.VmCpuStat;
@@ -66,11 +64,6 @@
 
 public class VmCpuControllerTest {
 
-    @Before
-    public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
     @SuppressWarnings({ "unchecked", "rawtypes" }) // any(List.class)
     @Test
     public void testChartUpdate() {
@@ -90,7 +83,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         final VmCpuView view = mock(VmCpuView.class);
         ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class);
@@ -100,7 +94,7 @@
         when(viewProvider.createView()).thenReturn(view);
 
         @SuppressWarnings("unused")
-        VmCpuController controller = new VmCpuController(vmCpuStatDAO, ref, viewProvider);
+        VmCpuController controller = new VmCpuController(appSvc, vmCpuStatDAO, ref, viewProvider);
 
         ActionListener<VmCpuView.Action> l = viewArgumentCaptor.getValue();
 
--- a/vm-cpu/client-swing/src/main/java/com/redhat/thermostat/vm/cpu/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-cpu/client-swing/src/main/java/com/redhat/thermostat/vm/cpu/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,22 +36,24 @@
 
 package com.redhat.thermostat.vm.cpu.client.swing;
 
+import java.util.Map;
 import java.util.Objects;
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
+import com.redhat.thermostat.common.MultipleServiceTracker;
+import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.vm.cpu.client.core.VmCpuService;
 import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider;
 
 public class Activator implements BundleActivator {
     
-    private ServiceTracker tracker;
+    private MultipleServiceTracker tracker;
     private ServiceRegistration reg;
 
     @Override
@@ -59,24 +61,29 @@
         VmCpuViewProvider viewProvider = new SwingVmCpuViewProvider();
         context.registerService(VmCpuViewProvider.class.getName(), viewProvider, null);
 
-        tracker = new ServiceTracker(context, VmCpuStatDAO.class.getName(), null) {
-            
+        Class<?>[] deps = new Class<?>[] {
+                VmCpuStatDAO.class,
+                ApplicationService.class
+            };
+
+        tracker = new MultipleServiceTracker(context, deps, new Action() {
+
             @Override
-            public Object addingService(ServiceReference reference) {
-                VmCpuStatDAO vmCpuStatDAO = (VmCpuStatDAO) context.getService(reference);
+            public void dependenciesAvailable(Map<String, Object> services) {
+                VmCpuStatDAO vmCpuStatDAO = (VmCpuStatDAO) services.get(VmCpuStatDAO.class.getName());
                 Objects.requireNonNull(vmCpuStatDAO);
-                VmCpuService service = new VmCpuService(vmCpuStatDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                Objects.requireNonNull(appSvc);
+                VmCpuService service = new VmCpuService(appSvc, vmCpuStatDAO);
                 reg = context.registerService(VmInformationService.class.getName(), service, null);
-                
-                return super.addingService(reference);
             }
 
             @Override
-            public void removedService(ServiceReference reference, Object service) {
-                context.ungetService(reference);
+            public void dependenciesUnavailable() {
                 reg.unregister();
             }
-        };
+
+        });
         tracker.open();
     }
 
--- a/vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-cpu/client-swing/src/test/java/com/redhat/thermostat/vm/cpu/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -43,6 +43,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmCpuStatDAO;
 import com.redhat.thermostat.test.StubBundleContext;
 import com.redhat.thermostat.vm.cpu.client.core.VmCpuService;
@@ -60,7 +61,7 @@
 
         // View provider registers unconditionally
         assertEquals(1, context.getAllServices().size());
-        assertEquals(1, context.getServiceListeners().size());
+        assertEquals(2, context.getServiceListeners().size());
         
         activator.stop(context);
 
@@ -71,8 +72,10 @@
     public void verifyActivatorRegistersServices() throws Exception {
         StubBundleContext context = new StubBundleContext();
         VmCpuStatDAO vmCpuStatDAO = mock(VmCpuStatDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(VmCpuStatDAO.class, vmCpuStatDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
@@ -83,7 +86,7 @@
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(2, context.getAllServices().size());
+        assertEquals(3, context.getAllServices().size());
     }
 
     @Test
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -51,10 +51,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -84,10 +84,10 @@
 
     private long lastSeenTimeStamp = Long.MIN_VALUE;
 
-    public VmGcController(VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef ref, VmGcViewProvider provider) {
+    public VmGcController(ApplicationService appSvc, VmMemoryStatDAO vmMemoryStatDao, VmGcStatDAO vmGcStatDao, VmRef ref, VmGcViewProvider provider) {
         this.ref = ref;
         this.view = provider.createView();
-        this.timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        this.timer = appSvc.getTimerFactory().createTimer();
 
         gcDao = vmGcStatDao;
         memDao = vmMemoryStatDao;
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,6 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -48,11 +49,13 @@
 public class VmGcService implements VmInformationService {
     
     private static final VmFilter FILTER = new AlwaysMatchFilter();
-    
+
+    private ApplicationService appSvc;
     private VmMemoryStatDAO vmMemoryStatDAO;
     private VmGcStatDAO vmGcStatDAO;
     
-    public VmGcService(VmMemoryStatDAO vmMemoryStatDAO, VmGcStatDAO vmGcStatDAO) {
+    public VmGcService(ApplicationService appSvc, VmMemoryStatDAO vmMemoryStatDAO, VmGcStatDAO vmGcStatDAO) {
+        this.appSvc = appSvc;
         this.vmMemoryStatDAO = vmMemoryStatDAO;
         this.vmGcStatDAO = vmGcStatDAO;
     }
@@ -61,7 +64,7 @@
     public VmInformationServiceController getInformationServiceController(
             VmRef ref) {
         VmGcViewProvider provider = OSGIUtils.getInstance().getService(VmGcViewProvider.class);
-        return new VmGcController(vmMemoryStatDAO, vmGcStatDAO, ref, provider);
+        return new VmGcController(appSvc, vmMemoryStatDAO, vmGcStatDAO, ref, provider);
     }
 
     @Override
--- a/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/VmGcControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/VmGcControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -48,18 +48,16 @@
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.dao.VmRef;
@@ -80,7 +78,6 @@
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
 
         // Setup Timer
         timer = mock(Timer.class);
@@ -89,7 +86,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // Set up fake data
         List<VmGcStat> stats = new ArrayList<>();
@@ -121,18 +119,13 @@
         // Now start the controller
         VmRef ref = mock(VmRef.class);
 
-        new VmGcController(vmMemoryStatDAO, vmGcStatDAO, ref, viewProvider);
+        new VmGcController(appSvc, vmMemoryStatDAO, vmGcStatDAO, ref, viewProvider);
 
         // Extract relevant objects
         viewListener = viewArgumentCaptor.getValue();
         timerAction = timerActionCaptor.getValue();
     }
 
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
     @Test
     public void verifyTimer() {
         verify(timer).setAction(isNotNull(Runnable.class));
--- a/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-gc/client-swing/src/main/java/com/redhat/thermostat/vm/gc/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.osgi.framework.ServiceRegistration;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.MultipleServiceTracker;
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
@@ -52,7 +53,7 @@
 import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider;
 
 public class Activator implements BundleActivator {
-    
+
     private MultipleServiceTracker tracker;
     private ServiceRegistration reg;
 
@@ -62,6 +63,7 @@
         context.registerService(VmGcViewProvider.class.getName(), viewProvider, null);
 
         Class<?>[] deps = new Class<?>[] {
+            ApplicationService.class,
             VmMemoryStatDAO.class,
             VmGcStatDAO.class,
         };
@@ -74,7 +76,8 @@
                 Objects.requireNonNull(vmMemoryStatDAO);
                 VmGcStatDAO vmGcStatDAO = (VmGcStatDAO) services.get(VmGcStatDAO.class.getName());
                 Objects.requireNonNull(vmGcStatDAO);
-                VmGcService service = new VmGcService(vmMemoryStatDAO, vmGcStatDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                VmGcService service = new VmGcService(appSvc, vmMemoryStatDAO, vmGcStatDAO);
                 reg = context.registerService(VmInformationService.class.getName(), service, null);
             }
 
--- a/vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-gc/client-swing/src/test/java/com/redhat/thermostat/vm/gc/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -44,6 +44,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmGcStatDAO;
 import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.test.StubBundleContext;
@@ -74,9 +75,11 @@
         StubBundleContext context = new StubBundleContext();
         VmMemoryStatDAO vmMemoryStatDAO = mock(VmMemoryStatDAO.class);
         VmGcStatDAO vmGcStatDAO = mock(VmGcStatDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(VmMemoryStatDAO.class, vmMemoryStatDAO, null);
         context.registerService(VmGcStatDAO.class, vmGcStatDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
@@ -87,7 +90,7 @@
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(3, context.getAllServices().size());
+        assertEquals(4, context.getAllServices().size());
     }
 
     @Test
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewController.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewController.java	Thu Nov 29 17:06:15 2012 -0500
@@ -45,10 +45,10 @@
 import com.redhat.thermostat.client.core.views.UIComponent;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.NotImplementedException;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.locale.Translate;
@@ -67,12 +67,12 @@
 
     private final VmOverviewView view;
 
-    public VmOverviewController(VmInfoDAO vmDao, VmRef vmRef, VmOverviewViewProvider provider) {
+    public VmOverviewController(ApplicationService appSvc, VmInfoDAO vmDao, VmRef vmRef, VmOverviewViewProvider provider) {
         this.ref = vmRef;
         this.view = provider.createView();
 
         dao = vmDao;
-        timer = ApplicationContext.getInstance().getTimerFactory().createTimer();
+        timer = appSvc.getTimerFactory().createTimer();
 
         vmRunningTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL);
 
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java	Thu Nov 29 17:06:15 2012 -0500
@@ -40,6 +40,7 @@
 import com.redhat.thermostat.client.core.VmInformationService;
 import com.redhat.thermostat.client.core.controllers.VmInformationServiceController;
 import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.utils.OSGIUtils;
@@ -47,10 +48,12 @@
 public class VmOverviewService implements VmInformationService {
     
     private static final VmFilter FILTER = new AlwaysMatchFilter();
-    
+
+    private ApplicationService appSvc;
     private VmInfoDAO vmInfoDAO;
     
-    public VmOverviewService(VmInfoDAO vmInfoDAO) {
+    public VmOverviewService(ApplicationService appSvc, VmInfoDAO vmInfoDAO) {
+        this.appSvc = appSvc;
         this.vmInfoDAO = vmInfoDAO;
     }
 
@@ -58,7 +61,7 @@
     public VmInformationServiceController getInformationServiceController(
             VmRef ref) {
         VmOverviewViewProvider provider = OSGIUtils.getInstance().getService(VmOverviewViewProvider.class);
-        return new VmOverviewController(vmInfoDAO, ref, provider);
+        return new VmOverviewController(appSvc, vmInfoDAO, ref, provider);
     }
 
     @Override
--- a/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewControllerTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewControllerTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -51,7 +51,6 @@
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -59,11 +58,10 @@
 import com.redhat.thermostat.client.core.views.BasicView.Action;
 import com.redhat.thermostat.common.ActionEvent;
 import com.redhat.thermostat.common.ActionListener;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.Timer.SchedulingType;
 import com.redhat.thermostat.common.TimerFactory;
-import com.redhat.thermostat.common.appctx.ApplicationContext;
-import com.redhat.thermostat.common.appctx.ApplicationContextUtil;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.common.dao.VmRef;
 import com.redhat.thermostat.common.locale.Translate;
@@ -97,8 +95,6 @@
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Before
     public void setUp() {
-        ApplicationContextUtil.resetApplicationContext();
-
         // Setup timer
         timer = mock(Timer.class);
         ArgumentCaptor<Runnable> timerActionCaptor = ArgumentCaptor
@@ -107,7 +103,8 @@
 
         TimerFactory timerFactory = mock(TimerFactory.class);
         when(timerFactory.createTimer()).thenReturn(timer);
-        ApplicationContext.getInstance().setTimerFactory(timerFactory);
+        ApplicationService appSvc = mock(ApplicationService.class);
+        when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // Setup DAOs
         VmInfo vmInfo = new VmInfo(VM_PID, START_TIME, STOP_TIME, JAVA_VERSION,
@@ -127,17 +124,12 @@
         VmOverviewViewProvider viewProvider = mock(VmOverviewViewProvider.class);
         when(viewProvider.createView()).thenReturn(view);
 
-        controller = new VmOverviewController(vmInfoDao, ref, viewProvider);
+        controller = new VmOverviewController(appSvc, vmInfoDao, ref, viewProvider);
 
         listener = listenerCaptor.getValue();
         timerAction = timerActionCaptor.getValue();
     }
 
-    @After
-    public void tearDown() {
-        ApplicationContextUtil.resetApplicationContext();
-    }
-
     @Test
     public void verifyViewIsUpdatedWithData() {
         timerAction.run();
--- a/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/Activator.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-overview/client-swing/src/main/java/com/redhat/thermostat/vm/overview/client/swing/Activator.java	Thu Nov 29 17:06:15 2012 -0500
@@ -36,22 +36,24 @@
 
 package com.redhat.thermostat.vm.overview.client.swing;
 
+import java.util.Map;
 import java.util.Objects;
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
+import com.redhat.thermostat.common.MultipleServiceTracker;
+import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.vm.overview.client.core.VmOverviewService;
 import com.redhat.thermostat.vm.overview.client.core.VmOverviewViewProvider;
 
 public class Activator implements BundleActivator {
     
-    private ServiceTracker tracker;
+    private MultipleServiceTracker tracker;
     private ServiceRegistration reg;
 
     @Override
@@ -59,24 +61,28 @@
         VmOverviewViewProvider viewProvider = new SwingVmOverviewViewProvider();
         context.registerService(VmOverviewViewProvider.class.getName(), viewProvider, null);
 
-        tracker = new ServiceTracker(context, VmInfoDAO.class.getName(), null) {
-            
+        Class<?>[] deps = new Class<?>[] {
+                VmInfoDAO.class,
+                ApplicationService.class
+        };
+        tracker = new MultipleServiceTracker(context, deps, new Action() {
+
             @Override
-            public Object addingService(ServiceReference reference) {
-                VmInfoDAO vmInfoDAO = (VmInfoDAO) context.getService(reference);
+            public void dependenciesAvailable(Map<String, Object> services) {
+                VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName());
                 Objects.requireNonNull(vmInfoDAO);
-                VmOverviewService service = new VmOverviewService(vmInfoDAO);
+                ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName());
+                Objects.requireNonNull(appSvc);
+                VmOverviewService service = new VmOverviewService(appSvc, vmInfoDAO);
                 reg = context.registerService(VmInformationService.class.getName(), service, null);
-                
-                return super.addingService(reference);
             }
 
             @Override
-            public void removedService(ServiceReference reference, Object service) {
-                context.ungetService(reference);
+            public void dependenciesUnavailable() {
                 reg.unregister();
             }
-        };
+
+        });
         tracker.open();
     }
 
--- a/vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/ActivatorTest.java	Thu Nov 29 19:47:42 2012 +0100
+++ b/vm-overview/client-swing/src/test/java/com/redhat/thermostat/vm/overview/client/swing/ActivatorTest.java	Thu Nov 29 17:06:15 2012 -0500
@@ -43,6 +43,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.client.core.VmInformationService;
+import com.redhat.thermostat.common.ApplicationService;
 import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.test.StubBundleContext;
 import com.redhat.thermostat.vm.overview.client.core.VmOverviewService;
@@ -62,7 +63,7 @@
 
         // View provider registers unconditionally
         assertEquals(1, context.getAllServices().size());
-        assertEquals(1, context.getServiceListeners().size());
+        assertEquals(2, context.getServiceListeners().size());
         
         activator.stop(context);
 
@@ -73,19 +74,22 @@
     public void verifyActivatorRegistersServices() throws Exception {
         StubBundleContext context = new StubBundleContext();
         VmInfoDAO vmInfoDAO = mock(VmInfoDAO.class);
+        ApplicationService appSvc = mock(ApplicationService.class);
 
         context.registerService(VmInfoDAO.class, vmInfoDAO, null);
+        context.registerService(ApplicationService.class, appSvc, null);
 
         Activator activator = new Activator();
 
         activator.start(context);
 
+        assertTrue(context.isServiceRegistered(VmOverviewViewProvider.class.getName(), SwingVmOverviewViewProvider.class));
         assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmOverviewService.class));
 
         activator.stop(context);
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(2, context.getAllServices().size());
+        assertEquals(3, context.getAllServices().size());
     }
 
     @Test