You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2012/10/22 15:24:39 UTC

svn commit: r1400871 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw: ./ decorator/ service/

Author: cschneider
Date: Mon Oct 22 13:24:39 2012
New Revision: 1400871

URL: http://svn.apache.org/viewvc?rev=1400871&view=rev
Log:
DOSGI-130 Cleanup unused code, fix warnings, switch to interfaces for some collections

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventAdminHelper.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Mon Oct 22 13:24:39 2012
@@ -95,15 +95,6 @@ public class Activator implements Manage
         return OsgiUtils.getIntentMap(bc);
     }
 
-    private Object getHeader(String key) {
-        Object value = bc.getBundle().getHeaders().get(key);
-        if (value == null) {
-            return "";
-        } else {
-            return value;
-        }
-    }
-
     public void stop() {
         LOG.fine("RemoteServiceAdmin Implementation is shutting down now");
         
@@ -121,7 +112,8 @@ public class Activator implements Manage
         // unregister other registered services (ManagedService + Hooks)
     }
 
-    public synchronized void updated(Dictionary props) throws ConfigurationException {
+    @SuppressWarnings("rawtypes")
+	public synchronized void updated(Dictionary props) throws ConfigurationException {
         if (props != null && CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID))) {
             // topManager.updated(props);
         }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ClassUtils.java Mon Oct 22 13:24:39 2012
@@ -94,7 +94,8 @@ public final class ClassUtils {
     	return null;
     }
     
