Author: cziegeler Date: Thu Jun 18 10:44:34 2015 New Revision: 1686177 URL: http://svn.apache.org/r1686177 Log: Update config admin bridge to R5
Modified: felix/trunk/eventadmin/bridge.configuration/pom.xml felix/trunk/eventadmin/bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java Modified: felix/trunk/eventadmin/bridge.configuration/pom.xml URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/bridge.configuration/pom.xml?rev=1686177&r1=1686176&r2=1686177&view=diff ============================================================================== --- felix/trunk/eventadmin/bridge.configuration/pom.xml (original) +++ felix/trunk/eventadmin/bridge.configuration/pom.xml Thu Jun 18 10:44:34 2015 @@ -19,8 +19,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/maven-v4_0_0.xsd"> <parent> <groupId>org.apache.felix</groupId> - <artifactId>felix</artifactId> - <version>1.0.4</version> + <artifactId>felix-parent</artifactId> + <version>2.1</version> <relativePath>../../pom/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> @@ -33,14 +33,14 @@ </description> <dependencies> <dependency> - <groupId>${pom.groupId}</groupId> + <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> - <version>1.0.0</version> + <version>5.0.0</version> </dependency> <dependency> - <groupId>${pom.groupId}</groupId> - <artifactId>org.osgi.compendium</artifactId> - <version>1.0.0</version> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.enterprise</artifactId> + <version>5.0.0</version> </dependency> </dependencies> <build> @@ -48,7 +48,7 @@ <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> - <version>1.4.0</version> + <version>2.5.3</version> <extensions>true</extensions> <configuration> <instructions> Modified: felix/trunk/eventadmin/bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java URL: http://svn.apache.org/viewvc/felix/trunk/eventadmin/bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java?rev=1686177&r1=1686176&r2=1686177&view=diff ============================================================================== --- felix/trunk/eventadmin/bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java (original) +++ felix/trunk/eventadmin/bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java Thu Jun 18 10:44:34 2015 @@ -1,4 +1,4 @@ -/* +/* * 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 @@ -19,6 +19,7 @@ package org.apache.felix.eventadmin.bridge.configuration; import java.util.Arrays; +import java.util.Dictionary; import java.util.Hashtable; import org.osgi.framework.BundleContext; @@ -49,72 +50,77 @@ public class ConfigurationEventToEventAd public void configurationEvent(final ConfigurationEvent event) { - final ServiceReference ref = m_context - .getServiceReference(EventAdmin.class.getName()); + final ServiceReference ref = m_context.getServiceReference(EventAdmin.class.getName()); - if(null != ref) + if (null != ref) { - final EventAdmin eventAdmin = (EventAdmin) m_context - .getService(ref); + final EventAdmin eventAdmin = (EventAdmin) m_context.getService(ref); - if(null != eventAdmin) + if (null != eventAdmin) { - final String topic; - - switch(event.getType()) - { - case ConfigurationEvent.CM_UPDATED: - topic = "org/osgi/service/cm/ConfigurationEvent/CM_UPDATED"; - break; - case ConfigurationEvent.CM_DELETED: - topic = "org/osgi/service/cm/ConfigurationEvent/CM_DELETED"; - break; - default: - m_context.ungetService(ref); - return; - } - - final Hashtable properties = new Hashtable(); - - if(null != event.getFactoryPid()) + try { - properties.put("cm.factoryPid", event.getFactoryPid()); - } - - properties.put("cm.pid", event.getPid()); - - final ServiceReference eventRef = event.getReference(); + final String topic; - if(null == eventRef) - { - throw new IllegalArgumentException( - "ConfigurationEvent.getReference() may not be null"); - } + switch (event.getType()) + { + case ConfigurationEvent.CM_UPDATED: + topic = "org/osgi/service/cm/ConfigurationEvent/CM_UPDATED"; + break; + case ConfigurationEvent.CM_DELETED: + topic = "org/osgi/service/cm/ConfigurationEvent/CM_DELETED"; + break; + case ConfigurationEvent.CM_LOCATION_CHANGED: + topic = "org/osgi/service/cm/ConfigurationEvent/CM_LOCATION_CHANGED"; + break; + default: + return; + } + + final Hashtable properties = new Hashtable(); + + if (null != event.getFactoryPid()) + { + properties.put("cm.factoryPid", event.getFactoryPid()); + } + + properties.put("cm.pid", event.getPid()); + + final ServiceReference eventRef = event.getReference(); + + if (null == eventRef) + { + throw new IllegalArgumentException( + "ConfigurationEvent.getReference() may not be null"); + } + + properties.put(EventConstants.SERVICE, eventRef); + + properties.put(EventConstants.SERVICE_ID, eventRef.getProperty( + EventConstants.SERVICE_ID)); + + final Object objectClass = eventRef.getProperty( + Constants.OBJECTCLASS); + + if(!(objectClass instanceof String[]) + || !Arrays.asList((String[]) objectClass).contains( + ConfigurationAdmin.class.getName())) + { + throw new IllegalArgumentException( + "Bad objectclass: " + objectClass); + } - properties.put(EventConstants.SERVICE, eventRef); + properties.put(EventConstants.SERVICE_OBJECTCLASS, objectClass); - properties.put(EventConstants.SERVICE_ID, eventRef.getProperty( - EventConstants.SERVICE_ID)); + properties.put(EventConstants.SERVICE_PID, eventRef.getProperty( + EventConstants.SERVICE_PID)); - final Object objectClass = eventRef.getProperty( - Constants.OBJECTCLASS); - - if(!(objectClass instanceof String[]) - || !Arrays.asList((String[]) objectClass).contains( - ConfigurationAdmin.class.getName())) + eventAdmin.postEvent(new Event(topic, (Dictionary)properties)); + } + finally { - throw new IllegalArgumentException( - "Bad objectclass: " + objectClass); + m_context.ungetService(ref); } - - properties.put(EventConstants.SERVICE_OBJECTCLASS, objectClass); - - properties.put(EventConstants.SERVICE_PID, eventRef.getProperty( - EventConstants.SERVICE_PID)); - - eventAdmin.postEvent(new Event(topic, properties)); - - m_context.ungetService(ref); } } }