You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2014/11/27 16:14:40 UTC

svn commit: r1642172 [4/4] - in /felix/trunk/connect: ./ src/main/java/org/apache/felix/connect/ src/main/java/org/apache/felix/connect/felix/framework/ src/main/java/org/apache/felix/connect/felix/framework/capabilityset/ src/main/java/org/apache/feli...

Modified: felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/ClasspathScanner.java
URL: http://svn.apache.org/viewvc/felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/ClasspathScanner.java?rev=1642172&r1=1642171&r2=1642172&view=diff
==============================================================================
--- felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/ClasspathScanner.java (original)
+++ felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/ClasspathScanner.java Thu Nov 27 15:14:39 2014
@@ -50,7 +50,7 @@ public class ClasspathScanner
     }
 
     public List<BundleDescriptor> scanForBundles(String filterString, ClassLoader loader)
-        throws Exception
+            throws Exception
     {
         Filter filter = (filterString != null) ? FrameworkUtil
                 .createFilter(filterString) : null;
@@ -58,105 +58,106 @@ public class ClasspathScanner
         loader = (loader != null) ? loader : getClass().getClassLoader();
 
         List<BundleDescriptor> bundles = new ArrayList<BundleDescriptor>();
-		byte[] bytes = new byte[1024 * 1024 * 2];
+        byte[] bytes = new byte[1024 * 1024 * 2];
         for (Enumeration<URL> e = loader.getResources(
-                "META-INF/MANIFEST.MF"); e.hasMoreElements();)
+                "META-INF/MANIFEST.MF"); e.hasMoreElements(); )
         {
             URL manifestURL = e.nextElement();
             InputStream input = null;
             try
             {
                 input = manifestURL.openStream();
-				int size = 0;
-				for (int i = input.read(bytes); i != -1; i = input.read(bytes, size, bytes.length - size)) {
-					size += i;
-					if (size == bytes.length) {
-					     byte[] tmp = new byte[size * 2];
-						 System.arraycopy(bytes, 0, tmp, 0, bytes.length);
-						 bytes = tmp;
-					}
-				}
-
-				// Now parse the main attributes. The idea is to do that
-				// without creating new byte arrays. Therefore, we read through
-				// the manifest bytes inside the bytes array and write them back into
-				// the same array unless we don't need them (e.g., \r\n and \n are skipped).
-				// That allows us to create the strings from the bytes array without the skipped
-				// chars. We stopp as soon as we see a blankline as that denotes that the main
-				//attributes part is finished.
-				String key = null;
-				int last = 0;
-				int current = 0;
+                int size = 0;
+                for (int i = input.read(bytes); i != -1; i = input.read(bytes, size, bytes.length - size))
+                {
+                    size += i;
+                    if (size == bytes.length)
+                    {
+                        byte[] tmp = new byte[size * 2];
+                        System.arraycopy(bytes, 0, tmp, 0, bytes.length);
+                        bytes = tmp;
+                    }
+                }
+
+                // Now parse the main attributes. The idea is to do that
+                // without creating new byte arrays. Therefore, we read through
+                // the manifest bytes inside the bytes array and write them back into
+                // the same array unless we don't need them (e.g., \r\n and \n are skipped).
+                // That allows us to create the strings from the bytes array without the skipped
+                // chars. We stopp as soon as we see a blankline as that denotes that the main
+                //attributes part is finished.
+                String key = null;
+                int last = 0;
+                int current = 0;
 
                 Map<String, String> headers = new HashMap<String, String>();
-				for (int i = 0; i < size; i++)
-				{
-					// skip \r and \n if it is follows by another \n
-					// (we catch the blank line case in the next iteration)
-					if (bytes[i] == '\r')
-					{
-						if ((i + 1 < size) && (bytes[i + 1] == '\n'))
-						{
-							continue;
-						}
-					}
-					if (bytes[i] == '\n')
-					{
-						if ((i + 1 < size) && (bytes[i + 1] == ' '))
-						{
-							i++;
-							continue;
-						}
-					}
-					// If we don't have a key yet and see the first : we parse it as the key
-					// and skip the :<blank> that follows it.
-					if ((key == null) && (bytes[i] == ':'))
-					{
-						key = new String(bytes, last, (current - last), "UTF-8");
-						if ((i + 1 < size) && (bytes[i + 1] == ' '))
-						{
-							last = current + 1;
-							continue;
-						}
-						else
-						{
-							throw new Exception(
-								"Manifest error: Missing space separator - " + key);
-						}
-					}
-					// if we are at the end of a line
-					if (bytes[i] == '\n')
-					{
-						// and it is a blank line stop parsing (main attributes are done)
-						if ((last == current) && (key == null))
-						{
-							break;
-						}
-						// Otherwise, parse the value and add it to the map (we throw an
-						// exception if we don't have a key or the key already exist.
-						String value = new String(bytes, last, (current - last), "UTF-8");
-						if (key == null)
-						{
-							throw new Exception("Manifst error: Missing attribute name - " + value);
-						}
-						else if (headers.put(key, value) != null)
-						{
-							throw new Exception("Manifst error: Duplicate attribute name - " + key);
-						}
-						last = current;
-						key = null;
-					}
-					else
-					{
-						// write back the byte if it needs to be included in the key or the value.
-						bytes[current++] = bytes[i];
-					}
-				}
+                for (int i = 0; i < size; i++)
+                {
+                    // skip \r and \n if it is follows by another \n
+                    // (we catch the blank line case in the next iteration)
+                    if (bytes[i] == '\r')
+                    {
+                        if ((i + 1 < size) && (bytes[i + 1] == '\n'))
+                        {
+                            continue;
+                        }
+                    }
+                    if (bytes[i] == '\n')
+                    {
+                        if ((i + 1 < size) && (bytes[i + 1] == ' '))
+                        {
+                            i++;
+                            continue;
+                        }
+                    }
+                    // If we don't have a key yet and see the first : we parse it as the key
+                    // and skip the :<blank> that follows it.
+                    if ((key == null) && (bytes[i] == ':'))
+                    {
+                        key = new String(bytes, last, (current - last), "UTF-8");
+                        if ((i + 1 < size) && (bytes[i + 1] == ' '))
+                        {
+                            last = current + 1;
+                            continue;
+                        }
+                        else
+                        {
+                            throw new Exception(
+                                    "Manifest error: Missing space separator - " + key);
+                        }
+                    }
+                    // if we are at the end of a line
+                    if (bytes[i] == '\n')
+                    {
+                        // and it is a blank line stop parsing (main attributes are done)
+                        if ((last == current) && (key == null))
+                        {
+                            break;
+                        }
+                        // Otherwise, parse the value and add it to the map (we throw an
+                        // exception if we don't have a key or the key already exist.
+                        String value = new String(bytes, last, (current - last), "UTF-8");
+                        if (key == null)
+                        {
+                            throw new Exception("Manifst error: Missing attribute name - " + value);
+                        }
+                        else if (headers.put(key, value) != null)
+                        {
+                            throw new Exception("Manifst error: Duplicate attribute name - " + key);
+                        }
+                        last = current;
+                        key = null;
+                    }
+                    else
+                    {
+                        // write back the byte if it needs to be included in the key or the value.
+                        bytes[current++] = bytes[i];
+                    }
+                }
                 if ((filter == null)
-                        || filter.match(new MapToDictionary(headers)))
+                        || filter.match(new MapToDictionary<String, String>(headers)))
                 {
-                    bundles.add(new BundleDescriptor(loader, getParentURL(manifestURL),
-                            headers));
+                    bundles.add(new BundleDescriptor(loader, getParentURL(manifestURL).toExternalForm(), headers));
                 }
             }
             finally

