You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2015/03/16 17:20:14 UTC

[1/3] karaf-decanter git commit: Fixed feature name

Repository: karaf-decanter
Updated Branches:
  refs/heads/EventAdmin fde7be571 -> 8b9fd6484


Fixed feature name

Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/1f79bc54
Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/1f79bc54
Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/1f79bc54

Branch: refs/heads/EventAdmin
Commit: 1f79bc5456a0ed98f84fd3eb861e09091e674123
Parents: 36f4569
Author: cschneider <ch...@die-schneider.net>
Authored: Sat Mar 14 13:57:48 2015 +0100
Committer: cschneider <ch...@die-schneider.net>
Committed: Sat Mar 14 13:57:48 2015 +0100

----------------------------------------------------------------------
 README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/1f79bc54/README
----------------------------------------------------------------------
diff --git a/README b/README
index f5a18e6..006fce9 100644
--- a/README
+++ b/README
@@ -52,7 +52,7 @@ Apache Karaf Decanter is available as a Karaf features.
 
 You have to register the Decater features repository:
 
-karaf@root()> feature:repo-add mvn:org.apache.karaf.decanter/decanter/3.0.0-SNAPSHOT/xml/features
+karaf@root()> feature:repo-add mvn:org.apache.karaf.decanter/apache-karaf-decanter/3.0.0-SNAPSHOT/xml/features
 
 It's up to you to choose the features to install, depending of the systems that you want:
 


[3/3] karaf-decanter git commit: Adding config admin support

Posted by cs...@apache.org.
Adding config admin support


Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/8b9fd648
Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/8b9fd648
Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/8b9fd648

Branch: refs/heads/EventAdmin
Commit: 8b9fd64844dc08b0f6e12f9a5aa499644bbaa48d
Parents: fde7be5 f19041a
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Mar 16 17:19:35 2015 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Mar 16 17:19:35 2015 +0100

----------------------------------------------------------------------
 appender/elasticsearch/pom.xml                  | 21 +++++++++-
 ...he.karaf.decanter.appender.elasticsearch.cfg |  2 +
 .../appender/elasticsearch/Activator.java       | 44 +++++++++++++++++---
 assembly/src/main/feature/feature.xml           |  1 +
 4 files changed, 61 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/8b9fd648/appender/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --cc appender/elasticsearch/pom.xml
index 9cf873f,7fb4ee8..26732e9
--- a/appender/elasticsearch/pom.xml
+++ b/appender/elasticsearch/pom.xml
@@@ -45,43 -53,62 +45,62 @@@
              <groupId>org.osgi</groupId>
              <artifactId>org.osgi.compendium</artifactId>
          </dependency>
-         
  
 -        <!-- JSON builder -->
 -        <dependency>
 -            <groupId>javax.json</groupId>
 -            <artifactId>javax.json-api</artifactId>
 -        </dependency>
 -        <!-- SLF4J -->
 -        <dependency>
 -            <groupId>org.slf4j</groupId>
 -            <artifactId>slf4j-api</artifactId>
 -        </dependency>
 +		<!-- JSON builder -->
 +		<dependency>
 +			<groupId>javax.json</groupId>
 +			<artifactId>javax.json-api</artifactId>
 +		</dependency>
 +		<!-- SLF4J -->
 +		<dependency>
 +			<groupId>org.slf4j</groupId>
 +			<artifactId>slf4j-api</artifactId>
 +		</dependency>
  
 -    </dependencies>
 +	</dependencies>
  
 -    <build>
 -        <plugins>
 -            <plugin>
 -                <groupId>org.apache.felix</groupId>
 -                <artifactId>maven-bundle-plugin</artifactId>
 -                <inherited>true</inherited>
 -                <extensions>true</extensions>
 -                <configuration>
 -                    <instructions>
 -                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
 -                        <Bundle-Version>${project.version}</Bundle-Version>
 -                        <Bundle-Activator>org.apache.karaf.decanter.appender.elasticsearch.Activator</Bundle-Activator>
 -                        <Import-Package>
 -                            org.apache.karaf.decanter.api;version=${project.version},
 -                            org.slf4j;version="[1.7,2)";resolution:=optional,
 -                            org.elasticsearch*;version="[1,2)",
 -                            *
 -                        </Import-Package>
 -                    </instructions>
 -                </configuration>
 -            </plugin>
 +	<build>
 +		<plugins>
 +			<plugin>
 +				<groupId>org.apache.felix</groupId>
 +				<artifactId>maven-bundle-plugin</artifactId>
 +				<inherited>true</inherited>
 +				<extensions>true</extensions>
 +				<configuration>
 +					<instructions>
 +						<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
 +						<Bundle-Version>${project.version}</Bundle-Version>
 +						<Bundle-Activator>org.apache.karaf.decanter.appender.elasticsearch.Activator</Bundle-Activator>
 +						<Import-Package>
 +							org.apache.karaf.decanter.api;version=${project.version},
 +							org.slf4j;version="[1.7,2)";resolution:=optional,
 +							org.elasticsearch*;version="[1,2)",
 +							*
 +						</Import-Package>
 +					</instructions>
 +				</configuration>
 +			</plugin>
