You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/06/08 21:31:08 UTC
svn commit: r782737 [3/8] - in
/felix/trunk/org.osgi.core/src/main/java/org/osgi: framework/
framework/hooks/ framework/hooks/service/ framework/launch/
service/condpermadmin/ service/packageadmin/ service/permissionadmin/
service/startlevel/ service/url/
Modified: felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleException.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleException.java?rev=782737&r1=782736&r2=782737&view=diff
==============================================================================
--- felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleException.java (original)
+++ felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleException.java Mon Jun 8 19:31:06 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleException.java,v 1.15 2006/07/11 13:15:54 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2000, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2008). 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.
@@ -23,84 +21,198 @@
* occurred.
*
* <p>
- * <code>BundleException</code> object is created by the Framework to denote
+ * A <code>BundleException</code> object is created by the Framework to denote
* an exception condition in the lifecycle of a bundle.
* <code>BundleException</code>s should not be created by bundle developers.
+ * A type code is used to identify the exception type for future extendability.
+ *
+ * <p>
+ * OSGi Alliance reserves the right to extend the set of types.
*
* <p>
- * This exception is updated to conform to the general purpose exception
- * chaining mechanism.
+ * This exception conforms to the general purpose exception chaining mechanism.
*
- * @version $Revision: 1.15 $
+ * @version $Revision: 6083 $
*/
public class BundleException extends Exception {
- static final long serialVersionUID = 3571095144220455665L;
+ static final long serialVersionUID = 3571095144220455665L;
+ /**
+ * Type of bundle exception.
+ *
+ * @since 1.5
+ */
+ private final int type;
+
+ /**
+ * No exception type is unspecified.
+ *
+ * @since 1.5
+ */
+ public static final int UNSPECIFIED = 0;
+ /**
+ * The operation was unsupported.
+ *
+ * @since 1.5
+ */
+ public static final int UNSUPPORTED_OPERATION = 1;
+ /**
+ * The operation was invalid.
+ *
+ * @since 1.5
+ */
+ public static final int INVALID_OPERATION = 2;
+ /**
+ * The bundle manifest was in error.
+ *
+ * @since 1.5
+ */
+ public static final int MANIFEST_ERROR = 3;
+ /**
+ * The bundle was not resolved.
+ *
+ * @since 1.5
+ */
+ public static final int RESOLVE_ERROR = 4;
+ /**
+ * The bundle activator was in error.
+ *
+ * @since 1.5
+ */
+ public static final int ACTIVATOR_ERROR = 5;
+ /**
+ * The operation failed due to insufficient permissions.
+ *
+ * @since 1.5
+ */
+ public static final int SECURITY_ERROR = 6;
+ /**
+ * The operation failed to complete the requested lifecycle state change.
+ *
+ * @since 1.5
+ */
+ public static final int STATECHANGE_ERROR = 7;
+
+ /**
+ * The bundle could not be resolved due to an error with the
+ * Bundle-NativeCode header.
+ *
+ * @since 1.5
+ */
+ public static final int NATIVECODE_ERROR = 8;
+
/**
- * Nested exception.
+ * The install or update operation failed because another
+ * already installed bundle has the same symbolic name and version.
+ * @since 1.5
+ */
+ public static final int DUPLICATE_BUNDLE_ERROR = 9;
+
+ /**
+ * The start transient operation failed because the start level of the
+ * bundle is greater than the current framework start level
+ *
+ * @since 1.5
*/
- private final Throwable cause;
+ public static final int START_TRANSIENT_ERROR = 10;
/**
- * Creates a <code>BundleException</code> that wraps another exception.
+ * Creates a <code>BundleException</code> with the specified message and
+ * exception cause.
*
* @param msg The associated message.
* @param cause The cause of this exception.
*/
public BundleException(String msg, Throwable cause) {
- super(msg);
- this.cause = cause;
+ this(msg, UNSPECIFIED, cause);
}
/**
- * Creates a <code>BundleException</code> object with the specified
- * message.
+ * Creates a <code>BundleException</code> with the specified message.
*
* @param msg The message.
*/
public BundleException(String msg) {
+ this(msg, UNSPECIFIED);
+ }
+
+ /**
+ * Creates a <code>BundleException</code> with the specified message, type
+ * and exception cause.
+ *
+ * @param msg The associated message.
+ * @param type The type for this exception.
+ * @param cause The cause of this exception.
+ * @since 1.5
+ */
+ public BundleException(String msg, int type, Throwable cause) {
+ super(msg, cause);
+ this.type = type;
+ }
+
+ /**
+ * Creates a <code>BundleException</code> with the specified message and
+ * type.
+ *
+ * @param msg The message.
+ * @param type The type for this exception.
+ * @since 1.5
+ */
+ public BundleException(String msg, int type) {
super(msg);
- this.cause = null;
+ this.type = type;
}
/**
- * Returns any nested exceptions included in this exception.
+ * Returns the cause of this exception or <code>null</code> if no cause was
+ * specified when this exception was created.
*
* <p>
* This method predates the general purpose exception chaining mechanism.
- * The {@link #getCause()} method is now the preferred means of obtaining
- * this information.
+ * The <code>getCause()</code> method is now the preferred means of
+ * obtaining this information.
*
- * @return The nested exception; <code>null</code> if there is no nested
- * exception.
+ * @return The result of calling <code>getCause()</code>.
*/
public Throwable getNestedException() {
- return cause;
+ return getCause();
}
/**
- * Returns the cause of this exception or <code>null</code> if no cause
- * was specified when this exception was created.
+ * Returns the cause of this exception or <code>null</code> if no cause was
+ * set.
*
- * @return The cause of this exception or <code>null</code> if no cause
- * was specified.
+ * @return The cause of this exception or <code>null</code> if no cause was
+ * set.
* @since 1.3
*/
- public Throwable getCause() {
- return cause;
+ public Throwable getCause() {
+ return super.getCause();
}
/**
- * The cause of this exception can only be set when constructed.
+ * Initializes the cause of this exception to the specified value.
*
- * @param cause Cause of the exception.
- * @return This object.
- * @throws java.lang.IllegalStateException This method will always throw an
- * <code>IllegalStateException</code> since the cause of this
- * exception can only be set when constructed.
+ * @param cause The cause of this exception.
+ * @return This exception.
+ * @throws IllegalArgumentException If the specified cause is this
+ * exception.
+ * @throws IllegalStateException If the cause of this exception has already
+ * been set.
* @since 1.3
*/
public Throwable initCause(Throwable cause) {
- throw new IllegalStateException();
+ return super.initCause(cause);
+ }
+
+ /**
+ * Returns the type for this exception or <code>UNSPECIFIED</code> if the
+ * type was unspecified or unknown.
+ *
+ * @return The type of this exception.
+ * @since 1.5
+ */
+ public int getType() {
+ return type;
}
}
Modified: felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleListener.java?rev=782737&r1=782736&r2=782737&view=diff
==============================================================================
--- felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleListener.java (original)
+++ felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleListener.java Mon Jun 8 19:31:06 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleListener.java,v 1.13 2007/02/21 16:49:05 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2008). 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.
@@ -36,7 +34,7 @@
*
* @see BundleEvent
* @NotThreadSafe
- * @version $Revision: 1.13 $
+ * @version $Revision: 5673 $
*/
public interface BundleListener extends EventListener {
Modified: felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundlePermission.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundlePermission.java?rev=782737&r1=782736&r2=782737&view=diff
==============================================================================
--- felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundlePermission.java (original)
+++ felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundlePermission.java Mon Jun 8 19:31:06 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundlePermission.java,v 1.16 2007/02/20 00:06:02 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2007). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2009). 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,32 +17,46 @@
package org.osgi.framework;
import java.io.IOException;
-import java.security.*;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Map;
/**
* A bundle's authority to require or provide a bundle or to receive or attach
* fragments.
*
* <p>
- * A bundle symbolic name defines a unique fully qualified name.
- * <p>
- * For example:
+ * A bundle symbolic name defines a unique fully qualified name. Wildcards may
+ * be used.
+ *
+ * <pre>
+ * name ::= <symbolic name> | <symbolic name ending in ".*"> | *
+ * </pre>
+ *
+ * Examples:
*
* <pre>
- * <code>
* org.osgi.example.bundle
- * </code>
+ * org.osgi.example.*
+ * *
* </pre>
*
* <p>
- * <code>BundlePermission</code> has four actions: <code>PROVIDE</code>,
- * <code>REQUIRE</code>,<code>HOST</code>, and <code>FRAGMENT</code>.
- * The <code>PROVIDE</code> action implies the <code>REQUIRE</code> action.
+ * <code>BundlePermission</code> has four actions: <code>provide</code>,
+ * <code>require</code>,<code>host</code>, and <code>fragment</code>. The
+ * <code>provide</code> action implies the <code>require</code> action.
*
* @since 1.3
- * @version $Revision: 1.16 $
+ * @ThreadSafe
+ * @version $Revision: 6860 $
*/
public final class BundlePermission extends BasicPermission {
@@ -52,12 +64,14 @@
private static final long serialVersionUID = 3257846601685873716L;
/**
- * The action string <code>provide</code>.
+ * The action string <code>provide</code>. The <code>provide</code> action
+ * implies the <code>require</code> action.
*/
public final static String PROVIDE = "provide";
/**
- * The action string <code>require</code>.
+ * The action string <code>require</code>. The <code>require</code> action
+ * is implied by the <code>provide</code> action.
*/
public final static String REQUIRE = "require";
@@ -79,18 +93,18 @@
| ACTION_REQUIRE
| ACTION_HOST
| ACTION_FRAGMENT;
- private final static int ACTION_NONE = 0;
+ final static int ACTION_NONE = 0;
/**
* The actions mask.
*/
- private transient int action_mask = ACTION_NONE;
+ private transient int action_mask;
/**
* The actions in canonical form.
*
* @serial
*/
- private String actions = null;
+ private volatile String actions = null;
/**
* Defines the authority to provide and/or require and or specify a host
@@ -104,24 +118,23 @@
* for that symbolic name; a bundle that specifies a fragment host must have
* the appropriate <code>BundlePermission</code> for that symbolic name.
*
- * @param symbolicName the bundle symbolic name.
- * @param actions <code>PROVIDE</code>,<code>REQUIRE</code>,
- * <code>HOST</code>,<code>FRAGMENT</code> (canonical order).
+ * @param symbolicName The bundle symbolic name.
+ * @param actions <code>provide</code>,<code>require</code>,
+ * <code>host</code>,<code>fragment</code> (canonical order).
*/
-
public BundlePermission(String symbolicName, String actions) {
- this(symbolicName, getMask(actions));
+ this(symbolicName, parseActions(actions));
}
/**
- * Bundle private constructor used by BundlePermissionCollection.
+ * Package private constructor used by BundlePermissionCollection.
*
* @param symbolicName the bundle symbolic name
* @param mask the action mask
*/
BundlePermission(String symbolicName, int mask) {
super(symbolicName);
- init(mask);
+ setTransients(mask);
}
/**
@@ -129,7 +142,7 @@
*
* @param mask
*/
- private void init(int mask) {
+ private synchronized void setTransients(int mask) {
if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) {
throw new IllegalArgumentException("invalid action string");
}
@@ -138,25 +151,36 @@
}
/**
+ * Returns the current action mask.
+ * <p>
+ * Used by the BundlePermissionCollection class.
+ *
+ * @return Current action mask.
+ */
+ synchronized int getActionsMask() {
+ return action_mask;
+ }
+
+ /**
* Parse action string into action mask.
*
* @param actions Action string.
* @return action mask.
*/
- private static int getMask(String actions) {
+ private static int parseActions(String actions) {
boolean seencomma = false;
int mask = ACTION_NONE;
if (actions == null) {
- return (mask);
+ return mask;
}
char[] a = actions.toCharArray();
int i = a.length - 1;
if (i < 0)
- return (mask);
+ return mask;
while (i != -1) {
char c;
@@ -224,7 +248,7 @@
switch (a[i - matchlen]) {
case ',' :
seencomma = true;
- /* FALLTHROUGH */
+ /* FALLTHROUGH */
case ' ' :
case '\r' :
case '\n' :
@@ -246,7 +270,7 @@
throw new IllegalArgumentException("invalid permission: " + actions);
}
- return (mask);
+ return mask;
}
/**
@@ -268,21 +292,20 @@
* x.y,"provide" -> x.y.z, "provide" is false
* </pre>
*
- * @param p The target permission to interrogate.
- * @return <code>true</code> if the specified
- * <code>BundlePermission</code> action is implied by this object;
- * <code>false</code> otherwise.
+ * @param p The requested permission.
+ * @return <code>true</code> if the specified <code>BundlePermission</code>
+ * action is implied by this object; <code>false</code> otherwise.
*/
-
public boolean implies(Permission p) {
- if (p instanceof BundlePermission) {
- BundlePermission target = (BundlePermission) p;
-
- return (((action_mask & target.action_mask) == target.action_mask) && super
- .implies(p));
+ if (!(p instanceof BundlePermission)) {
+ return false;
}
+ BundlePermission requested = (BundlePermission) p;
- return (false);
+ final int effective = getActionsMask();
+ final int desired = requested.getActionsMask();
+ return ((effective & desired) == desired)
+ && super.implies(requested);
}
/**
@@ -291,13 +314,15 @@
*
* <p>
* Always returns present <code>BundlePermission</code> actions in the
- * following order: <code>PROVIDE</code>,<code>REQUIRE</code>,
- * <code>HOST</code>,<code>FRAGMENT.
- * @return Canonical string representation of the <code>BundlePermission</code> actions.
+ * following order: <code>provide</code>, <code>require</code>,
+ * <code>host</code>, <code>fragment</code>.
+ *
+ * @return Canonical string representation of the <code>BundlePermission
+ * </code> actions.
*/
-
public String getActions() {
- if (actions == null) {
+ String result = actions;
+ if (result == null) {
StringBuffer sb = new StringBuffer();
boolean comma = false;
@@ -326,10 +351,9 @@
sb.append(FRAGMENT);
}
- actions = sb.toString();
+ actions = result = sb.toString();
}
-
- return (actions);
+ return result;
}
/**
@@ -339,7 +363,7 @@
* @return A new <code>PermissionCollection</code> object.
*/
public PermissionCollection newPermissionCollection() {
- return (new BundlePermissionCollection());
+ return new BundlePermissionCollection();
}
/**
@@ -352,22 +376,23 @@
* @param obj The object to test for equality with this
* <code>BundlePermission</code> object.
* @return <code>true</code> if <code>obj</code> is a
- * <code>BundlePermission</code>, and has the same bundle
- * symbolic name and actions as this <code>BundlePermission</code>
- * object; <code>false</code> otherwise.
+ * <code>BundlePermission</code>, and has the same bundle symbolic
+ * name and actions as this <code>BundlePermission</code> object;
+ * <code>false</code> otherwise.
*/
public boolean equals(Object obj) {
if (obj == this) {
- return (true);
+ return true;
}
if (!(obj instanceof BundlePermission)) {
- return (false);
+ return false;
}
- BundlePermission p = (BundlePermission) obj;
+ BundlePermission bp = (BundlePermission) obj;
- return ((action_mask == p.action_mask) && getName().equals(p.getName()));
+ return (getActionsMask() == bp.getActionsMask())
+ && getName().equals(bp.getName());
}
/**
@@ -375,20 +400,10 @@
*
* @return A hash code value for this object.
*/
-
public int hashCode() {
- return (getName().hashCode() ^ getActions().hashCode());
- }
-
- /**
- * Returns the current action mask.
- * <p>
- * Used by the BundlePermissionCollection class.
- *
- * @return Current action mask.
- */
- int getMask() {
- return (action_mask);
+ int h = 31 * 17 + getName().hashCode();
+ h = 31 * h + getActions().hashCode();
+ return h;
}
/**
@@ -396,7 +411,6 @@
* <code>BundlePermission</code> object to a stream. The actions are
* serialized, and the superclass takes care of the name.
*/
-
private synchronized void writeObject(java.io.ObjectOutputStream s)
throws IOException {
// Write out the actions. The superclass takes care of the name
@@ -414,7 +428,7 @@
throws IOException, ClassNotFoundException {
// Read in the action, then initialize the rest
s.defaultReadObject();
- init(getMask(actions));
+ setTransients(parseActions(actions));
}
}
@@ -427,23 +441,20 @@
*/
final class BundlePermissionCollection extends PermissionCollection {
-
- /**
- * Comment for <code>serialVersionUID</code>
- */
private static final long serialVersionUID = 3258407326846433079L;
/**
* Table of permissions.
*
- * @serial
+ * @GuardedBy this
*/
- private Hashtable permissions;
+ private transient Map permissions;
/**
* Boolean saying if "*" is in the collection.
*
* @serial
+ * @GuardedBy this
*/
private boolean all_allowed;
@@ -451,53 +462,51 @@
* Create an empty BundlePermissions object.
*
*/
-
public BundlePermissionCollection() {
- permissions = new Hashtable();
+ permissions = new HashMap();
all_allowed = false;
}
/**
- * Adds a permission to the <code>BundlePermission</code> objects. The key
- * for the hash is the symbolic name.
+ * Add a permission to this permission collection.
*
* @param permission The <code>BundlePermission</code> object to add.
- *
* @throws IllegalArgumentException If the permission is not a
* <code>BundlePermission</code> instance.
* @throws SecurityException If this <code>BundlePermissionCollection</code>
* object has been marked read-only.
*/
-
- public void add(Permission permission) {
- if (!(permission instanceof BundlePermission))
+ public void add(final Permission permission) {
+ if (!(permission instanceof BundlePermission)) {
throw new IllegalArgumentException("invalid permission: "
+ permission);
- if (isReadOnly())
+ }
+ if (isReadOnly()) {
throw new SecurityException("attempt to add a Permission to a "
+ "readonly PermissionCollection");
+ }
+ final BundlePermission bp = (BundlePermission) permission;
+ final String name = bp.getName();
+ synchronized (this) {
+ Map pc = permissions;
+ BundlePermission existing = (BundlePermission) pc.get(name);
+ if (existing != null) {
+ final int oldMask = existing.getActionsMask();
+ final int newMask = bp.getActionsMask();
+ if (oldMask != newMask) {
+ pc.put(name, new BundlePermission(name, oldMask
+ | newMask));
- BundlePermission bp = (BundlePermission) permission;
- String name = bp.getName();
-
- BundlePermission existing = (BundlePermission) permissions.get(name);
-
- if (existing != null) {
- int oldMask = existing.getMask();
- int newMask = bp.getMask();
- if (oldMask != newMask) {
- permissions.put(name, new BundlePermission(name, oldMask
- | newMask));
-
+ }
+ }
+ else {
+ pc.put(name, bp);
}
- }
- else {
- permissions.put(name, permission);
- }
- if (!all_allowed) {
- if (name.equals("*"))
- all_allowed = true;
+ if (!all_allowed) {
+ if (name.equals("*"))
+ all_allowed = true;
+ }
}
}
@@ -507,68 +516,60 @@
*
* @param permission The Permission object to compare with this
* <code>BundlePermission</code> object.
- *
- * @return <code>true</code> if <code>permission</code> is a proper
- * subset of a permission in the set; <code>false</code>
- * otherwise.
+ * @return <code>true</code> if <code>permission</code> is a proper subset
+ * of a permission in the set; <code>false</code> otherwise.
*/
-
- public boolean implies(Permission permission) {
- if (!(permission instanceof BundlePermission))
- return (false);
-
- BundlePermission bp = (BundlePermission) permission;
- BundlePermission x;
-
- int desired = bp.getMask();
- int effective = 0;
-
- // short circuit if the "*" Permission was added
- if (all_allowed) {
- x = (BundlePermission) permissions.get("*");
- if (x != null) {
- effective |= x.getMask();
- if ((effective & desired) == desired)
- return (true);
+ public boolean implies(final Permission permission) {
+ if (!(permission instanceof BundlePermission)) {
+ return false;
+ }
+ BundlePermission requested = (BundlePermission) permission;
+ String requestedName = requested.getName();
+ final int desired = requested.getActionsMask();
+ int effective = BundlePermission.ACTION_NONE;
+ BundlePermission bp;
+
+ synchronized (this) {
+ Map pc = permissions;
+ /* short circuit if the "*" Permission was added */
+ if (all_allowed) {
+ bp = (BundlePermission) pc.get("*");
+ if (bp != null) {
+ effective |= bp.getActionsMask();
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
}
- }
-
- // strategy:
- // Check for full match first. Then work our way up the
- // name looking for matches on a.b.*
-
- String name = bp.getName();
-
- x = (BundlePermission) permissions.get(name);
-
- if (x != null) {
- // we have a direct hit!
- effective |= x.getMask();
- if ((effective & desired) == desired)
- return (true);
- }
-
- // work our way up the tree...
- int last, offset;
-
- offset = name.length() - 1;
-
- while ((last = name.lastIndexOf(".", offset)) != -1) {
-
- name = name.substring(0, last + 1) + "*";
- x = (BundlePermission) permissions.get(name);
-
- if (x != null) {
- effective |= x.getMask();
- if ((effective & desired) == desired)
- return (true);
+ bp = (BundlePermission) pc.get(requestedName);
+ // strategy:
+ // Check for full match first. Then work our way up the
+ // name looking for matches on a.b.*
+ if (bp != null) {
+ // we have a direct hit!
+ effective |= bp.getActionsMask();
+ if ((effective & desired) == desired) {
+ return true;
+ }
}
- offset = last - 1;
+ // work our way up the tree...
+ int last;
+ int offset = requestedName.length() - 1;
+ while ((last = requestedName.lastIndexOf(".", offset)) != -1) {
+ requestedName = requestedName.substring(0, last + 1) + "*";
+ bp = (BundlePermission) pc.get(requestedName);
+ if (bp != null) {
+ effective |= bp.getActionsMask();
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
+ offset = last - 1;
+ }
+ // we don't have to check for "*" as it was already checked
+ // at the top (all_allowed), so we just return false
+ return false;
}
-
- // we don't have to check for "*" as it was already checked
- // at the top (all_allowed), so we just return false
- return (false);
}
/**
@@ -577,8 +578,29 @@
*
* @return Enumeration of all <code>BundlePermission</code> objects.
*/
+ public synchronized Enumeration elements() {
+ return Collections.enumeration(permissions.values());
+ }
+
+ /* serialization logic */
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("permissions", Hashtable.class),
+ new ObjectStreamField("all_allowed", Boolean.TYPE) };
- public Enumeration elements() {
- return (permissions.elements());
+ private synchronized void writeObject(ObjectOutputStream out)
+ throws IOException {
+ Hashtable hashtable = new Hashtable(permissions);
+ ObjectOutputStream.PutField pfields = out.putFields();
+ pfields.put("permissions", hashtable);
+ pfields.put("all_allowed", all_allowed);
+ out.writeFields();
+ }
+
+ 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);
+ all_allowed = gfields.get("all_allowed", false);
}
}
Added: felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleReference.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleReference.java?rev=782737&view=auto
==============================================================================
--- felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleReference.java (added)
+++ felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/BundleReference.java Mon Jun 8 19:31:06 2009
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) OSGi Alliance (2009). 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;
+
+/**
+ * A reference to a Bundle.
+ *
+ * @since 1.5
+ * @ThreadSafe
+ * @version $Revision: 6860 $
+ */
+public interface BundleReference {
+ /**
+ * Returns the <code>Bundle</code> object associated with this
+ * <code>BundleReference</code>.
+ *
+ * @return The <code>Bundle</code> object associated with this
+ * <code>BundleReference</code>.
+ */
+ public Bundle getBundle();
+}
Modified: felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/Configurable.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/Configurable.java?rev=782737&r1=782736&r2=782737&view=diff
==============================================================================
--- felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/Configurable.java (original)
+++ felix/trunk/org.osgi.core/src/main/java/org/osgi/framework/Configurable.java Mon Jun 8 19:31:06 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/Configurable.java,v 1.12 2007/02/20 00:07:22 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2009). 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,7 +26,7 @@
* <code>instanceof Configurable</code>.
*
* @deprecated As of 1.2. Please use Configuration Admin service.
- * @version $Revision: 1.12 $
+ * @version $Revision: 6361 $
*/
public interface Configurable {
/**
@@ -44,7 +42,7 @@
* returning the configuration object.
*
* @return The configuration object for this service.
- * @throws java.lang.SecurityException If the caller does not have an
+ * @throws SecurityException If the caller does not have an
* appropriate permission and the Java Runtime Environment supports
* permissions.
* @deprecated As of 1.2. Please use Configuration Admin service.