ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1513878 [3/5] - in /ace/trunk: cnf/localrepo/ cnf/localrepo/org.eclipse.jetty.continuation/ cnf/localrepo/org.eclipse.jetty.http/ cnf/localrepo/org.eclipse.jetty.io/ cnf/localrepo/org.eclipse.jetty.jmx/ cnf/localrepo/org.eclipse.jetty.secu...
Date Wed, 14 Aug 2013 13:37:48 GMT
Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.continuation/org.eclipse.jetty.continuation-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.continuation/org.eclipse.jetty.continuation-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.continuation/org.eclipse.jetty.continuation-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.http/org.eclipse.jetty.http-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.http/org.eclipse.jetty.http-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.http/org.eclipse.jetty.http-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.io/org.eclipse.jetty.io-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.io/org.eclipse.jetty.io-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.io/org.eclipse.jetty.io-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.jmx/org.eclipse.jetty.jmx-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.jmx/org.eclipse.jetty.jmx-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.jmx/org.eclipse.jetty.jmx-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.security/org.eclipse.jetty.security-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.security/org.eclipse.jetty.security-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.security/org.eclipse.jetty.security-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.server/org.eclipse.jetty.server-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.server/org.eclipse.jetty.server-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.server/org.eclipse.jetty.server-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.servlet/org.eclipse.jetty.servlet-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.servlet/org.eclipse.jetty.servlet-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.servlet/org.eclipse.jetty.servlet-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ace/trunk/cnf/localrepo/org.eclipse.jetty.util/org.eclipse.jetty.util-7.6.9.jar
URL: http://svn.apache.org/viewvc/ace/trunk/cnf/localrepo/org.eclipse.jetty.util/org.eclipse.jetty.util-7.6.9.jar?rev=1513878&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ace/trunk/cnf/localrepo/org.eclipse.jetty.util/org.eclipse.jetty.util-7.6.9.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ManagementAgentTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ManagementAgentTest.java?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ManagementAgentTest.java (original)
+++ ace/trunk/org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/ManagementAgentTest.java Wed Aug 14 13:37:47 2013
@@ -18,18 +18,10 @@
  */
 package org.apache.ace.agent.itest;
 
-import java.util.Hashtable;
-import java.util.Map;
-
 import junit.framework.Assert;
 