+             <plugin>
+                 <groupId>org.codehaus.mojo</groupId>
+                 <artifactId>build-helper-maven-plugin</artifactId>
+                 <executions>
+                     <execution>
+                         <phase>package</phase>
+                         <goals>
+                             <goal>attach-artifact</goal>
+                         </goals>
+                         <configuration>
+                             <artifacts>
+                                 <artifact>
+                                     <file>src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg</file>
+                                     <type>cfg</type>
+                                 </artifact>
+                             </artifacts>
+                         </configuration>
+                     </execution>
+                 </executions>
+             </plugin>
 -        </plugins>
 -    </build>
 +		</plugins>
 +	</build>
  
  </project>

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/8b9fd648/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
----------------------------------------------------------------------
diff --cc appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
index 553d778,0aad636..05a6971
--- a/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
+++ b/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
@@@ -19,10 -19,13 +19,14 @@@ package org.apache.karaf.decanter.appen
  import java.util.Dictionary;
  import java.util.Hashtable;
  
 -import org.apache.karaf.decanter.api.Appender;
  import org.osgi.framework.BundleActivator;
  import org.osgi.framework.BundleContext;
 +import org.osgi.service.event.EventConstants;
 +import org.osgi.service.event.EventHandler;
+ import org.osgi.framework.Constants;
+ import org.osgi.framework.ServiceRegistration;
+ import org.osgi.service.cm.ConfigurationException;
+ import org.osgi.service.cm.ManagedService;
  
  public class Activator implements BundleActivator {
  
@@@ -38,7 -41,34 +42,35 @@@
      }
  
      public void stop(BundleContext bundleContext) {
 +        appender.close();
+         if (appender != null) {
+             appender.close();
+         }
      }
  
+     private final class ConfigUpdater implements ManagedService {
+         private BundleContext bundleContext;
+         private ServiceRegistration<?> serviceReg;
+ 
+         public ConfigUpdater(BundleContext bundleContext) {
+             this.bundleContext = bundleContext;
+         }
+ 
+         @SuppressWarnings("rawtypes")
+         @Override
+         public void updated(Dictionary config) throws ConfigurationException {
+             if (appender != null) {
+                 appender.close();
+                 serviceReg.unregister();
+             }
+ 
+             String host = config != null ? (String)config.get("host") : "localhost";
+             int port = config != null ? Integer.parseInt((String)config.get("port")) : 9300;
+             appender = new ElasticsearchAppender(host, port);
+             appender.open();
+             Dictionary<String, String> properties = new Hashtable<>();
 -            properties.put("name", "elasticsearch");
 -            serviceReg = bundleContext.registerService(Appender.class, appender, properties);
++            properties.put(EventConstants.EVENT_TOPIC, "decanter/*");
++        	serviceReg =  bundleContext.registerService(EventHandler.class, appender, properties);
+         }
+     }
  }

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/8b9fd648/assembly/src/main/feature/feature.xml
----------------------------------------------------------------------


[2/3] karaf-decanter git commit: [KARAF-3608] Adding config admin support to elasticsearcg appender with thanks to Morgan Hautman

Posted by cs...@apache.org.
[KARAF-3608] Adding config admin support to elasticsearcg appender with thanks to Morgan Hautman


Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/f19041a4
Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/f19041a4
Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/f19041a4

