felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1103907 [7/8] - in /felix/trunk/framework/src/main/java/org: apache/felix/framework/ osgi/framework/ osgi/framework/startlevel/ osgi/framework/wiring/
Date Mon, 16 May 2011 21:30:33 GMT
Modified: felix/trunk/framework/src/main/java/org/osgi/framework/ServiceFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/ServiceFactory.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/ServiceFactory.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/ServiceFactory.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,65 +21,73 @@ package org.osgi.framework;
  * environment.
  * 
  * <p>
- * When registering a service, a <code>ServiceFactory</code> object can be
- * used instead of a service object, so that the bundle developer can gain
- * control of the specific service object granted to a bundle that is using the
- * service.
+ * When registering a service, a {@code ServiceFactory} object can be used
+ * instead of a service object, so that the bundle developer can gain control of
+ * the specific service object granted to a bundle that is using the service.
  * 
  * <p>
- * When this happens, the
- * <code>BundleContext.getService(ServiceReference)</code> method calls the
- * <code>ServiceFactory.getService</code> method to create a service object
- * specifically for the requesting bundle. The service object returned by the
- * <code>ServiceFactory</code> is cached by the Framework until the bundle
+ * When this happens, the {@code BundleContext.getService(ServiceReference)}
+ * method calls the {@code ServiceFactory.getService} method to create a service
+ * object specifically for the requesting bundle. The service object returned by
+ * the {@code ServiceFactory} is cached by the Framework until the bundle
  * releases its use of the service.
  * 
  * <p>
- * When the bundle's use count for the service equals zero (including the bundle
- * stopping or the service being unregistered), the
- * <code>ServiceFactory.ungetService</code> method is called.
+ * When the bundle's use count for the service is decremented to zero (including
+ * the bundle stopping or the service being unregistered), the
+ * {@code ServiceFactory.ungetService} method is called.
  * 
  * <p>
- * <code>ServiceFactory</code> objects are only used by the Framework and are
- * not made available to other bundles in the OSGi environment. The Framework
- * may concurrently call a <code>ServiceFactory</code>.
+ * {@code ServiceFactory} objects are only used by the Framework and are not
+ * made available to other bundles in the OSGi environment. The Framework may
+ * concurrently call a {@code ServiceFactory}.
  * 
+ * @param <S> Type of Service
  * @see BundleContext#getService
  * @ThreadSafe
- * @version $Revision: 5967 $
+ * @version $Id: 94cd1a0127aaad9beb484f557342a8fbd0be2322 $
  */
 