-import org.apache.ace.agent.ManagementAgent;
-import org.apache.ace.agent.ManagementAgentFactory;
+import org.apache.ace.agent.AgentControl;
 import org.apache.ace.it.IntegrationTestBase;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
 
 /**
  * Integration test for Management Agent Configuration
@@ -37,127 +29,11 @@ import org.osgi.framework.ServiceReferen
  */
 public class ManagementAgentTest extends IntegrationTestBase {
 
-    /**
-     * One basic agent using CM API
-     * 
-     */
     public void testOneAgentConfiguration() throws Exception {
 
         // agent factory should be up
-        ManagementAgentFactory agentFactory = getService(ManagementAgentFactory.class);
-        Assert.assertNotNull(agentFactory);
-
-        assertAgentDown("007");
-
-        // configure an agent
-        Map<String, String> config = new Hashtable<String, String>();
-        config.put("verbose", "true");
-        config.put("agents", "007");
-        config.put("serverurl", "http://localhost:8080");
-        config.put("logstores", "auditlog");
-        agentFactory.updated(config);
-
-        assertAgentUp("007");
-
-        config = new Hashtable<String, String>();
-        config.put("verbose", "true");
-        agentFactory.updated(config);
-
-        assertAgentDown("007");
-    }
-
-    /**
-     * Two basic agents using static config
-     * 
-     */
-    public void testTwoAgentsConfiguration() throws Exception {
-
-        // agent factory should be up
-        ManagementAgentFactory agentFactory = getService(ManagementAgentFactory.class);
-        Assert.assertNotNull(agentFactory);
-
-        assertAgentDown("007");
-        assertAgentDown("009");
-
-        // configure an agent
-        Map<String, String> config = new Hashtable<String, String>();
-        config.put("verbose", "true");
-        config.put("agents", "007,009");
-        config.put("serverurl", "http://localhost:8080");
-        config.put("logstores", "auditlog");
-        agentFactory.updated(config);
-
-        assertAgentUp("007");
-        assertAgentUp("009");
-
-        config = new Hashtable<String, String>();
-        config.put("verbose", "true");
-        agentFactory.updated(config);
-
-        assertAgentDown("007");
-        assertAgentDown("009");
-    }
-
-    private void assertAgentUp(String agentId) throws InvalidSyntaxException {
-
-        String agentFilter = "(agent=" + agentId + ")";
-
-        ManagementAgent agent = getService(ManagementAgent.class, agentFilter);
-        assertNotNull(agent);
-
-        ServiceReference[] references = m_bundleContext.getAllServiceReferences("org.apache.ace.identification.Identification", agentFilter);
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences("org.apache.ace.discovery.Discovery", agentFilter);
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences("org.apache.ace.deployment.Deployment", agentFilter);
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences("org.apache.ace.deployment.service.DeploymentService", agentFilter);
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences("org.apache.ace.log.Log", "(&" + agentFilter + "(name=auditlog))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences("org.apache.ace.log.target.store.LogStore", "(&" + agentFilter + "(name=auditlog))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences(Runnable.class.getName(), "(&" + agentFilter + "(name=auditlog))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences(Runnable.class.getName(), "(&" + agentFilter + "(taskName=DeploymentUpdateTask))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences(Runnable.class.getName(), "(&" + agentFilter + "(taskName=DeploymentCheckTask))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-
-        references = m_bundleContext.getAllServiceReferences(Runnable.class.getName(), "(&" + agentFilter + "(taskName=LogSyncTask)(name=auditlog))");
-        assertNotNull(references);
-        assertEquals(1, references.length);
-    }
-
-    private void assertAgentDown(String agentId) throws InvalidSyntaxException {
-        String agentFilter = "(agent=" + agentId + ")";
-        ServiceReference[] references = m_bundleContext.getAllServiceReferences(ManagementAgent.class.getName(), agentFilter);
-        assertNull(references);
-    }
+        AgentControl agentControl = getService(AgentControl.class);
+        Assert.assertNotNull(agentControl);
 
-    private void restartBundle(String bsn) throws BundleException {
-        for (Bundle bundle : m_bundleContext.getBundles()) {
-            if (bundle.getSymbolicName().equals(bsn)) {
-                bundle.stop();
-                bundle.start();
-            }
-        }
     }
 }

Modified: ace/trunk/org.apache.ace.agent.launcher/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/bnd.bnd?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.agent.launcher/bnd.bnd Wed Aug 14 13:37:47 2013
@@ -1,27 +1,22 @@
--buildpath: osgi.core,\
-	org.apache.felix.framework,\
-	org.apache.ace.agent;version=latest,\
-	commons-codec,\
-	org.apache.commons.cli
-
-# Embed everything we need
-Private-Package: org.apache.ace.*;-split-package:=merge-last,\
-	org.apache.felix.*;-split-package:=merge-last,\
-	org.apache.commons.codec;-split-package:=merge-last,\
-	org.apache.commons.codec.binary;-split-package:=merge-last,\
-	org.osgi.framework.*;-split-package:=merge-last,\
-	org.osgi.util.tracker;-split-package:=merge-last,\
-	org.osgi.service.*;-split-package:=merge-last,\
-	org.apache.commons.cli
-
-# This is not a real bundle
-Import-Package: 
-
-# Include the felix defaults
-Include-Resource: default.properties=resources/felix-defaults.properties
-  
 # The Jar Main-Class header
-Main-Class: org.apache.ace.agent.launcher.Main
+Main-Class: org.apache.ace.agent.launcher.Launcher
 Bundle-Version: 1.0.0
 Bundle-Name: Apache ACE Agent launcher
 Bundle-Description: Standalone laucher that start an Apache Felix framework with an embedded ACE Agent
+
+# Include the felix defaults
+Include-Resource: @${repo;org.apache.felix.framework;4.0.3}!/default.properties,\
+    @${repo;org.apache.felix.framework;4.0.3}!/META-INF/services/*,\
+    @${repo;org.apache.felix.framework;4.0.3}!/org/*,\
+	${repo;org.apache.ace.agent;latest},\
+	resources/META-INF/services/org.apache.ace.agent.launcher.BundleProvider==META-INF/services/org.apache.ace.agent.launcher.BundleProvider
+  
+Private-Package: org.apache.ace.agent.launcher,\
+	org.apache.commons.cli,\
+	org.apache.ace.agent;-split-package:=merge-first
+
+-buildpath: osgi.core;version='[4.3,5)',\
+	org.apache.commons.cli,\
+	org.apache.ace.agent;version=latest,\
+	org.apache.ace.test;version=latest
+-sources: false

Modified: ace/trunk/org.apache.ace.agent.launcher/launch.bndrun
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/launch.bndrun?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/launch.bndrun (original)
+++ ace/trunk/org.apache.ace.agent.launcher/launch.bndrun Wed Aug 14 13:37:47 2013
@@ -9,4 +9,4 @@
 -runrequires:\
 	osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
 	osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
--resolve.effective: active
\ No newline at end of file
+-resolve.effective: active

Added: ace/trunk/org.apache.ace.agent.launcher/resources/META-INF/services/org.apache.ace.agent.launcher.BundleProvider
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/resources/META-INF/services/org.apache.ace.agent.launcher.BundleProvider?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/resources/META-INF/services/org.apache.ace.agent.launcher.BundleProvider (added)
+++ ace/trunk/org.apache.ace.agent.launcher/resources/META-INF/services/org.apache.ace.agent.launcher.BundleProvider Wed Aug 14 13:37:47 2013
@@ -0,0 +1 @@
+org.apache.ace.agent.launcher.AgentBundleProvider

Added: ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/AgentBundleProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/AgentBundleProvider.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/AgentBundleProvider.java (added)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/AgentBundleProvider.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.launcher;
+
+import java.io.InputStream;
+
+/**
+ * {@link BundleProvider} for the core agent bundle.
+ * 
+ * @see META-INF/services/org.apache.ace.agent.launcher.BundleProvider
+ * 
+ */
+public class AgentBundleProvider implements BundleProvider {
+
+    @Override
+    public String getLocation() {
+        return "org.apache.ace.agent.jar";
+    }
+
+    @Override
+    public InputStream getInputStream() {
+        return getClass().getClassLoader().getResourceAsStream("org.apache.ace.agent.jar");
+    }
+}

Added: ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/BundleProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/BundleProvider.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/BundleProvider.java (added)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/BundleProvider.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.launcher;
+
+import java.io.InputStream;
+import java.util.ServiceLoader;
+
+/**
+ * {@link ServiceLoader} interface for launcher extension bundles providers.
+ * 
+ */
+public interface BundleProvider {
+
+    /**
+     * The bundle location.
+     * 
+     * @return The location
+     */
+    String getLocation();
+
+    /**
+     * The bundle input stream
+     * 
+     * @return The input
+     */
+    InputStream getInputStream();
+}

Added: ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Launcher.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Launcher.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Launcher.java (added)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Launcher.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,353 @@
+/*
+ * 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.launcher;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.ServiceLoader;
+
+import org.apache.ace.agent.AgentControl;
+import org.apache.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A simple launcher, that launches the embedded Felix together with a management agent. Additional bundles may be
+ * installed by putting {@link BundleProvider} services on the classpath.
+ */
+public class Launcher {
+
+    public static void main(String[] args) throws Exception {
+
+        Options options = new Options();
+        options.addOption("a", "agent", true, "agentid (default handler)");
+        options.addOption("s", "serverurl", true, "serverurl (default handler");
+        options.addOption("v", "verbose", false, "verbose logging");
+        options.addOption("h", "help", false, "print this message");
+
+        CommandLineParser parser = new BasicParser();
+        CommandLine command = parser.parse(options, args);
+
+        if (command.hasOption("h")) {
+            printHelp(options);
+            return;
+        }
+
+        String[] arguments = command.getArgs();
+        if (arguments.length > 1) {
+            printHelp(options);
+        }
+
+        Map<String, String> configuration = new Hashtable<String, String>();
+
+        // first map all default properties
+        Properties defaultProperties = loadDefaultProperties();
+        for (Object key : defaultProperties.keySet()) {
+            configuration.put((String) key, defaultProperties.getProperty((String) key));
+        }
+
+        // overwrite with user properties
+        if (arguments.length == 1) {
+            Properties userProperties = loadUserProperties(arguments[0]);
+            if (userProperties != null) {
+                for (Object key : userProperties.keySet()) {
+                    configuration.put((String) key, userProperties.getProperty((String) key));
+                }
+            }
+        }
+
+        if (command.hasOption("v")) {
+            configuration.put("verbose", "true");
+        }
+
+        // // overwrite with user args
+        // if (command.hasOption("a")) {
+        // configuration.put(CONFIG_IDENTIFICATION_KEY, command.getOptionValue("a"));
+        // }
+        // if (command.hasOption("s")) {
+        // configuration.put(CONFIG_SERVERURL_KEY, command.getOptionValue("s"));
+        // }
+        // if (command.hasOption("v")) {
+        // configuration.put(CONFIG_LOGLEVEL_KEY, "DEBUG");
+        // }
+        //
+        // // set defaults
+        // if (!configuration.containsKey(CONFIG_LOGLEVEL_KEY)) {
+        // configuration.put(CONFIG_LOGLEVEL_KEY, "INFO");
+        // }
+        //
+        // // basic checks
+        // if (!configuration.containsKey(CONFIG_IDENTIFICATION_KEY)) {
+        // System.err.println("No agent specified");
+        // System.exit(1);
+        // }
+
+        new Launcher(configuration).run();
+    }
+
+    private static void printHelp(Options options) {
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp(120, "java -jar org.apache.ace.agent.launcher [options] [configurationfile]",
+            "\nApache ACE AgentLauncher\n\n", options,
+            "\n\nConfiguration file options\n\nTODO", false);
+    }
+
+    private static Properties loadDefaultProperties() throws IOException {
+        Properties properties = new Properties();
+        ClassLoader classloader = Launcher.class.getClassLoader();
+        InputStream inStream = classloader.getResourceAsStream("org/apache/ace/agent/launcher/launcher-defaults.properties");
+        try {
+
+            properties.load(inStream);
+            return properties;
+        }
+        finally {
+            inStream.close();
+        }
+    }
+
+    private static Properties loadUserProperties(String configFileArgument) throws IOException {
+        File configFile = new File(configFileArgument);
+        if (!configFile.exists() || !configFile.isFile() || !configFile.canRead()) {
+            System.err.println("Can not acces configuration file : " + configFileArgument);
+            return null;
+        }
+        Properties properties = new Properties();
+        try {
+            properties.load(new FileInputStream(configFile));
+        }
+        catch (IOException e) {
+            System.err.println("Can not load configuration file : " + configFileArgument);
+            return null;
+        }
+        return properties;
+    }
+
+    private final Map<String, String> m_configuration;
+    private final boolean m_verbose;
+
+    public Launcher(Map<String, String> configuration) {
+        m_configuration = configuration;
+        m_verbose = (m_configuration.get("verbose") != null) && Boolean.parseBoolean(m_configuration.get("verbose"));
+    }
+
+    /**
+     * Main execution logic of the launcher; Start a framework, install bundles and pass configuration to the
+     * {@link AgentFactory}.
+     * 
+     * @throws Exception on failure
+     */
+    public void run() throws Exception {
+
+        try {
+            FrameworkFactory frameworkFactory = loadFrameworkFactory();
+            Map<String, String> frameworkProperties = createFrameworkProperties();
+            if (m_verbose)
+                System.out.println("Launching OSGI framework\n factory\t: " + frameworkFactory.getClass().getName() + "\n properties\t: " + frameworkProperties);
+
+            Framework framework = frameworkFactory.newFramework(frameworkProperties);
+            BundleContext context = null;
+            framework.init();
+            context = framework.getBundleContext();
+
+            BundleProvider[] bundleFactories = loadBundleProviders();
+            if (bundleFactories != null) {
+                for (BundleProvider bundleFactory : bundleFactories) {
+                    if (m_verbose)
+                        System.out.println(" bundle\t: " + bundleFactory.getLocation());
+                    InputStream inputStream = bundleFactory.getInputStream();
+                    try {
+                        Bundle bundle = context.installBundle(bundleFactory.getLocation(), inputStream);
+                        bundle.start();
+                    }
+                    finally {
+                        inputStream.close();
+                    }
+                }
+            }
+
+            File[] bundleFiles = loadBundleFiles();
+            if (bundleFiles != null) {
+                for (File bundleFile : bundleFiles) {
+                    if (m_verbose)
+                        System.out.println(" bundle\t: " + bundleFile.getAbsolutePath());
+                    InputStream inputStream = new FileInputStream(bundleFile);
+                    try {
+                        Bundle bundle = context.installBundle(bundleFile.getAbsolutePath(), inputStream);
+                        bundle.start();
+                    }
+                    finally {
+                        inputStream.close();
+                    }
+                }
+            }
+
+            framework.start();
+
+            if (m_verbose)
+                System.out.println("Startup complete..");
+            framework.waitForStop(0);
+        }
+        catch (Exception e) {
+            System.err.println(e.getMessage());
+            e.printStackTrace();
+            System.exit(1);
+        }
+        System.exit(0);
+    }
+
+    /**
+     * Load {@link FrameworkFactory} through the {@link ServiceLoader}.
+     * 
+     * @return the first factory
+     * @throws Exception on failure
+     */
+    private FrameworkFactory loadFrameworkFactory() throws Exception {
+        ServiceLoader<FrameworkFactory> frameworkFactoryLoader = ServiceLoader.load(FrameworkFactory.class);
+        Iterator<FrameworkFactory> frameworkFactoryIterator = frameworkFactoryLoader.iterator();
+        if (!frameworkFactoryIterator.hasNext()) {
+            throw new IllegalStateException("Unable to load any FrameworkFactory");
+        }
+        return frameworkFactoryIterator.next();
+    }
+
+    /**
+     * Load bundle file specified through configuration.
+     * 
+     * @return list of files
+     * @throws Exception on failure
+     */
+    private File[] loadBundleFiles() throws Exception {
+        List<File> bundleFiles = new ArrayList<File>();
+        String bundleFileConfig = m_configuration.get("system.bundles");
+        if (bundleFileConfig != null && !bundleFileConfig.trim().equals("")) {
+            String[] bundleFileNames = bundleFileConfig.trim().split(",");
+            int i = 0;
+            for (String bundleFileName : bundleFileNames) {
+                File bundleFile = new File(bundleFileName);
+                if (!bundleFile.exists() || !bundleFile.isFile() || !bundleFile.canRead()) {
+                    throw new IllegalArgumentException("Can not access configured file: " + bundleFile.getAbsolutePath());
+                }
+                bundleFiles.add(bundleFile);
+            }
+        }
+        return bundleFiles.toArray(new File[bundleFiles.size()]);
+    }
+
+    /**
+     * Load {@link BundleProvider}s through the {@link ServiceLoader}.
+     * 
+     * @return list of providers
+     * @throws Exception on failure
+     */
+    private BundleProvider[] loadBundleProviders() throws Exception {
+        ServiceLoader<BundleProvider> bundleFactoryLoader = ServiceLoader.load(BundleProvider.class);
+        Iterator<BundleProvider> bundleFactoryIterator = bundleFactoryLoader.iterator();
+        List<BundleProvider> bundelFactoryList = new ArrayList<BundleProvider>();
+        while (bundleFactoryIterator.hasNext()) {
+            bundelFactoryList.add(bundleFactoryIterator.next());
+        }
+        return bundelFactoryList.toArray(new BundleProvider[bundelFactoryList.size()]);
+    }
+
+    /**
+     * Build the framework launch properties.
+     * 
+     * @return the launch properties
+     * @throws Exception on failure
+     */
+    private Map<String, String> createFrameworkProperties() throws Exception {
+        Map<String, String> frameworkProperties = new HashMap<String, String>();
+        for (Entry<String, String> entry : m_configuration.entrySet()) {
+            if (entry.getKey().startsWith("framework.")) {
+                String frameworkKey = entry.getKey().replaceFirst("framework.", "");
+                String frameworkValue = m_configuration.get(entry.getValue());
+                frameworkProperties.put(frameworkKey, frameworkValue);
+            }
+        }
+        getAgentApiPackageSpec();
+        String extraPackage = frameworkProperties.get(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA);
+        if (extraPackage == null || extraPackage.equals("")) {
+            frameworkProperties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, getAgentApiPackageSpec());
+        }
+        else {
+            frameworkProperties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, extraPackage + "," + getAgentApiPackageSpec());
+
+        }
+        return frameworkProperties;
+    }
+
+    /**
+     * Determines the export clause for the agent API package.
+     * 
+     * @return the export clause
+     * @throws Exception on failure
+     */
+    private String getAgentApiPackageSpec() throws IOException {
+
+        String apiPackage = AgentControl.class.getPackage().getName();
+        String apiVersion = Version.emptyVersion.toString();
+        InputStream packageInfoStream = null;
+        BufferedReader packageInfoReader = null;
+        try {
+            packageInfoStream = getClass().getClassLoader().getResourceAsStream(apiPackage.replaceAll("\\.", "/") + "/packageinfo");
+            packageInfoReader = new BufferedReader(new InputStreamReader(packageInfoStream));
+            String packageInfoLine = null;
+            while ((packageInfoLine = packageInfoReader.readLine()) != null) {
+                if (packageInfoLine.trim().startsWith("version ")) {
+                    apiVersion = packageInfoLine.trim().replaceFirst("version ", "");
+                    break;
+                }
+            }
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            if (packageInfoReader != null) {
+                packageInfoReader.close();
+            }
+            else {
+                if (packageInfoStream != null) {
+                    packageInfoStream.close();
+                }
+            }
+        }
+        return apiPackage + ";version=" + apiVersion;
+    }
+}

Modified: ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties (original)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties Wed Aug 14 13:37:47 2013
@@ -1,52 +1 @@
-
-# Apache ACE agent launcher defaults
-# 
-# This file is loaded by the launcher to provide solid defaults. The 'default' agent 
-# configuration will typically be overridden in a user specified configuration. The 
-# 'system' and 'framework' options below are expert only.
-#
-
-agents=default
-serverurl=http://localhost:8080
-logstores=auditlog
-
-#
-# Component factories
-#
-# Used to instantiate the the agent service components. These are instantiated by the management 
-# agent factory when a new agent is configured and may be specified per agent. 
-# All classes MUST be on the (system)bundle class-path.
-#
-#system.factories= org.apache.ace.agent.identification.IdentifierBasedIdentificationFactory, \
-#  	org.apache.ace.agent.discovery.PropertyBasedDiscoveryFactory,\
-#   	org.apache.ace.agent.logging.LogFactory,\
-#	org.apache.ace.agent.logging.LogStoreFactory,\
-#	org.apache.ace.agent.logging.LogSyncTaskFactory,\
-#	org.apache.ace.agent.deployment.DeploymentServiceFactory,\
-#	org.apache.ace.agent.deployment.DeploymentAdminDeployerFactory,\
-#	org.apache.ace.agent.deployment.DeploymentCheckTaskFactory,\
-#	org.apache.ace.agent.deployment.DeploymentUpdateTaskFactory,\
-#	org.apache.ace.agent.connection.ConnectionFactoryFactory
-
-#
-# Extension activators
-#
-# Additional 'extension' activators to be started at Management Agent startup. These these are 
-# handled by the management agent configuration component once, before configuring any agents. 
-# All classes MUST be on the (system)bundle class-path.
-#
-#system.activators= org.apache.ace.connectionfactory.impl.Activator, \
-#	org.apache.ace.scheduler.Activator,\
-#	org.apache.felix.deploymentadmin.Activator	
-
-#
-# Framework options 
-#
-# Additional framework specific configuration properties that are passed on at framework 
-# initialization. These are handled by the launcher itself and follow the pattern 
-# 'framework.<some.property' allowing any property to be passed on (unchecked).
-#
-
-framework.org.osgi.framework.system.packages.extra= org.osgi.service.deploymentadmin;version="1.0",\
-	org.osgi.service.deploymentadmin.spi;version="1.0"
-	
\ No newline at end of file
+#TODO
\ No newline at end of file

Modified: ace/trunk/org.apache.ace.agent/.classpath
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/.classpath?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/.classpath (original)
+++ ace/trunk/org.apache.ace.agent/.classpath Wed Aug 14 13:37:47 2013
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="test_bin" path="test"/>
 	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: ace/trunk/org.apache.ace.agent/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/bnd.bnd?rev=1513878&r1=1513877&r2=1513878&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.agent/bnd.bnd Wed Aug 14 13:37:47 2013
@@ -1,91 +1,56 @@
-Bundle-Activator: org.apache.ace.agent.impl.Activator
+Bundle-Name: Apache ACE Agent
+Bundle-Description: Implementation of the Apache ACE Agent
 Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.ace.agent.impl.Activator
 
--buildpath: osgi.core,\
-	osgi.cmpn,\
-	org.apache.felix.dependencymanager,\
+Private-Package: \
+	org.apache.ace.agent.impl,\
+    org.apache.commons.codec,\
+	org.apache.commons.codec.binary,\
+	org.apache.commons.codec.digest,\
+	org.apache.commons.codec.language,\
+	org.apache.commons.codec.net,\
 	org.apache.felix.deploymentadmin,\
-	org.apache.ace.connectionfactory;version=latest,\
-	org.apache.ace.consolelogger;version=latest,\
-	org.apache.ace.log.target;version=latest,\
-	org.apache.ace.log.target.store.impl;version=latest,\
-	org.apache.ace.range.api;version=latest,\
-	org.apache.ace.log.api;version=latest,\
-	org.apache.ace.log.listener;version=latest,\
-	org.apache.ace.discovery.api;version=latest,\
-	org.apache.ace.discovery.property;version=latest,\
-	org.apache.ace.identification.api;version=latest,\
-	org.apache.ace.identification.property;version=latest,\
-	org.apache.ace.deployment.api;version=latest,\
-	org.apache.ace.deployment.deploymentadmin;version=latest,\
-	org.apache.ace.deployment.task.base;version=latest,\
-	org.apache.ace.deployment.task;version=latest,\
-	org.apache.ace.scheduler.impl;version=latest,\
-	commons-codec;version=1.4,\
-	org.apache.ace.scheduler.api;version=latest
-
-#
-# Embedding all required api and implementation packages to ensure that the
-# Management Agent can run in any plain vanilla framework.
-#	
-Private-Package: org.apache.ace.agent.connection,\
-	org.apache.ace.agent.scheduler.impl,\
-	org.apache.ace.agent.scheduler.impl,\
+	org.apache.felix.deploymentadmin.spi,\
+	org.apache.felix.dm.impl.dependencies,\
 	org.apache.felix.dm,\
-	org.apache.felix.dm.tracker,\
-	org.apache.felix.dm.tracker,\
-	org.osgi.service.log,\
-	org.apache.ace.agent,\
-	org.apache.ace.agent.spi,\
-	org.apache.ace.deployment,\
-	org.apache.ace.log.util,\
-	org.apache.ace.deployment.service,\
-	org.apache.ace.discovery,\
-	org.apache.ace.identification,\
-	org.apache.ace.log,\
-	org.apache.ace.log.target.store,\
-	org.apache.ace.log.target.task,\
-	org.apache.ace.range,\
-	org.apache.ace.agent.identification,\
-	org.apache.ace.consolelogger,\
-	org.apache.ace.connectionfactory.impl,\
-	org.apache.ace.connectionfactory,\
-	org.apache.ace.agent.logging,\
-	org.apache.ace.agent.impl,\
-	org.apache.ace.agent.deployment,\
-	org.apache.ace.agent.discovery,\
-	org.apache.ace.log.target,\
 	org.apache.felix.dm.impl,\
-	org.apache.felix.dm.impl.dependencies,\
 	org.apache.felix.dm.impl.index,\
 	org.apache.felix.dm.impl.metatype,\
-	org.apache.felix.deploymentadmin;-split-package:=first,\
-	org.apache.felix.deploymentadmin.spi;-split-package:=first,\
-	org.osgi.service.metatype;-split-package:=first,\
-	org.osgi.util.tracker;-split-package:=first,\
-	org.apache.commons.codec;-split-package:=first,\
-	org.apache.commons.codec.binary;-split-package:=first
-	
-# 
-# Exporting deploymentadmin and (some) compendium services so resource processors 
-# can wire up to the management agent. As bnd will generate the appropriate imports
-# this should not lead to any conflicts with deployment packages.
-#
-# We could consider exposing all compendium packages by default in this way?
-#
-Export-Package: org.osgi.service.deploymentadmin;version=1.0;-split-package:=first,\
-	org.osgi.service.deploymentadmin.spi;version=1.0;-split-package:=first,\
-	org.osgi.service.event;version=1.2;-split-package:=first,\
-	org.osgi.service.log;version=1.3;-split-package:=first,\
-	org.osgi.service.useradmin;version=1.2;-split-package:=first,\
-	org.apache.ace.agent
-    
-# 
-# Make sure the apropriate imports are generated for the exported packages.
-#
-Import-Package:	\
-	!org.osgi.service.cm,\
+	org.apache.felix.dm.tracker,\
+	org.osgi.util.tracker
+
+Import-Package: \
+    !org.osgi.service.cm,\
+	!org.osgi.service.metatype,\
+	org.osgi.service.event;resolution:=optional,\
+	org.osgi.service.log;resolution:=optional,\
 	*
-		
-Bundle-Name: Apache ACE Agent
-Bundle-Description: Implementation of the Apache ACE Agent
\ No newline at end of file
+	
+Export-Package: \
+    org.apache.ace.agent,\
+	org.osgi.service.deploymentadmin;-split-package:=merge-last,\
+	org.osgi.service.deploymentadmin.spi;-split-package:=merge-last
+
+-buildpath: osgi.core;version=4.2,\
+	osgi.cmpn;version=4.2,\
+	javax.servlet;version=2.5,\
+	org.eclipse.jetty.http;version=7.6.9,\
+	org.eclipse.jetty.io;version=7.6.9,\
+	org.eclipse.jetty.jmx;version=7.6.9,\
+	org.eclipse.jetty.security;version=7.6.9,\
+	org.eclipse.jetty.server;version=7.6.9,\
+	org.eclipse.jetty.servlet;version=7.6.9,\
+	org.eclipse.jetty.util;version=7.6.9,\
+	org.eclipse.jetty.continuation;version=7.6.9.v20130131,\
+	org.apache.felix.deploymentadmin;version=0.9.4,\
+	org.easymock,\
+	org.apache.felix.dependencymanager,\
+	commons-codec;version=1.4.0
+
+-sources false
+-runfw: org.apache.felix.framework;version='[4.0.3,4.0.3]'
+-runee: JavaSE-1.6
+-runbundles: org.apache.felix.gogo.command,\
+	org.apache.felix.gogo.runtime,\
+	org.apache.felix.gogo.shell
\ No newline at end of file

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentConstants.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * Compile time constants for this package.
+ * 
+ */
+public interface AgentConstants {
+
+    /**
+     * HTTP headers name for Deployment Package size estimate.
+     */
+    String HEADER_DPSIZE = "X-ACE-DPSize";
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/AgentControl.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.List;
+
+
+/**
+ * The agent's control (service) interface. Provides control functions and access to configuration for consumers that
+ * wish to control the agent's behavior.
+ */
+public interface AgentControl {
+
+    /** access to the configuration */
+    ConfigurationHandler getConfiguration();
+
+    /** access to the feedback channels */
+    List<String> getFeedbackChannelNames();
+
+    FeedbackChannel getFeedbackChannel(String name);
+
+    DownloadHandler getDownloadHandler();
+
+    DeploymentHandler getDeploymentHandler();
+
+    // TODO
+    // AgentUpdateHandler getAgentUpdateHandler();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConfigurationHandler.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.logging.Level;
+
+/**
+ * The agent's persisted configuration. External launchers can override the default values through system properties
+ * when the agent starts. However, once a configuration value has been stored in the persisted configuration is will no
+ * longer be overwritten by system properties. This ensures a simple system restart will not override configuration set
+ * by runtime controllers.
+ */
+// TODO should we support recovery by allow config overrides through system properties or should a luancher just wip
+// the bundle cache when it requires a clean boostrap?
+public interface ConfigurationHandler {
+
+    // NOTE Configuration of the default subsystems for identification, discovery and connection handling is not part of
+    // this definition. Even though they are default implementations the are still extensions.
+
+    /**
+     * Sync interval; When sync is active it will automatically install updates and send feedback to the server. The
+     * time unit is seconds. A value of 0 or less disables the sync.
+     */
+    String CONFIG_KEY_SYNC_INTERVAL = ConfigurationHandler.class.getPackage().getName() + ".syncinterval";
+    long CONFIG_DEFAULT_SYNC_INTERVAL = 300l;
+
+    void setSyncInterval(long seconds);
+
+    long getSyncInterval();
+
+    /**
+     * SyncRetries value; When an install fails during a sync the agent can try to recover by ignoring optimization
+     * flags and potentially restarting a Deployment Package download. A value of 1 or less disables the retry behavior.
+     */
+    String CONFIG_KEY_SYNC_RETRIES = ConfigurationHandler.class.getPackage().getName() + ".syncretries";
+    int CONFIG_DEFAULT_SYNC_RETRIES = 3;
+
+    void setSyncRetries(int value);
+
+    int getSyncRetries();
+
+    /**
+     * UpdateStreaming flag; When set Deployment Packages are installed directly from the download stream reducing
+     * overhead and disk usage, but disabling resume capabilities. This strategy is of interest to highly resource
+     * constraint devices and/or system with highly reliable connectivity and no need for resume semantics.
+     */
+    String CONFIG_KEY_STREAMING_UPDATES = ConfigurationHandler.class.getPackage().getName() + ".updatestreaming";
+    boolean CONFIG_DEFAULT_UPDATE_STREAMING = false;
+
+    void setUpdateStreaming(boolean flag);
+
+    boolean getUpdateStreaming();
+
+    /**
+     * StopUnaffected flag; When set all target bundles of a Deployment Package will be restarted as part of the
+     * deployment session. Otherwise the agent tries to minimize the impact by only restarting bundles that are actually
+     * affected. Not stopping unaffected bundles reduces overhead, but may fail in complex wiring scenarios.
+     */
+    String CONFIG_KEY_STOP_UNAFFECTED = ConfigurationHandler.class.getPackage().getName() + ".stopunaffected";
+    boolean CONFIG_DEFAULT_STOP_UNAFFECTED = true; // spec behavior
+
+    void setStopUnaffected(boolean flag);
+
+    boolean getStopUnaffected();
+
+    /**
+     * FixPackages flag; When set the Agent will request the server for fix packages instead of full deployment
+     * packages. This behavior significantly reduces bandwidth consumption.
+     */
+    String CONFIG_KEY_FIX_PACKAGES = ConfigurationHandler.class.getPackage().getName() + ".fixpackages";
+    boolean CONFIG_DEFAULT_FIX_PACKAGES = true;
+
+    void setFixPackage(boolean flag);
+
+    boolean getFixPackages();
+
+    /**
+     * Log level; Logging uses standard Java logging to guarantee optimal compatibility in any standard Java
+     * environment.
+     */
+    String CONFIG_KEY_LOG_LEVEL = ConfigurationHandler.class.getPackage().getName() + ".loglevel";
+    Level CONFIG_DEFAULT_LOG_LEVEL = Level.INFO;
+
+    void setLogLevel(Level level);
+
+    Level getLogLevel();
+
+    /**
+     * Custom configuration keys; This is provided to allow a launcher to specify system properties that should be
+     * included in the persistent configuration map. The initial values of these properties are only read once when the
+     * agent starts and only stored if no value is set in the configuration map.
+     */
+    String CONFIG_KEY_EXTENSION_PROPERTIES = ConfigurationHandler.class.getPackage().getName() + ".extensionkeys";
+
+    /**
+     * Direct access to the configuration map; This is provided to allow extensions to access custom configuration
+     * properties.
+     */
+    void setMap(Map<String, String> configuration);
+
+    Map<String, String> getMap();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConnectionHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConnectionHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConnectionHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/ConnectionHandler.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Agent control delegate interface that is responsible for opening connection.
+ * 
+ */
+public interface ConnectionHandler {
+
+    /**
+     * Return a connection for the specified url.
+     * 
+     * @param url The URL
+     * @return The connection
+     * @throws IOException If opening the connection fails
+     */
+    URLConnection getConnection(URL url) throws IOException;
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DeploymentHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DeploymentHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DeploymentHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DeploymentHandler.java Wed Aug 14 13:37:47 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.SortedSet;
+
+import org.osgi.framework.Version;
+
+/**
+ * Agent control delegate interface that provides the deployment functions.
+ * 
+ */
+public interface DeploymentHandler {
+
+    /**
+     * Return the installed deployment package version for this agent.
+     * 
+     * @return The installed version, {@link Version.emptyVersion} if no packages have been installed
+     */
+    Version getInstalledVersion();
+
+    /**
+     * Return the sorted set of available deployment package versions as reported by the server.
+     * 
+     * @return The sorted set of versions, may be empty
+     * @throws RetryAfterException If the server indicates it is too busy with a Retry-After header
+     * @throws IOException If the connection to the server fails
+     */
+    SortedSet<Version> getAvailableVersions() throws RetryAfterException, IOException;
+
+    /**
+     * Return the estimated size for a deployment package as reported by the server.
+     * 
+     * @param version The version of the package
+     * @param fixPackage Request the server for a fix-package
+     * @return The estimated size in bytes, <code>-1</code> indicates the size is unknown
+     * @throws RetryAfterException If the server indicates it is too busy with a Retry-After header
+     * @throws IOException If the connection to the server fails
+     */
+    long getPackageSize(Version version, boolean fixPackage) throws RetryAfterException, IOException;
+
+    /**
+     * Returns the {@link InputStream} for a deployment package.
+     * 
+     * @param version The version of the deployment package
+     * @param fixPackage Request the server for a fix-package
+     * @return The input-stream for the deployment package
+     * @throws RetryAfterException If the server indicates it is too busy with a Retry-After header
+     * @throws IOException If the connection to the server fails
+     */
+    InputStream getInputStream(Version version, boolean fixPackage) throws RetryAfterException, IOException;
+
+    /**
+     * Return the {@link DownloadHandle} for a deployment package.
+     * 
+     * @param version The version of the deployment package
+     * @param fixPackage Request the server for a fix-package
+     * @return The download handle
+     */
+    DownloadHandle getDownloadHandle(Version version, boolean fixPackage);
+
+    /**
+     * Install a deployment package from an input stream.
+     * 
+     * @param inputStream The inputStream, not <code>null</code>
+     * @throws IOException If reading the input stream fails.
+     */
+    // TODO deployment exceptions
+    void deployPackage(InputStream inputStream) throws IOException;
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DiscoveryHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DiscoveryHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DiscoveryHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DiscoveryHandler.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import java.net.URL;
+
+/**
+ * Agent control delegate interface that is responsible for discovering servers. If the handler supports dynamic
+ * discovery or multiple URLs it should select the most appropriate candidate.
+ * 
+ */
+public interface DiscoveryHandler {
+
+    /**
+     * Return a server base URL.
+     * 
+     * @return The URL, <code>null</code> if none is available
+     */
+    URL getServerUrl();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandle.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandle.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandle.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandle.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+/**
+ * A {@link DownloadHandle} provides control over an asynchronous download and access to the resulting file when the it
+ * is completed. <br/>
+ * <br/>
+ * Consumers must consider the following rules;
+ * <ul>
+ * <li>Control methods must be called in logical order.
+ * <li>Implementations are not expected to be thread-safe.
+ * <li>Resulting files must be assumed to be transient.
+ * <ul>
+ */
+public interface DownloadHandle {
+
+    /**
+     * Size of the buffer used while downloading the content stream.
+     */
+    int DEFAULT_READBUFFER_SIZE = 1024;
+
+    /**
+     * Callback interface; when registered the progress method will be invoked while downloading the content stream for
+     * every {@link READBUFFER_SIZE} bytes.
+     */
+    interface ProgressListener {
+        /**
+         * Called while downloading the content stream.
+         * 
+         * @param contentLength The total length of the content or -1 if unknown.
+         * @param progress The number of bytes that has been received so far.
+         */
+        void progress(long contentLength, long progress);
+    }
+
+    /**
+     * Callback interface; when registered the completed method will be invoked when the download terminates for any
+     * reason.
+     * 
+     */
+    interface CompletedListener {
+        /**
+         * Called when a download terminates.
+         * 
+         * @param result The result of the download.
+         */
+        void completed(DownloadResult result);
+    }
+
+    /**
+     * Registers the progress listener.
+     * 
+     * @param listener The progress listener.
+     * @return this
+     */
+    DownloadHandle setProgressListener(ProgressListener listener);
+
+    /**
+     * Registers the completion listener.
+     * 
+     * @param listener The completion listener.
+     * @return this
+     */
+    DownloadHandle setCompletionListener(CompletedListener listener);
+
+    /**
+     * Starts the download.
+     * 
+     * @return this
+     */
+    DownloadHandle start();
+
+    /**
+     * Pauses the download.
+     * 
+     * @return this
+     */
+    DownloadHandle stop();
+
+    /**
+     * Retrieves the download result. Will wait for completion before returning.
+     * 
+     * @return The result of the download
+     */
+    DownloadResult result();
+
+    /**
+     * Releases any resources that may be held by the handle.
+     */
+    void discard();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadHandler.java Wed Aug 14 13:37:47 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;
+
+import java.net.URL;
+
+/**
+ * Service interface for a DownloadHandler component.
+ */
+public interface DownloadHandler {
+
+    /**
+     * Returns a {@link DownloadHandle} for a URL.
+     * 
+     * @param url The url
+     * @return The {@link DownloadHandle}
+     */
+    DownloadHandle getHandle(URL url);
+    
+    //TODO named handlers (resume over urls)
+    DownloadHandle getHandle(URL url, int readBufferSize);
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadResult.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadResult.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadResult.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadResult.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents the result of a download task.
+ * 
+ */
+public interface DownloadResult {
+
+    /**
+     * Returns the state of the result.
+     * 
+     * @return The state
+     */
+    DownloadState getState();
+
+    /**
+     * Returns the download file.
+     * 
+     * @return The file, <code>null</code> if the download was unsuccessful
+     */
+    //TODO inputstream
+    File getFile();
+
+    int getCode();
+    
+    Map<String, List<String>> getHeaders();
+    /**
+     * Return the cause of an unsuccessful download.
+     * 
+     * @return The cause, <code>null</code> if the download was successful
+     */
+    Throwable getCause();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadState.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadState.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadState.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/DownloadState.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+/**
+ * The state of a download handle that completed.
+ */
+public enum DownloadState {
+    /**
+     * The handle completed successfully.
+     */
+    SUCCESSFUL,
+    /**
+     * The handle completed because it was stopped.
+     */
+    STOPPED,
+    /**
+     * The handle completed due to an unrecoverable error. It can not be resumed.
+     */
+    FAILED,
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackChannel.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackChannel.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackChannel.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/FeedbackChannel.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.Map;
+
+
+/**
+ * 
+ *
+ */
+public interface FeedbackChannel {
+
+    /**
+     * Synchronizes the feedback with the current server. Ensures the server has at least as much feedback data as we
+     * do.
+     */
+    void sendFeedback() throws RetryAfterException, IOException;
+
+    /**
+     * Logs a new message to the channel.
+     * 
+     * @param type
+     * @param properties
+     */
+    void write(int type, Map<String, String> properties);
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/IdentificationHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/IdentificationHandler.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/IdentificationHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/IdentificationHandler.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+/**
+ * Agent control delegate interface that is responsible for target identification.
+ * 
+ */
+public interface IdentificationHandler {
+
+    /**
+     * Return the agent identification.
+     * 
+     * @return The identification, <code>null</code> if none is available.
+     */
+    String getIdentification();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/RetryAfterException.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+public class RetryAfterException extends Exception {
+
+    private static final long serialVersionUID = 1L;
+    private final int m_seconds;
+
+    public RetryAfterException(int seconds) {
+        super("Server too busy. Retry after " + seconds + " seconds");
+        m_seconds = seconds;
+    }
+    
+    public int getSeconds(){
+        return m_seconds;
+    }
+}

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=1513878&r1=1513877&r2=1513878&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 14 13:37:47 2013
@@ -18,75 +18,135 @@
  */
 package org.apache.ace.agent.impl;
 
-import java.util.Properties;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
 
-import org.apache.ace.agent.ManagementAgentFactory;
-import org.apache.ace.agent.scheduler.impl.Scheduler;
-import org.apache.ace.scheduler.constants.SchedulerConstants;
+import org.apache.ace.agent.AgentControl;
+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.DownloadHandler;
+import org.apache.ace.agent.IdentificationHandler;
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
-import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
 
-/**
- * OSGi {@link BundleActivator} for the Apache ACE ManagementAgent.
- * 
- */
-public class Activator extends DependencyActivatorBase {
+// TODO Decouple from DM to save 170k in agent size.
+public class Activator extends DependencyActivatorBase implements AgentContext {
+
+    private volatile ConfigurationHandler m_configurationHandler;
+    private volatile IdentificationHandler m_identificationHandler;
+    private volatile DiscoveryHandler m_discoveryHandler;
+    private volatile DeploymentHandler m_deploymentHandler;
+    private volatile DownloadHandler m_downloadHandler;
+    private volatile ConnectionHandler m_connectionHandler;
+    private volatile ScheduledExecutorService m_executorService;
+    private volatile AgentControlImpl m_agentControl;
+
+    private volatile DefaultController m_controller;
 
-    private Scheduler m_scheduler;
+    private DependencyManager m_manager;
+    private Component m_component;
 
     @Override
     public void init(BundleContext context, DependencyManager manager) throws Exception {
 
-        Properties properties = new Properties();
-        m_scheduler = new Scheduler();
-        manager.add(createComponent()
-            .setImplementation(m_scheduler)
-            .add(createServiceDependency()
-                .setService(LogService.class).setRequired(false))
-            .add(createServiceDependency()
-                .setService(Runnable.class).setRequired(false)
-                .setAutoConfig(false)
-                .setCallbacks(this, "addRunnable", "addRunnable", "removeRunnable")));
-
-        properties = new Properties();
-        ManagementAgentFactoryImpl factory = new ManagementAgentFactoryImpl();
-        manager.add(createComponent()
-            .setInterface(ManagementAgentFactory.class.getName(), properties)
-            .setImplementation(factory)
-            .add(createServiceDependency().setService(LogService.class).setRequired(false)));
+        m_manager = manager;
+
+        m_executorService = Executors.newScheduledThreadPool(1);
+        m_configurationHandler = new ConfigurationHandlerImpl(this);
+        m_deploymentHandler = new DeploymentHandlerImpl(this);
+        m_downloadHandler = new DownloadHandlerImpl(this);
+        m_agentControl = new AgentControlImpl(this);
+
+        Component service = createComponent().setImplementation(this)
+            .setCallbacks("initAgent", "startAgent", "stopAgent", "destroyAgent")
+            .setAutoConfig(DependencyManager.class, false)
+            .setAutoConfig(Component.class, false);
+
+        if (Boolean.parseBoolean(System.getProperty("agent.identificationhandler.disabled"))) {
+            service.add(createServiceDependency().setService(IdentificationHandler.class).setRequired(true));
+        }
+        else {
+            m_identificationHandler = new IdentificationHandlerImpl(this);
+        }
+
+        if (Boolean.parseBoolean(System.getProperty("agent.discoveryhandler.disabled"))) {
+            service.add(createServiceDependency().setService(DiscoveryHandler.class).setRequired(true));
+        }
+        else {
+            m_discoveryHandler = new DiscoveryHandlerImpl(this);
+        }
+
+        if (Boolean.parseBoolean(System.getProperty("agent.connectionhandler.disabled"))) {
+            service.add(createServiceDependency().setService(DiscoveryHandler.class).setRequired(true));
+        }
+        else {
+            m_connectionHandler = new ConnectionHandlerImpl(this);
+        }
 
+        if (!Boolean.parseBoolean(System.getProperty("agent.defaultcontroller.disabled"))) {
+            m_controller = new DefaultController(m_agentControl, m_executorService);
+        }
+        
+        manager.add(service);
     }
 
     @Override
     public void destroy(BundleContext context, DependencyManager manager) throws Exception {
     }
 
-    /**
-     * Handler for both adding and updating runnable service registrations.
-     * 
-     * @throws Exception
-     *             Is thrown when the <code>SCHEDULER_RECIPE</code> contained in <code>ref</code>'s service dictionary
-     *             cannot be parsed by the scheduler.
-     */
-    public void addRunnable(ServiceReference ref, Runnable task) throws Exception {
-        String name = (String) ref.getProperty(SchedulerConstants.SCHEDULER_NAME_KEY);
-        if (name != null) {
-            String description = (String) ref.getProperty(SchedulerConstants.SCHEDULER_DESCRIPTION_KEY);
-            Object recipe = ref.getProperty(SchedulerConstants.SCHEDULER_RECIPE);
-            boolean recipeOverride = Boolean.valueOf((String) ref.getProperty(SchedulerConstants.SCHEDULER_RECIPE_OVERRIDE)).booleanValue();
-            m_scheduler.addRunnable(name, task, description, recipe, recipeOverride);
-        }
+    void startAgent() throws Exception {
+        System.out.println("Starting agent!");
+        m_component = createComponent()
+            .setInterface(AgentControl.class.getName(), null)
+            .setImplementation(m_agentControl);
+        m_manager.add(m_component);
+        if (m_controller != null)
+            m_controller.start();
     }
 
-    public synchronized void removeRunnable(ServiceReference ref, Runnable task) {
-        String name = (String) ref.getProperty(SchedulerConstants.SCHEDULER_NAME_KEY);
-        if (name != null) {
-            m_scheduler.removeRunnable(name);
-        }
+    void stopAgent() throws Exception {
+        System.out.println("Stopping agent");
+        if (m_controller != null)
+            m_controller.stop();
+        m_manager.remove(m_component);
+    }
+
+    @Override
+    public IdentificationHandler getIdentificationHandler() {
+        return m_identificationHandler;
+    }
+
+    @Override
+    public DiscoveryHandler getDiscoveryHandler() {
+        return m_discoveryHandler;
+    }
+
+    @Override
+    public DeploymentHandler getDeploymentHandler() {
+        return m_deploymentHandler;
+    }
+
+    @Override
+    public ScheduledExecutorService getExecutorService() {
+        return m_executorService;
     }
 
+    @Override
+    public ConfigurationHandler getConfigurationHandler() {
+        return m_configurationHandler;
+    }
+
+    @Override
+    public ConnectionHandler getConnectionHandler() {
+        return m_connectionHandler;
+    }
+
+    @Override
+    public DownloadHandler getDownloadHandler() {
+        return m_downloadHandler;
+    }
 }

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContext.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContext.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContext.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentContext.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,45 @@
+/*
+ * 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 java.util.concurrent.ScheduledExecutorService;
+
+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.DownloadHandler;
+import org.apache.ace.agent.IdentificationHandler;
+
+public interface AgentContext {
+
+    IdentificationHandler getIdentificationHandler();
+    
+    DiscoveryHandler getDiscoveryHandler();
+
+    ConnectionHandler getConnectionHandler();
+    
+    DeploymentHandler getDeploymentHandler();
+    
+    DownloadHandler getDownloadHandler();
+    
+    ScheduledExecutorService getExecutorService();
+    
+    ConfigurationHandler getConfigurationHandler();
+}

Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java?rev=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentControlImpl.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.List;
+
+import org.apache.ace.agent.AgentControl;
+import org.apache.ace.agent.ConfigurationHandler;
+import org.apache.ace.agent.DeploymentHandler;
+import org.apache.ace.agent.DownloadHandler;
+import org.apache.ace.agent.FeedbackChannel;
+
+public class AgentControlImpl implements AgentControl {
+
+    private final AgentContext m_agentContext;
+
+    public AgentControlImpl(AgentContext agentContext) {
+        m_agentContext = agentContext;
+    }
+
+    @Override
+    public ConfigurationHandler getConfiguration() {
+        return m_agentContext.getConfigurationHandler();
+    }
+
+    @Override
+    public DownloadHandler getDownloadHandler() {
+        return m_agentContext.getDownloadHandler();
+    }
+
+    @Override
+    public DeploymentHandler getDeploymentHandler() {
+        return m_agentContext.getDeploymentHandler();
+    }
+
+    @Override
+    public List<String> getFeedbackChannelNames() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public FeedbackChannel getFeedbackChannel(String name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}

Added: 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=1513878&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java Wed Aug 14 13:37:47 2013
@@ -0,0 +1,97 @@
+/*
+ * 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 java.util.Map;
+import java.util.logging.Level;
+
+import org.apache.ace.agent.ConfigurationHandler;
+
+public class ConfigurationHandlerImpl implements ConfigurationHandler {
+
+    private final AgentContext m_agentContext;
+
+    public ConfigurationHandlerImpl(AgentContext agentContext) {
+        m_agentContext = agentContext;
+    }
+
+    @Override
+    public void setSyncInterval(long seconds) {
+    }
+
+    @Override
+    public long getSyncInterval() {
+        return 10;
+    }
+
+    @Override
+    public void setSyncRetries(int value) {
+    }
+
+    @Override
+    public int getSyncRetries() {
+        return 3;
+    }
+
+    @Override
+    public void setUpdateStreaming(boolean flag) {
+    }
+
+    @Override
+    public boolean getUpdateStreaming() {
+        return false;
+    }
+
+    @Override
+    public void setStopUnaffected(boolean flag) {
+    }
+
+    @Override
+    public boolean getStopUnaffected() {
+        return false;
+    }
+
+    @Override
+    public void setFixPackage(boolean flag) {
+    }
+
+    @Override
+    public boolean getFixPackages() {
+        return false;
+    }
+
+    @Override
+    public void setLogLevel(Level level) {
+    }
+
+    @Override
+    public Level getLogLevel() {
+        return null;
+    }
+
+    @Override
+    public void setMap(Map<String, String> configuration) {
+    }
+
+    @Override
+    public Map<String, String> getMap() {
+        return null;
+    }
+
+}



Mime
View raw message