Branch: refs/heads/EventAdmin
Commit: f19041a499e6f39e0dba7d999f7bc9ae1ef5bc6a
Parents: 1f79bc5
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Sun Mar 15 17:39:27 2015 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Sun Mar 15 17:39:27 2015 +0100

----------------------------------------------------------------------
 appender/elasticsearch/pom.xml                  | 174 +++++++++++--------
 ...he.karaf.decanter.appender.elasticsearch.cfg |   2 +
 .../appender/elasticsearch/Activator.java       |  45 ++++-
 assembly/src/main/feature/feature.xml           |   1 +
 4 files changed, 141 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/f19041a4/appender/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/appender/elasticsearch/pom.xml b/appender/elasticsearch/pom.xml
index 09291dc..7fb4ee8 100644
--- a/appender/elasticsearch/pom.xml
+++ b/appender/elasticsearch/pom.xml
@@ -1,88 +1,114 @@
 <?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">
+<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. -->
+    <!-- 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>
+    <modelVersion>4.0.0</modelVersion>
 
-	<parent>
-		<groupId>org.apache.karaf.decanter</groupId>
-		<artifactId>appender</artifactId>
-		<version>3.0.0-SNAPSHOT</version>
-		<relativePath>../pom.xml</relativePath>
-	</parent>
+    <parent>
+        <groupId>org.apache.karaf.decanter</groupId>
+        <artifactId>appender</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
 
-	<groupId>org.apache.karaf.decanter.appender</groupId>
-	<artifactId>org.apache.karaf.decanter.appender.elasticsearch</artifactId>
-	<packaging>bundle</packaging>
-	<name>Apache Karaf :: Decanter :: Appender :: Elasticsearch</name>
+    <groupId>org.apache.karaf.decanter.appender</groupId>
+    <artifactId>org.apache.karaf.decanter.appender.elasticsearch</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: Decanter :: Appender :: Elasticsearch</name>
 
-	<dependencies>
+    <dependencies>
 
-		<!-- Decanter -->
-		<dependency>
-			<groupId>org.apache.karaf.decanter</groupId>
-			<artifactId>org.apache.karaf.decanter.api</artifactId>
-		</dependency>
+        <!-- Decanter -->
+        <dependency>
+            <groupId>org.apache.karaf.decanter</groupId>
+            <artifactId>org.apache.karaf.decanter.api</artifactId>
+        </dependency>
 
-		<!-- Elasticsearch -->
-		<dependency>
-			<groupId>org.elasticsearch</groupId>
-			<artifactId>elasticsearch</artifactId>
-			<version>${elasticsearch.version}</version>
-		</dependency>
+        <!-- Elasticsearch -->
+        <dependency>
+            <groupId>org.elasticsearch</groupId>
+            <artifactId>elasticsearch</artifactId>
+            <version>${elasticsearch.version}</version>
+        </dependency>
 
-		<!-- OSGi -->
-		<dependency>
-			<groupId>org.osgi</groupId>
-			<artifactId>org.osgi.core</artifactId>
-		</dependency>
+        <!-- OSGi -->
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
 
-		<!-- JSON builder -->
-		<dependency>
-			<groupId>javax.json</groupId>
-			<artifactId>javax.json-api</artifactId>
-		</dependency>
-		<!-- SLF4J -->
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-api</artifactId>
-		</dependency>
+        <!-- JSON builder -->
+        <dependency>
+            <groupId>javax.json</groupId>
+            <artifactId>javax.json-api</artifactId>
+        </dependency>
+        <!-- SLF4J -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
 
