ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r998045 - in /incubator/ace/trunk/ace-managementagent: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/ace/ src/main/java/org/apache/ace/managementagent/
Date Fri, 17 Sep 2010 09:59:55 GMT
Author: marrs
Date: Fri Sep 17 09:59:55 2010
New Revision: 998045

URL: http://svn.apache.org/viewvc?rev=998045&view=rev
Log:
ACE-91 Initial implementation of a self-contained management agent, hopefully a good starting
point for further work.

Added:
    incubator/ace/trunk/ace-managementagent/
    incubator/ace/trunk/ace-managementagent/osgi.bnd
    incubator/ace/trunk/ace-managementagent/pom.xml
    incubator/ace/trunk/ace-managementagent/src/
    incubator/ace/trunk/ace-managementagent/src/main/
    incubator/ace/trunk/ace-managementagent/src/main/java/
    incubator/ace/trunk/ace-managementagent/src/main/java/org/
    incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/
    incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/
    incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/
    incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java

Added: incubator/ace/trunk/ace-managementagent/osgi.bnd
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-managementagent/osgi.bnd?rev=998045&view=auto
==============================================================================
--- incubator/ace/trunk/ace-managementagent/osgi.bnd (added)
+++ incubator/ace/trunk/ace-managementagent/osgi.bnd Fri Sep 17 09:59:55 2010
@@ -0,0 +1,22 @@
+Bundle-Activator: ${bundle.namespace}.managementagent.Activator
+
+Bundle-Version>:\
+  ${pom.version}
+
+Bundle-SymbolicName:\
+  ${bundle.symbolicName}
+
+Private-Package: \
+	org.apache.ace.*, \
+	org.apache.felix.*, \
+	EDU.oswego.cs.dl.util.concurrent
+	
+
+Export-Package: \
+	org.osgi.service.cm;version="1.2", \
+	org.osgi.service.deploymentadmin;version="1.0", \
+	org.osgi.service.deploymentadmin.spi;version="1.0", \
+	org.osgi.service.event;version="1.2", \
+	org.osgi.service.log;version="1.3", \
+	org.osgi.service.metatype;version="1.1"
+

Added: incubator/ace/trunk/ace-managementagent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-managementagent/pom.xml?rev=998045&view=auto
==============================================================================
--- incubator/ace/trunk/ace-managementagent/pom.xml (added)
+++ incubator/ace/trunk/ace-managementagent/pom.xml Fri Sep 17 09:59:55 2010
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.0-SNAPSHOT</version>
+        <relativePath>../pom/</relativePath>                
+    </parent>
+
+    <groupId>org.apache.ace</groupId>
+    <artifactId>ace-managementagent</artifactId>
+    <version>0.8.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE - Management Agent</name>
+
+    <properties>
+        <bundle.symbolicName>${namespace}.managementagent</bundle.symbolicName>
+        <bundle.namespace>${namespace}</bundle.namespace>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+                     </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+                     </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.eventadmin</artifactId>
+                     </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.dependencymanager</artifactId>
+                     </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.deploymentadmin</artifactId>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-log-listener</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-gateway-log</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-gateway-log-store</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-range-api</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-log</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-discovery-api</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-discovery-property</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-identification-api</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-identification-property</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-scheduler</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+					<!--
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-configurator</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+-->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-deployment-api</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-deployment-deploymentadmin</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>ace-deployment-task</artifactId>
+            <version>${project.version}</version>
+                     </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Added: incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java?rev=998045&view=auto
==============================================================================
--- incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
(added)
+++ incubator/ace/trunk/ace-managementagent/src/main/java/org/apache/ace/managementagent/Activator.java
Fri Sep 17 09:59:55 2010
@@ -0,0 +1,123 @@
+package org.apache.ace.managementagent;
+
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Properties;
+
+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.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+public class Activator extends DependencyActivatorBase {
+    private BundleActivator[] m_activators = new BundleActivator[] {
+        new org.apache.ace.deployment.deploymentadmin.Activator(),
+        new org.apache.ace.deployment.task.Activator(),
+        new org.apache.ace.discovery.property.Activator(),
+        new org.apache.ace.gateway.log.Activator(),
+        new org.apache.ace.gateway.log.store.impl.Activator(),
+        new org.apache.ace.identification.property.Activator(),
+        new org.apache.ace.log.listener.Activator(),
+        new org.apache.ace.scheduler.Activator(),
+        new org.apache.felix.cm.impl.ConfigurationManager(),
+        new org.apache.felix.deploymentadmin.Activator(),
+        new org.apache.felix.eventadmin.impl.Activator()
+    };
+    
+    private volatile ConfigurationAdmin m_config;
+    
+    @Override
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
+        for (int i = 0; i < m_activators.length; i++) {
+            BundleActivator a = m_activators[i];
+            a.start(context);
+//            if (a instanceof DependencyActivatorBase) {
+//                DependencyActivatorBase dab = (DependencyActivatorBase) a;
+//                dab.init(context, manager);
+//            }
+//            else {
+//                a.start(context);
+//            }
+        }
+        
+        manager.add(createComponent()
+            .setImplementation(this)
+            .add(createServiceDependency()
+                .setService(ConfigurationAdmin.class)
+                .setRequired(true)));
+    }
+    
+    public void start() {
+        try {
+            configure("org.apache.ace.discovery.property", "serverURL", System.getProperty("discovery",
"http://localhost:8080"));
+            configure("org.apache.ace.identification.property", "gatewayID", System.getProperty("identification",
"configuredGatewayID"));
+            configure("org.apache.ace.scheduler", "auditlog", "2000", "org.apache.ace.deployment.task.DeploymentUpdateTask",
"2000");
+            configureFactory("org.apache.ace.gateway.log.factory", "name", "auditlog");
+            configureFactory("org.apache.ace.gateway.log.store.factory", "name", "auditlog");
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void configure(String pid, String... params) throws IOException {
+        Configuration conf = m_config.getConfiguration(pid, null);
+        Dictionary properties = conf.getProperties();
+        if (properties == null) {
+            properties = new Properties();
+        }
+        System.out.println("props=" + properties);
+        boolean changed = false;
+        for (int i = 0; i < params.length; i += 2) {
+            System.out.println("key=" + params[i] + " value=" + params[i + 1]);
+            if (!params[i + 1].equals(properties.get(params[i]))) {
+                properties.put(params[i], params[i + 1]);
+                changed = true;
+            }
+        }
+        if (changed) {
+            System.out.println("Updating " + pid);
+            conf.update(properties);
+        }
+    }
+
+    private void configureFactory(String pid, String... params) throws IOException {
+        Configuration conf = m_config.createFactoryConfiguration(pid, null);
+        Dictionary properties = conf.getProperties();
+        if (properties == null) {
+            properties = new Properties();
+        }
+        boolean changed = false;
+        for (int i = 0; i < params.length; i += 2) {
+            if (!params[i + 1].equals(properties.get(params[i]))) {
+                properties.put(params[i], params[i + 1]);
+                changed = true;
+            }
+        }
+        if (changed) {
+            System.out.println("Updating factory " + pid);
+            conf.update(properties);
+        }
+    }
+    
+    public void stop() {
+        
+    }
+
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception
{
+        for (int i = 0; i < m_activators.length; i++) {
+            BundleActivator a = m_activators[i];
+            a.stop(context);
+//            if (a instanceof DependencyActivatorBase) {
+//                DependencyActivatorBase dab = (DependencyActivatorBase) a;
+//                dab.destroy(context, manager);
+//            }
+//            else {
+//                a.stop(context);
+//            }
+        }
+    }
+}



Mime
View raw message