-    public static List<Object> loadProviderClasses(BundleContext callingContext, Map sd, String propName) {
+    @SuppressWarnings("rawtypes")
+	public static List<Object> loadProviderClasses(BundleContext callingContext, Map sd, String propName) {
     	
     	Object serviceProviders = sd.get(propName);
         if (serviceProviders != null) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Mon Oct 22 13:24:39 2012
@@ -64,118 +64,11 @@ public final class OsgiUtils {
 
     private static final String SERVICE_DESCRIPTION_ELEMENT = "service-description";
 
-//    private static final String PROVIDE_INTERFACE_ELEMENT = "provide";
-//    private static final String PROVIDE_INTERFACE_NAME_ATTRIBUTE = "interface";
-
-//    private static final String PROPERTY_ELEMENT = "property";
-//    private static final String PROPERTY_NAME_ATTRIBUTE = "name";
-//    private static final String PROPERTY_VALUE_ATTRIBUTE = "value";
-//    private static final String PROPERTY_INTERFACE_ATTRIBUTE = "interface";
-
-//    private static final String INTERFACE_WILDCARD = "*";
-//    private static final String INTERFACE_SEPARATOR = ":";
-
     private OsgiUtils() {
     }
 
-//    // Used by PublishHook
-//    public static ServiceEndpointDescription getRemoteReference(ServiceReference sref, boolean matchAllNames) {
-//
-//        String[] names = (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
-//        if (names == null || names.length == 0) {
-//            return null;
-//        }
-//
-//        Map<String, Object> userProperties = new HashMap<String, Object>();
-//        for (String key : sref.getPropertyKeys()) {
-//            userProperties.put(key, sref.getProperty(key));
-//        }
-//        List<ServiceEndpointDescription> srefs = getRemoteReferences(sref.getBundle(), names, userProperties,
-//                                                                     matchAllNames);
-//        setAdditionalProperties(sref, userProperties);
-//
-//        if (srefs.isEmpty()) {
-//            return new ServiceEndpointDescriptionImpl(Arrays.asList(names), userProperties);
-//        }
-//
-//        return srefs.get(0);
-//    }
-
-//    @SuppressWarnings("unchecked")
-//    public static List<ServiceEndpointDescription> getRemoteReferences(Bundle b, String[] names,
-//                                                                       Map<String, Object> userProperties,
-//                                                                       boolean matchAllNames) {
-//
-//        List<Element> references = getAllDescriptionElements(b);
-//
-//        List<ServiceEndpointDescription> srefs = new ArrayList<ServiceEndpointDescription>();
-//        Namespace ns = Namespace.getNamespace(REMOTE_SERVICES_NS);
-//        for (Element ref : references) {
-//            List<String> iNames = getProvidedInterfaces(ref.getChildren(PROVIDE_INTERFACE_ELEMENT, ns));
-//            if (!serviceNamesMatch(names, iNames, matchAllNames)) {
-//                continue;
-//            }
-//
-//            Map<String, Object> remoteProps = new HashMap<String, Object>(userProperties);
-//            addProperties(remoteProps, ref.getChildren(PROPERTY_ELEMENT, ns));
-//            srefs.add(new ServiceEndpointDescriptionImpl(iNames, remoteProps));
-//        }
-//        return srefs;
-//
-//    }
-
-//    public static ServiceEndpointDescription[] flattenServiceDescription(ServiceEndpointDescription sd) {
-//        ServiceEndpointDescription[] list = null;
-//        int interfaceNameCount = sd.getProvidedInterfaces().size();
-//        if (sd.getProvidedInterfaces() == null || interfaceNameCount <= 1) {
-//            list = new ServiceEndpointDescription[] {
-//                sd
-//            };
-//        } else {
-//            String[] iNames = (String[])sd.getProvidedInterfaces().toArray(new String[interfaceNameCount]);
-//            list = new ServiceEndpointDescription[iNames.length];
-//            for (int i = 0; i < iNames.length; i++) {
-//                Map<String, Object> props = excludeProperty(sd.getProperties(),
-//                                                            Constants.EXPORTED_INTERFACES,
-//                                                            Constants.EXPORTED_INTERFACES_OLD,
-//                                                            Constants.RS_PROVIDER_GLOBAL_PROP_KEY,
-//                                                            Constants.RS_PROVIDER_EXPECTED_PROP_KEY,
-//                                                            Constants.RS_PROVIDER_PROP_KEY);
-//
-//                String keys[] = props.keySet().toArray(new String[props.size()]);
-//                for (int j = 0; j < keys.length; j++) {
-//                    int sep = keys[j].indexOf(INTERFACE_SEPARATOR);
-//                    if (sep > -1) {
-//                        String value = (String)props.remove(keys[j]);
-//                        String root = keys[j].substring(0, sep);
-//                        String iface = sep + INTERFACE_SEPARATOR.length() < keys[j].length() ? keys[j]
-//                            .substring(sep + INTERFACE_SEPARATOR.length()) : "";
-//                        if (iNames[i].equals(iface)) {
-//                            props.put(root, value);
-//                        }
-//                    }
-//                }
-//                list[i] = new ServiceEndpointDescriptionImpl(iNames[i], props);
-//            }
-//        }
-//        return list;
-//    }
-
-//    private static Map<String, Object> excludeProperty(Map properties, String... excludes) {
-//        Collection<String> exList = Arrays.asList(excludes);
-//
-//        Map<String, Object> pruned = new HashMap<String, Object>();
-//        for (Object key : properties.keySet()) {
-//            if (exList.contains(key)) {
-//                // exclude
-//            } else {
-//                pruned.put((String)key, properties.get(key));
-//            }
-//        }
-//        return pruned;
-//    }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static List<Element> getAllDescriptionElements(Bundle b) {
         Object directory = null;
 
@@ -207,82 +100,6 @@ public final class OsgiUtils {
         return elements;
     }
 
-//    private static void setAdditionalProperties(ServiceReference sref, Map<String, Object> props) {
-//        BundleContext bc = sref.getBundle().getBundleContext();
-//        ServiceReference[] refs;
-//        try {
-//            refs = bc.getServiceReferences(ServiceDecorator.class.getName(), null);
-//        } catch (InvalidSyntaxException e) {
-//            // should never happen, filter is null
-//            return;
-//        }
-//        if (refs == null) {
-//            return;
-//        }
-//
-//        for (ServiceReference ref : refs) {
-//            Object svc = bc.getService(ref);
-//            if (svc instanceof ServiceDecorator) {
-//                ((ServiceDecorator)svc).decorate(sref, props);
-//            }
-//        }
-//    }
-
-//    private static boolean serviceNamesMatch(String[] names, List<String> iNames, boolean matchAllNames) {
-//        if (names == null || names.length == 0) {
-//            return false;
-//        }
-//        if (matchAllNames) {
-//            for (String name : names) {
-//                if (!iNames.contains(name)) {
-//                    return false;
-//                }
-//            }
-//            return true;
-//        } else {
-//            for (String name : names) {
-//                if (iNames.contains(name)) {
-//                    return true;
-//                }
-//            }
-//            return false;
-//        }
-//    }
-
-    /*
-     * // TODO : consider creating a new List rather than modifyiing the existing one public static void
-     * matchServiceDescriptions(List<ServiceEndpointDescription> sds, String interfaceName, Filter filter,
-     * boolean matchAll) { for (Iterator<ServiceEndpointDescription> it = sds.iterator(); it.hasNext();) {
-     * ServiceEndpointDescription sd = it.next(); if (filter != null && !OsgiUtils.matchAgainstFilter(sd,
-     * interfaceName, filter, matchAll)) { it.remove(); } } }
-     * @SuppressWarnings("unchecked") public static boolean matchAgainstFilter(ServiceEndpointDescription sd,
-     * String interfaceName, Filter filter, boolean matchAll) { Dictionary props = new Hashtable(); for
-     * (Object key : sd.getPropertyKeys()) { if (matchAll ||
-     * key.toString().startsWith(DistributionConstants.REMOTE)) { props.put(key,
-     * sd.getProperty(key.toString())); } } String[] interfaceNames = getProvidedInterfaces(sd,
-     * interfaceName); if (interfaceNames != null) { props.put(org.osgi.framework.Constants.OBJECTCLASS,
-     * interfaceNames); } return filter.match(props); }
-     */
-
-//    public static String[] getProvidedInterfaces(ServiceEndpointDescription sd, String interfaceName) {
-//
-//        int interfaceNameCount = sd.getProvidedInterfaces().size();
-//        String[] interfaceNames = (String[])sd.getProvidedInterfaces()
-//            .toArray(new String[interfaceNameCount]);
-//        if (interfaceName == null) {
-//            return interfaceNames;
-//        }
-//
-//        for (String s : interfaceNames) {
-//            if (s.equals(interfaceName)) {
-//                return new String[] {
-//                    s
-//                };
-//            }
-//        }
-//        return null;
-//    }
-
     public static Filter createFilter(BundleContext bc, String filterValue) {
 
         if (filterValue == null) {
@@ -317,43 +134,7 @@ public final class OsgiUtils {
         return sb.toString();
     }
 
-//    private static Map<String, Object> getProperties(List<Element> elements) {
-//        Map<String, Object> props = new HashMap<String, Object>();
-//        addProperties(props, elements);
-//        return props;
-//    }
-
-//    private static void addProperties(Map<String, Object> props, List<Element> elements) {
-//        for (Element p : elements) {
-//            String key = p.getAttributeValue(PROPERTY_NAME_ATTRIBUTE);
-//            String value = p.getAttributeValue(PROPERTY_VALUE_ATTRIBUTE);
-//            if (value == null) {
-//                value = p.getTextTrim();
-//            }
-//
-//            String iface = p.getAttributeValue(PROPERTY_INTERFACE_ATTRIBUTE);
-//            if (key != null) {
-//                props.put(iface == null || iface.length() == 0 ? key : key + INTERFACE_SEPARATOR + iface,
-//                          value);
-//            }
-//        }
-//    }
-
-//    private static List<String> getProvidedInterfaces(List<Element> elements) {
-//
-//        List<String> names = new ArrayList<String>();
-//
-//        for (Element p : elements) {
-//            String name = p.getAttributeValue(PROVIDE_INTERFACE_NAME_ATTRIBUTE);
-//            if (name != null) {
-//                names.add(name);
-//            }
-//        }
-//
-//        return names;
-//    }
-
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static <T> OsgiService<T> getOsgiService(BundleContext bc, Class<T> serviceClass) {
         try {
             ServiceReference sr = bc.getServiceReference(serviceClass.getName());
@@ -417,27 +198,10 @@ public final class OsgiUtils {
         }
     }
 
-    // Eg. "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
-    public static Filter createFilterFromProperties(BundleContext bc, Dictionary properties) {
-
-        if (properties == null || properties.isEmpty()) {
-            return null;
-        }
-
-        StringBuilder sb = new StringBuilder();
-        sb.append("(&");
-        for (Enumeration keys = properties.keys(); keys.hasMoreElements();) {
-            String key = keys.nextElement().toString();
-            String value = properties.get(key).toString();
-            sb.append('(').append(key).append('=').append(value).append(')');
-        }
-        sb.append(')');
-        return createFilter(bc, sb.toString());
-    }
-
     // TODO : move these property helpers into PropertyUtils ?
 
-    public static boolean getBooleanProperty(Map sd, String name) {
+    @SuppressWarnings("rawtypes")
+	public static boolean getBooleanProperty(Map sd, String name) {
         Object value = sd.get(name);
         return toBoolean(value);
     }
@@ -473,7 +237,8 @@ public final class OsgiUtils {
 
     }
 
-    public static String getProperty(Map dict, String name) {
+    @SuppressWarnings("rawtypes")
+	public static String getProperty(Map dict, String name) {
         Object o = dict.get(name);
 
         if (o != null && o instanceof String) {
@@ -482,79 +247,6 @@ public final class OsgiUtils {
         return null;
     }
 
-//    @SuppressWarnings("unchecked")
-//    public static <T> T getProperty(ServiceEndpointDescription sd, String name, Class<T> type, T defaultValue) {
-//        Object o = sd.getProperty(name);
-//        if (o == null) {
-//            return defaultValue;
-//        }
-//        return type.isAssignableFrom(o.getClass()) ? (T)o : null;
-//    }
-//
-//    public static String[] getPublishableInterfaces(ServiceEndpointDescription sd, ServiceReference sref) {
-//        Collection<String> publishProperty = getMultiValueProperty(sd
-//            .getProperty(Constants.EXPORTED_INTERFACES));
-//        if (publishProperty == null) {
-//            publishProperty = getMultiValueProperty(sd.getProperty(Constants.EXPORTED_INTERFACES_OLD));
-//        }
-//
-//        String[] actualInterfaces = (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
-//        String[] publishableInterfaces = null;
-//
-//        if (actualInterfaces != null && actualInterfaces.length > 0 && publishProperty != null) {
-//
-//            if (publishProperty.size() == 1 && INTERFACE_WILDCARD.equals(publishProperty.iterator().next())) {
-//                // wildcard indicates all interfaces should be published
-//                //
-//                publishableInterfaces = actualInterfaces;
-//            } else {
-//                String[] requestedInterfaces;
-//                if (publishProperty.size() == 0) {
-//                    requestedInterfaces = null;
-//                } else if (publishProperty.size() == 1) {
-//                    requestedInterfaces = tokenize(publishProperty.iterator().next(), ",");
-//                } else {
-//                    requestedInterfaces = publishProperty.toArray(new String[publishProperty.size()]);
-//                }
-//
-//                ArrayList<String> publishableList = new ArrayList<String>();
-//                for (int i = 0; requestedInterfaces != null && i < requestedInterfaces.length; i++) {
-//                    if (contains(actualInterfaces, requestedInterfaces[i])) {
-//                        publishableList.add(requestedInterfaces[i]);
-//                    } else {
-//                        // simply ignore non-exposed interfaces
-//                        //
-//                        LOG.warning("ignoring publish interface, " + requestedInterfaces[i]
-//                                    + ", not exposed by service");
-//                    }
-//                }
-//
-//                if (publishableList.size() > 0) {
-//                    publishableInterfaces = publishableList.toArray(new String[publishableList.size()]);
-//                }
-//            }
-//        }
-//
-//        return publishableInterfaces;
-//    }
-
-//    private static String[] tokenize(String str, String delim) {
-//        StringTokenizer tokenizer = new StringTokenizer(str, delim);
-//        String[] tokens = new String[tokenizer.countTokens()];
-//        for (int i = 0; tokenizer.hasMoreTokens(); i++) {
-//            tokens[i] = tokenizer.nextToken();
-//        }
-//        return tokens;
-//    }
-//
-//    private static boolean contains(String[] list, String member) {
-//        boolean found = false;
-//        for (int i = 0; i < list.length && !found; i++) {
-//            found = member.equals(list[i]);
-//        }
-//        return found;
-//    }
-
     /**
      * Tries to retrieve the version of iClass via the PackageAdmin
      * 
@@ -601,7 +293,6 @@ public final class OsgiUtils {
         return "0.0.0";
     }
 
-    
     public static String getUUID(BundleContext bc) {
         synchronized ("org.osgi.framework.uuid") {
             String uuid = bc.getProperty("org.osgi.framework.uuid");

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java Mon Oct 22 13:24:39 2012
@@ -80,7 +80,7 @@ public class ServiceDecoratorImpl implem
         }
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     static List<Element> getDecorationElements(Bundle bundle) {
         Enumeration entries = bundle.findEntries("OSGI-INF/remote-service", "*.xml", false);
         if (entries == null) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventAdminHelper.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventAdminHelper.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventAdminHelper.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventAdminHelper.java Mon Oct 22 13:24:39 2012
@@ -43,11 +43,10 @@ public class EventAdminHelper {
         bctx = bc;
     }
 
-    private Event createEvent(Properties p, String t) {
-
-        String topic = "org/osgi/service/remoteserviceadmin/" + t;
-        Dictionary props = p;
+    @SuppressWarnings("rawtypes")
+	private Event createEvent(Properties props, String type) {
 
+        String topic = "org/osgi/service/remoteserviceadmin/" + type;
         props.put("bundle", bctx.getBundle());
         props.put("bundle.id", bctx.getBundle().getBundleId());
         props.put("bundle.symbolicname", bctx.getBundle().getSymbolicName());
@@ -63,7 +62,7 @@ public class EventAdminHelper {
         
         setIfNotNull(props, "bundle.version", v);
 
-        return new Event(topic, props);
+        return new Event(topic, (Dictionary)props);
     }
 
     public void notifyEventAdmin(RemoteServiceAdminEvent rsae) {
@@ -105,7 +104,8 @@ public class EventAdminHelper {
 
     }
 
-    private void setIfNotNull(Dictionary props, String key, Object o) {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	private void setIfNotNull(Dictionary props, String key, Object o) {
         if (o != null)
             props.put(key, o);
     }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/EventProducer.java Mon Oct 22 13:24:39 2012
@@ -43,7 +43,7 @@ public class EventProducer {
         eaHelper = new EventAdminHelper(bctx);
     }
 
-    protected void publishNotifcation(List<ExportRegistrationImpl> erl) {
+    protected void publishNotifcation(List<ExportRegistration> erl) {
         for (ExportRegistration exportRegistration : erl) {
             publishNotifcation(exportRegistration);
         }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportReferenceImpl.java Mon Oct 22 13:24:39 2012
@@ -21,12 +21,16 @@ package org.apache.cxf.dosgi.dsw.service
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
 
 public class ExportReferenceImpl implements ExportReference {
     private final ExportRegistrationImpl exportRegistration;
 
-    public ExportReferenceImpl(ExportRegistrationImpl exportRegistrationImpl) {
-        exportRegistration = exportRegistrationImpl;
+    public ExportReferenceImpl(ExportRegistration exportRegistration) {
+    	if (!(exportRegistration instanceof ExportRegistrationImpl)) {
+    		throw new IllegalArgumentException("Can only create a reference from ExportRegistrationImpl");	
+    	}
+        this.exportRegistration = (ExportRegistrationImpl) exportRegistration;
     }
 
     public EndpointDescription getExportedEndpoint() {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java Mon Oct 22 13:24:39 2012
@@ -37,9 +37,6 @@ import org.osgi.service.remoteserviceadm
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
-
-
-/// *************************** FIXME: some old methods might be in here ****
 public class ExportRegistrationImpl implements ExportRegistration {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ExportRegistrationImpl.class);
@@ -152,7 +149,7 @@ public class ExportRegistrationImpl impl
             r += "---> NULL <---- \n";
         } else {
             Set<Map.Entry<String,Object>> props = endpointDescription.getProperties().entrySet();
-            for (Map.Entry entry : props) {
+            for (Map.Entry<String,Object> entry : props) {
                 Object value = entry.getValue();
                 r += entry.getKey() + "  => " +
                     (value instanceof Object[] ? Arrays.toString((Object []) value) : value) + "\n";

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java Mon Oct 22 13:24:39 2012
@@ -46,6 +46,7 @@ import org.osgi.framework.ServiceReferen
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.ExportReference;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
 import org.osgi.service.remoteserviceadmin.ImportReference;
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
@@ -55,7 +56,7 @@ public class RemoteServiceAdminCore impl
 
     private static final Logger LOG = LogUtils.getL7dLogger(RemoteServiceAdminCore.class);
 
-    private final LinkedHashMap<ServiceReference, Collection<ExportRegistrationImpl>> exportedServices = new LinkedHashMap<ServiceReference, Collection<ExportRegistrationImpl>>();
+    private final LinkedHashMap<ServiceReference, Collection<ExportRegistration>> exportedServices = new LinkedHashMap<ServiceReference, Collection<ExportRegistration>>();
     private final LinkedHashMap<EndpointDescription, Collection<ImportRegistrationImpl>> importedServices = new LinkedHashMap<EndpointDescription, Collection<ImportRegistrationImpl>>();
 
     private BundleContext bctx;
@@ -83,7 +84,8 @@ public class RemoteServiceAdminCore impl
         eventProducer = new EventProducer(bctx);
     }
 
-    public List exportService(ServiceReference serviceReference, Map additionalProperties)
+    @SuppressWarnings("rawtypes")
+	public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
         LOG.fine("RemoteServiceAdmin: exportService: " + serviceReference.getClass().getName());
@@ -92,18 +94,21 @@ public class RemoteServiceAdminCore impl
             // check if it is already exported ....
             if (exportedServices.containsKey(serviceReference)) {
                 LOG.fine("already exported ...  " + serviceReference.getClass().getName());
-                Collection<ExportRegistrationImpl> regs = exportedServices.get(serviceReference);
+                Collection<ExportRegistration> regs = exportedServices.get(serviceReference);
 
                 List<EndpointDescription> copiedEndpoints = new ArrayList<EndpointDescription>();
 
                 // / create a new list with copies of the exportRegistrations
-                List<ExportRegistrationImpl> copy = new ArrayList<ExportRegistrationImpl>(regs.size());
-                for (ExportRegistrationImpl exportRegistration : regs) {
-                    // create one copy for each distinct endpoint description
-                    if (!copiedEndpoints.contains(exportRegistration.getEndpointDescription())) {
-                        copiedEndpoints.add(exportRegistration.getEndpointDescription());
-                        copy.add(new ExportRegistrationImpl(exportRegistration));
-                    }
+                List<ExportRegistration> copy = new ArrayList<ExportRegistration>(regs.size());
+                for (ExportRegistration exportRegistration : regs) {
+                	if (exportRegistration instanceof ExportRegistrationImpl) {
+                		ExportRegistrationImpl exportRegistrationImpl = (ExportRegistrationImpl) exportRegistration;
+                		// create one copy for each distinct endpoint description
+                		if (!copiedEndpoints.contains(exportRegistrationImpl.getEndpointDescription())) {
+                			copiedEndpoints.add(exportRegistrationImpl.getEndpointDescription());
+                			copy.add(new ExportRegistrationImpl(exportRegistrationImpl));
+                		}
+                	}
                 }
 
                 regs.addAll(copy);
@@ -115,7 +120,7 @@ public class RemoteServiceAdminCore impl
             if (isCreatedByThisRSA(serviceReference)) {
                 LOG.fine("proxy provided by this bundle ...  " + serviceReference.getClass().getName());
                 // TODO: publish error event ? Not sure
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
 
 
@@ -153,7 +158,7 @@ public class RemoteServiceAdminCore impl
                         .severe("service cannot be exported because the following intents are not supported by this RSA: "
                                 + unsupportedIntents);
                     // TODO: publish error event
-                    return Collections.EMPTY_LIST;
+                    return Collections.emptyList();
                 }
 
             }
@@ -169,7 +174,7 @@ public class RemoteServiceAdminCore impl
                     LOG
                         .severe("export failed: no provided service interfaces found or service_exported_interfaces is null !!");
                     // TODO: publish error event ? not sure
-                    return Collections.EMPTY_LIST;
+                    return Collections.emptyList();
                 }
 
                 if (allowedInterfaces.length == 1 && "*".equals(allowedInterfaces[0])) {
@@ -193,7 +198,7 @@ public class RemoteServiceAdminCore impl
             if (interfaces.size() == 0) {
                 LOG.warning("no interfaces to be exported");
                 // TODO: publish error event ? not sure
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
 
             List<String> configurationTypes = determineConfigurationTypes(serviceProperties);
@@ -204,7 +209,7 @@ public class RemoteServiceAdminCore impl
             if (configurationTypes.size() == 0) {
                 LOG.info("the requested configuration types are not supported");
                 // TODO: publish error event ? not sure
-                return Collections.EMPTY_LIST;
+                return Collections.emptyList();
             }
 
             LinkedHashMap<String, ExportRegistrationImpl> exportRegs = new LinkedHashMap<String, ExportRegistrationImpl>(
@@ -233,7 +238,7 @@ public class RemoteServiceAdminCore impl
 
                 if (handler == null) {
                     // TODO: publish error event ? not sure
-                    return Collections.EMPTY_LIST;
+                    return Collections.emptyList();
                 }
 
                 LOG.info("found handler for " + iface + "  -> " + handler);
@@ -261,9 +266,9 @@ public class RemoteServiceAdminCore impl
             }
 
             // enlist initial export Registrations in global list of exportRegistrations
-            exportedServices.put(serviceReference, new ArrayList<ExportRegistrationImpl>(exportRegs.values()));
+            exportedServices.put(serviceReference, new ArrayList<ExportRegistration>(exportRegs.values()));
 
-            List<ExportRegistrationImpl> lExpReg = new ArrayList<ExportRegistrationImpl>(exportRegs.values());
+            List<ExportRegistration> lExpReg = new ArrayList<ExportRegistration>(exportRegs.values());
             eventProducer.publishNotifcation(lExpReg);
 
             return lExpReg;
@@ -299,11 +304,11 @@ public class RemoteServiceAdminCore impl
         return sref.getBundle().equals(bctx.getBundle());
     }
 
-    public Collection getExportedServices() {
+    public Collection<ExportReference> getExportedServices() {
         synchronized (exportedServices) {
             List<ExportReference> ers = new ArrayList<ExportReference>();
-            for (Collection<ExportRegistrationImpl> exportRegistrations : exportedServices.values()) {
-                for (ExportRegistrationImpl er : exportRegistrations) {
+            for (Collection<ExportRegistration> exportRegistrations : exportedServices.values()) {
+                for (ExportRegistration er : exportRegistrations) {
                     ers.add(new ExportReferenceImpl(er));
                 }
             }
@@ -311,7 +316,7 @@ public class RemoteServiceAdminCore impl
         }
     }
 
-    public Collection getImportedEndpoints() {
+    public Collection<ImportReference> getImportedEndpoints() {
         synchronized (importedServices) {
             List<ImportReference> irs = new ArrayList<ImportReference>();
             for (Collection<ImportRegistrationImpl> irl : importedServices.values()) {
@@ -323,7 +328,7 @@ public class RemoteServiceAdminCore impl
         }
     }
 
-    private ConfigurationTypeHandler getHandler(List<String> configurationTypes, Map serviceProperties,
+    private ConfigurationTypeHandler getHandler(List<String> configurationTypes, Map<?, ?> serviceProperties,
                                                 Map<String, Object> props) {
         return ConfigTypeHandlerFactory.getInstance().getHandler(bctx, configurationTypes, serviceProperties,
                                                                  props);
@@ -357,7 +362,7 @@ public class RemoteServiceAdminCore impl
                 return ir;
             }
 
-            List remoteConfigurationTypes = endpoint.getConfigurationTypes();
+            List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
 
             if (remoteConfigurationTypes == null) {
                 LOG.severe("the supplied endpoint has no configuration type");
@@ -380,7 +385,7 @@ public class RemoteServiceAdminCore impl
                 return null;
             }
 
-            Map<String, Object> emptyProps = Collections.EMPTY_MAP;
+            Map<String, Object> emptyProps = Collections.emptyMap();
             ConfigurationTypeHandler handler = getHandler(usableConfigurationTypes, endpoint.getProperties(),
                                                           emptyProps);
 
@@ -436,7 +441,7 @@ public class RemoteServiceAdminCore impl
                 }
 
                 /* TODO: add additional local params ... */
-                Dictionary serviceProps = new Hashtable(imReg.getImportedEndpointDescription()
+                Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(imReg.getImportedEndpointDescription()
                     .getProperties());
                 serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
                 serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
@@ -469,7 +474,7 @@ public class RemoteServiceAdminCore impl
      */
     protected void removeExportRegistration(ExportRegistrationImpl eri) {
         synchronized (exportedServices) {
-            Collection<ExportRegistrationImpl> exRegs = exportedServices.get(eri.getServiceReference());
+            Collection<ExportRegistration> exRegs = exportedServices.get(eri.getServiceReference());
             if (exRegs != null && exRegs.contains(eri)) {
                 exRegs.remove(eri);
             } else {
@@ -490,14 +495,14 @@ public class RemoteServiceAdminCore impl
         Bundle exportingBundle = exportingBundleCtx.getBundle();
 
         // Work on a copy as the map gets modified as part of the behaviour by underlying methods
-        HashMap<ServiceReference, Collection<ExportRegistrationImpl>> exportCopy = new HashMap<ServiceReference, Collection<ExportRegistrationImpl>>(exportedServices);
+        HashMap<ServiceReference, Collection<ExportRegistration>> exportCopy = new HashMap<ServiceReference, Collection<ExportRegistration>>(exportedServices);
 
-        for (Iterator<Map.Entry<ServiceReference, Collection<ExportRegistrationImpl>>> it = exportCopy.entrySet().iterator(); it.hasNext(); ) {
-            Entry<ServiceReference, Collection<ExportRegistrationImpl>> entry = it.next();
+        for (Iterator<Map.Entry<ServiceReference, Collection<ExportRegistration>>> it = exportCopy.entrySet().iterator(); it.hasNext(); ) {
+            Entry<ServiceReference, Collection<ExportRegistration>> entry = it.next();
             Bundle regBundle = entry.getKey().getBundle();
             if (exportingBundle.equals(regBundle)) {
                 // Again work on a copy, as the value gets modified by the behaviour inside export.close()
-                for (ExportRegistrationImpl export : new ArrayList<ExportRegistrationImpl>(entry.getValue())) {
+                for (ExportRegistration export : new ArrayList<ExportRegistration>(entry.getValue())) {
                     // This will remove the registration from the real map of exports
                     export.close();
                 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java Mon Oct 22 13:24:39 2012
@@ -24,20 +24,17 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.logging.Logger;
 
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.EndpointPermission;
+import org.osgi.service.remoteserviceadmin.ExportRegistration;
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
 
 public class RemoteServiceAdminInstance implements RemoteServiceAdmin {
-    private static final Logger LOG = LogUtils.getL7dLogger(RemoteServiceAdminInstance.class);
-
     private BundleContext bctx;
     private RemoteServiceAdminCore rsaCore;
 
@@ -48,7 +45,8 @@ public class RemoteServiceAdminInstance 
         rsaCore = core;
     }
 
-    public List /* ExportRegistration */exportService(ServiceReference ref, Map properties)
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public List /* ExportRegistration */exportService(ServiceReference ref, Map properties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
         SecurityManager sm = System.getSecurityManager();
@@ -64,17 +62,18 @@ public class RemoteServiceAdminInstance 
         final Map propertiesFinal = properties;
 
         return AccessController.doPrivileged(new PrivilegedAction<List>() {
-            public List run() {
+            public List<ExportRegistration> run() {
 
                 if (closed)
-                    return Collections.EMPTY_LIST;
+                    return Collections.emptyList();
 
                  return rsaCore.exportService(refFinal, propertiesFinal);
             }
         });
     }
 
-    public Collection getExportedServices() {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	public Collection getExportedServices() {
 
         SecurityManager sm = System.getSecurityManager();
         EndpointPermission epp = new EndpointPermission("*", EndpointPermission.READ);
@@ -87,7 +86,8 @@ public class RemoteServiceAdminInstance 
         return rsaCore.getExportedServices();
     }
 
-    public Collection getImportedEndpoints() {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	public Collection getImportedEndpoints() {
 
         SecurityManager sm = System.getSecurityManager();
         EndpointPermission epp = new EndpointPermission("*", EndpointPermission.READ);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java Mon Oct 22 13:24:39 2012
@@ -32,13 +32,11 @@ import org.osgi.framework.ServiceRegistr
 public class RemoteServiceadminFactory implements ServiceFactory {
 
     private static final Logger LOG = LogUtils.getL7dLogger(RemoteServiceadminFactory.class);
-    private BundleContext bctx;
     private List<RemoteServiceAdminInstance> rsaServiceInstances = new ArrayList<RemoteServiceAdminInstance>();
 
     private RemoteServiceAdminCore rsaCore;
 
     public RemoteServiceadminFactory(BundleContext bc) {
-        bctx = bc;
         rsaCore = new RemoteServiceAdminCore(bc);
     }
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java?rev=1400871&r1=1400870&r2=1400871&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java Mon Oct 22 13:24:39 2012
@@ -36,7 +36,8 @@ public class Utils {
 
     private static final Logger LOG = LogUtils.getL7dLogger(Utils.class);
     
-    public static String[] normalizeStringPlus(Object object) {
+    @SuppressWarnings("rawtypes")
+	public static String[] normalizeStringPlus(Object object) {
 
         if (object instanceof String) {
             String s = (String)object;
@@ -98,7 +99,8 @@ public class Utils {
     }
     
     
-    public static String[] getAllRequiredIntents(Map serviceProperties){
+    @SuppressWarnings("rawtypes")
+	public static String[] getAllRequiredIntents(Map serviceProperties){
         // Get the intents that need to be supported by the RSA
         String[] requiredIntents = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
         if(requiredIntents==null){
@@ -116,7 +118,8 @@ public class Utils {
         return requiredIntents;
     }
 
-    public static String[] getInetntsImplementedByTheService(Map serviceProperties){
+    @SuppressWarnings("rawtypes")
+	public static String[] getInetntsImplementedByTheService(Map serviceProperties){
         // Get the Intents that are implemented by the service 
         String[] serviceIntents = Utils.normalizeStringPlus(serviceProperties.get(RemoteConstants.SERVICE_INTENTS));
         
@@ -143,7 +146,8 @@ public class Utils {
     }
     
     
-    public static void overlayProperties(Properties serviceProperties, Map additionalProperties) {
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	public static void overlayProperties(Properties serviceProperties, Map additionalProperties) {
         Enumeration<Object> keys = serviceProperties.keys();
         // Maps lower case key to original key
         HashMap<String,String> keysLowerCase = new HashMap<String, String>();