-	</dependencies>
+    </dependencies>
 
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.felix</groupId>
-				<artifactId>maven-bundle-plugin</artifactId>
-				<inherited>true</inherited>
-				<extensions>true</extensions>
-				<configuration>
-					<instructions>
-						<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-						<Bundle-Version>${project.version}</Bundle-Version>
-						<Bundle-Activator>org.apache.karaf.decanter.appender.elasticsearch.Activator</Bundle-Activator>
-						<Import-Package>
-							org.apache.karaf.decanter.api;version=${project.version},
-							org.slf4j;version="[1.7,2)";resolution:=optional,
-							org.elasticsearch*;version="[1,2)",
-							*
-						</Import-Package>
-					</instructions>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <inherited>true</inherited>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Version>${project.version}</Bundle-Version>
+                        <Bundle-Activator>org.apache.karaf.decanter.appender.elasticsearch.Activator</Bundle-Activator>
+                        <Import-Package>
+                            org.apache.karaf.decanter.api;version=${project.version},
+                            org.slf4j;version="[1.7,2)";resolution:=optional,
+                            org.elasticsearch*;version="[1,2)",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg</file>
+                                    <type>cfg</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/f19041a4/appender/elasticsearch/src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg
----------------------------------------------------------------------
diff --git a/appender/elasticsearch/src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg b/appender/elasticsearch/src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg
new file mode 100644
index 0000000..344f56a
--- /dev/null
+++ b/appender/elasticsearch/src/main/cfg/org.apache.karaf.decanter.appender.elasticsearch.cfg
@@ -0,0 +1,2 @@
+host=localhost
+port=9300
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/f19041a4/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
----------------------------------------------------------------------
diff --git a/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java b/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
index f43d137..0aad636 100644
--- a/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
+++ b/appender/elasticsearch/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/Activator.java
@@ -22,22 +22,53 @@ import java.util.Hashtable;
 import org.apache.karaf.decanter.api.Appender;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
 
 public class Activator implements BundleActivator {
 
     private ElasticsearchAppender appender;
+    private static final String CONFIG_PID = "org.apache.karaf.decanter.appender.elasticsearch";
 
-    public void start(BundleContext bundleContext) {
-        // TODO embed mode and configuration admin support for location of Elasticsearch
-        appender = new ElasticsearchAppender("localhost", 9300);
-        appender.open();
+    public void start(final BundleContext bundleContext) {
+        // TODO embed mode of Elasticsearch
         Dictionary<String, String> properties = new Hashtable<>();
-        properties.put("name", "elasticsearch");
-        bundleContext.registerService(Appender.class, appender, properties);
+        properties.put(Constants.SERVICE_PID, CONFIG_PID);
+        bundleContext.registerService(ManagedService.class.getName(), new ConfigUpdater(bundleContext),
+                                      properties);
     }
 
     public void stop(BundleContext bundleContext) {
-        appender.close();;
+        if (appender != null) {
+            appender.close();
+        }
     }
 
+    private final class ConfigUpdater implements ManagedService {
+        private BundleContext bundleContext;
+        private ServiceRegistration<?> serviceReg;
+
+        public ConfigUpdater(BundleContext bundleContext) {
+            this.bundleContext = bundleContext;
+        }
+
+        @SuppressWarnings("rawtypes")
+        @Override
+        public void updated(Dictionary config) throws ConfigurationException {
+            if (appender != null) {
+                appender.close();
+                serviceReg.unregister();
+            }
+
+            String host = config != null ? (String)config.get("host") : "localhost";
+            int port = config != null ? Integer.parseInt((String)config.get("port")) : 9300;
+            appender = new ElasticsearchAppender(host, port);
+            appender.open();
+            Dictionary<String, String> properties = new Hashtable<>();
+            properties.put("name", "elasticsearch");
+            serviceReg = bundleContext.registerService(Appender.class, appender, properties);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/f19041a4/assembly/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/feature/feature.xml b/assembly/src/main/feature/feature.xml
index 98eba4a..c034871 100644
--- a/assembly/src/main/feature/feature.xml
+++ b/assembly/src/main/feature/feature.xml
@@ -48,6 +48,7 @@
         <bundle>mvn:org.glassfish/javax.json/${glassfish-json.version}</bundle>
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch/${elasticsearch.bundle.version}</bundle>
         <bundle>mvn:org.apache.karaf.decanter.appender/org.apache.karaf.decanter.appender.elasticsearch/${project.version}</bundle>
+        <configfile finalname="/etc/org.apache.karaf.decanter.appender.elasticsearch.cfg">mvn:org.apache.karaf.decanter.appender/org.apache.karaf.decanter.appender.elasticsearch/${project.version}/cfg</configfile>
     </feature>
 
     <feature name="elasticsearch" version="${elasticsearch.version}" description="Embedded Elasticsearch node">