Remove some unnecesary inner classes inside the bridges and clean-up a bit. 


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@431000 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.eventadmin.bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java b/org.apache.felix.eventadmin.bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java
index 591a170..4606bc6 100644
--- a/org.apache.felix.eventadmin.bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java
+++ b/org.apache.felix.eventadmin.bridge.configuration/src/main/java/org/apache/felix/eventadmin/bridge/configuration/ConfigurationEventToEventAdminBridge.java
@@ -71,47 +71,46 @@
                         m_context.ungetService(ref);
                         return;
                 }
-
-                eventAdmin.postEvent(new Event(topic, new Hashtable()
+                
+                final Hashtable properties = new Hashtable();
+                
+                if(null != event.getFactoryPid())
                 {
-                    {
-                        if(null != event.getFactoryPid())
-                        {
-                            put("cm.factoryPid", event.getFactoryPid());
-                        }
-                        
-                        put("cm.pid", event.getPid());
-                        
-                        final ServiceReference ref = event.getReference();
+                    properties.put("cm.factoryPid", event.getFactoryPid());
+                }
+                
+                properties.put("cm.pid", event.getPid());
+                
+                final ServiceReference eventRef = event.getReference();
 
-                        if(null == ref)
-                        {
-                            throw new IllegalArgumentException(
-                                "ConfigurationEvent.getReference() may not be null");
-                        }
+                if(null == eventRef)
+                {
+                    throw new IllegalArgumentException(
+                        "ConfigurationEvent.getReference() may not be null");
+                }
 
-                        put(EventConstants.SERVICE, ref);
+                properties.put(EventConstants.SERVICE, eventRef);
 
-                        put(EventConstants.SERVICE_ID, ref
-                            .getProperty(EventConstants.SERVICE_ID));
+                properties.put(EventConstants.SERVICE_ID, eventRef.getProperty(
+                    EventConstants.SERVICE_ID));
 
-                        final Object objectClass = ref
-                            .getProperty(Constants.OBJECTCLASS);
+                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);
-                        }
+                if(!(objectClass instanceof String[])
+                    || !Arrays.asList((String[]) objectClass).contains(
+                    ConfigurationAdmin.class.getName()))
+                {
+                    throw new IllegalArgumentException(
+                        "Bad objectclass: " + objectClass);
+                }
 
-                        put(EventConstants.SERVICE_OBJECTCLASS, objectClass);
+                properties.put(EventConstants.SERVICE_OBJECTCLASS, objectClass);
 
-                        put(EventConstants.SERVICE_PID, ref
-                            .getProperty(EventConstants.SERVICE_PID));
-                    }
-                }));
+                properties.put(EventConstants.SERVICE_PID, eventRef.getProperty(
+                    EventConstants.SERVICE_PID));
+                
+                eventAdmin.postEvent(new Event(topic, properties));
 
                 m_context.ungetService(ref);
             }
diff --git a/org.apache.felix.eventadmin.bridge.useradmin/src/main/java/org/apache/felix/eventadmin/bridge/useradmin/UserAdminEventToEventAdminBridge.java b/org.apache.felix.eventadmin.bridge.useradmin/src/main/java/org/apache/felix/eventadmin/bridge/useradmin/UserAdminEventToEventAdminBridge.java
index 4b25c36..3a1617d 100644
--- a/org.apache.felix.eventadmin.bridge.useradmin/src/main/java/org/apache/felix/eventadmin/bridge/useradmin/UserAdminEventToEventAdminBridge.java
+++ b/org.apache.felix.eventadmin.bridge.useradmin/src/main/java/org/apache/felix/eventadmin/bridge/useradmin/UserAdminEventToEventAdminBridge.java
@@ -51,8 +51,7 @@
 
         if(null != ref)
         {
-            final EventAdmin eventAdmin = (EventAdmin) m_context
-                .getService(ref);
+            final EventAdmin eventAdmin = (EventAdmin) m_context.getService(ref);
 
             if(null != eventAdmin)
             {
@@ -74,48 +73,47 @@
                         return;
                 }
 
-                eventAdmin.postEvent(new Event(topic, new Hashtable()
+                final Hashtable properties = new Hashtable();
+                
+                properties.put(EventConstants.EVENT, event);
+
+                properties.put("role", event.getRole());
+
+                properties.put("role.name", event.getRole().getName());
+
+                properties.put("role.type", new Integer(event.getRole().getType()));
+
+                final ServiceReference eventRef = event
+                    .getServiceReference();
+
+                if(null == eventRef)
                 {
-                    {
-                        put(EventConstants.EVENT, event);
+                    throw new IllegalArgumentException(
+                        "UserAdminEvent.getServiceReference() may not be null");
+                }
 
-                        put("role", event.getRole());
+                properties.put(EventConstants.SERVICE, eventRef);
 
-                        put("role.name", event.getRole().getName());
+                properties.put(EventConstants.SERVICE_ID, eventRef
+                    .getProperty(EventConstants.SERVICE_ID));
 
-                        put("role.type", new Integer(event.getRole().getType()));
+                final Object objectClass = eventRef
+                    .getProperty(Constants.OBJECTCLASS);
 
-                        final ServiceReference ref = event
-                            .getServiceReference();
+                if(!(objectClass instanceof String[])
+                    || !Arrays.asList((String[]) objectClass).contains(
+                        UserAdmin.class.getName()))
+                {
+                    throw new IllegalArgumentException(
+                        "Bad objectclass: " + objectClass);
+                }
 
-                        if(null == ref)
-                        {
-                            throw new IllegalArgumentException(
-                                "UserAdminEvent.getServiceReference() may not be null");
-                        }
+                properties.put(EventConstants.SERVICE_OBJECTCLASS, objectClass);
 
-                        put(EventConstants.SERVICE, ref);
+                properties.put(EventConstants.SERVICE_PID, eventRef
+                    .getProperty(EventConstants.SERVICE_PID));
 
-                        put(EventConstants.SERVICE_ID, ref
-                            .getProperty(EventConstants.SERVICE_ID));
-
-                        final Object objectClass = ref
-                            .getProperty(Constants.OBJECTCLASS);
-
-                        if(!(objectClass instanceof String[])
-                            || !Arrays.asList((String[]) objectClass).contains(
-                                UserAdmin.class.getName()))
-                        {
-                            throw new IllegalArgumentException(
-                                "Bad objectclass: " + objectClass);
-                        }
-
-                        put(EventConstants.SERVICE_OBJECTCLASS, objectClass);
-
-                        put(EventConstants.SERVICE_PID, ref
-                            .getProperty(EventConstants.SERVICE_PID));
-                    }
-                }));
+                eventAdmin.postEvent(new Event(topic, properties));
 
                 m_context.ungetService(ref);
             }
