ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1516249 - in /ace/trunk/org.apache.ace.agent: ./ src/org/apache/ace/agent/ src/org/apache/ace/agent/impl/ test/org/apache/ace/agent/impl/ test/org/apache/ace/agent/testutil/
Date Wed, 21 Aug 2013 18:35:47 GMT
Author: bramk
Date: Wed Aug 21 18:35:46 2013
New Revision: 1516249

URL: http://svn.apache.org/r1516249
Log:
ACE-347 Internalized LogService package

Added:
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContextAware.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/HandlerBase.java
Modified:
    ace/trunk/org.apache.ace.agent/bnd.bnd
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentUpdateHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DeploymentHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/IdentificationHandlerImpl.java
    ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java
    ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DeploymentHandlerImplTest.java
    ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DiscoveryHandlerImplTest.java
    ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandlerTest.java
    ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/testutil/BaseAgentTest.java

Modified: ace/trunk/org.apache.ace.agent/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/bnd.bnd?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.agent/bnd.bnd Wed Aug 21 18:35:46 2013
@@ -23,22 +23,22 @@ Private-Package: org.apache.ace.range,\
 	org.apache.felix.dm.tracker,\
 	org.osgi.service.metatype,\
 	org.osgi.service.cm,\
+	org.osgi.service.log,\
 	org.osgi.util.tracker
 
-Import-Package: \
-    !org.osgi.service.cm,\
-	!org.osgi.service.metatype,\
-	*
-
-DynamicImport-Package: \
-	org.osgi.service.event,\
-	org.osgi.service.log
+# No wildcard import here on purpose. Are you sure the agent must 
+# require an extra external dependency? Probably not...
+Import-Package:javax.net.ssl,\
+	org.osgi.framework,\
+	org.osgi.service.packageadmin
 
+# This is a minimal set on purpose. Are you really sure the agent must 
+# expose another package? Probably not...
+# FIXME Decouple api from event admin as well
 Export-Package: org.apache.ace.agent,\
 	org.osgi.service.deploymentadmin;-split-package:=merge-last,\
 	org.osgi.service.deploymentadmin.spi;-split-package:=merge-last,\
-	org.osgi.service.event,\
-	org.osgi.service.log
+	org.osgi.service.event
 
 -buildpath: osgi.core;version=4.2,\
 	osgi.cmpn;version=4.2,\

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContext.java Wed Aug 21 18:35:46 2013
@@ -19,10 +19,10 @@
 package org.apache.ace.agent;
 
 import java.io.File;
+import java.util.Formatter;
 import java.util.concurrent.ScheduledExecutorService;
 
 import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
 
 /**
  * Internal interface that provides access to handlers, supporting services and static configuration.
@@ -94,13 +94,6 @@ public interface AgentContext {
     ScheduledExecutorService getExecutorService();
 
     /**
-     * Return the log service.
-     * 
-     * @return The service
-     */
-    LogService getLogService();
-
-    /**
      * Return the event admin.
      * 
      * @return The service
@@ -113,4 +106,88 @@ public interface AgentContext {
      * @return The directory
      */
     File getWorkDir();
+
+    /**
+     * Log a debug message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logDebug(String component, String message, Object... args);
+
+    /**
+     * Log a debug message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param cause The cause, may be <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logDebug(String component, String message, Throwable cause, Object... args);
+
+    /**
+     * Log an info message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logInfo(String component, String message, Object... args);
+
+    /**
+     * Log an info message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param cause The cause, may be <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logInfo(String component, String message, Throwable cause, Object... args);
+
+    /**
+     * Log a warning message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logWarning(String component, String message, Object... args);
+
+    /**
+     * Log a warning message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param cause The cause, may be <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logWarning(String component, String message, Throwable cause, Object... args);
+
+    /**
+     * Log an error message. If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logError(String component, String message, Object... args);
+
+    /**
+     * Log an error message.If <code>args</code> are provided the message will be processed as a format using the
+     * standard {@link Formatter}.
+     * 
+     * @param component The component identifier, not <code>null</code>
+     * @param message The log message or format, not <code>null</code>
+     * @param cause The cause, may be <code>null</code>
+     * @param args The optional formatter arguments
+     */
+    void logError(String component, String message, Throwable cause, Object... args);
 }

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContextAware.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContextAware.java?rev=1516249&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContextAware.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentContextAware.java Wed Aug 21 18:35:46 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.agent;
+
+/**
+ * Providers interface for (extension) components.
+ */
+public interface AgentContextAware {
+
+    /**
+     * Agent context started.
+     * 
+     * @param agentContext The agent context
+     * @throws Exception If the component fails to start
+     */
+    void start(AgentContext agentContext) throws Exception;
+
+    /**
+     * @throws Exception If the component fails to stop
+     */
+    void stop() throws Exception;
+}

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/Activator.java Wed Aug 21 18:35:46 2013
@@ -21,6 +21,7 @@ package org.apache.ace.agent.impl;
 import static org.apache.ace.agent.impl.ReflectionUtil.configureField;
 import static org.apache.ace.agent.impl.ReflectionUtil.invokeMethod;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -54,7 +55,7 @@ public class Activator extends Dependenc
 
     // internal delegates
     private final InternalEventAdmin m_internalEventAdmin = new InternalEventAdmin();