Modified: felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistry.java?rev=1642172&r1=1642171&r2=1642172&view=diff
==============================================================================
--- felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistry.java (original)
+++ felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistry.java Thu Nov 27 15:14:39 2014
@@ -18,8 +18,9 @@
  */
 package org.apache.felix.connect.launch;
 
+import java.util.Collection;
 import java.util.Dictionary;
-import java.util.List;
+
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceListener;
@@ -29,28 +30,24 @@ import org.osgi.framework.ServiceRegistr
 public interface PojoServiceRegistry
 {
     public BundleContext getBundleContext();
-	
-	public void startBundles(List<BundleDescriptor> bundles) throws Exception;
 
-    public void addServiceListener(ServiceListener listener, String filter)
-            throws InvalidSyntaxException;
+    public void startBundles(Collection<BundleDescriptor> bundles) throws Exception;
+
+    public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException;
 
     public void addServiceListener(ServiceListener listener);
 
     public void removeServiceListener(ServiceListener listener);
 
-    public ServiceRegistration registerService(String[] clazzes,
-            Object service, @SuppressWarnings("rawtypes") Dictionary properties);
+    public ServiceRegistration<?> registerService(String[] clazzes, Object service, Dictionary<String, ?> properties);
 
-    public ServiceRegistration registerService(String clazz, Object service,
-            @SuppressWarnings("rawtypes") Dictionary properties);
+    public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties);
 
-    public ServiceReference[] getServiceReferences(String clazz, String filter)
-            throws InvalidSyntaxException;
+    public ServiceReference<?>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
 
-    public ServiceReference getServiceReference(String clazz);
+    public ServiceReference<?> getServiceReference(String clazz);
 
-    public Object getService(ServiceReference reference);
+    public <S> S getService(ServiceReference<S> reference);
 
-    public boolean ungetService(ServiceReference reference);
+    public boolean ungetService(ServiceReference<?> reference);
 }

Modified: felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistryFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistryFactory.java?rev=1642172&r1=1642171&r2=1642172&view=diff
==============================================================================
--- felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistryFactory.java (original)
+++ felix/trunk/connect/src/main/java/org/apache/felix/connect/launch/PojoServiceRegistryFactory.java Thu Nov 27 15:14:39 2014
@@ -20,11 +20,10 @@ package org.apache.felix.connect.launch;
 
 import java.util.Map;
 
-public interface PojoServiceRegistryFactory 
+public interface PojoServiceRegistryFactory
 {
-    public static final String BUNDLE_DESCRIPTORS = PojoServiceRegistry.class
-            .getName().toLowerCase() + ".bundles";
+    public static final String BUNDLE_DESCRIPTORS =
+            PojoServiceRegistry.class.getName().toLowerCase() + ".bundles";
 
-    public PojoServiceRegistry newPojoServiceRegistry(Map configuration)
-            throws Exception;
+    public PojoServiceRegistry newPojoServiceRegistry(Map<String, Object> configuration) throws Exception;
 }