diff --git a/org.apache.felix.eventadmin.bridge.wireadmin/src/main/java/org/apache/felix/eventadmin/bridge/wireadmin/WireAdminEventToEventAdminBridge.java b/org.apache.felix.eventadmin.bridge.wireadmin/src/main/java/org/apache/felix/eventadmin/bridge/wireadmin/WireAdminEventToEventAdminBridge.java
index efe0a1e..006c34a 100644
--- a/org.apache.felix.eventadmin.bridge.wireadmin/src/main/java/org/apache/felix/eventadmin/bridge/wireadmin/WireAdminEventToEventAdminBridge.java
+++ b/org.apache.felix.eventadmin.bridge.wireadmin/src/main/java/org/apache/felix/eventadmin/bridge/wireadmin/WireAdminEventToEventAdminBridge.java
@@ -40,8 +40,7 @@
     {
         m_context = context;
 
-        m_context
-            .registerService(WireAdminListener.class.getName(), this, null);
+        m_context.registerService(WireAdminListener.class.getName(), this, null);
     }
 
     public void wireAdminEvent(final WireAdminEvent event)
@@ -89,71 +88,69 @@
                         return;
                 }
 
-                eventAdmin.postEvent(new Event(topic, new Hashtable()
+                final Hashtable properties = new Hashtable();
+                
+                properties.put(EventConstants.EVENT, event);
+
+                properties.put("wire", event.getWire());
+
+                properties.put("wire.flavors", event.getWire().getFlavors());
+
+                properties.put("wire.scope", event.getWire().getScope());
+
+                properties.put("wire.connected", (event.getWire().isConnected()) ? 
+                    Boolean.TRUE : Boolean.FALSE);
+
+                properties.put("wire.valid", (event.getWire().isValid()) ? 
+                    Boolean.TRUE : Boolean.FALSE);
+
+                final Throwable throwable = event.getThrowable();
+
+                if(null != throwable)
                 {
+                    properties.put(EventConstants.EXCEPTION, throwable);
+
+                    properties.put(EventConstants.EXCEPTION_CLASS, throwable
+                        .getClass().getName());
+
+                    final String message = throwable.getMessage();
+
+                    if(null != message)
                     {
-                        put(EventConstants.EVENT, event);
-
-                        put("wire", event.getWire());
-
-                        put("wire.flavors", event.getWire().getFlavors());
-
-                        put("wire.scope", event.getWire().getScope());
-
-                        put("wire.connected", Boolean.valueOf(event.getWire()
-                            .isConnected()));
-
-                        put("wire.valid", Boolean.valueOf(event.getWire()
-                            .isValid()));
-
-                        final Throwable throwable = event.getThrowable();
-
-                        if(null != throwable)
-                        {
-                            put(EventConstants.EXCEPTION, throwable);
-
-                            put(EventConstants.EXCEPTION_CLASS, throwable
-                                .getClass().getName());
-
-                            final String message = throwable.getMessage();
-
-                            if(null != message)
-                            {
-                                put(EventConstants.EXCEPTION_MESSAGE, message);
-                            }
-
-                            final ServiceReference ref = event
-                                .getServiceReference();
-
-                            if(null == ref)
-                            {
-                                throw new IllegalArgumentException(
-                                    "WireAdminEvent.getServiceReference() may not be null");
-                            }
-
-                            put(EventConstants.SERVICE, ref);
-
-                            put(EventConstants.SERVICE_ID, ref
-                                .getProperty(EventConstants.SERVICE_ID));
-
-                            final Object objectClass = ref
-                                .getProperty(Constants.OBJECTCLASS);
-
-                            if(!(objectClass instanceof String[])
-                                || !Arrays.asList((String[]) objectClass)
-                                    .contains(WireAdmin.class.getName()))
-                            {
-                                throw new IllegalArgumentException(
-                                    "Bad objectclass: " + objectClass);
-                            }
-
-                            put(EventConstants.SERVICE_OBJECTCLASS, objectClass);
-
-                            put(EventConstants.SERVICE_PID, ref
-                                .getProperty(EventConstants.SERVICE_PID));
-                        }
+                        properties.put(EventConstants.EXCEPTION_MESSAGE, message);
                     }
-                }));
+                }
+
+                final ServiceReference eventRef = event.getServiceReference();
+
+                if(null == eventRef)
+                {
+                    throw new IllegalArgumentException(
+                        "WireAdminEvent.getServiceReference() 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(WireAdmin.class.getName()))
+                {
+                    throw new IllegalArgumentException(
+                        "Bad objectclass: " + objectClass);
+                }
+
+                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);
             }