-    private final InternalLogService m_internalLogService = new InternalLogService();
+    private final InternalLogger m_internalLogger = new InternalLogger(1);
 
     // managed state
     private AgentContextImpl m_agentContext;
@@ -63,7 +64,6 @@ public class Activator extends Dependenc
     private AgentUpdateHandlerImpl m_agentUpdateHandler; // we use the implementation type here on purpose
     private DeploymentAdmin m_internalDeploymentAdmin;
     private Component m_agentControlComponent = null;
-    private Component m_defaultControllerComponent = null;
     private EventLoggerImpl m_eventLoggerImpl;
 
     // injected services
@@ -79,15 +79,14 @@ public class Activator extends Dependenc
         configureField(m_internalDeploymentAdmin, BundleContext.class, context);
         configureField(m_internalDeploymentAdmin, PackageAdmin.class, null);
         configureField(m_internalDeploymentAdmin, EventAdmin.class, m_internalEventAdmin);
-        configureField(m_internalDeploymentAdmin, LogService.class, m_internalLogService);
+        configureField(m_internalDeploymentAdmin, LogService.class, new InternalLogService(m_internalLogger, "deployment"));
 
-        m_agentContext = new AgentContextImpl(context.getDataFile(""));
+        m_agentContext = new AgentContextImpl(context.getDataFile(""), m_internalLogger);
         m_agentControl = new AgentControlImpl(m_agentContext);
         m_agentUpdateHandler = new AgentUpdateHandlerImpl(context);
 
         configureField(m_agentContext, AgentControl.class, m_agentControl);
         configureField(m_agentContext, EventAdmin.class, m_internalEventAdmin);
-        configureField(m_agentContext, LogService.class, m_internalLogService);
         configureField(m_agentContext, ConfigurationHandler.class, new ConfigurationHandlerImpl());
         configureField(m_agentContext, ConnectionHandler.class, new ConnectionHandlerImpl());
         configureField(m_agentContext, DeploymentHandler.class, new DeploymentHandlerImpl(m_internalDeploymentAdmin));
@@ -112,12 +111,12 @@ public class Activator extends Dependenc
 
         // FIXME fake config
         if (Boolean.parseBoolean(System.getProperty("agent.identificationhandler.disabled"))) {
-            m_internalLogService.log(LogService.LOG_INFO, "Initializing agent...");
+            m_internalLogger.logInfo("activator", "Initializing agent...", null);
             agentContextComponent.add(createServiceDependency().setService(IdentificationHandler.class).setRequired(true));
         }
         // FIXME fake config
         if (Boolean.parseBoolean(System.getProperty("agent.discoveryhandler.disabled"))) {
-            m_internalLogService.log(LogService.LOG_INFO, "Initializing agent...");
+            m_internalLogger.logInfo("activator", "Initializing agent...", null);
             agentContextComponent.add(createServiceDependency().setService(DiscoveryHandler.class).setRequired(true));
         }
         // FIXME fake config
@@ -161,30 +160,32 @@ public class Activator extends Dependenc
         }
     }
 
