Mercurial > hg > release > thermostat-2.0
changeset 2495:f457fcacc6f4
Make it hard to get invalid services from MultipleServiceTracker
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-October/021202.html
line wrap: on
line diff
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.agent.cli.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -47,6 +45,7 @@ import com.redhat.thermostat.common.ExitStatus; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.shared.config.SSLConfiguration; @@ -72,10 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ExitStatus exitStatus = (ExitStatus) services.get(ExitStatus.class.getName()); - WriterID writerID = (WriterID) services.get(WriterID.class.getName()); - SSLConfiguration sslConf = (SSLConfiguration) services.get(SSLConfiguration.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ExitStatus exitStatus = services.get(ExitStatus.class); + WriterID writerID = services.get(WriterID.class); + SSLConfiguration sslConf = services.get(SSLConfiguration.class); agentApplication = new AgentApplication(context, exitStatus, writerID, sslConf); reg.registerCommand("service", new ServiceCommand(context)); reg.registerCommand("agent", agentApplication);
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/internal/AgentApplication.java Tue Oct 25 16:15:19 2016 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/internal/AgentApplication.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.agent.cli.internal; import java.io.IOException; -import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.logging.Level; import java.util.logging.Logger; @@ -61,6 +60,7 @@ import com.redhat.thermostat.common.LaunchException; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.AbstractStateNotifyingCommand; import com.redhat.thermostat.common.cli.Arguments; import com.redhat.thermostat.common.cli.CommandContext; @@ -348,12 +348,10 @@ depTracker = new MultipleServiceTracker(bundleContext, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - Storage storage = (Storage) services.get(Storage.class.getName()); - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services - .get(AgentInfoDAO.class.getName()); - BackendInfoDAO backendInfoDAO = (BackendInfoDAO) services - .get(BackendInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + Storage storage = services.get(Storage.class); + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); + BackendInfoDAO backendInfoDAO = services.get(BackendInfoDAO.class); Agent agent = startAgent(storage, agentInfoDAO, backendInfoDAO); handler = new CustomSignalHandler(agent, configServer);
--- a/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.agent.command.internal; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -49,6 +48,7 @@ import com.redhat.thermostat.agent.ipc.server.AgentIPCService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.shared.config.CommonPaths; import com.redhat.thermostat.shared.config.SSLConfiguration; @@ -72,10 +72,10 @@ sslConfigTracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - SSLConfiguration sslConf = (SSLConfiguration) services.get(SSLConfiguration.class.getName()); - AgentIPCService ipcService = (AgentIPCService) services.get(AgentIPCService.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + CommonPaths paths = services.get(CommonPaths.class); + SSLConfiguration sslConf = services.get(SSLConfiguration.class); + AgentIPCService ipcService = services.get(AgentIPCService.class); CommandChannelDelegate confServer = new CommandChannelDelegate(receivers, sslConf, paths.getSystemBinRoot(), ipcService, paths.getUserIPCConfigurationFile()); confServerRegistration = context.registerService(ConfigurationServer.class.getName(), confServer, null);
--- a/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/agent/core/src/main/java/com/redhat/thermostat/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.agent.internal; import java.io.IOException; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -54,6 +53,7 @@ import com.redhat.thermostat.agent.utils.username.UserNameUtil; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.shared.config.CommonPaths; import com.redhat.thermostat.shared.config.InvalidConfigurationException; @@ -116,10 +116,10 @@ agentIPCTracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentIPCService ipcService = (AgentIPCService) services.get(AgentIPCService.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - UserNameUtil util = (UserNameUtil) services.get(UserNameUtil.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentIPCService ipcService = services.get(AgentIPCService.class); + CommonPaths paths = services.get(CommonPaths.class); + UserNameUtil util = services.get(UserNameUtil.class); pool = new MXBeanConnectionPoolImpl(paths.getSystemBinRoot(), util, ipcService, paths.getUserIPCConfigurationFile()); context.registerService(MXBeanConnectionPool.class, pool, null);
--- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,13 +36,12 @@ package com.redhat.thermostat.client.cli.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.common.config.ClientPreferences; @@ -85,11 +84,11 @@ connectTracker = new MultipleServiceTracker(context, classes, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - Keyring keyring = (Keyring) services.get(Keyring.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + Keyring keyring = services.get(Keyring.class); + CommonPaths paths = services.get(CommonPaths.class); ClientPreferences prefs = new ClientPreferences(paths); - SSLConfiguration sslConf = (SSLConfiguration) services.get(SSLConfiguration.class); + SSLConfiguration sslConf = services.get(SSLConfiguration.class); reg.registerCommand("connect", new ConnectCommand(context, prefs, keyring, sslConf)); } @@ -107,8 +106,8 @@ vmStatTracker = new MultipleServiceTracker(context, vmStatClasses, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); vmStatCommand.setVmInfoDAO(vmInfoDAO); } @@ -124,8 +123,8 @@ }; listAgentTracker = new MultipleServiceTracker(context, listAgentClasses, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); listAgentsCommand.setAgentInfoDAO(agentInfoDAO); } @@ -144,9 +143,9 @@ }; agentInfoTracker = new MultipleServiceTracker(context, agentInfoClasses, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - BackendInfoDAO backendInfoDAO = (BackendInfoDAO) services.get(BackendInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); + BackendInfoDAO backendInfoDAO = services.get(BackendInfoDAO.class); agentInfoCommand.setServices(agentInfoDAO, backendInfoDAO); }
--- a/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/internal/VMFilterActivator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/internal/VMFilterActivator.java Tue Oct 25 18:12:39 2016 -0400 @@ -40,7 +40,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -49,6 +48,7 @@ import com.redhat.thermostat.client.ui.MenuAction; import com.redhat.thermostat.client.ui.ReferenceFilter; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -70,12 +70,12 @@ tracker = new MultipleServiceTracker(context, services, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { @SuppressWarnings("rawtypes") ServiceRegistration registration = null; - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - HostInfoDAO hostDao = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + HostInfoDAO hostDao = services.get(HostInfoDAO.class); LivingHostFilter hostFilter = new LivingHostFilter(hostDao); registration = context.registerService(ReferenceFilter.class.getName(), hostFilter, null);
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/internal/vm/swing/VMFilterActivator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/internal/vm/swing/VMFilterActivator.java Tue Oct 25 18:12:39 2016 -0400 @@ -42,7 +42,6 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; -import java.util.Map; import com.redhat.thermostat.client.ui.MenuAction; import org.osgi.framework.BundleActivator; @@ -60,6 +59,7 @@ import com.redhat.thermostat.client.ui.ReferenceFieldIconDecorator; import com.redhat.thermostat.client.ui.ReferenceFieldLabelDecorator; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.dao.HostInfoDAO; import com.redhat.thermostat.storage.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -95,13 +95,13 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { ServiceRegistration registration = null; - UIDefaults uiDefaults = (UIDefaults) services.get(UIDefaults.class.getName()); + UIDefaults uiDefaults = services.get(UIDefaults.class); - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - HostInfoDAO hostDao = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + HostInfoDAO hostDao = services.get(HostInfoDAO.class); Dictionary<String, String> decoratorProperties = new Hashtable<>(); @@ -137,8 +137,7 @@ registeredServices.add(registration); - NetworkInterfaceInfoDAO networkDao = (NetworkInterfaceInfoDAO) - services.get(NetworkInterfaceInfoDAO.class.getName()); + NetworkInterfaceInfoDAO networkDao = services.get(NetworkInterfaceInfoDAO.class); HostNetworkInterfaceLabelDecorator hostLabelDecorator = new HostNetworkInterfaceLabelDecorator(networkDao);
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Tue Oct 25 16:15:19 2016 -0400 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Tue Oct 25 18:12:39 2016 -0400 @@ -85,6 +85,7 @@ import com.redhat.thermostat.common.ApplicationInfo; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.ThermostatExtensionRegistry; import com.redhat.thermostat.common.config.ClientPreferences; import com.redhat.thermostat.common.utils.LoggingUtils; @@ -229,8 +230,8 @@ }; issuesDepTracker = new MultipleServiceTracker(context, issuesDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - IssueViewProvider provider = (IssueViewProvider) services.get(IssueViewProvider.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + IssueViewProvider provider = services.get(IssueViewProvider.class); IssueView issuesView = provider.createView(); issuesController = new IssueViewController(context, appSvc, view.getDecoratorManager(), issuesView); issuesController.addIssueSelectionListener(new ActionListener<IssueViewController.IssueSelectionAction>() { @@ -273,32 +274,21 @@ depTracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - keyring = (Keyring) services.get(Keyring.class.getName()); - Objects.requireNonNull(keyring); - paths = (CommonPaths) services.get(CommonPaths.class.getName()); - Objects.requireNonNull(paths); - hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - Objects.requireNonNull(agentInfoDAO); - backendInfoDAO = (BackendInfoDAO) services.get(BackendInfoDAO.class.getName()); - Objects.requireNonNull(backendInfoDAO); - summaryViewProvider = (VersionAndInfoViewProvider) services.get(VersionAndInfoViewProvider.class.getName()); - Objects.requireNonNull(summaryViewProvider); - hostInfoViewProvider = (HostInformationViewProvider) services.get(HostInformationViewProvider.class.getName()); - Objects.requireNonNull(hostInfoViewProvider); - vmInfoViewProvider = (VmInformationViewProvider) services.get(VmInformationViewProvider.class.getName()); - Objects.requireNonNull(vmInfoViewProvider); - agentInfoViewProvider = (AgentInformationViewProvider) services.get(AgentInformationViewProvider.class.getName()); - Objects.requireNonNull(agentInfoViewProvider); - clientConfigViewProvider = (ClientConfigViewProvider) services.get(ClientConfigViewProvider.class.getName()); - Objects.requireNonNull(clientConfigViewProvider); + public void dependenciesAvailable(DependencyProvider services) { + keyring = services.get(Keyring.class); + paths = services.get(CommonPaths.class); + hostInfoDAO = services.get(HostInfoDAO.class); + vmInfoDAO = services.get(VmInfoDAO.class); + agentInfoDAO = services.get(AgentInfoDAO.class); + backendInfoDAO = services.get(BackendInfoDAO.class); + summaryViewProvider = services.get(VersionAndInfoViewProvider.class); + hostInfoViewProvider = services.get(HostInformationViewProvider.class); + vmInfoViewProvider = services.get(VmInformationViewProvider.class); + agentInfoViewProvider = services.get(AgentInformationViewProvider.class); + clientConfigViewProvider = services.get(ClientConfigViewProvider.class); - networkMonitor = (NetworkMonitor) services.get(NetworkMonitor.class.getName()); - hostMonitor = (HostMonitor) services.get(HostMonitor.class.getName()); + networkMonitor = services.get(NetworkMonitor.class); + hostMonitor = services.get(HostMonitor.class); initView();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/ThermostatActivator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/ThermostatActivator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.client.swing.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -57,7 +55,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; - +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.shared.config.CommonPaths; @@ -105,11 +103,11 @@ private Main main; @Override - public void dependenciesAvailable(Map<String, Object> services) { - Keyring keyring = (Keyring) services.get(Keyring.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - SSLConfiguration sslConf = (SSLConfiguration) services.get(SSLConfiguration.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + Keyring keyring = services.get(Keyring.class); + CommonPaths paths = services.get(CommonPaths.class); + ApplicationService appSvc = services.get(ApplicationService.class); + SSLConfiguration sslConf = services.get(SSLConfiguration.class); cmdReg = new CommandRegistryImpl(context); main = new Main(context, keyring, paths, appSvc, sslConf);
--- a/common/core/src/main/java/com/redhat/thermostat/common/MultipleServiceTracker.java Tue Oct 25 16:15:19 2016 -0400 +++ b/common/core/src/main/java/com/redhat/thermostat/common/MultipleServiceTracker.java Tue Oct 25 18:12:39 2016 -0400 @@ -55,8 +55,27 @@ */ public class MultipleServiceTracker { + public static class DependencyProvider { + + private Map<String, Object> deps; + + public DependencyProvider(Map<String, Object> deps) { + this.deps = deps; + } + + public <T> T get(Class<T> klass) { + T dep = (T) deps.get(klass.getName()); + return Objects.requireNonNull(dep); + } + + // for testing only + Map<String, Object> getDependencies() { + return deps; + } + } + public interface Action { - public void dependenciesAvailable(Map<String, Object> services); + public void dependenciesAvailable(DependencyProvider services); public void dependenciesUnavailable(); } @@ -67,7 +86,7 @@ Object service = context.getService(reference); services.put(getServiceClassName(reference), context.getService(reference)); if (allServicesReady()) { - action.dependenciesAvailable(services); + action.dependenciesAvailable(new DependencyProvider(services)); } return service; }
--- a/common/core/src/test/java/com/redhat/thermostat/common/MultipleServiceTrackerTest.java Tue Oct 25 16:15:19 2016 -0400 +++ b/common/core/src/test/java/com/redhat/thermostat/common/MultipleServiceTrackerTest.java Tue Oct 25 18:12:39 2016 -0400 @@ -51,6 +51,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.MultipleServiceTracker.InternalServiceTrackerCustomizer; import static org.mockito.Matchers.eq; @@ -113,7 +114,7 @@ verify(objectTracker).open(); customizer.addingService(objectReference); - verify(action).dependenciesAvailable(isA(Map.class)); + verify(action).dependenciesAvailable(isA(DependencyProvider.class)); customizer.removedService(objectReference, OBJECT); verify(action).dependenciesUnavailable(); @@ -124,7 +125,7 @@ Class<?>[] deps = { Object.class, String.class }; MultipleServiceTracker tracker = new MultipleServiceTracker(context, deps, action); - ArgumentCaptor<Map> serviceMap = ArgumentCaptor.forClass(Map.class); + ArgumentCaptor<DependencyProvider> dependencyProvider = ArgumentCaptor.forClass(DependencyProvider.class); ArgumentCaptor<ServiceTrackerCustomizer> customizerCaptor = ArgumentCaptor.forClass(ServiceTrackerCustomizer.class); verifyNew(ServiceTracker.class).withArguments(eq(context), @@ -141,9 +142,9 @@ customizer.addingService(objectReference); customizer.addingService(stringReference); - verify(action).dependenciesAvailable(serviceMap.capture()); + verify(action).dependenciesAvailable(dependencyProvider.capture()); - Map caputerServices = serviceMap.getValue(); + Map caputerServices = dependencyProvider.getValue().getDependencies(); Assert.assertTrue(caputerServices.containsKey(Object.class.getName())); Assert.assertTrue(caputerServices.containsKey(String.class.getName())); Assert.assertEquals(2, caputerServices.size());
--- a/dev/ipc-test/test-server/src/main/java/com/redhat/thermostat/dev/ipc/test/server/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/dev/ipc-test/test-server/src/main/java/com/redhat/thermostat/dev/ipc/test/server/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.dev.ipc.test.server.internal; import java.io.IOException; -import java.util.Map; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; @@ -47,6 +46,7 @@ import com.redhat.thermostat.agent.ipc.server.AgentIPCService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.shared.config.CommonPaths; public class Activator implements BundleActivator { @@ -61,9 +61,9 @@ tracker = new MultipleServiceTracker(ctx, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentIPCService service = (AgentIPCService) services.get(AgentIPCService.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentIPCService service = services.get(AgentIPCService.class); + CommonPaths paths = services.get(CommonPaths.class); server = new UnixSocketTestServer(service, paths); try { server.start();
--- a/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.host.cpu.agent.internal; -import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -48,6 +47,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; import com.redhat.thermostat.storage.core.WriterID; @@ -71,10 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - CpuStatDAO cpuStatDao = (CpuStatDAO) services.get(CpuStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + CpuStatDAO cpuStatDao = services.get(CpuStatDAO.class); Version version = new Version(context.getBundle()); - WriterID id = (WriterID) services.get(WriterID.class.getName()); + WriterID id = services.get(WriterID.class); backend = new HostCpuBackend(executor, cpuStatDao, version, id); reg = context.registerService(Backend.class, backend, null); }
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; @@ -73,15 +73,11 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - CpuStatDAO cpuStatDAO = (CpuStatDAO) services.get(CpuStatDAO.class.getName()); - Objects.requireNonNull(cpuStatDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - HostCpuViewProvider viewProvider = (HostCpuViewProvider) services.get(HostCpuViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + CpuStatDAO cpuStatDAO = services.get(CpuStatDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + HostCpuViewProvider viewProvider = services.get(HostCpuViewProvider.class); HostCpuService service = new HostCpuServiceImpl(appSvc, hostInfoDAO, cpuStatDAO, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.host.memory.agent.internal; -import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -48,6 +47,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; import com.redhat.thermostat.storage.core.WriterID; @@ -71,10 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - MemoryStatDAO memoryStatDao = (MemoryStatDAO) services.get(MemoryStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + MemoryStatDAO memoryStatDao = services.get(MemoryStatDAO.class); Version version = new Version(context.getBundle()); - WriterID id = (WriterID) services.get(WriterID.class.getName()); + WriterID id = services.get(WriterID.class); backend = new HostMemoryBackend(executor, memoryStatDao, version, id); reg = context.registerService(Backend.class.getName(), backend, null); }
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; @@ -73,15 +73,11 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - MemoryStatDAO memoryStatDAO = (MemoryStatDAO) services.get(MemoryStatDAO.class.getName()); - Objects.requireNonNull(memoryStatDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - HostMemoryViewProvider viewProvider = (HostMemoryViewProvider) services.get(HostMemoryViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + MemoryStatDAO memoryStatDAO = services.get(MemoryStatDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + HostMemoryViewProvider viewProvider = services.get(HostMemoryViewProvider.class); HostMemoryService service = new HostMemoryServiceImpl(appSvc, hostInfoDAO, memoryStatDAO, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.host.cpu.common.CpuStatDAO; import com.redhat.thermostat.host.memory.common.MemoryStatDAO; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; @@ -77,23 +77,15 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - NetworkInterfaceInfoDAO networkInfoDAO = (NetworkInterfaceInfoDAO) - services.get(NetworkInterfaceInfoDAO.class.getName()); - Objects.requireNonNull(networkInfoDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - HostOverviewViewProvider viewProvider = (HostOverviewViewProvider) services - .get(HostOverviewViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + NetworkInterfaceInfoDAO networkInfoDAO = services.get(NetworkInterfaceInfoDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + HostOverviewViewProvider viewProvider = services.get(HostOverviewViewProvider.class); - CpuStatDAO cpuDao = (CpuStatDAO) services.get(CpuStatDAO.class.getName()); - Objects.requireNonNull(cpuDao); + CpuStatDAO cpuDao = services.get(CpuStatDAO.class); - MemoryStatDAO memoryDao = (MemoryStatDAO) services.get(MemoryStatDAO.class.getName()); - Objects.requireNonNull(memoryDao); + MemoryStatDAO memoryDao = services.get(MemoryStatDAO.class); HostOverviewService service = new HostOverviewServiceImpl(appSvc, hostInfoDAO,
--- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.killvm.client.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -47,6 +45,7 @@ import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.killvm.common.KillVMRequest; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -67,10 +66,10 @@ killVmActionTracker = new MultipleServiceTracker(context, serviceDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - KillVMRequest request = (KillVMRequest) services.get(KillVMRequest.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + KillVMRequest request = services.get(KillVMRequest.class); KillVMAction service = new KillVMAction(agentDao, vmDao, request, new SwingVMKilledListener()); killActionRegistration = context.registerService(ReferenceContextAction.class.getName(), service, null); }
--- a/killvm/command/src/main/java/com/redhat/thermostat/killvm/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/killvm/command/src/main/java/com/redhat/thermostat/killvm/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.killvm.command.internal; import java.util.Hashtable; -import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -45,6 +44,7 @@ import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.killvm.common.KillVMRequest; import com.redhat.thermostat.storage.dao.AgentInfoDAO; @@ -67,10 +67,10 @@ serviceTracker = new MultipleServiceTracker(context, serviceDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - KillVMRequest request = (KillVMRequest) services.get(KillVMRequest.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + KillVMRequest request = services.get(KillVMRequest.class); command.setAgentInfoDAO(agentDao); command.setVmInfoDAO(vmDao);
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -41,6 +41,7 @@ import com.redhat.thermostat.common.ExitStatus; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.NotImplementedException; import com.redhat.thermostat.common.ThermostatExtensionRegistry; import com.redhat.thermostat.common.cli.CommandContextFactory; @@ -68,7 +69,6 @@ import java.io.File; import java.io.IOException; -import java.util.Map; public class Activator implements BundleActivator { @@ -91,11 +91,11 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - Keyring keyring = (Keyring) services.get(Keyring.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + CommonPaths paths = services.get(CommonPaths.class); + Keyring keyring = services.get(Keyring.class); ClientPreferences prefs = new ClientPreferences(paths); - SSLConfiguration sslConf = (SSLConfiguration) services.get(SSLConfiguration.class.getName()); + SSLConfiguration sslConf = services.get(SSLConfiguration.class); String commandsDir = new File(paths.getSystemConfigurationDirectory(), "commands").toString(); CommandInfoSource builtInCommandSource = @@ -206,9 +206,9 @@ }; shellTracker = new MultipleServiceTracker(context, shellClasses, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - ConfigurationInfoSource config = (ConfigurationInfoSource) services.get(ConfigurationInfoSource.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + CommonPaths paths = services.get(CommonPaths.class); + ConfigurationInfoSource config = services.get(ConfigurationInfoSource.class); shellCommand = new ShellCommand(context, paths, config); shellCommand.setTabCompletion(tabCompletion); shellCommand.setCompleterServiceRegistry(completerServiceRegistry); @@ -277,9 +277,9 @@ vmIdCompleterDepsTracker = new MultipleServiceTracker(context, vmIdCompleterDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); vmIdCompleterService.setVmInfoDAO(vmDao); vmIdCompleterService.setAgentInfoDAO(agentDao); } @@ -296,8 +296,8 @@ final Class<?>[] agentIdCompleterDeps = new Class[] { AgentInfoDAO.class }; agentIdCompleterDepsTracker = new MultipleServiceTracker(context, agentIdCompleterDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); agentIdCompleterService.setAgentInfoDAO(agentDao); } @@ -312,8 +312,8 @@ final Class<?>[] pingCommandCompleterDeps = new Class[] { AgentInfoDAO.class }; pingCommandCompleterDepsTracker = new MultipleServiceTracker(context, pingCommandCompleterDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); pingCommandCompleterService.setAgentInfoDAO(agentDao); }
--- a/launcher/src/test/java/com/redhat/thermostat/launcher/internal/ActivatorTest.java Tue Oct 25 16:15:19 2016 -0400 +++ b/launcher/src/test/java/com/redhat/thermostat/launcher/internal/ActivatorTest.java Tue Oct 25 18:12:39 2016 -0400 @@ -39,6 +39,7 @@ import com.redhat.thermostat.common.ExitStatus; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.common.cli.CompleterService; import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource; @@ -212,6 +213,7 @@ Action action = actionCaptor.getAllValues().get(0); assertNotNull(action); + SSLConfiguration sslConfiguration = mock(SSLConfiguration.class); Keyring keyringService = mock(Keyring.class); CommonPaths paths = mock(CommonPaths.class); when(paths.getSystemThermostatHome()).thenReturn(mock(File.class)); @@ -232,7 +234,8 @@ services.put(Keyring.class.getName(), keyringService); services.put(CommonPaths.class.getName(), paths); services.put(ConfigurationInfoSource.class.getName(), configurationInfoSource); - action.dependenciesAvailable(services); + services.put(SSLConfiguration.class.getName(), sslConfiguration); + action.dependenciesAvailable(new DependencyProvider(services)); assertTrue(context.isServiceRegistered(CommandInfoSource.class.getName(), mock(CompoundCommandInfoSource.class).getClass())); assertTrue(context.isServiceRegistered(BundleManager.class.getName(), BundleManagerImpl.class)); @@ -307,7 +310,7 @@ Map<String, Object> services = new HashMap<>(); services.put(CommonPaths.class.getName(), paths); services.put(ConfigurationInfoSource.class.getName(), configurationInfoSource); - action.dependenciesAvailable(services); + action.dependenciesAvailable(new DependencyProvider(services)); assertTrue(context.isServiceRegistered(Command.class.getName(), ShellCommand.class)); @@ -404,7 +407,9 @@ Action action = vmCaptor.getValue(); Map<String, Object> services = new HashMap<>(); - action.dependenciesAvailable(services); + services.put(AgentInfoDAO.class.getName(), mock(AgentInfoDAO.class)); + services.put(VmInfoDAO.class.getName(), mock(VmInfoDAO.class)); + action.dependenciesAvailable(new DependencyProvider(services)); assertTrue(context.isServiceRegistered(CompleterService.class.getName(), VmIdCompleterService.class)); @@ -456,7 +461,8 @@ Action action = agentCaptor.getAllValues().get(1); Map<String, Object> services = new HashMap<>(); - action.dependenciesAvailable(services); + services.put(AgentInfoDAO.class.getName(), mock(AgentInfoDAO.class)); + action.dependenciesAvailable(new DependencyProvider(services)); assertTrue(context.isServiceRegistered(CompleterService.class.getName(), AgentIdCompleterService.class)); @@ -508,7 +514,8 @@ Action action = pingCaptor.getValue(); Map<String, Object> services = new HashMap<>(); - action.dependenciesAvailable(services); + services.put(AgentInfoDAO.class.getName(), mock(AgentInfoDAO.class)); + action.dependenciesAvailable(new DependencyProvider(services)); assertTrue(context.isServiceRegistered(CompleterService.class.getName(), PingCommandCompleterService.class));
--- a/local/command/src/main/java/com/redhat/thermostat/local/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/local/command/src/main/java/com/redhat/thermostat/local/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,9 +36,8 @@ package com.redhat.thermostat.local.command.internal; -import java.util.Map; - import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.launcher.Launcher; @@ -64,9 +63,9 @@ }; tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - Launcher launcher = (Launcher) services.get(Launcher.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + CommonPaths paths = services.get(CommonPaths.class); + Launcher launcher = services.get(Launcher.class); localCommand.setPaths(paths); localCommand.setLauncher(launcher); }
--- a/notes/client-cli/src/main/java/com/redhat/thermostat/notes/client/cli/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/notes/client-cli/src/main/java/com/redhat/thermostat/notes/client/cli/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,6 +37,7 @@ package com.redhat.thermostat.notes.client.cli.internal; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; @@ -51,7 +52,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Objects; public class Activator implements BundleActivator { @@ -85,17 +85,12 @@ serviceTracker = new MultipleServiceTracker(context, serviceDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - Objects.requireNonNull(agentInfoDAO); - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - VmNoteDAO vmNoteDAO = (VmNoteDAO) services.get(VmNoteDAO.class.getName()); - Objects.requireNonNull(vmNoteDAO); - HostNoteDAO hostNoteDAO = (HostNoteDAO) services.get(HostNoteDAO.class.getName()); - Objects.requireNonNull(hostNoteDAO); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + VmNoteDAO vmNoteDAO = services.get(VmNoteDAO.class); + HostNoteDAO hostNoteDAO = services.get(HostNoteDAO.class); for (NotesCommand command : commands) { command.setVmInfoDao(vmInfoDAO); @@ -120,9 +115,9 @@ final Class<?>[] noteIdCompleterDeps = new Class<?>[] { HostNoteDAO.class, VmNoteDAO.class }; noteIdCompleterDepsTracker = new MultipleServiceTracker(context, noteIdCompleterDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HostNoteDAO hostNoteDAO = (HostNoteDAO) services.get(HostNoteDAO.class.getName()); - VmNoteDAO vmNoteDAO = (VmNoteDAO) services.get(VmNoteDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + HostNoteDAO hostNoteDAO = services.get(HostNoteDAO.class); + VmNoteDAO vmNoteDAO = services.get(VmNoteDAO.class); noteIdCompleterService.setHostNoteDao(hostNoteDAO); noteIdCompleterService.setVmNoteDao(vmNoteDAO); }
--- a/notes/client-core/src/main/java/com/redhat/thermostat/notes/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/notes/client-core/src/main/java/com/redhat/thermostat/notes/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -40,6 +40,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.SystemClock; import com.redhat.thermostat.notes.client.core.HostNotesControllerProvider; import com.redhat.thermostat.notes.client.core.NotesViewProvider; @@ -53,7 +54,6 @@ import org.osgi.framework.ServiceRegistration; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; public class Activator implements BundleActivator { @@ -75,13 +75,10 @@ }; hostNotesDaoTracker = new MultipleServiceTracker(context, hostDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - HostNoteDAO hostNoteDao = (HostNoteDAO) services.get(HostNoteDAO.class.getName()); - Objects.requireNonNull(hostNoteDao); - NotesViewProvider viewProvider = (NotesViewProvider) services.get(NotesViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + ApplicationService appSvc = services.get(ApplicationService.class); + HostNoteDAO hostNoteDao = services.get(HostNoteDAO.class); + NotesViewProvider viewProvider = services.get(NotesViewProvider.class); HostNotesControllerProvider hostNotesService = new HostNotesControllerProvider(new SystemClock(), appSvc, hostNoteDao, viewProvider); Hashtable<String, String> properties = new Hashtable<>(); properties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName()); @@ -103,13 +100,10 @@ }; vmNotesDaoTracker = new MultipleServiceTracker(context, vmDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmNoteDAO vmNoteDao = (VmNoteDAO) services.get(VmNoteDAO.class.getName()); - Objects.requireNonNull(vmNoteDao); - NotesViewProvider viewProvider = (NotesViewProvider) services.get(NotesViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + ApplicationService appSvc = services.get(ApplicationService.class); + VmNoteDAO vmNoteDao = services.get(VmNoteDAO.class); + NotesViewProvider viewProvider = services.get(NotesViewProvider.class); VmNotesControllerProvider notesService = new VmNotesControllerProvider(new SystemClock(), appSvc, vmNoteDao, viewProvider); Hashtable<String, String> properties = new Hashtable<>(); properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName());
--- a/notes/common/src/main/java/com/redhat/thermostat/notes/common/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/notes/common/src/main/java/com/redhat/thermostat/notes/common/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,13 +36,12 @@ package com.redhat.thermostat.notes.common.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.notes.common.HostNoteDAO; import com.redhat.thermostat.notes.common.VmNoteDAO; import com.redhat.thermostat.storage.core.Storage; @@ -65,8 +64,8 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { - Storage storage = (Storage) services.get(Storage.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + Storage storage = services.get(Storage.class); HostNoteDAO hostNoteDao = new HostNoteDAOImpl(storage); hostNoteDaoregistration = context.registerService(HostNoteDAO.class, hostNoteDao, null);
--- a/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.numa.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -47,6 +45,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.numa.common.NumaDAO; import com.redhat.thermostat.storage.core.WriterID; @@ -69,11 +68,11 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ApplicationService appService = (ApplicationService) services.get(ApplicationService.class.getName()); - NumaDAO numaDAO = (NumaDAO) services.get(NumaDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ApplicationService appService = services.get(ApplicationService.class); + NumaDAO numaDAO = services.get(NumaDAO.class); Version version = new Version(context.getBundle()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); NumaCollector collector = new NumaCollector(); backend = new NumaBackend(appService, numaDAO, collector, version, writerId); reg = context.registerService(Backend.class, backend, null);
--- a/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/numa/client-core/src/main/java/com/redhat/thermostat/numa/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.numa.client.core.NumaInformationService; import com.redhat.thermostat.numa.client.core.NumaViewProvider; import com.redhat.thermostat.numa.common.NumaDAO; @@ -71,13 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - NumaDAO numaDAO = (NumaDAO) services.get(NumaDAO.class.getName()); - Objects.requireNonNull(numaDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - NumaViewProvider numaViewProvider = (NumaViewProvider) services.get(NumaViewProvider.class.getName()); - Objects.requireNonNull(numaViewProvider); + public void dependenciesAvailable(DependencyProvider services) { + NumaDAO numaDAO = services.get(NumaDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + NumaViewProvider numaViewProvider = services.get(NumaViewProvider.class); NumaInformationServiceImpl service = new NumaInformationServiceImpl(appSvc, numaDAO, numaViewProvider); Dictionary<String, String> properties = new Hashtable<>(); properties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName());
--- a/setup/command/src/main/java/com/redhat/thermostat/setup/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/setup/command/src/main/java/com/redhat/thermostat/setup/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,10 +36,9 @@ package com.redhat.thermostat.setup.command.internal; -import java.util.Map; - import com.redhat.thermostat.common.ExitStatus; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.launcher.Launcher; @@ -72,12 +71,12 @@ }; tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ExitStatus exitStatus = (ExitStatus) services.get(ExitStatus.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); - Launcher launcher = (Launcher) services.get(Launcher.class.getName()); - Keyring keyring = (Keyring) services.get(Keyring.class.getName()); - ProcessHandler processHandler = (ProcessHandler) services.get(ProcessHandler.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ExitStatus exitStatus = services.get(ExitStatus.class); + CommonPaths paths = services.get(CommonPaths.class); + Launcher launcher = services.get(Launcher.class); + Keyring keyring = services.get(Keyring.class); + ProcessHandler processHandler = services.get(ProcessHandler.class); setupCommand.setExitStatusService(exitStatus); setupCommand.setPaths(paths); setupCommand.setLauncher(launcher);
--- a/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,14 +36,13 @@ package com.redhat.thermostat.storage.cli.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import com.redhat.thermostat.common.ExitStatus; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; import com.redhat.thermostat.service.process.ProcessHandler; @@ -66,10 +65,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ExitStatus exitStatus = (ExitStatus) services.get(ExitStatus.class.getName()); - ProcessHandler processHandler = (ProcessHandler) services.get(ProcessHandler.class.getName()); - CommonPaths paths = (CommonPaths) services.get(CommonPaths.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ExitStatus exitStatus = services.get(ExitStatus.class); + ProcessHandler processHandler = services.get(ProcessHandler.class); + CommonPaths paths = services.get(CommonPaths.class); reg.registerCommand("storage", new StorageCommand(exitStatus, processHandler, paths)); }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.UUID; import org.osgi.framework.BundleActivator; @@ -47,6 +46,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.storage.core.WriterID; @@ -95,9 +95,9 @@ tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { - Storage storage = (Storage) services.get(Storage.class.getName()); + Storage storage = services.get(Storage.class); SchemaInfoDAO schemaInfoDAO = new SchemaInfoDAOImpl(storage); ServiceRegistration<?> reg = context.registerService(SchemaInfoDAO.class.getName(), schemaInfoDAO, null); regs.add(reg); @@ -122,7 +122,7 @@ reg = context.registerService(VmInfoDAO.class.getName(), vmInfoDao, null); regs.add(reg); - ApplicationService appService = (ApplicationService) services.get(ApplicationService.class.getName()); + ApplicationService appService = services.get(ApplicationService.class); TimerFactory timers = appService.getTimerFactory(); NetworkMonitor networkMonitor = new NetworkMonitorImpl(timers, hostInfoDao); reg = context.registerService(NetworkMonitor.class.getName(), networkMonitor, null);
--- a/system-backend/src/main/java/com/redhat/thermostat/backend/system/internal/SystemBackendActivator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/system-backend/src/main/java/com/redhat/thermostat/backend/system/internal/SystemBackendActivator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.backend.system.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -48,6 +46,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.storage.dao.HostInfoDAO; @@ -79,15 +78,14 @@ }; tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - NetworkInterfaceInfoDAO netInfoDAO = (NetworkInterfaceInfoDAO) services - .get(NetworkInterfaceInfoDAO.class.getName()); - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - UserNameUtil userNameUtil = (UserNameUtil) services.get(UserNameUtil.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + NetworkInterfaceInfoDAO netInfoDAO = services.get(NetworkInterfaceInfoDAO.class); + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + UserNameUtil userNameUtil = services.get(UserNameUtil.class); Version version = new Version(context.getBundle()); - WriterID id = (WriterID) services.get(WriterID.class.getName()); - VmBlacklist blacklist = (VmBlacklist) services.get(VmBlacklist.class.getName()); + WriterID id = services.get(WriterID.class); + VmBlacklist blacklist = services.get(VmBlacklist.class); backend = new SystemBackend(hostInfoDAO, netInfoDAO, vmInfoDAO, version, notifier, userNameUtil, id, blacklist); reg = context.registerService(Backend.class, backend, null);
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -42,6 +42,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; @@ -51,7 +52,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -78,13 +78,13 @@ private ServiceRegistration registration; @Override - public void dependenciesAvailable(Map<String, Object> services) { - ThreadCollectorFactory collectorFactory = (ThreadCollectorFactory) services.get(ThreadCollectorFactory.class.getName()); - ApplicationService applicationService = (ApplicationService) services.get(ApplicationService.class.getName()); - VmInfoDAO vmInfoDao = Objects.requireNonNull((VmInfoDAO) services.get(VmInfoDAO.class.getName())); - LockInfoDao lockInfoDao = Objects.requireNonNull((LockInfoDao) services.get(LockInfoDao.class.getName())); - ThreadViewProvider viewFactory = (ThreadViewProvider) services.get(ThreadViewProvider.class.getName()); - ProgressNotifier notifier = (ProgressNotifier) services.get(ProgressNotifier.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ThreadCollectorFactory collectorFactory = services.get(ThreadCollectorFactory.class); + ApplicationService applicationService = services.get(ApplicationService.class); + VmInfoDAO vmInfoDao = services.get(VmInfoDAO.class); + LockInfoDao lockInfoDao = services.get(LockInfoDao.class); + ThreadViewProvider viewFactory = services.get(ThreadViewProvider.class); + ProgressNotifier notifier = services.get(ProgressNotifier.class); ThreadInformationService vmInfoService = new ThreadInformationServiceImpl(applicationService,
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -39,11 +39,12 @@ import com.redhat.thermostat.client.swing.UIDefaults; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.swing.SwingThreadViewService; import java.util.ArrayList; import java.util.List; -import java.util.Map; + import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -69,9 +70,9 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { - UIDefaults uiDefaults = (UIDefaults) services.get(UIDefaults.class.getName()); + UIDefaults uiDefaults = services.get(UIDefaults.class); ServiceRegistration reg = context.registerService(ThreadViewProvider.class.getName(), new SwingThreadViewService(uiDefaults), null);
--- a/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/thread/harvester/src/main/java/com/redhat/thermostat/thread/harvester/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.thread.harvester.internal; -import java.util.Map; import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -52,6 +51,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.thread.dao.LockInfoDao; @@ -79,10 +79,9 @@ private ThreadCountBackend threadCountBackend; @Override - public void dependenciesAvailable(Map<String, Object> services) { - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); - ThreadDao dao = (ThreadDao) services.get(ThreadDao.class.getName()); - Objects.requireNonNull(dao); + public void dependenciesAvailable(DependencyProvider services) { + WriterID writerId = services.get(WriterID.class); + ThreadDao dao = services.get(ThreadDao.class); threadCountBackend = new ThreadCountBackend(dao, VERSION, VM_STATUS_REGISTRAR, writerId); registration = context.registerService(Backend.class, threadCountBackend, null); } @@ -108,10 +107,9 @@ private LockInfoBackend lockInfoBackend; @Override - public void dependenciesAvailable(Map<String, Object> services) { - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); - LockInfoDao dao = (LockInfoDao) services.get(LockInfoDao.class.getName()); - Objects.requireNonNull(dao); + public void dependenciesAvailable(DependencyProvider services) { + WriterID writerId = services.get(WriterID.class); + LockInfoDao dao = services.get(LockInfoDao.class); lockInfoBackend = new LockInfoBackend(dao, VERSION, VM_STATUS_REGISTRAR, writerId); registration = context.registerService(Backend.class, lockInfoBackend, null); } @@ -141,10 +139,10 @@ private ScheduledExecutorService executor; @Override - public void dependenciesAvailable(Map<String, Object> services) { - MXBeanConnectionPool pool = (MXBeanConnectionPool) services.get(MXBeanConnectionPool.class.getName()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); - ThreadDao threadDao = (ThreadDao) services.get(ThreadDao.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + MXBeanConnectionPool pool = services.get(MXBeanConnectionPool.class); + WriterID writerId = services.get(WriterID.class); + ThreadDao threadDao = services.get(ThreadDao.class); executor = Executors.newScheduledThreadPool(24); ThreadHarvester harvester = new ThreadHarvester(executor, pool, writerId);
--- a/vm-classstat/agent/src/main/java/com/redhat/thermostat/vm/classstat/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-classstat/agent/src/main/java/com/redhat/thermostat/vm/classstat/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.classstat.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -47,6 +45,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.classstat.common.VmClassStatDAO; @@ -70,10 +69,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmClassStatDAO vmClassStatDao = (VmClassStatDAO) services.get(VmClassStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmClassStatDAO vmClassStatDao = services.get(VmClassStatDAO.class); Version version = new Version(context.getBundle()); - WriterID id = (WriterID) services.get(WriterID.class.getName()); + WriterID id = services.get(WriterID.class); backend = new VmClassStatBackend(vmClassStatDao, version, registrar, id); reg = context.registerService(Backend.class, backend, null); }
--- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; @@ -71,13 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmClassStatDAO dao = (VmClassStatDAO) services.get(VmClassStatDAO.class.getName()); - Objects.requireNonNull(dao); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmClassStatViewProvider viewProvider = (VmClassStatViewProvider) services.get(VmClassStatViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmClassStatDAO dao = services.get(VmClassStatDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmClassStatViewProvider viewProvider = services.get(VmClassStatViewProvider.class); VmClassStatService service = new VmClassStatServiceImpl(appSvc, dao, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-compiler/agent/src/main/java/com/redhat/thermostat/vm/compiler/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-compiler/agent/src/main/java/com/redhat/thermostat/vm/compiler/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.compiler.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -47,6 +45,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.compiler.common.VmCompilerStatDao; @@ -70,10 +69,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmCompilerStatDao vmCompilerStatDao = (VmCompilerStatDao) services.get(VmCompilerStatDao.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmCompilerStatDao vmCompilerStatDao = services.get(VmCompilerStatDao.class); Version version = new Version(context.getBundle()); - WriterID id = (WriterID) services.get(WriterID.class.getName()); + WriterID id = services.get(WriterID.class); backend = new VmCompilerStatBackend(vmCompilerStatDao, version, registrar, id); reg = context.registerService(Backend.class, backend, null); }
--- a/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-compiler/client-core/src/main/java/com/redhat/thermostat/vm/compiler/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.compiler.client.core.VmCompilerStatService; import com.redhat.thermostat.vm.compiler.client.core.VmCompilerStatViewProvider; @@ -71,13 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmCompilerStatDao dao = (VmCompilerStatDao) services.get(VmCompilerStatDao.class.getName()); - Objects.requireNonNull(dao); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmCompilerStatViewProvider viewProvider = (VmCompilerStatViewProvider) services.get(VmCompilerStatViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmCompilerStatDao dao = services.get(VmCompilerStatDao.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmCompilerStatViewProvider viewProvider = services.get(VmCompilerStatViewProvider.class); VmCompilerStatService service = new VmCompilerStatServiceImpl(appSvc, dao, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-cpu/agent/src/main/java/com/redhat/thermostat/vm/cpu/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-cpu/agent/src/main/java/com/redhat/thermostat/vm/cpu/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.vm.cpu.agent.internal; -import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -49,6 +48,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.cpu.common.VmCpuStatDAO; @@ -74,10 +74,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmCpuStatDAO vmCpuStatDao = (VmCpuStatDAO) services.get(VmCpuStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmCpuStatDAO vmCpuStatDao = services.get(VmCpuStatDAO.class); Version version = new Version(context.getBundle()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); backend = new VmCpuBackend(executor, vmCpuStatDao, version, registrar, writerId); reg = context.registerService(Backend.class, backend, null); }
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; @@ -71,13 +71,10 @@ tracker = new MultipleServiceTracker(context, deps , new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmCpuStatDAO vmCpuStatDAO = (VmCpuStatDAO) services.get(VmCpuStatDAO.class.getName()); - Objects.requireNonNull(vmCpuStatDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmCpuViewProvider viewProvider = (VmCpuViewProvider) services.get(VmCpuViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmCpuStatDAO vmCpuStatDAO = services.get(VmCpuStatDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmCpuViewProvider viewProvider = services.get(VmCpuViewProvider.class); VmCpuService service = new VmCpuServiceImpl(appSvc, vmCpuStatDAO, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-find/command/src/main/java/com/redhat/thermostat/vm/find/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-find/command/src/main/java/com/redhat/thermostat/vm/find/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,6 +37,7 @@ package com.redhat.thermostat.vm.find.command.internal; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.HostInfoDAO; @@ -46,7 +47,6 @@ import org.osgi.framework.ServiceRegistration; import java.util.Hashtable; -import java.util.Map; /** * Registers the {@link FindVmCommand} with Thermostat. @@ -68,10 +68,10 @@ serviceTracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - HostInfoDAO hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); + HostInfoDAO hostInfoDAO = services.get(HostInfoDAO.class); + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); findVmCommand.setAgentInfoDAO(agentInfoDAO); findVmCommand.setHostInfoDAO(hostInfoDAO);
--- a/vm-gc/agent/src/main/java/com/redhat/thermostat/vm/gc/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-gc/agent/src/main/java/com/redhat/thermostat/vm/gc/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.gc.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -47,6 +45,7 @@ import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.gc.common.VmGcStatDAO; @@ -70,10 +69,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmGcStatDAO vmGcStatDao = (VmGcStatDAO) services.get(VmGcStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmGcStatDAO vmGcStatDao = services.get(VmGcStatDAO.class); Version version = new Version(context.getBundle()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); backend = new VmGcBackend(vmGcStatDao, version, registerer, writerId); reg = context.registerService(Backend.class, backend, null); }
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -52,6 +51,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.SystemClock; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.storage.core.VmRef; @@ -85,21 +85,14 @@ tracker = new MultipleServiceTracker(context, viewDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmMemoryStatDAO vmMemoryStatDAO = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName()); - Objects.requireNonNull(vmMemoryStatDAO); - VmGcStatDAO vmGcStatDAO = (VmGcStatDAO) services.get(VmGcStatDAO.class.getName()); - Objects.requireNonNull(vmGcStatDAO); - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - AgentInfoDAO agentInfoDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - Objects.requireNonNull(agentInfoDAO); - GCRequest gcRequest = (GCRequest) services.get(GCRequest.class.getName()); - Objects.requireNonNull(gcRequest); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmGcViewProvider viewProvider = (VmGcViewProvider) services.get(VmGcViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmMemoryStatDAO vmMemoryStatDAO = services.get(VmMemoryStatDAO.class); + VmGcStatDAO vmGcStatDAO = services.get(VmGcStatDAO.class); + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + AgentInfoDAO agentInfoDAO = services.get(AgentInfoDAO.class); + GCRequest gcRequest = services.get(GCRequest.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmGcViewProvider viewProvider = services.get(VmGcViewProvider.class); VmGcService service = new VmGcServiceImpl(appSvc, vmMemoryStatDAO, vmGcStatDAO, vmInfoDAO, agentInfoDAO, viewProvider, gcRequest); Dictionary<String, String> properties = new Hashtable<>(); @@ -123,10 +116,9 @@ issueServiceTracker = new MultipleServiceTracker(context, issueDeps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { Clock clock = new SystemClock(); - VmGcStatDAO vmGcStatDAO = - (VmGcStatDAO) Objects.requireNonNull(services.get(VmGcStatDAO.class.getName())); + VmGcStatDAO vmGcStatDAO = services.get(VmGcStatDAO.class); VmGcIssueDiagnoser service = new VmGcIssueDiagnoser(clock, vmGcStatDAO); issueServiceReg = context.registerService(IssueDiagnoser.class.getName(), service, null);
--- a/vm-gc/command/src/main/java/com/redhat/thermostat/vm/gc/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-gc/command/src/main/java/com/redhat/thermostat/vm/gc/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.vm.gc.command.internal; import java.util.Hashtable; -import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -45,6 +44,7 @@ import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.storage.dao.AgentInfoDAO; @@ -78,10 +78,10 @@ gcCommandDepsServiceTracker = new MultipleServiceTracker(context, serviceDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - GCRequest request = (GCRequest) services.get(GCRequest.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + GCRequest request = services.get(GCRequest.class); gcCommand.setServices(request, agentDao, vmInfoDAO); } @@ -100,9 +100,9 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - VmGcStatDAO vmGcStatDAO = (VmGcStatDAO) services.get(VmGcStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + VmGcStatDAO vmGcStatDAO = services.get(VmGcStatDAO.class); showGcNameCmd.setVmInfo(vmInfoDAO); showGcNameCmd.setVmGcStat(vmGcStatDAO); }
--- a/vm-heap-analysis/agent/src/main/java/com/redhat/thermostat/vm/heap/analysis/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-heap-analysis/agent/src/main/java/com/redhat/thermostat/vm/heap/analysis/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.heap.analysis.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -45,6 +43,7 @@ import com.redhat.thermostat.agent.utils.management.MXBeanConnectionPool; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; @@ -69,10 +68,10 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - HeapDAO service = (HeapDAO) services.get(HeapDAO.class.getName()); - MXBeanConnectionPool pool = (MXBeanConnectionPool) services.get(MXBeanConnectionPool.class.getName()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + HeapDAO service = services.get(HeapDAO.class); + MXBeanConnectionPool pool = services.get(MXBeanConnectionPool.class); + WriterID writerId = services.get(WriterID.class); receiver = new HeapDumpReceiver(service, pool, writerId); receivers.registerReceiver(receiver); }
--- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -51,6 +50,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumpDetailsViewProvider; @@ -89,37 +89,22 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { + public void dependenciesAvailable(DependencyProvider services) { - ProgressNotifier notifier = (ProgressNotifier) services.get(ProgressNotifier.class.getName()); - Objects.requireNonNull(notifier); + ProgressNotifier notifier = services.get(ProgressNotifier.class); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmInfoDAO vmInfoDao = Objects.requireNonNull((VmInfoDAO) services.get(VmInfoDAO.class.getName())); - VmMemoryStatDAO vmMemoryStatDao = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName()); - Objects.requireNonNull(vmMemoryStatDao); - HeapDAO heapDao = (HeapDAO) services.get(HeapDAO.class.getName()); - Objects.requireNonNull(heapDao); - HeapViewProvider viewProvider = (HeapViewProvider) services.get(HeapViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); - HeapDumpDetailsViewProvider detailsViewProvider = (HeapDumpDetailsViewProvider) services - .get(HeapDumpDetailsViewProvider.class.getName()); - Objects.requireNonNull(detailsViewProvider); - HeapHistogramViewProvider histogramViewProvider = (HeapHistogramViewProvider) services - .get(HeapHistogramViewProvider.class.getName()); - HeapTreeMapViewProvider treeMapViewProvider = (HeapTreeMapViewProvider) services - .get(HeapTreeMapViewProvider.class.getName()); - Objects.requireNonNull(histogramViewProvider); - ObjectDetailsViewProvider objectDetailsViewProvider = (ObjectDetailsViewProvider) services - .get(ObjectDetailsViewProvider.class.getName()); - Objects.requireNonNull(objectDetailsViewProvider); - ObjectRootsViewProvider objectRootsViewProvider = (ObjectRootsViewProvider) services - .get(ObjectRootsViewProvider.class.getName()); - Objects.requireNonNull(objectRootsViewProvider); + ApplicationService appSvc = services.get(ApplicationService.class); + VmInfoDAO vmInfoDao = services.get(VmInfoDAO.class); + VmMemoryStatDAO vmMemoryStatDao = services.get(VmMemoryStatDAO.class); + HeapDAO heapDao = services.get(HeapDAO.class); + HeapViewProvider viewProvider = services.get(HeapViewProvider.class); + HeapDumpDetailsViewProvider detailsViewProvider = services.get(HeapDumpDetailsViewProvider.class); + HeapHistogramViewProvider histogramViewProvider = services.get(HeapHistogramViewProvider.class); + HeapTreeMapViewProvider treeMapViewProvider = services.get(HeapTreeMapViewProvider.class); + ObjectDetailsViewProvider objectDetailsViewProvider = services.get(ObjectDetailsViewProvider.class); + ObjectRootsViewProvider objectRootsViewProvider = services.get(ObjectRootsViewProvider.class); - HeapDumpListViewProvider heapDumpListViewProvider = (HeapDumpListViewProvider) services - .get(HeapDumpListViewProvider.class.getName()); + HeapDumpListViewProvider heapDumpListViewProvider = services.get(HeapDumpListViewProvider.class); HeapDumperService service = new HeapDumperServiceImpl(appSvc, vmInfoDao, vmMemoryStatDao, heapDao, viewProvider,
--- a/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-heap-analysis/command/src/main/java/com/redhat/thermostat/vm/heap/analysis/command/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.heap.analysis.command.internal; -import java.util.Map; - import com.redhat.thermostat.common.cli.CompleterService; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; import org.osgi.framework.BundleActivator; @@ -45,6 +43,7 @@ import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; @@ -81,11 +80,11 @@ serviceTracker = new MultipleServiceTracker(context, serviceDeps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - HeapDAO heapDao = (HeapDAO) services.get(HeapDAO.class.getName()); - RequestQueue queue = (RequestQueue) services.get(RequestQueue.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmDao = services.get(VmInfoDAO.class); + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); + HeapDAO heapDao = services.get(HeapDAO.class); + RequestQueue queue = services.get(RequestQueue.class); completerService.setHeapDAO(heapDao); completerService.setVmInfoDAO(vmDao);
--- a/vm-io/agent/src/main/java/com/redhat/thermostat/vm/io/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-io/agent/src/main/java/com/redhat/thermostat/vm/io/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.vm.io.agent.internal; -import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Clock; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.SystemClock; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; @@ -75,10 +75,10 @@ }; tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmIoStatDAO vmIoStatDao = (VmIoStatDAO) services.get(VmIoStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmIoStatDAO vmIoStatDao = services.get(VmIoStatDAO.class); Version version = new Version(context.getBundle()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); Clock clock = new SystemClock(); backend = new VmIoBackend(clock, executor, version, vmIoStatDao, registrar, writerId); reg = context.registerService(Backend.class, backend, null);
--- a/vm-io/client-core/src/main/java/com/redhat/thermostat/vm/io/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-io/client-core/src/main/java/com/redhat/thermostat/vm/io/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.io.client.core.VmIoService; import com.redhat.thermostat.vm.io.client.core.VmIoViewProvider; @@ -70,13 +70,10 @@ tracker = new MultipleServiceTracker(context, deps , new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmIoStatDAO vmCpuStatDAO = (VmIoStatDAO) services.get(VmIoStatDAO.class.getName()); - Objects.requireNonNull(vmCpuStatDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmIoViewProvider viewProvider = (VmIoViewProvider) services.get(VmIoViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmIoStatDAO vmCpuStatDAO = services.get(VmIoStatDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmIoViewProvider viewProvider = services.get(VmIoViewProvider.class); VmIoService service = new VmIoServiceImpl(appSvc, vmCpuStatDAO, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-jmx/agent/src/main/java/com/redhat/thermostat/vm/jmx/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-jmx/agent/src/main/java/com/redhat/thermostat/vm/jmx/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.jmx.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -46,6 +44,7 @@ import com.redhat.thermostat.agent.utils.management.MXBeanConnectionPool; import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.jmx.common.JmxNotificationDAO; @@ -67,13 +66,13 @@ tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - MXBeanConnectionPool pool = (MXBeanConnectionPool) services.get(MXBeanConnectionPool.class.getName()); - JmxNotificationDAO dao = (JmxNotificationDAO) services.get(JmxNotificationDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + MXBeanConnectionPool pool = services.get(MXBeanConnectionPool.class); + JmxNotificationDAO dao = services.get(JmxNotificationDAO.class); Version version = new Version(context.getBundle()); ReceiverRegistry registry = new ReceiverRegistry(context); JmxRequestListener receiver = new JmxRequestListener(); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); jmxBackend = new JmxBackend(version, registry, dao, pool, receiver, writerId); receiver.setBackend(jmxBackend); registration = context.registerService(Backend.class, jmxBackend, null);
--- a/vm-jmx/client-core/src/main/java/com/redhat/thermostat/vm/jmx/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-jmx/client-core/src/main/java/com/redhat/thermostat/vm/jmx/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import com.redhat.thermostat.storage.dao.VmInfoDAO; import org.osgi.framework.BundleActivator; @@ -51,6 +50,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.AgentInfoDAO; @@ -77,14 +77,14 @@ depsTracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - AgentInfoDAO agentDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - JmxNotificationDAO notificationDao = (JmxNotificationDAO) services.get(JmxNotificationDAO.class.getName()); - JmxNotificationsViewProvider viewProvider = (JmxNotificationsViewProvider) services.get(JmxNotificationsViewProvider.class.getName()); - TimerFactory tf = ((ApplicationService) services.get(ApplicationService.class.getName())).getTimerFactory(); - RequestQueue queue = (RequestQueue) services.get(RequestQueue.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ApplicationService appSvc = services.get(ApplicationService.class); + AgentInfoDAO agentDao = services.get(AgentInfoDAO.class); + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + JmxNotificationDAO notificationDao = services.get(JmxNotificationDAO.class); + JmxNotificationsViewProvider viewProvider = services.get(JmxNotificationsViewProvider.class); + TimerFactory tf = services.get(ApplicationService.class).getTimerFactory(); + RequestQueue queue = services.get(RequestQueue.class); JmxNotificationsViewServiceImpl notificationsView = new JmxNotificationsViewServiceImpl(appSvc, agentDao, vmInfoDAO, notificationDao, queue, tf, viewProvider);
--- a/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,8 +36,6 @@ package com.redhat.thermostat.vm.memory.agent.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -48,6 +46,7 @@ import com.redhat.thermostat.backend.VmListenerBackend; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO; @@ -73,11 +72,11 @@ tracker = new MultipleServiceTracker(context, deps, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmMemoryStatDAO vmMemoryStatDao = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName()); - VmTlabStatDAO vmTlabStatDao = (VmTlabStatDAO) services.get(VmTlabStatDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmMemoryStatDAO vmMemoryStatDao = services.get(VmMemoryStatDAO.class); + VmTlabStatDAO vmTlabStatDao = services.get(VmTlabStatDAO.class); Version version = new Version(context.getBundle()); - WriterID writerId = (WriterID) services.get(WriterID.class.getName()); + WriterID writerId = services.get(WriterID.class); backend = new VmMemoryBackend(vmMemoryStatDao, vmTlabStatDao, version, registrar, writerId); reg = context.registerService(Backend.class, backend, null); }
--- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.AgentInfoDAO; @@ -85,21 +85,14 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDao); - VmMemoryStatDAO memoryStatDao = (VmMemoryStatDAO) services.get(VmMemoryStatDAO.class.getName()); - Objects.requireNonNull(memoryStatDao); - VmTlabStatDAO tlabStatDao = (VmTlabStatDAO) services.get(VmTlabStatDAO.class.getName()); - Objects.requireNonNull(tlabStatDao); - AgentInfoDAO agentDAO = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - Objects.requireNonNull(agentDAO); - GCRequest gcRequest = (GCRequest) services.get(GCRequest.class.getName()); - Objects.requireNonNull(gcRequest); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - MemoryStatsViewProvider viewProvider = (MemoryStatsViewProvider) services.get(MemoryStatsViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmInfoDao = services.get(VmInfoDAO.class); + VmMemoryStatDAO memoryStatDao = services.get(VmMemoryStatDAO.class); + VmTlabStatDAO tlabStatDao = services.get(VmTlabStatDAO.class); + AgentInfoDAO agentDAO = services.get(AgentInfoDAO.class); + GCRequest gcRequest = services.get(GCRequest.class); + ApplicationService appSvc = services.get(ApplicationService.class); + MemoryStatsViewProvider viewProvider = services.get(MemoryStatsViewProvider.class); MemoryStatsService impl = new MemoryStatsServiceImpl(appSvc, vmInfoDao, memoryStatDao, tlabStatDao, agentDAO, gcRequest, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-numa/agent/src/main/java/com/redhat/thermostat/vm/numa/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-numa/agent/src/main/java/com/redhat/thermostat/vm/numa/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,7 +36,6 @@ package com.redhat.thermostat.vm.numa.agent.internal; -import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -48,6 +47,7 @@ import com.redhat.thermostat.backend.Backend; import com.redhat.thermostat.backend.BackendService; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.Version; import com.redhat.thermostat.storage.core.WriterID; import com.redhat.thermostat.vm.numa.common.VmNumaDAO; @@ -71,10 +71,10 @@ tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmNumaDAO vmNumaDAO = (VmNumaDAO) services.get(VmNumaDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmNumaDAO vmNumaDAO = services.get(VmNumaDAO.class); Version version = new Version(context.getBundle()); - WriterID writerID = (WriterID) services.get(WriterID.class.getName()); + WriterID writerID = services.get(WriterID.class); backend = constructBackend(executor, vmNumaDAO, version, registrar, writerID); if (backend.canRegister()) { reg = context.registerService(Backend.class, backend, null);
--- a/vm-numa/client-core/src/main/java/com/redhat/thermostat/vm/numa/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-numa/client-core/src/main/java/com/redhat/thermostat/vm/numa/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -48,6 +47,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.numa.common.NumaDAO; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.vm.numa.client.core.VmNumaService; @@ -71,11 +71,11 @@ tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmNumaDAO vmNumaDAO = (VmNumaDAO) services.get(VmNumaDAO.class.getName()); - ApplicationService applicationService = (ApplicationService) services.get(ApplicationService.class.getName()); - VmNumaViewProvider vmNumaViewProvider = (VmNumaViewProvider) services.get(VmNumaViewProvider.class.getName()); - NumaDAO numaDAO = (NumaDAO) services.get(NumaDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + VmNumaDAO vmNumaDAO = services.get(VmNumaDAO.class); + ApplicationService applicationService = services.get(ApplicationService.class); + VmNumaViewProvider vmNumaViewProvider = services.get(VmNumaViewProvider.class); + NumaDAO numaDAO = services.get(NumaDAO.class); VmNumaServiceImpl vmNumaService = new VmNumaServiceImpl(applicationService, numaDAO, vmNumaDAO, vmNumaViewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -38,7 +38,6 @@ import java.util.Dictionary; import java.util.Hashtable; -import java.util.Map; import java.util.Objects; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.VmInfoDAO; import com.redhat.thermostat.vm.overview.client.core.VmOverviewService; @@ -71,13 +71,10 @@ tracker = new MultipleServiceTracker(context, deps , new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmOverviewViewProvider viewProvider = (VmOverviewViewProvider) services.get(VmOverviewViewProvider.class.getName()); - Objects.requireNonNull(viewProvider); + public void dependenciesAvailable(DependencyProvider services) { + VmInfoDAO vmInfoDAO = services.get(VmInfoDAO.class); + ApplicationService appSvc = services.get(ApplicationService.class); + VmOverviewViewProvider viewProvider = services.get(VmOverviewViewProvider.class); VmOverviewService service = new VmOverviewServiceImpl(appSvc, vmInfoDAO, viewProvider); Dictionary<String, String> properties = new Hashtable<>();
--- a/vm-profiler/agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-profiler/agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -49,6 +49,7 @@ import com.redhat.thermostat.agent.command.ReceiverRegistry; import com.redhat.thermostat.agent.utils.management.MXBeanConnectionPool; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.shared.config.CommonPaths; import com.redhat.thermostat.storage.core.WriterID; @@ -84,11 +85,11 @@ } @Override - public void dependenciesAvailable(Map<String, Object> services) { - CommonPaths path = get(CommonPaths.class, services); - MXBeanConnectionPool pool = get(MXBeanConnectionPool.class, services); - WriterID writerIdProvider = get(WriterID.class, services); - ProfileDAO dao = get(ProfileDAO.class, services); + public void dependenciesAvailable(DependencyProvider services) { + CommonPaths path = services.get(CommonPaths.class); + MXBeanConnectionPool pool = services.get(MXBeanConnectionPool.class); + WriterID writerIdProvider = services.get(WriterID.class); + ProfileDAO dao = services.get(ProfileDAO.class); String writerId = writerIdProvider.getWriterID(); final Properties configuration = new Properties(); @@ -120,9 +121,6 @@ } } - private <T> T get(Class<T> klass, Map<String, Object> services) { - return (T) services.get(klass.getName()); - } }); tracker.open();
--- a/vm-profiler/client-cli/src/main/java/com/redhat/thermostat/vm/profiler/client/cli/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-profiler/client-cli/src/main/java/com/redhat/thermostat/vm/profiler/client/cli/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.vm.profiler.client.cli.internal; import java.util.Hashtable; -import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -46,6 +45,7 @@ import com.redhat.thermostat.client.command.RequestQueue; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.common.cli.Command; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -76,14 +76,14 @@ profileVmCommandDepsTracker = new MultipleServiceTracker(context, classes, new Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - AgentInfoDAO agentInfoDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + AgentInfoDAO agentInfoDao = services.get(AgentInfoDAO.class); command.setAgentInfoDAO(agentInfoDao); - VmInfoDAO vmInfoDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); + VmInfoDAO vmInfoDao = services.get(VmInfoDAO.class); command.setVmInfoDAO(vmInfoDao); - RequestQueue requestQueue = (RequestQueue) services.get(RequestQueue.class.getName()); + RequestQueue requestQueue = services.get(RequestQueue.class); command.setRequestQueue(requestQueue); - ProfileDAO profileDao = (ProfileDAO) services.get(ProfileDAO.class.getName()); + ProfileDAO profileDao = services.get(ProfileDAO.class); command.setProfileDAO(profileDao); }
--- a/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -37,7 +37,6 @@ package com.redhat.thermostat.vm.profiler.client.swing.internal; import java.util.Hashtable; -import java.util.Map; import com.redhat.thermostat.client.swing.UIDefaults; import org.osgi.framework.BundleActivator; @@ -50,6 +49,7 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.VmRef; import com.redhat.thermostat.storage.dao.AgentInfoDAO; import com.redhat.thermostat.storage.dao.VmInfoDAO; @@ -79,17 +79,16 @@ tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - ApplicationService service = (ApplicationService) services.get(ApplicationService.class.getName()); - ProgressNotifier notifier = (ProgressNotifier) services.get(ProgressNotifier.class.getName()); - AgentInfoDAO agentInfoDao = (AgentInfoDAO) services.get(AgentInfoDAO.class.getName()); - VmInfoDAO vmInfoDao = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - ProfileDAO profileDao = (ProfileDAO) services.get(ProfileDAO.class.getName()); - RequestQueue queue = (RequestQueue) services.get(RequestQueue.class.getName()); - VmProfileTreeMapViewProvider treeMapViewProvider = (VmProfileTreeMapViewProvider) services - .get(VmProfileTreeMapViewProvider.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + ApplicationService service = services.get(ApplicationService.class); + ProgressNotifier notifier = services.get(ProgressNotifier.class); + AgentInfoDAO agentInfoDao = services.get(AgentInfoDAO.class); + VmInfoDAO vmInfoDao = services.get(VmInfoDAO.class); + ProfileDAO profileDao = services.get(ProfileDAO.class); + RequestQueue queue = services.get(RequestQueue.class); + VmProfileTreeMapViewProvider treeMapViewProvider = services.get(VmProfileTreeMapViewProvider.class); - UIDefaults uiDefaults = (UIDefaults) services.get(UIDefaults.class.getName()); + UIDefaults uiDefaults = services.get(UIDefaults.class); InformationService<VmRef> profileService = new VmProfileService(service, notifier, agentInfoDao, vmInfoDao, profileDao, queue, treeMapViewProvider, uiDefaults);
--- a/vm-profiler/common/src/main/java/com/redhat/thermostat/vm/profiler/common/internal/Activator.java Tue Oct 25 16:15:19 2016 -0400 +++ b/vm-profiler/common/src/main/java/com/redhat/thermostat/vm/profiler/common/internal/Activator.java Tue Oct 25 18:12:39 2016 -0400 @@ -36,13 +36,12 @@ package com.redhat.thermostat.vm.profiler.common.internal; -import java.util.Map; - import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import com.redhat.thermostat.common.MultipleServiceTracker; +import com.redhat.thermostat.common.MultipleServiceTracker.DependencyProvider; import com.redhat.thermostat.storage.core.Storage; import com.redhat.thermostat.vm.profiler.common.ProfileDAO; @@ -58,8 +57,8 @@ }; tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { @Override - public void dependenciesAvailable(Map<String, Object> services) { - Storage storage = (Storage) services.get(Storage.class.getName()); + public void dependenciesAvailable(DependencyProvider services) { + Storage storage = services.get(Storage.class); ProfileDAOImpl impl = new ProfileDAOImpl(storage); daoRegistration = context.registerService(ProfileDAO.class, impl, null);