You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by br...@apache.org on 2013/05/08 11:19:49 UTC
svn commit: r1480191 [2/2] - in /ace/trunk:
org.apache.ace.agent.itest/resources/
org.apache.ace.agent.itest/src/org/apache/ace/agent/itest/
org.apache.ace.agent.launcher/ org.apache.ace.agent.launcher/.settings/
org.apache.ace.agent.launcher/resources...
Added: ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Main.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Main.java?rev=1480191&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Main.java (added)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/Main.java Wed May 8 09:19:48 2013
@@ -0,0 +1,220 @@
+/*
+ * 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.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.ace.agent.Constants;
+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.apache.felix.framework.util.FelixConstants;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.service.cm.ManagedService;
+
+/**
+ * A simple launcher, that launches the embedded Felix together with a management agent.
+ */
+public class Main {
+
+ public static void main(String[] args) throws Exception {
+
+ Options options = new Options();
+ 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);
+ }
+
+ Properties defaultProperties = loadDefaultProperties();
+ Properties userProperties = null;
+ if (arguments.length == 1) {
+ userProperties = loadUserProperties(arguments[0]);
+ if (userProperties == null) {
+ printHelp(options);
+ return;
+ }
+ }
+
+ Dictionary<String, String> configuration = new Hashtable<String, String>();
+
+ // first map all default properties
+ for (Object key : defaultProperties.keySet()) {
+ configuration.put((String) key, defaultProperties.getProperty((String) key));
+ }
+
+ // overwrite with user properties
+ if (userProperties != null) {
+ for (Object key : userProperties.keySet()) {
+ configuration.put((String) key, userProperties.getProperty((String) key));
+ }
+ }
+
+ if (command.hasOption("v")) {
+ configuration.put("verbose", "true");
+ }
+
+ new Main(configuration).run();
+ }
+
+ private static void printHelp(Options options) {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.setWidth(80);
+ formatter.printHelp("java -jar org.apache.ace.agent.launcher [options] [configurationfile]", options);
+ }
+
+ private static Properties loadDefaultProperties() throws IOException {
+ Properties properties = new Properties();
+ ClassLoader classloader = Main.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 Dictionary<String, String> m_configuration;
+ private final boolean m_verbose;
+
+ public Main(Dictionary<String, String> configuration) {
+ m_configuration = configuration;
+ m_verbose = (m_configuration.get("verbose") != null) && Boolean.parseBoolean(m_configuration.get("verbose"));
+ }
+
+ public void run() throws Exception {
+
+ try {
+ Map<String, Object> frameworkProperties = createFrameworkProperties();
+ if (m_verbose)
+ System.out.println("Launching OSGi framework.. " + frameworkProperties);
+ FrameworkFactory factory = createFrameworkFactory();
+ Framework framework = factory.newFramework(frameworkProperties);
+ framework.start();
+
+ if (m_verbose)
+ System.out.println("Configuring Management Agent.. " + m_configuration);
+ BundleContext context = framework.getBundleContext();
+ ServiceReference[] references = context.getServiceReferences(ManagedService.class.getName(), "(" + org.osgi.framework.Constants.SERVICE_PID + "=" + Constants.CONFIG_PID + ")");
+ if (references != null) {
+ ManagedService service = (ManagedService) context.getService(references[0]);
+ service.updated(m_configuration);
+ context.ungetService(references[0]);
+ }
+ else {
+ System.err.println("Can not find Management Agent config service! Aborting..");
+ System.exit(1);
+ }
+
+ 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);
+ }
+
+ private FrameworkFactory createFrameworkFactory() throws Exception {
+ String factoryClass = "org.apache.felix.framework.FrameworkFactory";
+ try {
+ Class<?> clazz = Class.forName(factoryClass);
+ return (FrameworkFactory) clazz.newInstance();
+ }
+ catch (Exception e) {
+ throw new Exception("Failed to create framework factory: " + factoryClass, e);
+ }
+ }
+
+ private Map<String, Object> createFrameworkProperties() throws Exception {
+
+ Map<String, Object> frameworkProperties = new HashMap<String, Object>();
+ Enumeration<String> keyEnumeration = m_configuration.keys();
+ while (keyEnumeration.hasMoreElements()) {
+ String key = keyEnumeration.nextElement();
+ if (key.startsWith("framework.")) {
+ String frameworkKey = key.replaceFirst("framework.", "");
+ String frameworkValue = m_configuration.get(key);
+ frameworkProperties.put(frameworkKey, frameworkValue);
+ }
+ }
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ List<Object> result = new ArrayList<Object>();
+ try {
+ Object instance = cl.loadClass("org.apache.ace.agent.impl.Activator").newInstance();
+ result.add(instance);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ frameworkProperties.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, result);
+ return frameworkProperties;
+ }
+}
Added: 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=1480191&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties (added)
+++ ace/trunk/org.apache.ace.agent.launcher/src/org/apache/ace/agent/launcher/launcher-defaults.properties Wed May 8 09:19:48 2013
@@ -0,0 +1,52 @@
+
+# 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
Modified: ace/trunk/org.apache.ace.agent/README
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/README?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/README (original)
+++ ace/trunk/org.apache.ace.agent/README Wed May 8 09:19:48 2013
@@ -1,19 +1,18 @@
-Management Agent redesign (ACE-347)
+ACE Management Agent
+@see ACE-347
Notes:
* Switched to factory SPI approach for pluggability/extensions.
* Removed export package atributes / cleaned up bundle contents.
* Assembled most target specific business logic code in project.
-* Supports configuration through single config file (as well as CM api).
-* Supports clean multiple agent configuration (if we want to keep it).
+* Supports configuration through single (multi-agent) configuration.
TODOs:
* Cleanup assembled code and parent projects
* More config options
* More (i)testing
- * Create launcher project
* Create run-agent project
- * Replace ace executor with a executorservice
\ No newline at end of file
+ * Replace ace executor with a executorservice?
\ No newline at end of file
Modified: ace/trunk/org.apache.ace.agent/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/bnd.bnd?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.agent/bnd.bnd Wed May 8 09:19:48 2013
@@ -32,7 +32,6 @@ Private-Package: org.apache.ace.agent.co
org.apache.felix.dm,\
org.apache.felix.dm.tracker,\
org.apache.felix.dm.tracker,\
- org.apache.ace.agent.spi,\
org.osgi.service.log,\
org.osgi.service.useradmin,\
org.apache.ace.agent,\
@@ -81,5 +80,6 @@ Export-Package: org.osgi.service.deploym
org.apache.ace.agent
#
+# Make sure the apropriate imports are generated for the exported packages.
#
-Import-Package: *
\ No newline at end of file
+Import-Package: *
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/Constants.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/Constants.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/Constants.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/Constants.java Wed May 8 09:19:48 2013
@@ -18,11 +18,31 @@
*/
package org.apache.ace.agent;
+import org.apache.ace.agent.impl.AgentFactory;
+
/**
* Compile time constants for the bundle. Only located in the API package for development time visbility.
*
*/
public interface Constants {
- String FACTORY_PID = "org.apache.ace.managementagent.factory";
+ /**
+ * Configuration PID for the {@link AgentFactory}
+ */
+ String FACTORY_PID = "org.apache.ace.agent.factory";
+
+ /**
+ * Configuration PID for the {@link ConfigurationHandler}
+ */
+ String CONFIG_PID = "org.apache.ace.agent.config";
+
+ /**
+ * Configuration key for the list of component factories.
+ */
+ String CONFIG_FACTORIES_KEY = "system.factories";
+
+ /**
+ * Configuration key for the list of extensions activators.
+ */
+ String CONFIG_ACTIVATORS_KEY = "system.activators";
}
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/connection/ConnectionFactoryFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/connection/ConnectionFactoryFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/connection/ConnectionFactoryFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/connection/ConnectionFactoryFactory.java Wed May 8 09:19:48 2013
@@ -20,7 +20,6 @@ package org.apache.ace.agent.connection;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.Map;
import java.util.Properties;
import org.apache.ace.agent.connection.UrlCredentialsFactory.MissingValueException;
@@ -51,7 +50,7 @@ public class ConnectionFactoryFactory ex
UrlCredentialsFactory.KEY_AUTH_USER_PASSWORD };
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
Properties properties = getAgentproperties(configuration);
properties.put("impl.type", "jdk");
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentAdminDeployerFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentAdminDeployerFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentAdminDeployerFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentAdminDeployerFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.deployment;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.deployment.Deployment;
@@ -36,7 +36,7 @@ import org.osgi.service.log.LogService;
public class DeploymentAdminDeployerFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
return manager.createComponent()
.setInterface(Deployment.class.getName(), getAgentproperties(configuration))
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentCheckTaskFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentCheckTaskFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentCheckTaskFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentCheckTaskFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.deployment;
-import java.util.Map;
+import java.util.Dictionary;
import java.util.Properties;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
@@ -37,7 +37,7 @@ import org.osgi.service.log.LogService;
public class DeploymentCheckTaskFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
Properties properties = getAgentproperties(configuration);
properties.put(SchedulerConstants.SCHEDULER_NAME_KEY, DeploymentCheckTask.class.getSimpleName());
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentServiceFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentServiceFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentServiceFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentServiceFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.deployment;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.connectionfactory.ConnectionFactory;
@@ -40,7 +40,7 @@ import org.osgi.service.log.LogService;
public class DeploymentServiceFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
return manager.createComponent()
.setInterface(DeploymentService.class.getName(), getAgentproperties(configuration))
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentUpdateTaskFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentUpdateTaskFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentUpdateTaskFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/deployment/DeploymentUpdateTaskFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.deployment;
-import java.util.Map;
+import java.util.Dictionary;
import java.util.Properties;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
@@ -37,7 +37,7 @@ import org.osgi.service.log.LogService;
public class DeploymentUpdateTaskFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
Properties properties = getAgentproperties(configuration);
properties.put(SchedulerConstants.SCHEDULER_NAME_KEY, DeploymentUpdateTask.class.getSimpleName());
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/discovery/PropertyBasedDiscoveryFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/discovery/PropertyBasedDiscoveryFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/discovery/PropertyBasedDiscoveryFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/discovery/PropertyBasedDiscoveryFactory.java Wed May 8 09:19:48 2013
@@ -20,7 +20,7 @@ package org.apache.ace.agent.discovery;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.discovery.Discovery;
@@ -40,7 +40,7 @@ public class PropertyBasedDiscoveryFacto
public static final String DISCOVERY_PROPERTY_VALUE = "serverurl";
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
final String urlStr = (String) configuration.get(DISCOVERY_PROPERTY_VALUE);
if (urlStr == null || urlStr.equals("")) {
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/IdentifierBasedIdentificationFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/IdentifierBasedIdentificationFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/IdentifierBasedIdentificationFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/IdentifierBasedIdentificationFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.identification;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.identification.Identification;
@@ -35,7 +35,7 @@ import org.osgi.service.log.LogService;
public class IdentifierBasedIdentificationFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) {
final String value = getAgentIdentifier(configuration);
Identification impl = new Identification() {
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/PropertyBasedIdentificationFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/PropertyBasedIdentificationFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/PropertyBasedIdentificationFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/PropertyBasedIdentificationFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.identification;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.discovery.Discovery;
@@ -39,7 +39,7 @@ public class PropertyBasedIdentification
public static final String IDENTIFICATION_PROPERTY_VALUE = "identification";
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
final String value = configuration.get(IDENTIFICATION_PROPERTY_VALUE);
if (value == null || value.equals("")) {
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/ifconfigBasedIdentificationFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/ifconfigBasedIdentificationFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/ifconfigBasedIdentificationFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/identification/ifconfigBasedIdentificationFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.identification;
-import java.util.Map;
+import java.util.Dictionary;
import org.apache.ace.agent.spi.OneComponentFactoryBase;
import org.apache.ace.identification.Identification;
@@ -34,7 +34,7 @@ import org.osgi.service.log.LogService;
public class ifconfigBasedIdentificationFactory extends OneComponentFactoryBase {
@Override
- public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) {
+ public Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) {
Identification impl = new IfconfigIdentification();
return manager.createComponent()
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=1480191&r1=1480190&r2=1480191&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 May 8 09:19:48 2013
@@ -18,6 +18,7 @@
*/
package org.apache.ace.agent.impl;
+import static org.apache.ace.agent.Constants.CONFIG_PID;
import static org.apache.ace.agent.Constants.FACTORY_PID;
import java.util.Properties;
@@ -27,35 +28,32 @@ import org.apache.felix.dm.DependencyMan
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.service.cm.ManagedService;
import org.osgi.service.cm.ManagedServiceFactory;
import org.osgi.service.log.LogService;
/**
- * OSGi {@link BundleActivator} for the Apache ACE ManagementAGent.
+ * OSGi {@link BundleActivator} for the Apache ACE ManagementAgent.
*
*/
public class Activator extends DependencyActivatorBase {
- private final BundleActivator[] m_activators = new BundleActivator[] {
- new org.apache.ace.connectionfactory.impl.Activator(),
- new org.apache.ace.scheduler.Activator(),
- new org.apache.ace.consolelogger.Activator(),
- new org.apache.felix.deploymentadmin.Activator()
- };
-
@Override
public void init(BundleContext context, DependencyManager manager) throws Exception {
Properties properties = new Properties();
properties.put(Constants.SERVICE_PID, FACTORY_PID);
- ManagementAgentFactory factory = new ManagementAgentFactory();
+ AgentFactory factory = new AgentFactory();
manager.add(createComponent()
.setInterface(ManagedServiceFactory.class.getName(), properties)
.setImplementation(factory)
.add(createServiceDependency().setService(LogService.class).setRequired(false)));
- StaticConfigurationHandler handler = new StaticConfigurationHandler();
+ properties = new Properties();
+ properties.put(Constants.SERVICE_PID, CONFIG_PID);
+ ConfigurationHandler handler = new ConfigurationHandler();
manager.add(createComponent()
+ .setInterface(ManagedService.class.getName(), properties)
.setImplementation(handler)
.add(createServiceDependency().setService(ManagedServiceFactory.class, "(" + Constants.SERVICE_PID + "=" + FACTORY_PID + ")").setRequired(true))
.add(createServiceDependency().setService(LogService.class).setRequired(false)));
Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentFactory.java?rev=1480191&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentFactory.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/AgentFactory.java Wed May 8 09:19:48 2013
@@ -0,0 +1,152 @@
+/*
+ * 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.Dictionary;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.ace.agent.Constants;
+import org.apache.ace.agent.ManagementAgent;
+import org.apache.ace.agent.spi.ComponentFactory;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.log.LogService;
+
+/**
+ * Factory that handles configuration of management agents services. For every subsystem a {@link ComponentFactory} is
+ * used to instantiate the actual components. Factories can be specified through configuration using a
+ * <code><subsystem>.factory</code> property.
+ */
+public class AgentFactory implements ManagedServiceFactory {
+
+ private final Map<String, Set<Component>> m_components = new HashMap<String, Set<Component>>();
+
+ private volatile BundleContext m_context;
+ private volatile DependencyManager m_manager;
+ private volatile LogService m_logService;
+
+ @Override
+ public String getName() {
+ return AgentFactory.class.getSimpleName();
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void updated(String pid, Dictionary /* <string, String> */configuration) throws ConfigurationException {
+
+ String agent = getAgentIdentifier((Dictionary<String, String>) configuration);
+ m_logService.log(LogService.LOG_DEBUG, "Receiving updated for pid/agent : " + pid + "/" + agent);
+
+ Set<ComponentFactory> componentFactories = getComponentFactories((Dictionary<String, String>) configuration);
+ Set<Component> components = new HashSet<Component>();
+
+ for (ComponentFactory componentFactory : componentFactories) {
+ components.addAll(componentFactory.createComponents(m_context, m_manager, m_logService, (Dictionary<String, String>) configuration));
+ }
+
+ // This is kind of void but at present the only reasonable way for user-space consumers to see that we
+ // successfully configured the agent. Could be replaced by events. but this API may prove usefull in future to
+ // expose limited functionality into user-space.
+ Properties agentProperties = new Properties();
+ agentProperties.put("agent", agent);
+ Component agentComponent = m_manager.createComponent()
+ .setInterface(ManagementAgent.class.getName(), agentProperties)
+ .setImplementation(new ManagementAgent() {
+ });
+ components.add(agentComponent);
+
+ synchronized (m_components) {
+ m_components.put(pid, components);
+
+ }
+
+ for (Component component : components) {
+ m_manager.add(component);
+ }
+ }
+
+ @Override
+ public void deleted(String pid) {
+ Set<Component> deleted;
+ synchronized (m_components) {
+ deleted = m_components.remove(pid);
+ }
+ if (deleted != null) {
+ for (Component component : deleted) {
+ m_manager.remove(component);
+ }
+ }
+ }
+
+ private Set<ComponentFactory> getComponentFactories(Dictionary<String, String> configuration) throws ConfigurationException {
+
+ Set<ComponentFactory> componentFactories = new HashSet<ComponentFactory>();
+
+ String factoriesProperty = ((String) configuration.get(Constants.CONFIG_FACTORIES_KEY));
+ if (factoriesProperty != null && !factoriesProperty.equals("")) {
+ String[] componentFactoryNames = factoriesProperty.split(",");
+ for (String componentFactoryName : componentFactoryNames) {
+ ComponentFactory componentFactory = getComponentFactory(componentFactoryName.trim());
+ componentFactories.add(componentFactory);
+ }
+ }
+ return componentFactories;
+ }
+
+ private String getAgentIdentifier(Dictionary<String, String> configuration) throws ConfigurationException {
+ String agentIdentifier = ((String) configuration.get("agent"));
+ if (agentIdentifier != null) {
+ agentIdentifier = agentIdentifier.trim();
+ }
+ if (agentIdentifier == null || agentIdentifier.equals("")) {
+ throw new ConfigurationException("agent", "Updating an agent requires a valid configuration (empty name)");
+ }
+ return agentIdentifier;
+ }
+
+ private ComponentFactory getComponentFactory(String componentFactoryName) throws ConfigurationException {
+
+ try {
+ Class<?> clazz = AgentFactory.class.getClassLoader().loadClass(componentFactoryName);
+ if (!ComponentFactory.class.isAssignableFrom(clazz)) {
+ throw new ConfigurationException("factories", "Factory class does not implement ComponentFactory interface: " + componentFactoryName);
+ }
+ try {
+ Object instance = clazz.newInstance();
+ return (ComponentFactory) instance;
+ }
+ catch (InstantiationException e) {
+ throw new ConfigurationException("factories", "Factory class does not have a default constructor: " + componentFactoryName);
+ }
+ catch (IllegalAccessException e) {
+ throw new ConfigurationException("factories", "Factory class does not have a default constructor: " + componentFactoryName);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ throw new ConfigurationException("factories", "Factory class not found: " + componentFactoryName);
+ }
+ }
+}
Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandler.java?rev=1480191&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandler.java (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandler.java Wed May 8 09:19:48 2013
@@ -0,0 +1,261 @@
+/*
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.ace.agent.Constants;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.log.LogService;
+
+/**
+ * Handles management agent configuration system properties and subsequently calls
+ * {@link AgentFactory#updated(String, Dictionary)} for every agent specific configuration.
+ *
+ */
+public class ConfigurationHandler implements ManagedService {
+
+ private static final String DEFAULTS_RESOURCE = "org/apache/ace/agent/impl/agent-defaults.properties";
+
+ private final Set<BundleActivator> m_startedActivators = new HashSet<BundleActivator>();
+ private final Set<String> m_configuredAgentPIDs = new HashSet<String>();
+
+ // injected services
+ private volatile BundleContext m_context;
+ private volatile ManagedServiceFactory m_agentFactory;
+ private volatile LogService m_logService;
+
+ private volatile Dictionary<String, String> m_defaultConfiguration;
+ private volatile boolean m_verbose;
+
+ // service life-cycle
+ public void start() throws Exception {
+ m_defaultConfiguration = loadDefaultConfiguration();
+ }
+
+ public void stop() throws Exception {
+ stopConfiguredAgents();
+ stopSystemActivators();
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ @Override
+ public void updated(Dictionary/* <String, String> */configuration) throws ConfigurationException {
+
+ // CLI verbose support
+ m_verbose = (configuration.get("verbose") != null) && Boolean.parseBoolean((String) configuration.get("verbose"));
+
+ @SuppressWarnings("unchecked")
+ Dictionary<String, String> mergedConfiguration = getMergedConfiguration((Dictionary<String, String>) configuration);
+
+ stopConfiguredAgents();
+ stopSystemActivators();
+
+ startSystemActivators(mergedConfiguration);
+ startConfiguredAgents(mergedConfiguration);
+ }
+
+ private Dictionary<String, String> loadDefaultConfiguration() throws IOException {
+ Properties properties = new Properties();
+ ClassLoader classloader = getClass().getClassLoader();
+ InputStream inStream = classloader.getResourceAsStream(DEFAULTS_RESOURCE);
+ if (inStream != null) {
+ try {
+ properties.load(inStream);
+ }
+ finally {
+ inStream.close();
+ }
+ }
+ Dictionary<String, String> configuration = new Hashtable<String, String>();
+ for (Object key : properties.keySet()) {
+ configuration.put((String) key, (String) properties.getProperty((String) key));
+ }
+ return configuration;
+ }
+
+ private void startConfiguredAgents(Dictionary<String, String> configuration) throws ConfigurationException {
+
+ String agentsProperty = (String) configuration.get("agents");
+ if (agentsProperty == null || agentsProperty.equals("")) {
+ if (m_verbose)
+ System.out.println("Configuration does not specify any agents");
+ m_logService.log(LogService.LOG_WARNING, "Configuration does not specify any agents");
+ return;
+ }
+
+ String[] agents = agentsProperty.split(",");
+ for (String agent : agents) {
+ Dictionary<String, String> dictionary = getAgentConfiguration(agent, configuration);
+ String agentPID = "pid-agent-" + agent;
+ if (m_verbose)
+ System.out.println("Configuring new agent.. " + dictionary);
+ synchronized (m_configuredAgentPIDs) {
+ m_configuredAgentPIDs.add(agentPID);
+ }
+ m_agentFactory.updated(agentPID, dictionary);
+ }
+ }
+
+ private void stopConfiguredAgents() {
+ Set<String> configuredAgentPIDs = new HashSet<String>();
+ synchronized (m_configuredAgentPIDs) {
+ configuredAgentPIDs.addAll(m_configuredAgentPIDs);
+ m_configuredAgentPIDs.clear();
+ }
+ for (String configuredAgentPID : configuredAgentPIDs) {
+ if (m_verbose)
+ System.out.println("Removing configured agent with PID " + configuredAgentPID);
+ m_agentFactory.deleted(configuredAgentPID);
+ }
+ }
+
+ private void startSystemActivators(Dictionary<String, String> configuration) throws ConfigurationException {
+
+ Set<String> bundleActivators = null;
+ String activatorsProperty = (String) configuration.get(Constants.CONFIG_ACTIVATORS_KEY);
+ if (activatorsProperty != null && !activatorsProperty.equals("")) {
+ bundleActivators = new HashSet<String>();
+ String[] activators = activatorsProperty.split(",");
+ for (String activator : activators) {
+ bundleActivators.add(activator.trim());
+ }
+ }
+
+ for (String bundleActivatorName : bundleActivators) {
+ BundleActivator activator = getBundleActivator(bundleActivatorName);
+ if (m_verbose)
+ System.out.println("Starting system activator.. " + activator.getClass().getName());
+ try {
+ activator.start(m_context);
+ }
+ catch (Exception e) {
+ if (m_verbose)
+ e.printStackTrace();
+ m_logService.log(LogService.LOG_WARNING, "Activator stop exception! Continuing...", e);
+ }
+ synchronized (m_startedActivators) {
+ m_startedActivators.add(activator);
+ }
+ }
+ }
+
+ private void stopSystemActivators() throws ConfigurationException {
+
+ Set<BundleActivator> bundleActivators = new HashSet<BundleActivator>();
+ synchronized (m_startedActivators) {
+ bundleActivators.addAll(m_startedActivators);
+ m_startedActivators.clear();
+ }
+
+ for (BundleActivator activator : bundleActivators) {
+ if (m_verbose)
+ System.out.println("Stopping system activator.. " + activator.getClass().getName());
+ try {
+ activator.stop(m_context);
+ }
+ catch (Exception e) {
+ if (m_verbose)
+ e.printStackTrace();
+ m_logService.log(LogService.LOG_WARNING, "Activator stop exception! Continuing...", e);
+ }
+ }
+ }
+
+ private Dictionary<String, String> getMergedConfiguration(Dictionary<String, String> configuration) {
+
+ Dictionary<String, String> mergedConfiguration = new Hashtable<String, String>();
+ Dictionary<String, String> defaultConfiguration = m_defaultConfiguration;
+
+ // first map all default properties
+ Enumeration<String> defaultKeys = defaultConfiguration.keys();
+ while (defaultKeys.hasMoreElements()) {
+ String key = defaultKeys.nextElement();
+ mergedConfiguration.put(key, defaultConfiguration.get(key));
+ }
+ // overwrite with configuration properties
+ Enumeration<String> configurationKeys = configuration.keys();
+ while (configurationKeys.hasMoreElements()) {
+ String key = configurationKeys.nextElement();
+ mergedConfiguration.put(key, configuration.get(key));
+ }
+ return mergedConfiguration;
+ }
+
+ private Dictionary<String, String> getAgentConfiguration(String agent, Dictionary<String, String> configuration) throws ConfigurationException {
+
+ String agentPrefix = agent + ".";
+ Dictionary<String, String> agentConfiguration = new Hashtable<String, String>();
+
+ // first map all global properties
+ Enumeration<String> configurationKeys = configuration.keys();
+ while (configurationKeys.hasMoreElements()) {
+ String key = configurationKeys.nextElement();
+ if (!key.startsWith(agentPrefix)) {
+ agentConfiguration.put(key, configuration.get(key));
+ }
+ }
+
+ // overwrite with agent specific properties
+ configurationKeys = configuration.keys();
+ while (configurationKeys.hasMoreElements()) {
+ String key = configurationKeys.nextElement();
+ if (key.startsWith(agentPrefix)) {
+ agentConfiguration.put(key.replaceFirst(agentPrefix, ""), configuration.get(key));
+ }
+ }
+
+ agentConfiguration.put("agent", agent);
+ return agentConfiguration;
+ }
+
+ private BundleActivator getBundleActivator(String bundleActivatorName) throws ConfigurationException {
+
+ try {
+ Class<?> clazz = ConfigurationHandler.class.getClassLoader().loadClass(bundleActivatorName);
+ if (!BundleActivator.class.isAssignableFrom(clazz)) {
+ throw new ConfigurationException("activators", "Factory class does not implement ComponentFactory interface: " + bundleActivatorName);
+ }
+ try {
+ Object instance = clazz.newInstance();
+ return (BundleActivator) instance;
+ }
+ catch (InstantiationException e) {
+ throw new ConfigurationException("activators", "BundleActivator class does not have a default constructor: " + bundleActivatorName);
+ }
+ catch (IllegalAccessException e) {
+ throw new ConfigurationException("activators", "BundleActivator class does not have a default constructor: " + bundleActivatorName);
+ }
+ }
+ catch (ClassNotFoundException e) {
+ throw new ConfigurationException("activators", "BundleActivator class not found: " + bundleActivatorName);
+ }
+ }
+}
Added: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/agent-defaults.properties
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/agent-defaults.properties?rev=1480191&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/agent-defaults.properties (added)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/agent-defaults.properties Wed May 8 09:19:48 2013
@@ -0,0 +1,32 @@
+
+#
+# Apache ACE agent defaults
+#
+
+#
+# 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.scheduler.Activator,\
+ org.apache.felix.deploymentadmin.Activator
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogFactory.java Wed May 8 09:19:48 2013
@@ -18,8 +18,8 @@
*/
package org.apache.ace.agent.logging;
+import java.util.Dictionary;
import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -41,7 +41,7 @@ public class LogFactory extends Componen
public static final String LOG_NAME = "name";
@Override
- public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) {
+ public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) {
Set<Component> components = new HashSet<Component>();
String value = configuration.get(LOG_STORES);
@@ -52,7 +52,7 @@ public class LogFactory extends Componen
return components;
}
- private Component createLogComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration, String store) {
+ private Component createLogComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration, String store) {
Properties properties = getAgentproperties(configuration);
properties.put("name", store);
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogStoreFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogStoreFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogStoreFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogStoreFactory.java Wed May 8 09:19:48 2013
@@ -19,8 +19,8 @@
package org.apache.ace.agent.logging;
import java.io.File;
+import java.util.Dictionary;
import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -39,7 +39,7 @@ import org.osgi.service.log.LogService;
public class LogStoreFactory extends ComponentFactoryBase {
@Override
- public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) {
+ public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) {
Set<Component> components = new HashSet<Component>();
String value = configuration.get(LogFactory.LOG_STORES);
@@ -50,7 +50,7 @@ public class LogStoreFactory extends Com
return components;
}
- private Component createLogStoreComponent(BundleContext context, DependencyManager manager, Map<String, String> configuration, LogService logService, String store) {
+ private Component createLogStoreComponent(BundleContext context, DependencyManager manager, Dictionary<String, String> configuration, LogService logService, String store) {
Properties properties = getAgentproperties(configuration);
properties.put(LogFactory.LOG_NAME, store);
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogSyncTaskFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogSyncTaskFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogSyncTaskFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/logging/LogSyncTaskFactory.java Wed May 8 09:19:48 2013
@@ -18,8 +18,8 @@
*/
package org.apache.ace.agent.logging;
+import java.util.Dictionary;
import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -42,7 +42,7 @@ import org.osgi.service.log.LogService;
public class LogSyncTaskFactory extends ComponentFactoryBase {
@Override
- public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) {
+ public Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) {
Set<Component> components = new HashSet<Component>();
String value = configuration.get(LogFactory.LOG_STORES);
@@ -61,16 +61,13 @@ public class LogSyncTaskFactory extends
return components;
}
- private Component createLogSyncComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration, String store) {
-
- String schedulerName = getAgentIdentifier(configuration) + "-" + store;
- String description = "Task that synchronizes log store " + store + " for agent=" + getAgentIdentifier(configuration) + " on the target and server";
+ private Component createLogSyncComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration, String store) {
Properties props = getAgentproperties(configuration);
props.put(LogFactory.LOG_NAME, store);
props.put(SchedulerConstants.SCHEDULER_NAME_KEY, LogSyncTask.class.getSimpleName());
- props.put(SchedulerConstants.SCHEDULER_DESCRIPTION_KEY, description);
+ props.put(SchedulerConstants.SCHEDULER_DESCRIPTION_KEY, "Task that synchronizes log store " + store + " for agent=" + getAgentIdentifier(configuration) + " on the target and server");
props.put(SchedulerConstants.SCHEDULER_RECIPE, "2000");
Component component = manager.createComponent()
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactory.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactory.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactory.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactory.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.spi;
-import java.util.Map;
+import java.util.Dictionary;
import java.util.Set;
import org.apache.felix.dm.Component;
@@ -50,5 +50,5 @@ public interface ComponentFactory {
* @throws ConfigurationException
* If there is a fatal problem.
*/
- Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException;
+ Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException;
}
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactoryBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactoryBase.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactoryBase.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/ComponentFactoryBase.java Wed May 8 09:19:48 2013
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.spi;
-import java.util.Map;
+import java.util.Dictionary;
import java.util.Properties;
/**
@@ -33,7 +33,7 @@ public abstract class ComponentFactoryBa
* The configuration
* @return The identifier
*/
- protected String getAgentIdentifier(Map<String, String> configuration) {
+ protected String getAgentIdentifier(Dictionary<String, String> configuration) {
return configuration.get("agent");
}
@@ -44,7 +44,7 @@ public abstract class ComponentFactoryBa
* The configuration
* @return The properties
*/
- protected Properties getAgentproperties(Map<String, String> configuration) {
+ protected Properties getAgentproperties(Dictionary<String, String> configuration) {
Properties properties = new Properties();
properties.put("agent", getAgentIdentifier(configuration));
return properties;
@@ -59,7 +59,7 @@ public abstract class ComponentFactoryBa
* The optional base filter
* @return The filter
*/
- protected String getAgentFilter(Map<String, String> configuration, String base) {
+ protected String getAgentFilter(Dictionary<String, String> configuration, String base) {
if (base == null) {
return "(agent=" + getAgentIdentifier(configuration) + ")";
}
Modified: ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/OneComponentFactoryBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/OneComponentFactoryBase.java?rev=1480191&r1=1480190&r2=1480191&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/OneComponentFactoryBase.java (original)
+++ ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/spi/OneComponentFactoryBase.java Wed May 8 09:19:48 2013
@@ -19,8 +19,8 @@
package org.apache.ace.agent.spi;
import java.util.Collections;
+import java.util.Dictionary;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.felix.dm.Component;
@@ -36,7 +36,7 @@ import org.osgi.service.log.LogService;
public abstract class OneComponentFactoryBase extends ComponentFactoryBase {
@Override
- public final Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException {
+ public final Set<Component> createComponents(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException {
Component component = createComponent(context, manager, logService, configuration);
if (component != null) {
Set<Component> components = new HashSet<Component>();
@@ -61,5 +61,5 @@ public abstract class OneComponentFactor
* @throws ConfigurationException
* If there is a fatal problem
*/
- public abstract Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Map<String, String> configuration) throws ConfigurationException;
+ public abstract Component createComponent(BundleContext context, DependencyManager manager, LogService logService, Dictionary<String, String> configuration) throws ConfigurationException;
}