You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/09/25 13:45:25 UTC
svn commit: r818822 - in
/felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal:
ConfigurationListener.java converter/ConfigurationEventConverter.java
Author: cziegeler
Date: Fri Sep 25 11:45:25 2009
New Revision: 818822
URL: http://svn.apache.org/viewvc?rev=818822&view=rev
Log:
#1607 - Add support for configuration events.
Added:
felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java (with props)
Modified:
felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/ConfigurationListener.java
Modified: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/ConfigurationListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/ConfigurationListener.java?rev=818822&r1=818821&r2=818822&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/ConfigurationListener.java (original)
+++ felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/ConfigurationListener.java Fri Sep 25 11:45:25 2009
@@ -22,11 +22,13 @@
import java.util.Dictionary;
import java.util.Hashtable;
+import org.apache.felix.webconsole.plugins.event.internal.converter.ConfigurationEventConverter;
import org.osgi.framework.*;
+import org.osgi.service.cm.ConfigurationEvent;
import org.osgi.service.cm.ManagedService;
-public class ConfigurationListener implements ManagedService
+public class ConfigurationListener implements ManagedService, org.osgi.service.cm.ConfigurationListener
{
private final PluginServlet plugin;
@@ -41,7 +43,8 @@
props.put( Constants.SERVICE_DESCRIPTION, "Event plugin for the Felix Web Console Configuration Receiver" );
props.put( Constants.SERVICE_PID, cl.pid );
- return context.registerService( ManagedService.class.getName(), cl, props );
+ return context.registerService( new String[] {ManagedService.class.getName(),
+ org.osgi.service.cm.ConfigurationListener.class.getName()}, cl, props );
}
@@ -50,9 +53,21 @@
this.plugin = plugin;
this.pid = plugin.getClass().getName();
}
+ //---------- ConfigurationListener
+ /**
+ * @see org.osgi.service.cm.ConfigurationListener#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
+ */
+ public void configurationEvent(ConfigurationEvent event)
+ {
+ this.plugin.getCollector().add(ConfigurationEventConverter.getInfo(event));
+
+ }
//---------- ManagedService
+ /**
+ * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
+ */
public void updated( Dictionary config )
{
plugin.updateConfiguration( config );
Added: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java?rev=818822&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java (added)
+++ felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java Fri Sep 25 11:45:25 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.felix.webconsole.plugins.event.internal.converter;
+
+import org.apache.felix.webconsole.plugins.event.internal.EventInfo;
+import org.osgi.service.cm.ConfigurationEvent;
+
+public class ConfigurationEventConverter {
+
+ public static final String TOPIC = ConfigurationEventConverter.class.getName().replace('.', '/');
+
+ public static EventInfo getInfo(final ConfigurationEvent event) {
+ if ( event == null )
+ {
+ return null;
+ }
+
+ final StringBuffer topic = new StringBuffer(TOPIC);
+ topic.append('/');
+ final StringBuffer buffer = new StringBuffer( "Configuration event: " );
+ buffer.append(event.getPid());
+ if ( event.getFactoryPid() != null )
+ {
+ buffer.append(" (factoryPid=");
+ buffer.append(event.getFactoryPid());
+ buffer.append(")");
+ }
+ switch ( event.getType() )
+ {
+ case ConfigurationEvent.CM_DELETED:
+ buffer.append( " deleted" );
+ topic.append( "CM_DELETED" );
+ break;
+ case ConfigurationEvent.CM_UPDATED:
+ buffer.append( " changed" );
+ topic.append( "CM_UPDATED" );
+ break;
+ default:
+ return null; // IGNORE
+ }
+
+ return new EventInfo(topic.toString(), buffer.toString(), "config");
+ }
+}
Propchange: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/webconsole-plugins/event/src/main/java/org/apache/felix/webconsole/plugins/event/internal/converter/ConfigurationEventConverter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain