Mercurial > hg > release > thermostat-0.5
changeset 645:b0523ce8b494
Use BackendInfoDAO as a service
Use BackendInfoDAO as an osgi service rather than through DaoFactory.
This should make it possible for third-party plugins to access
BackendInfoDAO.
Reviewed-by: rkennke
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003373.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Wed, 26 Sep 2012 19:36:51 -0400 |
parents | 21042beca200 |
children | 9088495a62bc |
files | agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java |
diffstat | 3 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java Wed Sep 26 19:36:51 2012 -0400 +++ b/agent/cli/src/main/java/com/redhat/thermostat/agent/cli/AgentApplication.java Wed Sep 26 19:36:51 2012 -0400 @@ -163,7 +163,7 @@ System.exit(Constants.EXIT_BACKEND_LOAD_ERROR); } - final Agent agent = new Agent(backendRegistry, configuration, daoFactory, daoFactory.getAgentInfoDAO()); + final Agent agent = new Agent(backendRegistry, configuration, daoFactory, daoFactory.getAgentInfoDAO(), daoFactory.getBackendInfoDAO()); try { logger.fine("Starting agent."); agent.start();
--- a/agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java Wed Sep 26 19:36:51 2012 -0400 +++ b/agent/core/src/main/java/com/redhat/thermostat/agent/Agent.java Wed Sep 26 19:36:51 2012 -0400 @@ -73,18 +73,18 @@ private BackendInfoDAO backendDao; private boolean started = false; - public Agent(BackendRegistry backendRegistry, AgentStartupConfiguration config, DAOFactory daos, AgentInfoDAO agentDao) { - this(backendRegistry, UUID.randomUUID(), config, daos, agentDao); + public Agent(BackendRegistry backendRegistry, AgentStartupConfiguration config, DAOFactory daos, AgentInfoDAO agentDao, BackendInfoDAO backendDao) { + this(backendRegistry, UUID.randomUUID(), config, daos, agentDao, backendDao); } - public Agent(BackendRegistry registry, UUID agentId, AgentStartupConfiguration config, DAOFactory daos, AgentInfoDAO agentDao) { + public Agent(BackendRegistry registry, UUID agentId, AgentStartupConfiguration config, DAOFactory daos, AgentInfoDAO agentDao, BackendInfoDAO backendDao) { this.id = agentId; this.backendRegistry = registry; this.config = config; this.storage = daos.getStorage(); this.storage.setAgentId(agentId); this.agentDao = agentDao; - this.backendDao = daos.getBackendInfoDAO(); + this.backendDao = backendDao; } private void startBackends() throws LaunchException {
--- a/agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java Wed Sep 26 19:36:51 2012 -0400 +++ b/agent/core/src/test/java/com/redhat/thermostat/agent/AgentTest.java Wed Sep 26 19:36:51 2012 -0400 @@ -85,7 +85,6 @@ backendInfoDao = mock(BackendInfoDAO.class); daos = mock(DAOFactory.class); when(daos.getStorage()).thenReturn(storage); - when(daos.getBackendInfoDAO()).thenReturn(backendInfoDao); backend = mock(Backend.class); when(backend.getName()).thenReturn("testname"); @@ -103,7 +102,7 @@ public void testStartAgent() throws Exception { // Start agent. - Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao); + Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao, backendInfoDao); agent.start(); // Verify that backend has been activated and storage received the agent information. @@ -129,7 +128,7 @@ @Test public void testStopAgentWithPurging() throws Exception { - Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao); + Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao, backendInfoDao); agent.start(); // stop agent @@ -149,7 +148,7 @@ when(config.getStartTime()).thenReturn(123L); when(config.purge()).thenReturn(false); - Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao); + Agent agent = new Agent(backendRegistry, config, daos, agentInfoDao, backendInfoDao); agent.start(); // stop agent