-public interface ServiceFactory {
+public interface ServiceFactory<S> {
 	/**
 	 * Creates a new service object.
 	 * 
 	 * <p>
 	 * The Framework invokes this method the first time the specified
-	 * <code>bundle</code> requests a service object using the
-	 * <code>BundleContext.getService(ServiceReference)</code> method. The
-	 * service factory can then return a specific service object for each
-	 * bundle.
+	 * {@code bundle} requests a service object using the
+	 * {@code BundleContext.getService(ServiceReference)} method. The service
+	 * factory can then return a specific service object for each bundle.
 	 * 
 	 * <p>
-	 * The Framework caches the value returned (unless it is <code>null</code>),
-	 * and will return the same service object on any future call to
-	 * <code>BundleContext.getService</code> for the same bundle. This means the
-	 * Framework must not allow this method to be concurrently called for the
-	 * same bundle.
+	 * The Framework must check that the returned service object is valid. If
+	 * the returned service object is {@code null} or is not an
+	 * {@code instanceof} all the classes named when the service was registered,
+	 * a framework event of type {@link FrameworkEvent#ERROR} is fired
+	 * containing a service exception of type
+	 * {@link ServiceException#FACTORY_ERROR} and {@code null} is returned to
+	 * the bundle. If this method throws an exception, a framework event of type
+	 * {@link FrameworkEvent#ERROR} is fired containing a service exception of
+	 * type {@link ServiceException#FACTORY_EXCEPTION} with the thrown exception
+	 * as the cause and {@code null} is returned to the bundle. If this method
+	 * is recursively called for the specified bundle, a framework event of type
+	 * {@link FrameworkEvent#ERROR} is fired containing a service exception of
+	 * type {@link ServiceException#FACTORY_RECURSION} and {@code null} is
+	 * returned to the bundle.
 	 * 
 	 * <p>
-	 * The Framework will check if the returned service object is an instance of
-	 * all the classes named when the service was registered. If not, then
-	 * <code>null</code> is returned to the bundle.
-	 * 
-	 * @param bundle The bundle using the service.
-	 * @param registration The <code>ServiceRegistration</code> object for the
-	 *        service.
+	 * The Framework caches the valid service object and will return the same
+	 * service object on any future call to {@code BundleContext.getService} for
+	 * the specified bundle. This means the Framework must not allow this method
+	 * to be concurrently called for the specified bundle.
+	 * 
+	 * @param bundle The bundle requesting the service.
+	 * @param registration The {@code ServiceRegistration} object for the
+	 *        requested service.
 	 * @return A service object that <strong>must</strong> be an instance of all
 	 *         the classes named when the service was registered.
 	 * @see BundleContext#getService
 	 */
-	public Object getService(Bundle bundle, ServiceRegistration registration);
+	public S getService(Bundle bundle, ServiceRegistration<S> registration);
 
 	/**
 	 * Releases a service object.
@@ -88,13 +96,20 @@ public interface ServiceFactory {
 	 * The Framework invokes this method when a service has been released by a
 	 * bundle. The service object may then be destroyed.
 	 * 
+	 * <p>
+	 * If this method throws an exception, a framework event of type
+	 * {@link FrameworkEvent#ERROR} is fired containing a service exception of
+	 * type {@link ServiceException#FACTORY_EXCEPTION} with the thrown exception
+	 * as the cause.
+	 * 
 	 * @param bundle The bundle releasing the service.
-	 * @param registration The <code>ServiceRegistration</code> object for the
-	 *        service.
+	 * @param registration The {@code ServiceRegistration} object for the
+	 *        service being released.
 	 * @param service The service object returned by a previous call to the
-	 *        <code>ServiceFactory.getService</code> method.
+	 *        {@link #getService(Bundle, ServiceRegistration) getService}
+	 *        method.
 	 * @see BundleContext#ungetService
 	 */
-	public void ungetService(Bundle bundle, ServiceRegistration registration,
-			Object service);
+	public void ungetService(Bundle bundle, ServiceRegistration<S> registration,
+			S service);
 }

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/ServiceListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/ServiceListener.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/ServiceListener.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/ServiceListener.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,46 +19,46 @@ package org.osgi.framework;
 import java.util.EventListener;
 
 /**
- * A <code>ServiceEvent</code> listener. <code>ServiceListener</code> is a
+ * A {@code ServiceEvent} listener. {@code ServiceListener} is a
  * listener interface that may be implemented by a bundle developer. When a
- * <code>ServiceEvent</code> is fired, it is synchronously delivered to a
- * <code>ServiceListener</code>. The Framework may deliver
- * <code>ServiceEvent</code> objects to a <code>ServiceListener</code> out
+ * {@code ServiceEvent} is fired, it is synchronously delivered to a
+ * {@code ServiceListener}. The Framework may deliver
+ * {@code ServiceEvent} objects to a {@code ServiceListener} out
  * of order and may concurrently call and/or reenter a
- * <code>ServiceListener</code>.
+ * {@code ServiceListener}.
  * 
  * <p>
- * A <code>ServiceListener</code> object is registered with the Framework
- * using the <code>BundleContext.addServiceListener</code> method.
- * <code>ServiceListener</code> objects are called with a
- * <code>ServiceEvent</code> object when a service is registered, modified, or
+ * A {@code ServiceListener} object is registered with the Framework
+ * using the {@code BundleContext.addServiceListener} method.
+ * {@code ServiceListener} objects are called with a
+ * {@code ServiceEvent} object when a service is registered, modified, or
  * is in the process of unregistering.
  * 
  * <p>
- * <code>ServiceEvent</code> object delivery to <code>ServiceListener</code>
+ * {@code ServiceEvent} object delivery to {@code ServiceListener}
  * objects is filtered by the filter specified when the listener was registered.
  * If the Java Runtime Environment supports permissions, then additional
- * filtering is done. <code>ServiceEvent</code> objects are only delivered to
+ * filtering is done. {@code ServiceEvent} objects are only delivered to
  * the listener if the bundle which defines the listener object's class has the
- * appropriate <code>ServicePermission</code> to get the service using at
+ * appropriate {@code ServicePermission} to get the service using at
  * least one of the named classes under which the service was registered.
  * 
  * <p>
- * <code>ServiceEvent</code> object delivery to <code>ServiceListener</code>
+ * {@code ServiceEvent} object delivery to {@code ServiceListener}
  * objects is further filtered according to package sources as defined in
  * {@link ServiceReference#isAssignableTo(Bundle, String)}.
  * 
  * @see ServiceEvent
  * @see ServicePermission
  * @ThreadSafe
- * @version $Revision: 5673 $
+ * @version $Id: d73f8e9b4babc8b53b5d1cbe7b17b732f54bb2a3 $
  */
 
 public interface ServiceListener extends EventListener {
 	/**
 	 * Receives notification that a service has had a lifecycle change.
 	 * 
-	 * @param event The <code>ServiceEvent</code> object.
+	 * @param event The {@code ServiceEvent} object.
 	 */
 	public void serviceChanged(ServiceEvent event);
 }

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/ServicePermission.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/ServicePermission.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/ServicePermission.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/ServicePermission.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2000, 2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,42 +26,43 @@ import java.security.BasicPermission;
 import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.PrivilegedAction;
+import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * A bundle's authority to register or get a service.
  * <ul>
- * <li>The <code>register</code> action allows a bundle to register a service on
+ * <li>The {@code register} action allows a bundle to register a service on
  * the specified names.
- * <li>The <code>get</code> action allows a bundle to detect a service and get
+ * <li>The {@code get} action allows a bundle to detect a service and get
  * it.
  * </ul>
  * Permission to get a service is required in order to detect events regarding
  * the service. Untrusted bundles should not be able to detect the presence of
  * certain services unless they have the appropriate
- * <code>ServicePermission</code> to get the specific service.
+ * {@code ServicePermission} to get the specific service.
  * 
  * @ThreadSafe
- * @version $Revision: 7189 $
+ * @version $Id: 1b6ee9543f4cbc16add8dc8c40dfa9a6dfee7aa2 $
  */
 
 public final class ServicePermission extends BasicPermission {
 	static final long			serialVersionUID	= -7662148639076511574L;
 	/**
-	 * The action string <code>get</code>.
+	 * The action string {@code get}.
 	 */
 	public final static String	GET					= "get";
 	/**
-	 * The action string <code>register</code>.
+	 * The action string {@code register}.
 	 */
 	public final static String	REGISTER			= "register";
 
@@ -87,7 +88,7 @@ public final class ServicePermission ext
 	 * The service used by this ServicePermission. Must be null if not
 	 * constructed with a service.
 	 */
-	transient final ServiceReference		service;
+	transient final ServiceReference< ? >					service;
 
 	/**
 	 * The object classes for this ServicePermission. Must be null if not
@@ -102,11 +103,11 @@ public final class ServicePermission ext
 	transient Filter						filter;
 
 	/**
-	 * This dictionary holds the properties of the permission, used to match a
-	 * filter in implies. This is not initialized until necessary, and then
-	 * cached in this object.
+	 * This map holds the properties of the permission, used to match a filter
+	 * in implies. This is not initialized until necessary, and then cached in
+	 * this object.
 	 */
-	private transient volatile Dictionary	properties;
+	private transient volatile Map<String, Object>	properties;
 
 	/**
 	 * True if constructed with a name and the name is "*" or ends with ".*".
@@ -138,7 +139,7 @@ public final class ServicePermission ext
 	 * *
 	 * </pre>
 	 * 
-	 * For the <code>get</code> action, the name can also be a filter
+	 * For the {@code get} action, the name can also be a filter
 	 * expression. The filter gives access to the service properties as well as
 	 * the following attributes:
 	 * <ul>
@@ -158,17 +159,17 @@ public final class ServicePermission ext
 	 * Service properties names are case insensitive.
 	 * 
 	 * <p>
-	 * There are two possible actions: <code>get</code> and
-	 * <code>register</code>. The <code>get</code> permission allows the owner
+	 * There are two possible actions: {@code get} and
+	 * {@code register}. The {@code get} permission allows the owner
 	 * of this permission to obtain a service with this name. The
-	 * <code>register</code> permission allows the bundle to register a service
+	 * {@code register} permission allows the bundle to register a service
 	 * under that name.
 	 * 
 	 * @param name The service class name
-	 * @param actions <code>get</code>,<code>register</code> (canonical order)
+	 * @param actions {@code get},{@code register} (canonical order)
 	 * @throws IllegalArgumentException If the specified name is a filter
 	 *         expression and either the specified action is not
-	 *         <code>get</code> or the filter has an invalid syntax.
+	 *         {@code get} or the filter has an invalid syntax.
 	 */
 	public ServicePermission(String name, String actions) {
 		this(name, parseActions(actions));
@@ -180,19 +181,19 @@ public final class ServicePermission ext
 	}
 
 	/**
-	 * Creates a new requested <code>ServicePermission</code> object to be used
-	 * by code that must perform <code>checkPermission</code> for the
-	 * <code>get</code> action. <code>ServicePermission</code> objects created
-	 * with this constructor cannot be added to a <code>ServicePermission</code>
+	 * Creates a new requested {@code ServicePermission} object to be used
+	 * by code that must perform {@code checkPermission} for the
+	 * {@code get} action. {@code ServicePermission} objects created
+	 * with this constructor cannot be added to a {@code ServicePermission}
 	 * permission collection.
 	 * 
 	 * @param reference The requested service.
-	 * @param actions The action <code>get</code>.
+	 * @param actions The action {@code get}.
 	 * @throws IllegalArgumentException If the specified action is not
-	 *         <code>get</code> or reference is <code>null</code>.
+	 *         {@code get} or reference is {@code null}.
 	 * @since 1.5
 	 */
-	public ServicePermission(ServiceReference reference, String actions) {
+	public ServicePermission(ServiceReference< ? > reference, String actions) {
 		super(createName(reference));
 		setTransients(null, parseActions(actions));
 		this.service = reference;
@@ -209,7 +210,7 @@ public final class ServicePermission ext
 	 * @param reference ServiceReference to use to create permission name.
 	 * @return permission name.
 	 */
-	private static String createName(ServiceReference reference) {
+	private static String createName(ServiceReference< ? > reference) {
 		if (reference == null) {
 			throw new IllegalArgumentException("reference must not be null");
 		}
@@ -351,7 +352,7 @@ public final class ServicePermission ext
 	 * 
 	 * @param filterString The filter string to parse.
 	 * @return a Filter for this bundle. If the specified filterString is not a
-	 *         filter expression, then <code>null</code> is returned.
+	 *         filter expression, then {@code null} is returned.
 	 * @throws IllegalArgumentException If the filter syntax is invalid.
 	 */
 	private static Filter parseFilter(String filterString) {
@@ -372,12 +373,12 @@ public final class ServicePermission ext
 	}
 
 	/**
-	 * Determines if a <code>ServicePermission</code> object "implies" the
+	 * Determines if a {@code ServicePermission} object "implies" the
 	 * specified permission.
 	 * 
 	 * @param p The target permission to check.
-	 * @return <code>true</code> if the specified permission is implied by this
-	 *         object; <code>false</code> otherwise.
+	 * @return {@code true} if the specified permission is implied by this
+	 *         object; {@code false} otherwise.
 	 */
 	public boolean implies(Permission p) {
 		if (!(p instanceof ServicePermission)) {
@@ -402,8 +403,8 @@ public final class ServicePermission ext
 	 *        validated as a proper argument. The requested ServicePermission
 	 *        must not have a filter expression.
 	 * @param effective The effective actions with which to start.
-	 * @return <code>true</code> if the specified permission is implied by this
-	 *         object; <code>false</code> otherwise.
+	 * @return {@code true} if the specified permission is implied by this
+	 *         object; {@code false} otherwise.
 	 */
 	boolean implies0(ServicePermission requested, int effective) {
 		/* check actions first - much faster */
@@ -419,7 +420,7 @@ public final class ServicePermission ext
 		/* if we have a filter */
 		Filter f = filter;
 		if (f != null) {
-			return f.matchCase(requested.getProperties());
+			return f.matches(requested.getProperties());
 		}
 		/* if requested permission not created with ServiceReference */
 		String[] requestedNames = requested.objectClass;
@@ -450,8 +451,8 @@ public final class ServicePermission ext
 
 	/**
 	 * Returns the canonical string representation of the actions. Always
-	 * returns present actions in the following order: <code>get</code>,
-	 * <code>register</code>.
+	 * returns present actions in the following order: {@code get},
+	 * {@code register}.
 	 * 
 	 * @return The canonical string representation of the actions.
 	 */
@@ -480,11 +481,11 @@ public final class ServicePermission ext
 	}
 
 	/**
-	 * Returns a new <code>PermissionCollection</code> object for storing
-	 * <code>ServicePermission<code> objects.
-	 *
-	 * @return A new <code>PermissionCollection</code> object suitable for storing
-	 * <code>ServicePermission</code> objects.
+	 * Returns a new {@code PermissionCollection} object for storing
+	 * {@code ServicePermission} objects.
+	 * 
+	 * @return A new {@code PermissionCollection} object suitable for storing
+	 *         {@code ServicePermission} objects.
 	 */
 	public PermissionCollection newPermissionCollection() {
 		return new ServicePermissionCollection();
@@ -494,12 +495,12 @@ public final class ServicePermission ext
 	 * Determines the equality of two ServicePermission objects.
 	 * 
 	 * Checks that specified object has the same class name and action as this
-	 * <code>ServicePermission</code>.
+	 * {@code ServicePermission}.
 	 * 
 	 * @param obj The object to test for equality.
-	 * @return true if obj is a <code>ServicePermission</code>, and has the same
-	 *         class name and actions as this <code>ServicePermission</code>
-	 *         object; <code>false</code> otherwise.
+	 * @return true if obj is a {@code ServicePermission}, and has the same
+	 *         class name and actions as this {@code ServicePermission}
+	 *         object; {@code false} otherwise.
 	 */
 	public boolean equals(Object obj) {
 		if (obj == this) {
@@ -558,27 +559,28 @@ public final class ServicePermission ext
 		s.defaultReadObject();
 		setTransients(parseFilter(getName()), parseActions(actions));
 	}
+
 	/**
-	 * Called by <code><@link ServicePermission#implies(Permission)></code>.
+	 * Called by {@code <@link ServicePermission#implies(Permission)>}. This
+	 * method is only called on a requested permission which cannot have a
+	 * filter set.
 	 * 
-	 * @return a dictionary of properties for this permission.
+	 * @return a map of properties for this permission.
 	 */
-	private Dictionary getProperties() {
-		Dictionary result = properties;
+	private Map<String, Object> getProperties() {
+		Map<String, Object> result = properties;
 		if (result != null) {
 			return result;
 		}
 		if (service == null) {
-			result = new Hashtable(1);
-			if (filter == null) {
-				result.put(Constants.OBJECTCLASS, new String[] {getName()});
-			}
+			result = new HashMap<String, Object>(1);
+			result.put(Constants.OBJECTCLASS, new String[] {getName()});
 			return properties = result;
 		}
-		final Map props = new HashMap(4);
+		final Map<String, Object> props = new HashMap<String, Object>(4);
 		final Bundle bundle = service.getBundle();
 		if (bundle != null) {
-			AccessController.doPrivileged(new PrivilegedAction() {
+			AccessController.doPrivileged(new PrivilegedAction<Object>() {
 				public Object run() {
 					props.put("id", new Long(bundle.getBundleId()));
 					props.put("location", bundle.getLocation());
@@ -597,13 +599,15 @@ public final class ServicePermission ext
 		return properties = new Properties(props, service);
 	}
 	
-	private static class Properties extends Dictionary {
-		private final Map				properties;
-		private final ServiceReference	service;
+	static private final class Properties extends AbstractMap<String, Object> {
+		private final Map<String, Object>	properties;
+		private final ServiceReference< ? >	service;
+		private transient volatile Set<Map.Entry<String, Object>>	entries;
 
-		Properties(Map properties, ServiceReference service) {
+		Properties(Map<String, Object> properties, ServiceReference< ? > service) {
 			this.properties = properties;
 			this.service = service;
+			entries = null;
 		}
 
 		public Object get(Object k) {
@@ -621,57 +625,64 @@ public final class ServicePermission ext
 			return service.getProperty(key);
 		}
 
-		public int size() {
-			return properties.size() + service.getPropertyKeys().length;
-		}
-
-		public boolean isEmpty() {
-			// we can return false because this must never be empty
-			return false;
-		}
-
-		public Enumeration keys() {
-			Collection pk = properties.keySet();
-			String spk[] = service.getPropertyKeys();
-			List all = new ArrayList(pk.size() + spk.length);
-			all.addAll(pk);
-			add:
-			for (int i = 0, length = spk.length; i < length; i++) {
-				String key = spk[i];
-				for (Iterator iter = pk.iterator(); iter.hasNext();) {
-					if (key.equalsIgnoreCase((String) iter.next())) {
+		public Set<Map.Entry<String, Object>> entrySet() {
+			if (entries != null) {
+				return entries;
+			}
+			Set<Map.Entry<String, Object>> all = new HashSet<Map.Entry<String, Object>>(
+					properties.entrySet());
+			add: for (String key : service.getPropertyKeys()) {
+				for (String k : properties.keySet()) {
+					if (key.equalsIgnoreCase(k)) {
 						continue add;
 					}
 				}
-				all.add(key);
+				all.add(new Entry(key, service.getProperty(key)));
 			}
-			return Collections.enumeration(all);
+			return entries = Collections.unmodifiableSet(all);
 		}
+		
+		static private final class Entry implements Map.Entry<String, Object> {
+			private final String	k;
+			private final Object	v;
 
-		public Enumeration elements() {
-			Collection pk = properties.keySet();
-			String spk[] = service.getPropertyKeys();
-			List all = new ArrayList(pk.size() + spk.length);
-			all.addAll(properties.values());
-			add:
-			for (int i = 0, length = spk.length; i < length; i++) {
-				String key = spk[i];
-				for (Iterator iter = pk.iterator(); iter.hasNext();) {
-					if (key.equalsIgnoreCase((String) iter.next())) {
-						continue add;
+			Entry(String key, Object value) {
+				this.k = key;
+				this.v = value;
+			}
+			public String getKey() {
+				return k;
+			}
+			public Object getValue() {
+				return v;
+			}
+			public Object setValue(Object value) {
+				throw new UnsupportedOperationException();
+			}
+			public String toString() {
+				return k + "=" + v;
+			}
+			public int hashCode() {
+				return ((k == null) ? 0 : k.hashCode())
+						^ ((v == null) ? 0 : v.hashCode());
+			}
+			public boolean equals(Object obj) {
+				if (obj == this) {
+					return true;
+				}
+				if (!(obj instanceof Map.Entry)) {
+					return false;
+				}
+				Map.Entry< ? , ? > e = (Map.Entry< ? , ? >) obj;
+				final Object key = e.getKey();
+				if ((k == key) || ((k != null) && k.equals(key))) {
+					final Object value = e.getValue();
+					if ((v == value) || ((v != null) && v.equals(value))) {
+						return true;
 					}
 				}
-				all.add(service.getProperty(key));
+				return false;
 			}
-			return Collections.enumeration(all);
-		}
-
-		public Object put(Object key, Object value) {
-			throw new UnsupportedOperationException();
-		}
-
-		public Object remove(Object key) {
-			throw new UnsupportedOperationException();
 		}
 	}
 }
@@ -690,7 +701,7 @@ final class ServicePermissionCollection 
 	 * 
 	 * @GuardedBy this
 	 */
-	private transient Map	permissions;
+	private transient Map<String, ServicePermission>	permissions;
 
 	/**
 	 * Boolean saying if "*" is in the collection.
@@ -706,13 +717,13 @@ final class ServicePermissionCollection 
 	 * @serial
 	 * @GuardedBy this
 	 */
-	private Map				filterPermissions;
+	private Map<String, ServicePermission>				filterPermissions;
 
 	/**
 	 * Creates an empty ServicePermissions object.
 	 */
 	public ServicePermissionCollection() {
-		permissions = new HashMap();
+		permissions = new HashMap<String, ServicePermission>();
 		all_allowed = false;
 	}
 
@@ -723,7 +734,7 @@ final class ServicePermissionCollection 
 	 * @throws IllegalArgumentException If the specified permission is not a
 	 *         ServicePermission object.
 	 * @throws SecurityException If this
-	 *         <code>ServicePermissionCollection</code> object has been marked
+	 *         {@code ServicePermissionCollection} object has been marked
 	 *         read-only.
 	 */
 	public void add(final Permission permission) {
@@ -746,17 +757,17 @@ final class ServicePermissionCollection 
 		final Filter f = sp.filter;
 		synchronized (this) {
 			/* select the bucket for the permission */
-			Map pc;
+			Map<String, ServicePermission> pc;
 			if (f != null) {
 				pc = filterPermissions;
 				if (pc == null) {
-					filterPermissions = pc = new HashMap();
+					filterPermissions = pc = new HashMap<String, ServicePermission>();
 				}
 			}
 			else {
 				pc = permissions;
 			}
-			final ServicePermission existing = (ServicePermission) pc.get(name);
+			final ServicePermission existing = pc.get(name);
 			
 			if (existing != null) {
 				final int oldMask = existing.action_mask;
@@ -781,11 +792,11 @@ final class ServicePermissionCollection 
 
 	/**
 	 * Determines if a set of permissions implies the permissions expressed in
-	 * <code>permission</code>.
+	 * {@code permission}.
 	 * 
 	 * @param permission The Permission object to compare.
-	 * @return <code>true</code> if <code>permission</code> is a proper
-	 *         subset of a permission in the set; <code>false</code>
+	 * @return {@code true} if {@code permission} is a proper
+	 *         subset of a permission in the set; {@code false}
 	 *         otherwise.
 	 */
 	public boolean implies(final Permission permission) {
@@ -799,12 +810,12 @@ final class ServicePermissionCollection 
 		}
 
 		int effective = ServicePermission.ACTION_NONE;
-		Collection perms;
+		Collection<ServicePermission> perms;
 		synchronized (this) {
 			final int desired = requested.action_mask;
 			/* short circuit if the "*" Permission was added */
 			if (all_allowed) {
-				ServicePermission sp = (ServicePermission) permissions.get("*");
+				ServicePermission sp = permissions.get("*");
 				if (sp != null) {
 					effective |= sp.action_mask;
 					if ((effective & desired) == desired) {
@@ -829,7 +840,7 @@ final class ServicePermissionCollection 
 					}
 				}
 			}
-			Map pc = filterPermissions;
+			Map<String, ServicePermission> pc = filterPermissions;
 			if (pc == null) {
 				return false;
 			}
@@ -837,9 +848,8 @@ final class ServicePermissionCollection 
 		}
 		
 		/* iterate one by one over filteredPermissions */
-		for (Iterator iter = perms.iterator(); iter.hasNext();) {
-			if (((ServicePermission) iter.next())
-					.implies0(requested, effective)) {
+		for (ServicePermission perm : perms) {
+			if (perm.implies0(requested, effective)) {
 				return true;
 			}
 		}
@@ -857,8 +867,8 @@ final class ServicePermissionCollection 
 	 */
 	private int effective(String requestedName, final int desired,
 			int effective) {
-		final Map pc = permissions;
-		ServicePermission sp = (ServicePermission) pc.get(requestedName);
+		final Map<String, ServicePermission> pc = permissions;
+		ServicePermission sp = pc.get(requestedName);
 		// strategy:
 		// Check for full match first. Then work our way up the
 		// name looking for matches on a.b.*
@@ -874,7 +884,7 @@ final class ServicePermissionCollection 
 		int offset = requestedName.length() - 1;
 		while ((last = requestedName.lastIndexOf(".", offset)) != -1) {
 			requestedName = requestedName.substring(0, last + 1) + "*";
-			sp = (ServicePermission) pc.get(requestedName);
+			sp = pc.get(requestedName);
 			if (sp != null) {
 				effective |= sp.action_mask;
 				if ((effective & desired) == desired) {
@@ -891,14 +901,14 @@ final class ServicePermissionCollection 
 	}
 	
 	/**
-	 * Returns an enumeration of all the <code>ServicePermission</code>
+	 * Returns an enumeration of all the {@code ServicePermission}
 	 * objects in the container.
 	 * 
 	 * @return Enumeration of all the ServicePermission objects.
 	 */
-	public synchronized Enumeration elements() {
-		List all = new ArrayList(permissions.values());
-		Map pc = filterPermissions;
+	public synchronized Enumeration<Permission> elements() {
+		List<Permission> all = new ArrayList<Permission>(permissions.values());
+		Map<String, ServicePermission> pc = filterPermissions;
 		if (pc != null) {
 			all.addAll(pc.values());
 		}
@@ -913,7 +923,8 @@ final class ServicePermissionCollection 
 
 	private synchronized void writeObject(ObjectOutputStream out)
 			throws IOException {
-		Hashtable hashtable = new Hashtable(permissions);
+		Hashtable<String, ServicePermission> hashtable = new Hashtable<String, ServicePermission>(
+				permissions);
 		ObjectOutputStream.PutField pfields = out.putFields();
 		pfields.put("permissions", hashtable);
 		pfields.put("all_allowed", all_allowed);
@@ -924,9 +935,12 @@ final class ServicePermissionCollection 
 	private synchronized void readObject(java.io.ObjectInputStream in)
 			throws IOException, ClassNotFoundException {
 		ObjectInputStream.GetField gfields = in.readFields();
-		Hashtable hashtable = (Hashtable) gfields.get("permissions", null);
-		permissions = new HashMap(hashtable);
+		Hashtable<String, ServicePermission> hashtable = (Hashtable<String, ServicePermission>) gfields
+				.get("permissions", null);
+		permissions = new HashMap<String, ServicePermission>(hashtable);
 		all_allowed = gfields.get("all_allowed", false);
-		filterPermissions = (HashMap) gfields.get("filterPermissions", null);
+		HashMap<String, ServicePermission> fp = (HashMap<String, ServicePermission>) gfields
+				.get("filterPermissions", null);
+		filterPermissions = fp;
 	}
 }

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/ServiceReference.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/ServiceReference.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/ServiceReference.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/ServiceReference.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2000, 2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,38 +22,40 @@ import java.util.Dictionary;
  * A reference to a service.
  * 
  * <p>
- * The Framework returns <code>ServiceReference</code> objects from the
- * <code>BundleContext.getServiceReference</code> and
- * <code>BundleContext.getServiceReferences</code> methods.
+ * The Framework returns {@code ServiceReference} objects from the
+ * {@code BundleContext.getServiceReference} and
+ * {@code BundleContext.getServiceReferences} methods.
  * <p>
- * A <code>ServiceReference</code> object may be shared between bundles and
- * can be used to examine the properties of the service and to get the service
+ * A {@code ServiceReference} object may be shared between bundles and can
+ * be used to examine the properties of the service and to get the service
  * object.
  * <p>
  * Every service registered in the Framework has a unique
- * <code>ServiceRegistration</code> object and may have multiple, distinct
- * <code>ServiceReference</code> objects referring to it.
- * <code>ServiceReference</code> objects associated with a
- * <code>ServiceRegistration</code> object have the same <code>hashCode</code>
- * and are considered equal (more specifically, their <code>equals()</code>
- * method will return <code>true</code> when compared).
+ * {@code ServiceRegistration} object and may have multiple, distinct
+ * {@code ServiceReference} objects referring to it.
+ * {@code ServiceReference} objects associated with a
+ * {@code ServiceRegistration} object have the same {@code hashCode}
+ * and are considered equal (more specifically, their {@code equals()}
+ * method will return {@code true} when compared).
  * <p>
  * If the same service object is registered multiple times,
- * <code>ServiceReference</code> objects associated with different
- * <code>ServiceRegistration</code> objects are not equal.
+ * {@code ServiceReference} objects associated with different
+ * {@code ServiceRegistration} objects are not equal.
  * 
+ * @param <S> Type of Service.
  * @see BundleContext#getServiceReference
  * @see BundleContext#getServiceReferences
  * @see BundleContext#getService
  * @ThreadSafe
- * @version $Revision: 6374 $
+ * @noimplement
+ * @version $Id: 771b9b4d4f65dbe593154d02912edba51a085b0c $
  */
 
-public interface ServiceReference extends Comparable {
+public interface ServiceReference<S> extends Comparable<Object> {
 	/**
 	 * Returns the property value to which the specified property key is mapped
-	 * in the properties <code>Dictionary</code> object of the service
-	 * referenced by this <code>ServiceReference</code> object.
+	 * in the properties {@code Dictionary} object of the service
+	 * referenced by this {@code ServiceReference} object.
 	 * 
 	 * <p>
 	 * Property keys are case-insensitive.
@@ -61,30 +63,30 @@ public interface ServiceReference extend
 	 * <p>
 	 * This method must continue to return property values after the service has
 	 * been unregistered. This is so references to unregistered services (for
-	 * example, <code>ServiceReference</code> objects stored in the log) can
+	 * example, {@code ServiceReference} objects stored in the log) can
 	 * still be interrogated.
 	 * 
 	 * @param key The property key.
-	 * @return The property value to which the key is mapped; <code>null</code>
+	 * @return The property value to which the key is mapped; {@code null}
 	 *         if there is no property named after the key.
 	 */
 	public Object getProperty(String key);
 
 	/**
-	 * Returns an array of the keys in the properties <code>Dictionary</code>
-	 * object of the service referenced by this <code>ServiceReference</code>
+	 * Returns an array of the keys in the properties {@code Dictionary}
+	 * object of the service referenced by this {@code ServiceReference}
 	 * object.
 	 * 
 	 * <p>
 	 * This method will continue to return the keys after the service has been
 	 * unregistered. This is so references to unregistered services (for
-	 * example, <code>ServiceReference</code> objects stored in the log) can
+	 * example, {@code ServiceReference} objects stored in the log) can
 	 * still be interrogated.
 	 * 
 	 * <p>
 	 * This method is <i>case-preserving </i>; this means that every key in the
 	 * returned array must have the same case as the corresponding key in the
-	 * properties <code>Dictionary</code> that was passed to the
+	 * properties {@code Dictionary} that was passed to the
 	 * {@link BundleContext#registerService(String[],Object,Dictionary)} or
 	 * {@link ServiceRegistration#setProperties} methods.
 	 * 
@@ -94,15 +96,15 @@ public interface ServiceReference extend
 
 	/**
 	 * Returns the bundle that registered the service referenced by this
-	 * <code>ServiceReference</code> object.
+	 * {@code ServiceReference} object.
 	 * 
 	 * <p>
-	 * This method must return <code>null</code> when the service has been
+	 * This method must return {@code null} when the service has been
 	 * unregistered. This can be used to determine if the service has been
 	 * unregistered.
 	 * 
 	 * @return The bundle that registered the service referenced by this
-	 *         <code>ServiceReference</code> object; <code>null</code> if that
+	 *         {@code ServiceReference} object; {@code null} if that
 	 *         service has already been unregistered.
 	 * @see BundleContext#registerService(String[],Object,Dictionary)
 	 */
@@ -110,12 +112,12 @@ public interface ServiceReference extend
 
 	/**
 	 * Returns the bundles that are using the service referenced by this
-	 * <code>ServiceReference</code> object. Specifically, this method returns
+	 * {@code ServiceReference} object. Specifically, this method returns
 	 * the bundles whose usage count for that service is greater than zero.
 	 * 
 	 * @return An array of bundles whose usage count for the service referenced
-	 *         by this <code>ServiceReference</code> object is greater than
-	 *         zero; <code>null</code> if no bundles are currently using that
+	 *         by this {@code ServiceReference} object is greater than
+	 *         zero; {@code null} if no bundles are currently using that
 	 *         service.
 	 * 
 	 * @since 1.1
@@ -124,60 +126,60 @@ public interface ServiceReference extend
 
 	/**
 	 * Tests if the bundle that registered the service referenced by this
-	 * <code>ServiceReference</code> and the specified bundle use the same
+	 * {@code ServiceReference} and the specified bundle use the same
 	 * source for the package of the specified class name.
 	 * <p>
 	 * This method performs the following checks:
 	 * <ol>
 	 * <li>Get the package name from the specified class name.</li>
 	 * <li>For the bundle that registered the service referenced by this
-	 * <code>ServiceReference</code> (registrant bundle); find the source for
-	 * the package. If no source is found then return <code>true</code> if the
+	 * {@code ServiceReference} (registrant bundle); find the source for
+	 * the package. If no source is found then return {@code true} if the
 	 * registrant bundle is equal to the specified bundle; otherwise return
-	 * <code>false</code>.</li>
+	 * {@code false}.</li>
 	 * <li>If the package source of the registrant bundle is equal to the
-	 * package source of the specified bundle then return <code>true</code>;
-	 * otherwise return <code>false</code>.</li>
+	 * package source of the specified bundle then return {@code true};
+	 * otherwise return {@code false}.</li>
 	 * </ol>
 	 * 
-	 * @param bundle The <code>Bundle</code> object to check.
+	 * @param bundle The {@code Bundle} object to check.
 	 * @param className The class name to check.
-	 * @return <code>true</code> if the bundle which registered the service
-	 *         referenced by this <code>ServiceReference</code> and the
+	 * @return {@code true} if the bundle which registered the service
+	 *         referenced by this {@code ServiceReference} and the
 	 *         specified bundle use the same source for the package of the
-	 *         specified class name. Otherwise <code>false</code> is returned.
-	 * @throws IllegalArgumentException If the specified <code>Bundle</code> was
+	 *         specified class name. Otherwise {@code false} is returned.
+	 * @throws IllegalArgumentException If the specified {@code Bundle} was
 	 *         not created by the same framework instance as this
-	 *         <code>ServiceReference</code>.
+	 *         {@code ServiceReference}.
 	 * @since 1.3
 	 */
 	public boolean isAssignableTo(Bundle bundle, String className);
 
 	/**
-	 * Compares this <code>ServiceReference</code> with the specified
-	 * <code>ServiceReference</code> for order.
+	 * Compares this {@code ServiceReference} with the specified
+	 * {@code ServiceReference} for order.
 	 * 
 	 * <p>
-	 * If this <code>ServiceReference</code> and the specified
-	 * <code>ServiceReference</code> have the same {@link Constants#SERVICE_ID
-	 * service id} they are equal. This <code>ServiceReference</code> is less
-	 * than the specified <code>ServiceReference</code> if it has a lower
+	 * If this {@code ServiceReference} and the specified
+	 * {@code ServiceReference} have the same {@link Constants#SERVICE_ID
+	 * service id} they are equal. This {@code ServiceReference} is less
+	 * than the specified {@code ServiceReference} if it has a lower
 	 * {@link Constants#SERVICE_RANKING service ranking} and greater if it has a
-	 * higher service ranking. Otherwise, if this <code>ServiceReference</code>
-	 * and the specified <code>ServiceReference</code> have the same
+	 * higher service ranking. Otherwise, if this {@code ServiceReference}
+	 * and the specified {@code ServiceReference} have the same
 	 * {@link Constants#SERVICE_RANKING service ranking}, this
-	 * <code>ServiceReference</code> is less than the specified
-	 * <code>ServiceReference</code> if it has a higher
+	 * {@code ServiceReference} is less than the specified
+	 * {@code ServiceReference} if it has a higher
 	 * {@link Constants#SERVICE_ID service id} and greater if it has a lower
 	 * service id.
 	 * 
-	 * @param reference The <code>ServiceReference</code> to be compared.
+	 * @param reference The {@code ServiceReference} to be compared.
 	 * @return Returns a negative integer, zero, or a positive integer if this
-	 *         <code>ServiceReference</code> is less than, equal to, or greater
-	 *         than the specified <code>ServiceReference</code>.
+	 *         {@code ServiceReference} is less than, equal to, or greater
+	 *         than the specified {@code ServiceReference}.
 	 * @throws IllegalArgumentException If the specified
-	 *         <code>ServiceReference</code> was not created by the same
-	 *         framework instance as this <code>ServiceReference</code>.
+	 *         {@code ServiceReference} was not created by the same
+	 *         framework instance as this {@code ServiceReference}.
 	 * @since 1.4
 	 */
 	public int compareTo(Object reference);

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/ServiceRegistration.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/ServiceRegistration.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/ServiceRegistration.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/ServiceRegistration.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2000, 2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,33 +22,35 @@ import java.util.Dictionary;
  * A registered service.
  * 
  * <p>
- * The Framework returns a <code>ServiceRegistration</code> object when a
- * <code>BundleContext.registerService</code> method invocation is successful.
- * The <code>ServiceRegistration</code> object is for the private use of the
+ * The Framework returns a {@code ServiceRegistration} object when a
+ * {@code BundleContext.registerService} method invocation is successful.
+ * The {@code ServiceRegistration} object is for the private use of the
  * registering bundle and should not be shared with other bundles.
  * <p>
- * The <code>ServiceRegistration</code> object may be used to update the
+ * The {@code ServiceRegistration} object may be used to update the
  * properties of the service or to unregister the service.
  * 
+ * @param <S> Type of Service.
  * @see BundleContext#registerService(String[],Object,Dictionary)
  * @ThreadSafe
- * @version $Revision: 6361 $
+ * @noimplement
+ * @version $Id: dc742ff3749821529f9ae62e05d9bd5d8eca00d7 $
  */
 
-public interface ServiceRegistration {
+public interface ServiceRegistration<S> {
 	/**
-	 * Returns a <code>ServiceReference</code> object for a service being
+	 * Returns a {@code ServiceReference} object for a service being
 	 * registered.
 	 * <p>
-	 * The <code>ServiceReference</code> object may be shared with other
+	 * The {@code ServiceReference} object may be shared with other
 	 * bundles.
 	 * 
 	 * @throws IllegalStateException If this
-	 *         <code>ServiceRegistration</code> object has already been
+	 *         {@code ServiceRegistration} object has already been
 	 *         unregistered.
-	 * @return <code>ServiceReference</code> object.
+	 * @return {@code ServiceReference} object.
 	 */
-	public ServiceReference getReference();
+	public ServiceReference<S> getReference();
 
 	/**
 	 * Updates the properties associated with a service.
@@ -70,17 +72,17 @@ public interface ServiceRegistration {
 	 *        be made to this object after calling this method. To update the
 	 *        service's properties this method should be called again.
 	 * 
-	 * @throws IllegalStateException If this <code>ServiceRegistration</code>
+	 * @throws IllegalStateException If this {@code ServiceRegistration}
 	 *         object has already been unregistered.
-	 * @throws IllegalArgumentException If <code>properties</code> contains
+	 * @throws IllegalArgumentException If {@code properties} contains
 	 *         case variants of the same key name.
 	 */
-	public void setProperties(Dictionary properties);
+	public void setProperties(Dictionary<String, ? > properties);
 
 	/**
-	 * Unregisters a service. Remove a <code>ServiceRegistration</code> object
-	 * from the Framework service registry. All <code>ServiceReference</code>
-	 * objects associated with this <code>ServiceRegistration</code> object
+	 * Unregisters a service. Remove a {@code ServiceRegistration} object
+	 * from the Framework service registry. All {@code ServiceReference}
+	 * objects associated with this {@code ServiceRegistration} object
 	 * can no longer be used to interact with the service once unregistration is
 	 * complete.
 	 * 
@@ -92,18 +94,18 @@ public interface ServiceRegistration {
 	 * <li>A service event of type {@link ServiceEvent#UNREGISTERING} is fired
 	 * so that bundles using this service can release their use of the service.
 	 * Once delivery of the service event is complete, the
-	 * <code>ServiceReference</code> objects for the service may no longer be
+	 * {@code ServiceReference} objects for the service may no longer be
 	 * used to get a service object for the service.
 	 * <li>For each bundle whose use count for this service is greater than
 	 * zero: <br>
 	 * The bundle's use count for this service is set to zero. <br>
 	 * If the service was registered with a {@link ServiceFactory} object, the
-	 * <code>ServiceFactory.ungetService</code> method is called to release
+	 * {@code ServiceFactory.ungetService} method is called to release
 	 * the service object for the bundle.
 	 * </ol>
 	 * 
 	 * @throws IllegalStateException If this
-	 *         <code>ServiceRegistration</code> object has already been
+	 *         {@code ServiceRegistration} object has already been
 	 *         unregistered.
 	 * @see BundleContext#ungetService
 	 * @see ServiceFactory#ungetService

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/SignerProperty.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/SignerProperty.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/SignerProperty.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/SignerProperty.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2009, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.osgi.framework;
 
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -27,9 +26,9 @@ import java.util.Map;
  * during filter expression evaluation in the permission implies method.
  * 
  * @Immutable
- * @version $Revision: 6479 $
+ * @version $Id: 3589831a7594cf36e645a51ab9b9ae5ebfd80beb $
  */
-class SignerProperty {
+final class SignerProperty {
 	private final Bundle	bundle;
 	private final String	pattern;
 
@@ -71,19 +70,21 @@ class SignerProperty {
 		SignerProperty other = (SignerProperty) o;
 		Bundle matchBundle = bundle != null ? bundle : other.bundle;
 		String matchPattern = bundle != null ? other.pattern : pattern;
-		Map/* <X509Certificate, List<X509Certificate>> */signers = matchBundle
+		Map<X509Certificate, List<X509Certificate>> signers = matchBundle
 				.getSignerCertificates(Bundle.SIGNERS_TRUSTED);
-		for (Iterator iSigners = signers.values().iterator(); iSigners
-				.hasNext();) {
-			List/* <X509Certificate> */signerCerts = (List) iSigners.next();
-			List/* <String> */dnChain = new ArrayList(signerCerts.size());
-			for (Iterator iCerts = signerCerts.iterator(); iCerts.hasNext();) {
-				dnChain.add(((X509Certificate) iCerts.next()).getSubjectDN()
-						.getName());
+		for (List<X509Certificate> signerCerts : signers.values()) {
+			List<String> dnChain = new ArrayList<String>(signerCerts.size());
+			for (X509Certificate signerCert : signerCerts) {
+				dnChain.add(signerCert.getSubjectDN().getName());
 			}
-			if (FrameworkUtil
-					.matchDistinguishedNameChain(matchPattern, dnChain)) {
-				return true;
+			try {
+				if (FrameworkUtil.matchDistinguishedNameChain(matchPattern,
+						dnChain)) {
+					return true;
+				}
+			}
+			catch (IllegalArgumentException e) {
+				continue; // bad pattern
 			}
 		}
 		return false;
@@ -106,7 +107,7 @@ class SignerProperty {
 		if (bundle == null) {
 			return false;
 		}
-		Map/* <X509Certificate, List<X509Certificate>> */signers = bundle
+		Map<X509Certificate, List<X509Certificate>> signers = bundle
 				.getSignerCertificates(Bundle.SIGNERS_TRUSTED);
 		return !signers.isEmpty();
 	}

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/SynchronousBundleListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/SynchronousBundleListener.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/SynchronousBundleListener.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/SynchronousBundleListener.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2001, 2008). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2001, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,35 +17,48 @@
 package org.osgi.framework;
 
 /**
- * A synchronous <code>BundleEvent</code> listener.
- * <code>SynchronousBundleListener</code> is a listener interface that may be
- * implemented by a bundle developer. When a <code>BundleEvent</code> is
- * fired, it is synchronously delivered to a
- * <code>SynchronousBundleListener</code>. The Framework may deliver
- * <code>BundleEvent</code> objects to a
- * <code>SynchronousBundleListener</code> out of order and may concurrently
- * call and/or reenter a <code>SynchronousBundleListener</code>.
+ * A synchronous {@code BundleEvent} listener.
+ * {@code SynchronousBundleListener} is a listener interface that may be
+ * implemented by a bundle developer. When a {@code BundleEvent} is fired,
+ * it is synchronously delivered to a {@code SynchronousBundleListener}.
+ * The Framework may deliver {@code BundleEvent} objects to a
+ * {@code SynchronousBundleListener} out of order and may concurrently call
+ * and/or reenter a {@code SynchronousBundleListener}.
+ * 
+ * <p>
+ * For {@code BundleEvent} types {@link BundleEvent#STARTED STARTED} and
+ * {@link BundleEvent#LAZY_ACTIVATION LAZY_ACTIVATION}, the Framework must not
+ * hold the referenced bundle's &quot;state change&quot; lock when the
+ * {@code BundleEvent} is delivered to a
+ * {@code SynchronousBundleListener}. For the other
+ * {@code BundleEvent} types, the Framework must hold the referenced
+ * bundle's &quot;state change&quot; lock when the {@code BundleEvent} is
+ * delivered to a {@code SynchronousBundleListener}. A
+ * {@code SynchronousBundleListener} cannot directly call life cycle
+ * methods on the referenced bundle when the Framework is holding the referenced
+ * bundle's &quot;state change&quot; lock.
+ * 
  * <p>
- * A <code>SynchronousBundleListener</code> object is registered with the
+ * A {@code SynchronousBundleListener} object is registered with the
  * Framework using the {@link BundleContext#addBundleListener} method.
- * <code>SynchronousBundleListener</code> objects are called with a
- * <code>BundleEvent</code> object when a bundle has been installed, resolved,
+ * {@code SynchronousBundleListener} objects are called with a
+ * {@code BundleEvent} object when a bundle has been installed, resolved,
  * starting, started, stopping, stopped, updated, unresolved, or uninstalled.
  * <p>
- * Unlike normal <code>BundleListener</code> objects,
- * <code>SynchronousBundleListener</code>s are synchronously called during
+ * Unlike normal {@code BundleListener} objects,
+ * {@code SynchronousBundleListener}s are synchronously called during
  * bundle lifecycle processing. The bundle lifecycle processing will not proceed
- * until all <code>SynchronousBundleListener</code>s have completed.
- * <code>SynchronousBundleListener</code> objects will be called prior to
- * <code>BundleListener</code> objects.
+ * until all {@code SynchronousBundleListener}s have completed.
+ * {@code SynchronousBundleListener} objects will be called prior to
+ * {@code BundleListener} objects.
  * <p>
- * <code>AdminPermission[bundle,LISTENER]</code> is required to add or remove
- * a <code>SynchronousBundleListener</code> object.
+ * {@code AdminPermission[bundle,LISTENER]} is required to add or remove a
+ * {@code SynchronousBundleListener} object.
  * 
  * @since 1.1
  * @see BundleEvent
  * @ThreadSafe
- * @version $Revision: 5673 $
+ * @version $Id: b22484f48ebdcb2141da9bba9eb65f5c40e0f520 $
  */
 
 public interface SynchronousBundleListener extends BundleListener {

Modified: felix/trunk/framework/src/main/java/org/osgi/framework/Version.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/Version.java?rev=1103907&r1=1103906&r2=1103907&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/Version.java (original)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/Version.java Mon May 16 21:30:32 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2004, 2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2010). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,24 +28,25 @@ import java.util.StringTokenizer;
  * <li>Major version. A non-negative integer.</li>
  * <li>Minor version. A non-negative integer.</li>
  * <li>Micro version. A non-negative integer.</li>
- * <li>Qualifier. A text string. See <code>Version(String)</code> for the
+ * <li>Qualifier. A text string. See {@code Version(String)} for the
  * format of the qualifier string.</li>
  * </ol>
  * 
  * <p>
- * <code>Version</code> objects are immutable.
+ * {@code Version} objects are immutable.
  * 
  * @since 1.3
  * @Immutable
- * @version $Revision: 6860 $
+ * @version $Id: a71e2e2d7685e65b5bbe375efdf97fda16eff0a5 $
  */
 
-public class Version implements Comparable {
+public class Version implements Comparable<Version> {
 	private final int			major;
 	private final int			minor;
 	private final int			micro;
 	private final String		qualifier;
-	private static final String	SEPARATOR		= ".";					//$NON-NLS-1$
+	private static final String	SEPARATOR		= ".";
+	private transient String	versionString;
 
 	/**
 	 * The empty version "0.0.0".
@@ -75,20 +76,21 @@ public class Version implements Comparab
 	 * @param minor Minor component of the version identifier.
 	 * @param micro Micro component of the version identifier.
 	 * @param qualifier Qualifier component of the version identifier. If
-	 *        <code>null</code> is specified, then the qualifier will be set to
+	 *        {@code null} is specified, then the qualifier will be set to
 	 *        the empty string.
 	 * @throws IllegalArgumentException If the numerical components are negative
 	 *         or the qualifier string is invalid.
 	 */
 	public Version(int major, int minor, int micro, String qualifier) {
 		if (qualifier == null) {
-			qualifier = ""; //$NON-NLS-1$
+			qualifier = "";
 		}
 
 		this.major = major;
 		this.minor = minor;
 		this.micro = micro;
 		this.qualifier = qualifier;
+		versionString = null;
 		validate();
 	}
 
@@ -111,46 +113,51 @@ public class Version implements Comparab
 	 * There must be no whitespace in version.
 	 * 
 	 * @param version String representation of the version identifier.
-	 * @throws IllegalArgumentException If <code>version</code> is improperly
+	 * @throws IllegalArgumentException If {@code version} is improperly
 	 *         formatted.
 	 */
 	public Version(String version) {
 		int maj = 0;
 		int min = 0;
 		int mic = 0;
-		String qual = ""; //$NON-NLS-1$
+		String qual = "";
 
 		try {
 			StringTokenizer st = new StringTokenizer(version, SEPARATOR, true);
 			maj = Integer.parseInt(st.nextToken());
 
-			if (st.hasMoreTokens()) {
+			if (st.hasMoreTokens()) { // minor
 				st.nextToken(); // consume delimiter
 				min = Integer.parseInt(st.nextToken());
 
-				if (st.hasMoreTokens()) {
+				if (st.hasMoreTokens()) { // micro
 					st.nextToken(); // consume delimiter
 					mic = Integer.parseInt(st.nextToken());
 
-					if (st.hasMoreTokens()) {
+					if (st.hasMoreTokens()) { // qualifier
 						st.nextToken(); // consume delimiter
-						qual = st.nextToken();
+						qual = st.nextToken(""); // remaining string
 
-						if (st.hasMoreTokens()) {
-							throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
+						if (st.hasMoreTokens()) { // fail safe
+							throw new IllegalArgumentException(
+									"invalid format: " + version);
 						}
 					}
 				}
 			}
 		}
 		catch (NoSuchElementException e) {
-			throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
+			IllegalArgumentException iae = new IllegalArgumentException(
+					"invalid format: " + version);
+			iae.initCause(e);
+			throw iae;
 		}
 
 		major = maj;
 		minor = min;
 		micro = mic;
 		qualifier = qual;
+		versionString = null;
 		validate();
 	}
 
@@ -162,13 +169,13 @@ public class Version implements Comparab
 	 */
 	private void validate() {
 		if (major < 0) {
-			throw new IllegalArgumentException("negative major"); //$NON-NLS-1$
+			throw new IllegalArgumentException("negative major");
 		}
 		if (minor < 0) {
-			throw new IllegalArgumentException("negative minor"); //$NON-NLS-1$
+			throw new IllegalArgumentException("negative minor");
 		}
 		if (micro < 0) {
-			throw new IllegalArgumentException("negative micro"); //$NON-NLS-1$
+			throw new IllegalArgumentException("negative micro");
 		}
 		char[] chars = qualifier.toCharArray();
 		for (int i = 0, length = chars.length; i < length; i++) {
@@ -185,8 +192,8 @@ public class Version implements Comparab
 			if ((ch == '_') || (ch == '-')) {
 				continue;
 			}
-			throw new IllegalArgumentException(
-					"invalid qualifier: " + qualifier); //$NON-NLS-1$
+			throw new IllegalArgumentException("invalid qualifier: "
+					+ qualifier);
 		}
 	}
 
@@ -194,15 +201,15 @@ public class Version implements Comparab
 	 * Parses a version identifier from the specified string.
 	 * 
 	 * <p>
-	 * See <code>Version(String)</code> for the format of the version string.
+	 * See {@code Version(String)} for the format of the version string.
 	 * 
 	 * @param version String representation of the version identifier. Leading
 	 *        and trailing whitespace will be ignored.
-	 * @return A <code>Version</code> object representing the version
-	 *         identifier. If <code>version</code> is <code>null</code> or
-	 *         the empty string then <code>emptyVersion</code> will be
+	 * @return A {@code Version} object representing the version
+	 *         identifier. If {@code version} is {@code null} or
+	 *         the empty string then {@code emptyVersion} will be
 	 *         returned.
-	 * @throws IllegalArgumentException If <code>version</code> is improperly
+	 * @throws IllegalArgumentException If {@code version} is improperly
 	 *         formatted.
 	 */
 	public static Version parseVersion(String version) {
@@ -258,13 +265,16 @@ public class Version implements Comparab
 	 * Returns the string representation of this version identifier.
 	 * 
 	 * <p>
-	 * The format of the version string will be <code>major.minor.micro</code>
+	 * The format of the version string will be {@code major.minor.micro}
 	 * if qualifier is the empty string or
-	 * <code>major.minor.micro.qualifier</code> otherwise.
+	 * {@code major.minor.micro.qualifier} otherwise.
 	 * 
 	 * @return The string representation of this version identifier.
 	 */
 	public String toString() {
+		if (versionString != null) {
+			return versionString;
+		}
 		int q = qualifier.length();
 		StringBuffer result = new StringBuffer(20 + q);
 		result.append(major);
@@ -276,7 +286,7 @@ public class Version implements Comparab
 			result.append(SEPARATOR);
 			result.append(qualifier);
 		}
-		return result.toString();
+		return versionString = result.toString();
 	}
 
 	/**
@@ -290,17 +300,17 @@ public class Version implements Comparab
 	}
 
 	/**
-	 * Compares this <code>Version</code> object to another object.
+	 * Compares this {@code Version} object to another object.
 	 * 
 	 * <p>
 	 * A version is considered to be <b>equal to </b> another version if the
 	 * major, minor and micro components are equal and the qualifier component
-	 * is equal (using <code>String.equals</code>).
+	 * is equal (using {@code String.equals}).
 	 * 
-	 * @param object The <code>Version</code> object to be compared.
-	 * @return <code>true</code> if <code>object</code> is a
-	 *         <code>Version</code> and is equal to this object;
-	 *         <code>false</code> otherwise.
+	 * @param object The {@code Version} object to be compared.
+	 * @return {@code true} if {@code object} is a
+	 *         {@code Version} and is equal to this object;
+	 *         {@code false} otherwise.
 	 */
 	public boolean equals(Object object) {
 		if (object == this) { // quicktest
@@ -317,7 +327,7 @@ public class Version implements Comparab
 	}
 
 	/**
-	 * Compares this <code>Version</code> object to another object.
+	 * Compares this {@code Version} object to another {@code Version}.
 	 * 
 	 * <p>
 	 * A version is considered to be <b>less than </b> another version if its
@@ -327,27 +337,25 @@ public class Version implements Comparab
 	 * and its micro component is less than the other version's micro component,
 	 * or the major, minor and micro components are equal and it's qualifier
 	 * component is less than the other version's qualifier component (using
-	 * <code>String.compareTo</code>).
+	 * {@code String.compareTo}).
 	 * 
 	 * <p>
 	 * A version is considered to be <b>equal to</b> another version if the
 	 * major, minor and micro components are equal and the qualifier component
-	 * is equal (using <code>String.compareTo</code>).
+	 * is equal (using {@code String.compareTo}).
 	 * 
-	 * @param object The <code>Version</code> object to be compared.
-	 * @return A negative integer, zero, or a positive integer if this object is
-	 *         less than, equal to, or greater than the specified
-	 *         <code>Version</code> object.
+	 * @param other The {@code Version} object to be compared.
+	 * @return A negative integer, zero, or a positive integer if this version
+	 *         is less than, equal to, or greater than the specified
+	 *         {@code Version} object.
 	 * @throws ClassCastException If the specified object is not a
-	 *         <code>Version</code>.
+	 *         {@code Version} object.
 	 */
-	public int compareTo(Object object) {
-		if (object == this) { // quicktest
+	public int compareTo(Version other) {
+		if (other == this) { // quicktest
 			return 0;
 		}
 
-		Version other = (Version) object;
-
 		int result = major - other.major;
 		if (result != 0) {
 			return result;

Added: felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/BundleStartLevel.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/BundleStartLevel.java?rev=1103907&view=auto
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/BundleStartLevel.java (added)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/BundleStartLevel.java Mon May 16 21:30:32 2011
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) OSGi Alliance (2010). All Rights Reserved.
+ * 
+ * Licensed 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.osgi.framework.startlevel;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
+
+/**
+ * Query and modify the start level information for a bundle. The start level
+ * object for a bundle can be obtained by calling {@link Bundle#adapt(Class)
+ * bundle.adapt(BundleStartLevel.class)} on the bundle.
+ * 
+ * <p>
+ * The bundle associated with this BundleStartLevel object can be obtained by
+ * calling {@link BundleReference#getBundle()}.
+ * 
+ * @ThreadSafe
+ * @noimplement
+ * @version $Id: 9a000be191fe3cb4ae82535a30940db0340d5356 $
+ */
+public interface BundleStartLevel extends BundleReference {
+	/**
+	 * Return the assigned start level value for the bundle.
+	 * 
+	 * @return The start level value of the bundle.
+	 * @see #setStartLevel(int)
+	 * @throws IllegalStateException If the bundle has been uninstalled.
+	 */
+	int getStartLevel();
+
+	/**
+	 * Assign a start level value to the bundle.
+	 * 
+	 * <p>
+	 * The bundle will be assigned the specified start level. The start level
+	 * value assigned to the bundle will be persistently recorded by the
+	 * Framework.
+	 * <p>
+	 * If the new start level for the bundle is lower than or equal to the
+	 * active start level of the Framework and the bundle's autostart setting
+	 * indicates this bundle must be started, the Framework will start the
+	 * bundle as described in the {@link Bundle#start(int)} method using the
+	 * {@link Bundle#START_TRANSIENT} option. The
+	 * {@link Bundle#START_ACTIVATION_POLICY} option must also be used if
+	 * {@link #isActivationPolicyUsed()} returns {@code true}. The actual
+	 * starting of the bundle must occur asynchronously.
+	 * <p>
+	 * If the new start level for the bundle is higher than the active start
+	 * level of the Framework, the Framework will stop the bundle as described
+	 * in the {@link Bundle#stop(int)} method using the
+	 * {@link Bundle#STOP_TRANSIENT} option. The actual stopping of the bundle
+	 * must occur asynchronously.
+	 * 
+	 * @param startlevel The new start level for the bundle.
+	 * @throws IllegalArgumentException If the specified start level is less
+	 *         than or equal to zero, or if the bundle is the system bundle.
+	 * @throws IllegalStateException If the bundle has been uninstalled.
+	 * @throws SecurityException If the caller does not have
+	 *         {@code AdminPermission[bundle,EXECUTE]} and the Java runtime
+	 *         environment supports permissions.
+	 */
+	void setStartLevel(int startlevel);
+
+	/**
+	 * Returns whether the bundle's autostart setting indicates it must be
+	 * started.
+	 * <p>
+	 * The autostart setting of a bundle indicates whether the bundle is to be
+	 * started when its start level is reached.
+	 * 
+	 * @return {@code true} if the autostart setting of the bundle indicates it
+	 *         is to be started. {@code false} otherwise.
+	 * @throws IllegalStateException If this bundle has been uninstalled.
+	 * @see Bundle#START_TRANSIENT
+	 */
+	boolean isPersistentlyStarted();
+
+	/**
+	 * Returns whether the bundle's autostart setting indicates that the
+	 * activation policy declared in the bundle manifest must be used.
+	 * <p>
+	 * The autostart setting of a bundle indicates whether the bundle's declared
+	 * activation policy is to be used when the bundle is started.
+	 * 
+	 * @return {@code true} if the bundle's autostart setting indicates the
+	 *         activation policy declared in the manifest must be used.
+	 *         {@code false} if the bundle must be eagerly activated.
+	 * @throws IllegalStateException If the bundle has been uninstalled.
+	 * @see Bundle#START_ACTIVATION_POLICY
+	 */
+	boolean isActivationPolicyUsed();
+}

Added: felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/FrameworkStartLevel.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/FrameworkStartLevel.java?rev=1103907&view=auto
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/FrameworkStartLevel.java (added)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/startlevel/FrameworkStartLevel.java Mon May 16 21:30:32 2011
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) OSGi Alliance (2002, 2010). All Rights Reserved.
+ * 
+ * Licensed 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.osgi.framework.startlevel;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.FrameworkListener;
+
+/**
+ * Query and modify the start level information for the framework. The start
+ * level object for the framework can be obtained by calling
+ * {@link Bundle#adapt(Class) bundle.adapt(FrameworkStartLevel.class)} on the
+ * system bundle. Only the system bundle can be adapted to a FrameworkStartLevel
+ * object.
+ * 
+ * <p>
+ * The system bundle associated with this FrameworkStartLevel object can be
+ * obtained by calling {@link BundleReference#getBundle()}.
+ * 
+ * @ThreadSafe
+ * @noimplement
+ * @version $Id: 2bca22671674ba50b8c6801d5d1df8e291fe2a9d $
+ */
+public interface FrameworkStartLevel extends BundleReference {
+	/**
+	 * Return the active start level value of the Framework.
+	 * 
+	 * If the Framework is in the process of changing the start level this
+	 * method must return the active start level if this differs from the
+	 * requested start level.
+	 * 
+	 * @return The active start level value of the Framework.
+	 */
+	int getStartLevel();
+
+	/**
+	 * Modify the active start level of the Framework and notify when complete.
+	 * 
+	 * <p>
+	 * The Framework will move to the requested start level. This method will
+	 * return immediately to the caller and the start level change will occur
+	 * asynchronously on another thread. The specified {@code FrameworkListener}
+	 * s are notified, in the order specified, when the start level change is
+	 * complete. When the start level change completes normally, each specified
+	 * {@code FrameworkListener} will be called with a Framework event of type
+	 * {@code FrameworkEvent.STARTLEVEL_CHANGED}. If the start level change does
+	 * not complete normally, each specified {@code FrameworkListener} will be
+	 * called with a Framework event of type {@code FrameworkEvent.ERROR}.
+	 * 
+	 * <p>
+	 * If the specified start level is higher than the active start level, the
+	 * Framework will continue to increase the start level until the Framework
+	 * has reached the specified start level.
+	 * 
+	 * At each intermediate start level value on the way to and including the
+	 * target start level, the Framework must:
+	 * <ol>
+	 * <li>Change the active start level to the intermediate start level value.
+	 * <li>Start bundles at the intermediate start level whose autostart setting
+	 * indicate they must be started. They are started as described in the
+	 * {@link Bundle#start(int)} method using the {@link Bundle#START_TRANSIENT}
+	 * option. The {@link Bundle#START_ACTIVATION_POLICY} option must also be
+	 * used if {@link BundleStartLevel#isActivationPolicyUsed()} returns
+	 * {@code true} for the bundle.
+	 * </ol>
+	 * When this process completes after the specified start level is reached,
+	 * the Framework will fire a Framework event of type
+	 * {@code FrameworkEvent.STARTLEVEL_CHANGED} to announce it has moved to the
+	 * specified start level.
+	 * 
+	 * <p>
+	 * If the specified start level is lower than the active start level, the
+	 * Framework will continue to decrease the start level until the Framework
+	 * has reached the specified start level.
+	 * 
+	 * At each intermediate start level value on the way to and including the
+	 * specified start level, the framework must:
+	 * <ol>
+	 * <li>Stop bundles at the intermediate start level as described in the
+	 * {@link Bundle#stop(int)} method using the {@link Bundle#STOP_TRANSIENT}
+	 * option.
+	 * <li>Change the active start level to the intermediate start level value.
+	 * </ol>
+	 * When this process completes after the specified start level is reached,
+	 * the Framework will fire a Framework event of type
+	 * {@code FrameworkEvent.STARTLEVEL_CHANGED} to announce it has moved to the
+	 * specified start level.
+	 * 
+	 * <p>
+	 * If the specified start level is equal to the active start level, then no
+	 * bundles are started or stopped, however, the Framework must fire a
+	 * Framework event of type {@code FrameworkEvent.STARTLEVEL_CHANGED} to
+	 * announce it has finished moving to the specified start level. This event
+	 * may arrive before this method returns.
+	 * 
+	 * @param startlevel The requested start level for the Framework.
+	 * @param listeners Zero or more listeners to be notified when the start
+	 *        level change has been completed. The specified listeners do not
+	 *        need to be otherwise registered with the framework. If a specified
+	 *        listener is already registered with the framework, it will be
+	 *        notified twice.
+	 * @throws IllegalArgumentException If the specified start level is less
+	 *         than or equal to zero.
+	 * @throws SecurityException If the caller does not have
+	 *         {@code AdminPermission[System Bundle,STARTLEVEL]} and the Java
+	 *         runtime environment supports permissions.
+	 */
+	void setStartLevel(int startlevel, FrameworkListener... listeners);
+
+	/**
+	 * Return the initial start level value that is assigned to a Bundle when it
+	 * is first installed.
+	 * 
+	 * @return The initial start level value for Bundles.
+	 * @see #setInitialBundleStartLevel
+	 */
+	int getInitialBundleStartLevel();
+
+	/**
+	 * Set the initial start level value that is assigned to a Bundle when it is
+	 * first installed.
+	 * 
+	 * <p>
+	 * The initial bundle start level will be set to the specified start level.
+	 * The initial bundle start level value will be persistently recorded by the
+	 * Framework.
+	 * 
+	 * <p>
+	 * When a Bundle is installed via {@code BundleContext.installBundle}, it is
+	 * assigned the initial bundle start level value.
+	 * 
+	 * <p>
+	 * The default initial bundle start level value is 1 unless this method has
+	 * been called to assign a different initial bundle start level value.
+	 * 
+	 * <p>
+	 * This method does not change the start level values of installed bundles.
+	 * 
+	 * @param startlevel The initial start level for newly installed bundles.
+	 * @throws IllegalArgumentException If the specified start level is less
+	 *         than or equal to zero.
+	 * @throws SecurityException If the caller does not have
+	 *         {@code AdminPermission[System Bundle,STARTLEVEL]} and the Java
+	 *         runtime environment supports permissions.
+	 */
+	void setInitialBundleStartLevel(int startlevel);
+}

Added: felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRevisions.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRevisions.java?rev=1103907&view=auto
==============================================================================
--- felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRevisions.java (added)
+++ felix/trunk/framework/src/main/java/org/osgi/framework/wiring/BundleRevisions.java Mon May 16 21:30:32 2011
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) OSGi Alliance (2011). All Rights Reserved.
+ * 
+ * Licensed 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.osgi.framework.wiring;
+
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
+
+/**
+ * The {@link BundleRevision bundle revisions} of a bundle. When a bundle is
+ * installed and each time a bundle is updated, a new bundle revision of the
+ * bundle is created. For a bundle that has not been uninstalled, the most
+ * recent bundle revision is defined to be the current bundle revision. A bundle
+ * in the UNINSTALLED state does not have a current revision. An in use bundle
+ * revision is associated with an {@link BundleWiring#isInUse() in use}
+ * {@link BundleWiring}. The current bundle revision, if there is one, and all
+ * in use bundle revisions are returned.
+ * 
+ * <p>
+ * The bundle revisions for a bundle can be obtained by calling
+ * {@link Bundle#adapt(Class) bundle.adapt}({@link BundleRevisions}.class).
+ * {@link #getRevisions()} on the bundle.
+ * 
+ * @ThreadSafe
+ * @noimplement
+ * @version $Id: 1d95ad10f0f08b100f8ee2485bdd34120032c7af $
+ */
+public interface BundleRevisions extends BundleReference {
+	/**
+	 * Return the bundle revisions for the {@link BundleReference#getBundle()
+	 * referenced} bundle.
+	 * 
+	 * <p>
+	 * The result is a list containing the current bundle revision, if there is
+	 * one, and all in use bundle revisions. The list may also contain
+	 * intermediate bundle revisions which are not in use.
+	 * 
+	 * <p>
+	 * The list is ordered in reverse chronological order such that the first
+	 * item is the most recent bundle revision and last item is the oldest
+	 * bundle revision.
+	 * 
+	 * <p>
+	 * Generally the list will have at least one bundle revision for the bundle:
+	 * the current bundle revision. However, for an uninstalled bundle with no
+	 * in use bundle revisions, the list may be empty.
+	 * 
+	 * @return A list containing a snapshot of the {@link BundleRevision}s for
+	 *         the referenced bundle.
+	 */
+	List<BundleRevision> getRevisions();
+}



Mime
View raw message