+    private DefaultController m_defaultController;
+
     void startAgent() throws Exception {
 
-        m_internalLogService.log(LogService.LOG_INFO, "Starting agent...");
-        invokeMethod(m_internalDeploymentAdmin, "start", new Class<?>[] {}, new Object[] {});
+        m_internalLogger.logInfo("activator", "Agent starting...", null);
 
+        m_internalLogger.logInfo("activator", "Agent starting...", null);
+        invokeMethod(m_internalDeploymentAdmin, "start", new Class<?>[] {}, new Object[] {});
         m_agentContext.start();
 
-        m_internalLogService.log(LogService.LOG_DEBUG, "* agent control service registered");
+        m_internalLogger.logInfo("activator", "Agent control service started", null);
         m_agentControlComponent = createComponent()
             .setInterface(AgentControl.class.getName(), null)
             .setImplementation(m_agentControl);
         getDependencyManager().add(m_agentControlComponent);
+
         // FIXME fake config
         if (!Boolean.parseBoolean(System.getProperty("agent.defaultcontroller.disabled"))) {
-            // FIXME move to agentcontext constructor
-            DefaultController defaultController = new DefaultController(m_agentContext);
-            m_defaultControllerComponent = createComponent()
-                .setImplementation(defaultController);
-            getDependencyManager().add(m_defaultControllerComponent);
-            m_internalLogService.log(LogService.LOG_DEBUG, "* default controller registered");
+            m_defaultController = new DefaultController();
+            m_defaultController.start(m_agentContext);
+            m_internalLogger.logInfo("activator", "Default controller started", null);
         }
         else {
-            m_internalLogService.log(LogService.LOG_DEBUG, "* default controller disabled");
+            m_internalLogger.logInfo("activator", "Default controller disabled", null);
         }
+
         // FIXME fake config
         if (!Boolean.parseBoolean(System.getProperty("agent.auditlogging.disabled"))) {
             m_eventLoggerImpl = new EventLoggerImpl(m_agentControl, getDependencyManager().getBundleContext());
@@ -192,25 +193,29 @@ public class Activator extends Dependenc
             bundleContext.addBundleListener(m_eventLoggerImpl);
             bundleContext.addFrameworkListener(m_eventLoggerImpl);
             m_internalEventAdmin.registerHandler(m_eventLoggerImpl, EventLoggerImpl.TOPICS_INTEREST);
-            m_internalLogService.log(LogService.LOG_DEBUG, "* auditlog listener registered");
+            m_internalLogger.logInfo("activator", "Audit logger started", null);
         }
         else {
-            m_internalLogService.log(LogService.LOG_DEBUG, "* auditlog listener disabled");
+            m_internalLogger.logInfo("activator", "Audit logger disabled", null);
         }
-        m_internalLogService.log(LogService.LOG_INFO, "Agent started!");
+
+        m_internalLogger.logInfo("activator", "Agent started", null);
     }
 
     void stopAgent() throws Exception {
 
-        m_internalLogService.log(LogService.LOG_INFO, "Stopping agent...");
+        m_internalLogger.logInfo("activator", "Agent stopping..", null);
+
         if (m_agentControlComponent != null) {
             getDependencyManager().remove(m_agentControlComponent);
             m_agentControlComponent = null;
         }
-        if (m_defaultControllerComponent != null) {
-            getDependencyManager().remove(m_defaultControllerComponent);
-            m_defaultControllerComponent = null;
+
+        if (m_defaultController != null) {
+            m_defaultController.stop();
+            m_defaultController = null;
         }
+
         if (m_eventLoggerImpl != null) {
             BundleContext bundleContext = getDependencyManager().getBundleContext();
             bundleContext.removeFrameworkListener(m_eventLoggerImpl);
@@ -220,7 +225,7 @@ public class Activator extends Dependenc
 
         m_agentContext.stop();
         invokeMethod(m_internalDeploymentAdmin, "stop", new Class<?>[] {}, new Object[] {});
-        m_internalLogService.log(LogService.LOG_INFO, "Agent stopped!");
+        m_internalLogger.logInfo("activator", "Agent stopped", null);
     }
 
     static class InternalEventAdmin implements EventAdmin {
@@ -272,43 +277,87 @@ public class Activator extends Dependenc
         }
     }
 
+    static class InternalLogger {
+
+        private final int m_level;
+
+        public InternalLogger(int level) {
+            m_level = level;
+        }
+
+        private void log(String level, String component, String message, Throwable exception, Object... args) {
+            if (args.length > 0)
+                message = String.format(message, args);
+            String line = String.format("[%s] %Tc (%s) %s", level, new Date(), component, message);
+            System.out.println(line);
+            if (exception != null)
+                exception.printStackTrace(System.out);
+        }
+
+        public void logDebug(String component, String message, Throwable exception, Object... args) {
+            if (m_level > 1)
+                return;
+            log("DEBUG", component, message, exception, args);
+        }
+
+        public void logInfo(String component, String message, Throwable exception, Object... args) {
+            if (m_level > 2)
+                return;
+            log("INFO", component, message, exception, args);
+        }
+
+        public void logWarning(String component, String message, Throwable exception, Object... args) {
+            if (m_level > 3)
+                return;
+            log("WARNING", component, message, exception, args);
+        }
+
+        public void logError(String component, String message, Throwable exception, Object... args) {
+            log("ERROR", component, message, exception, args);
+        }
+    }
+
     static class InternalLogService implements LogService {
 
-        private static String getName(int level) {
-            switch (level) {
-                case 1:
-                    return "[ERROR  ] ";
-                case 2:
-                    return "[WARNING] ";
-                case 3:
-                    return "[INFO   ] ";
-                case 4:
-                    return "[DEBUG  ] ";
-                default:
-                    throw new IllegalStateException("Unknown level: " + level);
-            }
+        private final InternalLogger m_logger;
+        private final String m_identifier;
+
+        public InternalLogService(InternalLogger logger, String identifier) {
+            m_logger = logger;
+            m_identifier = identifier;
         }
 
         @Override
         public void log(int level, String message) {
-            System.out.println(getName(level) + message);
+            log(level, message, null);
         }
 
         @Override
         public void log(int level, String message, Throwable exception) {
-            System.out.println(getName(level) + message);
-            exception.printStackTrace(System.out);
+            switch (level) {
+                case 1:
+                    m_logger.logDebug(m_identifier, message, exception);
+                    return;
+                case 2:
+                    m_logger.logInfo(m_identifier, message, exception);
+                    return;
+                case 3:
+                    m_logger.logWarning(m_identifier, message, exception);
+                    return;
+                default:
+                    m_logger.logError(m_identifier, message, exception);
+                    return;
+            }
         }
 
         @Override
         public void log(ServiceReference sr, int level, String message) {
-            System.out.println(getName(level) + message);
+            log(level, message, null);
         }
 
         @Override
         public void log(ServiceReference sr, int level, String message, Throwable exception) {
-            System.out.println(getName(level) + message);
-            exception.printStackTrace(System.out);
+            log(level, message, exception);
         }
     }
 

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContextImpl.java Wed Aug 21 18:35:46 2013
@@ -31,8 +31,8 @@ import org.apache.ace.agent.DeploymentHa
 import org.apache.ace.agent.DiscoveryHandler;
 import org.apache.ace.agent.DownloadHandler;
 import org.apache.ace.agent.IdentificationHandler;
+import org.apache.ace.agent.impl.Activator.InternalLogger;
 import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
 
 /**
  * Implementation of the internal agent context service.
@@ -51,12 +51,13 @@ public class AgentContextImpl implements
     private volatile AgentUpdateHandler m_agentUpdateHandler;
 
     private volatile ScheduledExecutorService m_executorService;
-    private volatile LogService m_logService;
     private volatile EventAdmin m_eventAdmin;
 
+    private final InternalLogger m_logger;
     private final File m_workDir;
 
-    public AgentContextImpl(File workDir) {
+    public AgentContextImpl(File workDir, InternalLogger logger) {
+        m_logger = logger;
         m_workDir = workDir;
     }
 
@@ -140,11 +141,6 @@ public class AgentContextImpl implements
     }
 
     @Override
-    public LogService getLogService() {
-        return m_logService;
-    }
-
-    @Override
     public EventAdmin getEventAdmin() {
         return m_eventAdmin;
     }
@@ -153,4 +149,44 @@ public class AgentContextImpl implements
     public AgentControl getAgentControl() {
         return m_agentControl;
     }
+
+    @Override
+    public void logDebug(String component, String message, Object... args) {
+        m_logger.logDebug(component, message, null,args);
+    }
+
+    @Override
+    public void logDebug(String component, String message, Throwable exception, Object... args) {
+        m_logger.logDebug(component, message, exception, args);
+    }
+
+    @Override
+    public void logInfo(String component, String message, Object... args) {
+        m_logger.logInfo(component, message, null, args);
+    }
+
+    @Override
+    public void logInfo(String component, String message, Throwable exception, Object... args) {
+        m_logger.logInfo(component, message, exception, args);
+    }
+
+    @Override
+    public void logWarning(String component, String message, Object... args) {
+        m_logger.logWarning(component, message, null, args);
+    }
+
+    @Override
+    public void logWarning(String component, String message, Throwable exception, Object... args) {
+        m_logger.logWarning(component, message, exception, args);
+    }
+
+    @Override
+    public void logError(String component, String message, Object... args) {
+        m_logger.logDebug(component, message, null, args);
+    }
+
+    @Override
+    public void logError(String component, String message, Throwable exception, Object... args) {
+        m_logger.logDebug(component, message, exception, args);
+    }
 }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentUpdateHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentUpdateHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentUpdateHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentUpdateHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -44,6 +44,9 @@ import org.osgi.util.tracker.ServiceTrac
 
 public class AgentUpdateHandlerImpl extends UpdateHandlerBase implements AgentUpdateHandler {
 
+    public static final String COMPONENT_IDENTIFIER = "agentupdate";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
     private static final int TIMEOUT = 15000;
     private static final String UPDATER_VERSION = "1.0.0";
     private static final String UPDATER_SYMBOLICNAME = "org.apache.ace.agent.updater";
@@ -51,6 +54,7 @@ public class AgentUpdateHandlerImpl exte
     private BundleContext m_bundleContext;
 
     public AgentUpdateHandlerImpl(BundleContext bundleContext) {
+        super(COMPONENT_IDENTIFIER);
         m_bundleContext = bundleContext;
     }
 

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -31,7 +31,6 @@ import java.util.Properties;
 import java.util.Set;
 
 import org.apache.ace.agent.ConfigurationHandler;
-import org.osgi.service.log.LogService;
 
 /**
  * Default configuration handler that reads the serverURL(s) from the configuration using key
@@ -39,6 +38,9 @@ import org.osgi.service.log.LogService;
  */
 public class ConfigurationHandlerImpl extends HandlerBase implements ConfigurationHandler {
 
+    public static final String COMPONENT_IDENTIFIER = "configuration";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
     /** Directory name use for storage. It is relative to the agent context work directory. */
     public static final String CONFIG_STORAGE_SUBDIR = "config";
 
@@ -47,6 +49,10 @@ public class ConfigurationHandlerImpl ex
 
     private Properties m_configProps = null;
 
+    public ConfigurationHandlerImpl() {
+        super(COMPONENT_IDENTIFIER);
+    }
+
     @Override
     public void onStart() {
         synchronized (this) {
@@ -155,7 +161,7 @@ public class ConfigurationHandlerImpl ex
             loadConfig();
         }
         catch (IOException e) {
-            getAgentContext().getLogService().log(LogService.LOG_ERROR, "Load config failed", e);
+            logError("Load config failed", e);
             throw new IllegalStateException("Load config failed", e);
         }
     }
@@ -168,7 +174,7 @@ public class ConfigurationHandlerImpl ex
             storeConfig();
         }
         catch (IOException e) {
-            getAgentContext().getLogService().log(LogService.LOG_ERROR, "Storing config failed", e);
+            logError("Storing config failed", e);
             throw new IllegalStateException("Store config failed", e);
         }
     }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConnectionHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -44,6 +44,9 @@ import org.apache.commons.codec.binary.B
  */
 public class ConnectionHandlerImpl extends HandlerBase implements ConnectionHandler {
 
+    public static final String COMPONENT_IDENTIFIER = "connection";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
     public static final String PROP_AUTHTYPE = "agent.authType";
     public static final String PROP_AUTHUSER = "agent.authUser";
     public static final String PROP_AUTHPASS = "agent.authPass";
@@ -92,6 +95,10 @@ public class ConnectionHandlerImpl exten
         }
     }
 
+    public ConnectionHandlerImpl() {
+        super(COMPONENT_IDENTIFIER);
+    }
+
     @Override
     public URLConnection getConnection(URL url) throws IOException {
         URLConnection connection = (HttpURLConnection) url.openConnection();

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DefaultController.java Wed Aug 21 18:35:46 2013
@@ -26,6 +26,7 @@ import java.util.concurrent.ScheduledFut
 import java.util.concurrent.TimeUnit;
 
 import org.apache.ace.agent.AgentContext;
+import org.apache.ace.agent.AgentContextAware;
 import org.apache.ace.agent.AgentControl;
 import org.apache.ace.agent.AgentUpdateHandler;
 import org.apache.ace.agent.ConfigurationHandler;
@@ -33,14 +34,14 @@ import org.apache.ace.agent.DeploymentHa
 import org.apache.ace.agent.FeedbackChannel;
 import org.apache.ace.agent.RetryAfterException;
 import org.osgi.framework.Version;
-import org.osgi.service.log.LogService;
 
 /**
  * Default configurable controller
  * 
  */
-public class DefaultController implements Runnable {
+public class DefaultController implements Runnable, AgentContextAware {
 
+    public static final String COMPONENT_IDENTIFIER = "controller";
     public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + ".controller";
 
     /**
@@ -90,25 +91,23 @@ public class DefaultController implement
     public static final String CONFIG_KEY_FIXPACKAGES = CONFIG_KEY_BASE + ".fixPackages";
     public static final boolean CONFIG_DEFAULT_FIXPACKAGES = true;
 
-    private final AgentContext m_agentContext;
+    private volatile AgentContext m_agentContext;
     private volatile ScheduledFuture<?> m_future;
 
-    public DefaultController(AgentContext agentContext) {
+    @Override
+    public void start(AgentContext agentContext) throws Exception {
         m_agentContext = agentContext;
-    }
 
-    public void start() {
         ConfigurationHandler configurationHandler = m_agentContext.getConfigurationHandler();
-        LogService logService = m_agentContext.getLogService();
 
         boolean disabled = configurationHandler.getBoolean(CONFIG_KEY_DISABLED, CONFIG_DEFAULT_DISABLED);
         if (disabled) {
-            logService.log(LogService.LOG_INFO, "Default controller disabled by configuration");
+            m_agentContext.logInfo(COMPONENT_IDENTIFIER, "Default controller disabled by configuration");
         }
         else {
             long delay = configurationHandler.getLong(CONFIG_KEY_SYNCDELAY, CONFIG_DEFAULT_SYNCDELAY);
             scheduleRun(delay);
-            logService.log(LogService.LOG_DEBUG, "Controller scheduled to sync in " + delay + " seconds");
+            m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Controller scheduled to sync in %d seconds", delay);
         }
     }
 
@@ -118,9 +117,8 @@ public class DefaultController implement
 
     public void run() {
         ConfigurationHandler configurationHandler = m_agentContext.getConfigurationHandler();
-        LogService logService = m_agentContext.getLogService();
 
-        logService.log(LogService.LOG_DEBUG, "Controller syncing...");
+        m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Controller syncing...");
         long interval = configurationHandler.getLong(CONFIG_KEY_SYNCINTERVAL, CONFIG_DEFAULT_SYNCINTERVAL);
         try {
             runSafeAgent();
@@ -129,23 +127,22 @@ public class DefaultController implement
         }
         catch (RetryAfterException e) {
             interval = e.getSeconds();
-            logService.log(LogService.LOG_INFO, "Sync received retry exception from server.");
+            m_agentContext.logInfo(COMPONENT_IDENTIFIER, "Sync received retry exception from server.");
         }
         catch (IOException e) {
-            logService.log(LogService.LOG_WARNING, "Sync aborted due to IOException.", e);
+            m_agentContext.logWarning(COMPONENT_IDENTIFIER, "Sync aborted due to IOException.", e);
         }
         catch (Exception e) {
-            logService.log(LogService.LOG_ERROR, "Sync aborted due to Exception.", e);
+            m_agentContext.logError(COMPONENT_IDENTIFIER, "Sync aborted due to Exception.", e);
         }
         scheduleRun(interval);
-        logService.log(LogService.LOG_DEBUG, "Sync completed. Rescheduled in " + interval + " seconds");
+        m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Sync completed. Rescheduled in %d seconds", interval);
     }
 
     private void runSafeAgent() throws RetryAfterException, IOException {
         AgentUpdateHandler deploymentHandler = m_agentContext.getAgentUpdateHandler();
-        LogService logService = m_agentContext.getLogService();
 
-        logService.log(LogService.LOG_DEBUG, "Checking for agent update");
+        m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Checking for agent update");
         Version current = deploymentHandler.getInstalledVersion();
         SortedSet<Version> available = deploymentHandler.getAvailableVersions();
         Version highest = Version.emptyVersion;
@@ -153,21 +150,20 @@ public class DefaultController implement
             highest = available.last();
         }
         if (highest.compareTo(current) > 0) {
-            logService.log(LogService.LOG_INFO, "Installing agent update " + current + " => " + highest);
+            m_agentContext.logInfo(COMPONENT_IDENTIFIER, "Installing agent update %s => %s", current, highest);
             InputStream inputStream = deploymentHandler.getInputStream(highest);
             deploymentHandler.install(inputStream);
         }
         else {
-            logService.log(LogService.LOG_DEBUG, "No agent update available for version" + current);
+            m_agentContext.logDebug(COMPONENT_IDENTIFIER, "No agent update available for version %s", current);
         }
     }
 
     private void runSafeUpdate() throws RetryAfterException, IOException {
         ConfigurationHandler configurationHandler = m_agentContext.getConfigurationHandler();
         DeploymentHandler deploymentHandler = m_agentContext.getDeploymentHandler();
-        LogService logService = m_agentContext.getLogService();
 
-        logService.log(LogService.LOG_DEBUG, "Checking for deployment update");
+        m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Checking for deployment update");
         Version current = deploymentHandler.getInstalledVersion();
         SortedSet<Version> available = deploymentHandler.getAvailableVersions();
         Version highest = Version.emptyVersion;
@@ -175,7 +171,7 @@ public class DefaultController implement
             highest = available.last();
         }
         if (highest.compareTo(current) > 0) {
-            logService.log(LogService.LOG_INFO, "Installing deployment update " + current + " => " + highest);
+            m_agentContext.logInfo(COMPONENT_IDENTIFIER, "Installing deployment update %s => %s", current, highest);
 
             // FIXME handle downloads
             // boolean streaming = configurationHandler.getBoolean(CONFIG_KEY_STREAMING_UPDATES,
@@ -190,21 +186,20 @@ public class DefaultController implement
             }
         }
         else {
-            logService.log(LogService.LOG_DEBUG, "No deployment update available for version" + current);
+            m_agentContext.logDebug(COMPONENT_IDENTIFIER, "No deployment update available for version %s", current);
         }
     }
 
     private void runSafeFeedback() throws RetryAfterException, IOException {
         AgentControl agentControl = m_agentContext.getAgentControl();
-        LogService logService = m_agentContext.getLogService();
 
-        logService.log(LogService.LOG_DEBUG, "Synchronizing feedback channels");
+        m_agentContext.logDebug(COMPONENT_IDENTIFIER, "Synchronizing feedback channels");
         List<String> channelNames = agentControl.getFeedbackChannelNames();
         for (String channelName : channelNames) {
-            logService.log(LogService.LOG_DEBUG, "Synchronizing channel: " + channelName);
             FeedbackChannel channel = agentControl.getFeedbackChannel(channelName);
-            if (channel != null)
+            if (channel != null) {
                 channel.sendFeedback();
+            }
         }
     }
 

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DeploymentHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DeploymentHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DeploymentHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DeploymentHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -34,9 +34,13 @@ import org.osgi.service.deploymentadmin.
 
 public class DeploymentHandlerImpl extends UpdateHandlerBase implements DeploymentHandler {
 
+    public static final String COMPONENT_IDENTIFIER = "deployment";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+    
     private final DeploymentAdmin m_deploymentAdmin;
 
     public DeploymentHandlerImpl(DeploymentAdmin deploymentAdmin) {
+        super(COMPONENT_IDENTIFIER);
         m_deploymentAdmin = deploymentAdmin;
     }
 

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DiscoveryHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -27,7 +27,6 @@ import java.util.Map;
 
 import org.apache.ace.agent.ConfigurationHandler;
 import org.apache.ace.agent.DiscoveryHandler;
-import org.osgi.service.log.LogService;
 
 /**
  * Default discovery handler that reads the serverURL(s) from the configuration using key {@link DISCOVERY_CONFIG_KEY}.
@@ -35,7 +34,12 @@ import org.osgi.service.log.LogService;
  */
 public class DiscoveryHandlerImpl extends HandlerBase implements DiscoveryHandler {
 
-    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + ".discovery";
+    public static final String COMPONENT_IDENTIFIER = "discovery";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
+    public DiscoveryHandlerImpl() {
+        super(COMPONENT_IDENTIFIER);
+    }
 
     /**
      * Configuration key for the default discovery handler. The value must be a comma-separated list of valid base
@@ -49,7 +53,6 @@ public class DiscoveryHandlerImpl extend
     @Override
     public URL getServerUrl() {
         ConfigurationHandler configurationHandler = getAgentContext().getConfigurationHandler();
-        LogService logService = getAgentContext().getLogService();
 
         String configValue = configurationHandler.get(CONFIG_KEY_SERVERURLS, CONFIG_DEFAULT_SERVERURLS);
         URL url = null;
@@ -64,7 +67,7 @@ public class DiscoveryHandlerImpl extend
             }
         }
         if (url == null) {
-            logService.log(LogService.LOG_WARNING, "No serverUrl available");
+            logWarning("No connectable serverUrl available");
         }
         return url;
     }
@@ -84,22 +87,21 @@ public class DiscoveryHandlerImpl extend
     private final Map<String, CheckedURL> m_checkedURLs = new HashMap<String, DiscoveryHandlerImpl.CheckedURL>();
 
     private URL checkURL(String serverURL) {
-        LogService logService = getAgentContext().getLogService();
 
         CheckedURL checked = m_checkedURLs.get(serverURL);
         if (checked != null && checked.timestamp > (System.currentTimeMillis() - CACHE_TIME)) {
-            logService.log(LogService.LOG_DEBUG, "Returning cached serverURL: " + checked.url.toExternalForm());
+            logDebug("Returning cached serverURL: " + checked.url.toExternalForm());
             return checked.url;
         }
         try {
             URL url = new URL(serverURL);
             tryConnect(url);
-            logService.log(LogService.LOG_DEBUG, "Succesfully connected to  serverURL: " + serverURL);
+            logDebug("Succesfully connected to  serverURL: %s", serverURL);
             m_checkedURLs.put(serverURL, new CheckedURL(url, System.currentTimeMillis()));
             return url;
         }
         catch (IOException e) {
-            logService.log(LogService.LOG_DEBUG, "Failed to connect to serverURL: " + serverURL);
+            logDebug("Failed to connect to serverURL: " + serverURL);
             return null;
         }
     }

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/DownloadHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -23,10 +23,16 @@ import java.util.concurrent.ExecutorServ
 
 import org.apache.ace.agent.DownloadHandle;
 import org.apache.ace.agent.DownloadHandler;
-import org.osgi.service.log.LogService;
 
 public class DownloadHandlerImpl extends HandlerBase implements DownloadHandler {
 
+    public static final String COMPONENT_IDENTIFIER = "download";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
+    public DownloadHandlerImpl() {
+        super(COMPONENT_IDENTIFIER);
+    }
+
     @Override
     public DownloadHandle getHandle(URL url) {
         return new DownloadHandleImpl(this, url);
@@ -43,16 +49,4 @@ public class DownloadHandlerImpl extends
     ExecutorService getExecutor() {
         return getAgentContext().getExecutorService();
     }
-
-    void logDebug(String message, Object... args) {
-        getAgentContext().getLogService().log(LogService.LOG_DEBUG, message);
-    }
-
-    void logInfo(String message, Object... args) {
-        getAgentContext().getLogService().log(LogService.LOG_INFO, message);
-    }
-
-    void logWarning(String message, Object... args) {
-        getAgentContext().getLogService().log(LogService.LOG_WARNING, message);
-    }
 }

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/HandlerBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/HandlerBase.java?rev=1516249&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/HandlerBase.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/HandlerBase.java Wed Aug 21 18:35:46 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.agent.impl;
+
+import org.apache.ace.agent.AgentContext;
+import org.apache.ace.agent.AgentContextAware;
+
+public abstract class HandlerBase implements AgentContextAware {
+
+    private final String m_componentIdentifier;
+    private AgentContext m_agentContext;
+
+    public HandlerBase(String handlerIdentifier) {
+        m_componentIdentifier = handlerIdentifier;
+    }
+
+    @Override
+    public final void start(AgentContext agentContext) throws Exception {
+        m_agentContext = agentContext;
+        onStart();
+    }
+
+    @Override
+    public final void stop() throws Exception {
+        m_agentContext = null;
+        onStop();
+    }
+
+    protected final AgentContext getAgentContext() {
+        if (m_agentContext == null)
+            throw new IllegalStateException("Handler is not started");
+        return m_agentContext;
+    }
+
+    protected void onStart() throws Exception {
+    }
+
+    protected void onStop() throws Exception {
+    }
+
+    protected final void logDebug(String message, Object... args) {
+        getAgentContext().logDebug(m_componentIdentifier, message, null, args);
+    }
+
+    protected final void logDebug(String message, Throwable cause, Object... args) {
+        getAgentContext().logDebug(m_componentIdentifier, message, cause, args);
+    }
+
+    protected final void logInfo(String message, Object... args) {
+        getAgentContext().logInfo(m_componentIdentifier, message, null, args);
+    }
+
+    protected final void logInfo(String message, Throwable cause, Object... args) {
+        getAgentContext().logInfo(m_componentIdentifier, message, cause, args);
+    }
+
+    protected final void logWarning(String message, Object... args) {
+        getAgentContext().logWarning(m_componentIdentifier, message, null, args);
+    }
+
+    protected final void logWarning(String message, Throwable cause, Object... args) {
+        getAgentContext().logWarning(m_componentIdentifier, message, cause, args);
+    }
+
+    protected final void logError(String message, Object... args) {
+        getAgentContext().logError(m_componentIdentifier, message, null, args);
+    }
+
+    protected final void logError(String message, Throwable cause, Object... args) {
+        getAgentContext().logError(m_componentIdentifier, message, cause, args);
+    }
+}

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/IdentificationHandlerImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/IdentificationHandlerImpl.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/IdentificationHandlerImpl.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/IdentificationHandlerImpl.java Wed Aug 21 18:35:46 2013
@@ -28,7 +28,12 @@ import org.apache.ace.agent.Identificati
  */
 public class IdentificationHandlerImpl extends HandlerBase implements IdentificationHandler {
 
-    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + ".identification";
+    public static final String COMPONENT_IDENTIFIER = "identification";
+    public static final String CONFIG_KEY_BASE = ConfigurationHandlerImpl.CONFIG_KEY_NAMESPACE + "." + COMPONENT_IDENTIFIER;
+
+    public IdentificationHandlerImpl() {
+        super(COMPONENT_IDENTIFIER);
+    }
 
     /**
      * Configuration key for the default identification handler. The value must be a single file-system and URL safe

Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/UpdateHandlerBase.java Wed Aug 21 18:35:46 2013
@@ -35,6 +35,10 @@ import org.osgi.framework.Version;
 
 public class UpdateHandlerBase extends HandlerBase {
 
+    public UpdateHandlerBase(String componentIdentifier) {
+        super(componentIdentifier);
+    }
+
     protected SortedSet<Version> getAvailableVersions(URL endpoint) throws RetryAfterException, IOException {
         SortedSet<Version> versions = new TreeSet<Version>();
         URLConnection connection = null;

Modified: ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DeploymentHandlerImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DeploymentHandlerImplTest.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DeploymentHandlerImplTest.java (original)
+++ ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DeploymentHandlerImplTest.java Wed Aug 21 18:35:46 2013
@@ -48,6 +48,7 @@ import javax.servlet.http.HttpServletRes
 import org.apache.ace.agent.AgentConstants;
 import org.apache.ace.agent.AgentContext;
 import org.apache.ace.agent.ConfigurationHandler;
+import org.apache.ace.agent.ConnectionHandler;
 import org.apache.ace.agent.DeploymentHandler;
 import org.apache.ace.agent.DiscoveryHandler;
 import org.apache.ace.agent.IdentificationHandler;
@@ -172,13 +173,13 @@ public class DeploymentHandlerImplTest e
         expect(agentContext.getDiscoveryHandler()).andReturn(discoveryHandler).anyTimes();
         expect(agentContext.getConfigurationHandler()).andReturn(configurationHandler).anyTimes();
 
-        ConnectionHandlerImpl connectionHandler = new ConnectionHandlerImpl();
-        connectionHandler.start(agentContext);
+        ConnectionHandler connectionHandler = new ConnectionHandlerImpl();
         expect(agentContext.getConnectionHandler()).andReturn(connectionHandler).anyTimes();
 
         replayTestMocks();
 
         m_deploymentHandler = new DeploymentHandlerImpl(deploymentAdmin);
+        startHandler(connectionHandler, agentContext);
         startHandler(m_deploymentHandler, agentContext);
     }
 

Modified: ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DiscoveryHandlerImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DiscoveryHandlerImplTest.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DiscoveryHandlerImplTest.java (original)
+++ ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DiscoveryHandlerImplTest.java Wed Aug 21 18:35:46 2013
@@ -72,7 +72,6 @@ public class DiscoveryHandlerImplTest ex
 
         expect(agentContext.getConfigurationHandler()).andReturn(m_configurationHandler).anyTimes();
         expect(agentContext.getConnectionHandler()).andReturn(m_connectionHandler).anyTimes();
-        expect(agentContext.getLogService()).andReturn(logService).anyTimes();
 
         replayTestMocks();
         startHandler(m_connectionHandler, agentContext);

Modified: ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandlerTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandlerTest.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandlerTest.java (original)
+++ ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/impl/DownloadHandlerTest.java Wed Aug 21 18:35:46 2013
@@ -18,10 +18,7 @@
  */
 package org.apache.ace.agent.impl;
 
-import static org.easymock.EasyMock.anyInt;
 import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.notNull;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
@@ -57,7 +54,6 @@ import org.apache.ace.agent.DownloadResu
 import org.apache.ace.agent.DownloadState;
 import org.apache.ace.agent.testutil.BaseAgentTest;
 import org.apache.ace.agent.testutil.TestWebServer;
-import org.osgi.service.log.LogService;
 import org.testng.annotations.AfterTest;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -119,11 +115,6 @@ public class DownloadHandlerTest extends
         AgentContext agentContext = addTestMock(AgentContext.class);
         expect(agentContext.getExecutorService()).andReturn(executorService).anyTimes();
 
-        LogService logService = addTestMock(LogService.class);
-        expect(agentContext.getLogService()).andReturn(logService).anyTimes();
-        logService.log(anyInt(), notNull(String.class));
-        expectLastCall().anyTimes();
-
         replayTestMocks();
         m_downloadHandler = new DownloadHandlerImpl();
         startHandler(m_downloadHandler, agentContext);

Modified: ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/testutil/BaseAgentTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/testutil/BaseAgentTest.java?rev=1516249&r1=1516248&r2=1516249&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/testutil/BaseAgentTest.java (original)
+++ ace/trunk/org.apache.ace.agent/test/org/apache/ace/agent/testutil/BaseAgentTest.java Wed Aug 21 18:35:46 2013
@@ -18,7 +18,7 @@
  */
 package org.apache.ace.agent.testutil;
 
-import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
@@ -38,7 +38,7 @@ public abstract class BaseAgentTest {
     private Set<Object> m_mocks = new HashSet<Object>();
 
     protected <T extends Object> T addTestMock(Class<T> clazz) {
-        T mock = createMock(clazz);
+        T mock = createNiceMock(clazz);
         m_mocks.add(mock);
         return mock;
     }



Mime
View raw message