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 2006/03/16 16:57:43 UTC
svn commit: r386363 [8/10] - in
/incubator/felix/trunk/org.osgi/src/main/java/org/osgi: framework/
service/condpermadmin/ service/packageadmin/ service/startlevel/
service/url/ util/tracker/
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/BundleSignerCondition.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/BundleSignerCondition.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/BundleSignerCondition.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/BundleSignerCondition.java Thu Mar 16 07:57:37 2006
@@ -1,69 +1,152 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/BundleSignerCondition.java,v 1.4 2005/05/25 16:22:46 twatson Exp $
- *
- * Copyright (c) OSGi Alliance (2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.condpermadmin;
-
-import org.osgi.framework.Bundle;
-
-/**
- * This condition checks the signer of a bundle. Since the bundle's signer can only change
- * when the bundle is updated, this condition is immutable.
- * <p>
- * The condition expressed using a single String that specifies a Distinguished Name (DN)
- * chain to match bundle signers against. DN's are encoded using IETF RFC 2253. Usually
- * signers use certificates that are issued by certificate authorities, which also have a
- * corresponding DN and certificate. The certificate authorities can form a chain of trust
- * where the last DN and certificate is known by the framework. The signer of a bundle is
- * expressed as signers DN followed by the DN of its issuer followed by the DN of the next
- * issuer until the DN of the root certificate authority. Each DN is separated by a semicolon.
- * <p>
- * A bundle can satisfy this condition if one of its signers has a DN chain that matches the
- * DN chain used to construct this condition.
- * Wildcards (`*') can be used to allow greater flexibility in specifying the DN chains.
- * Wildcards can be used in place of DNs, RDNs, or the value in an RDN. If a wildcard is
- * used for a value of an RDN, the value must be exactly "*" and will match any value for
- * the corresponding type in that RDN. If a wildcard is used for a RDN, it must be the
- * first RDN and will match any number of RDNs (including zero RDNs).
- *
- * @version $Revision: 1.4 $
- */
-public class BundleSignerCondition
-{
-// NOT USED!!!
-// private static final String CONDITION_TYPE = "org.osgi.service.condpermadmin.BundleSignerCondition";
-
- /**
- * Constructs a condition that tries to match the passed Bundle's location
- * to the location pattern.
- *
- * @param bundle the Bundle being evaluated.
- * @param info the ConditionInfo to construct the condition for. The args of the
- * ConditionInfo specify the chain of distinguished names pattern to match
- * against the signer of the Bundle
- */
- static public Condition getCondition(Bundle bundle, ConditionInfo info) {
-/*
- if (!CONDITION_TYPE.equals(info.getType()))
- throw new IllegalArgumentException("ConditionInfo must be of type \"" + CONDITION_TYPE + "\"");
- String[] args = info.getArgs();
- if (args.length != 1)
- throw new IllegalArgumentException("Illegal number of args: " + args.length);
- // implementation specific code used here
- AbstractBundle ab = (AbstractBundle) bundle;
- return ab.getBundleData().matchDNChain(args[0]) ? Condition.TRUE : Condition.FALSE;
-*/
- // TODO: Fix BundleSignerCondition.getCondition()
- return null;
- }
-
- private BundleSignerCondition() {
- // private constructor to prevent objects of this type
- }
-}
+/*
+ * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/BundleSignerCondition.java,v 1.9 2006/03/14 01:20:40 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005). 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.service.condpermadmin;
+
+import java.lang.reflect.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * Condition to test if the signer of a bundle matches a pattern. Since the bundle's signer can
+ * only change when the bundle is updated, this condition is immutable.
+ * <p>
+ * The condition expressed using a single String that specifies a Distinguished
+ * Name (DN) chain to match bundle signers against. DN's are encoded using IETF
+ * RFC 2253. Usually signers use certificates that are issued by certificate
+ * authorities, which also have a corresponding DN and certificate. The
+ * certificate authorities can form a chain of trust where the last DN and
+ * certificate is known by the framework. The signer of a bundle is expressed as
+ * signers DN followed by the DN of its issuer followed by the DN of the next
+ * issuer until the DN of the root certificate authority. Each DN is separated
+ * by a semicolon.
+ * <p>
+ * A bundle can satisfy this condition if one of its signers has a DN chain that
+ * matches the DN chain used to construct this condition. Wildcards (`*') can be
+ * used to allow greater flexibility in specifying the DN chains. Wildcards can
+ * be used in place of DNs, RDNs, or the value in an RDN. If a wildcard is used
+ * for a value of an RDN, the value must be exactly "*" and will match any value
+ * for the corresponding type in that RDN. If a wildcard is used for a RDN, it
+ * must be the first RDN and will match any number of RDNs (including zero
+ * RDNs).
+ *
+ * @version $Revision: 1.9 $
+ */
+public class BundleSignerCondition {
+ /*
+ * NOTE: A framework implementor may also choose to replace this class in
+ * their distribution with a class that directly interfaces with the
+ * framework implementation. This replacement class MUST NOT alter the
+ * public/protected signature of this class.
+ */
+
+ /*
+ * This class will load the BundleSignerCondition class in the package named
+ * by the org.osgi.vendor.condpermadmin package. This class will delegate
+ * getCondition methods calls to the vendor BundleSignerCondition class.
+ */
+ private static final String packageProperty = "org.osgi.vendor.condpermadmin";
+ private static final Method getCondition;
+ static {
+ getCondition = (Method) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ String packageName = System
+ .getProperty(packageProperty);
+ if (packageName == null) {
+ throw new NoClassDefFoundError(packageProperty
+ + " property not set");
+ }
+
+ Class delegateClass;
+ try {
+ delegateClass = Class.forName(packageName
+ + ".BundleSignerCondition");
+ }
+ catch (ClassNotFoundException e) {
+ throw new NoClassDefFoundError(e.toString());
+ }
+
+ Method result;
+ try {
+ result = delegateClass.getMethod("getCondition",
+ new Class[] {Bundle.class,
+ ConditionInfo.class });
+ }
+ catch (NoSuchMethodException e) {
+ throw new NoSuchMethodError(e.toString());
+ }
+
+ if (!Modifier.isStatic(result.getModifiers())) {
+ throw new NoSuchMethodError(
+ "getCondition method must be static");
+ }
+
+ return result;
+ }
+ });
+ }
+
+ private static final String CONDITION_TYPE = "org.osgi.service.condpermadmin.BundleSignerCondition";
+
+ /**
+ * Constructs a Condition that tries to match the passed Bundle's location
+ * to the location pattern.
+ *
+ * @param bundle The Bundle being evaluated.
+ * @param info The ConditionInfo to construct the condition for. The args of
+ * the ConditionInfo specify a single String specifying the chain of
+ * distinguished names pattern to match against the signer of the
+ * Bundle.
+ * @return A Condition which checks the signers of the specified bundle.
+ */
+ static public Condition getCondition(Bundle bundle, ConditionInfo info) {
+ if (!CONDITION_TYPE.equals(info.getType()))
+ throw new IllegalArgumentException(
+ "ConditionInfo must be of type \"" + CONDITION_TYPE + "\"");
+ String[] args = info.getArgs();
+ if (args.length != 1)
+ throw new IllegalArgumentException("Illegal number of args: "
+ + args.length);
+
+ try {
+ try {
+ return (Condition) getCondition.invoke(null, new Object[] {
+ bundle, info});
+ }
+ catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+ }
+ catch (Error e) {
+ throw e;
+ }
+ catch (RuntimeException e) {
+ throw e;
+ }
+ catch (Throwable e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ private BundleSignerCondition() {
+ // private constructor to prevent objects of this type
+ }
+}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/Condition.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/Condition.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/Condition.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/Condition.java Thu Mar 16 07:57:37 2006
@@ -1,97 +1,127 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/Condition.java,v 1.9 2005/05/25 16:22:46 twatson Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.condpermadmin;
-
-import java.util.Dictionary;
-
-/**
- * This interface is used to implement Conditions that are bound to Permissions
- * using ConditionalPermissionCollection. The Permissions of the
- * ConditionalPermissionCollection can only be used if the associated Condition
- * is satisfied.
- */
-public interface Condition {
- /**
- * A condition object that will always evaluate to true and that is never postponed.
- */
- public final static Condition TRUE = new BooleanCondition(true);
-
- /**
- * A condition object that will always evaluate to false and that is never postponed.
- */
- public final static Condition FALSE = new BooleanCondition(false);
-
- /**
- * This method returns true if the evaluation of the Condition must be postponed
- * until the end of the permission check. If it returns false, it must be able
- * to directly answer the isSatisfied method. In other
- * words, isSatisfied() will return very quickly since no external sources,
- * such as for example users, need to be consulted.
- *
- * @return false if evaluation is immediate, otherwise true to indicate the evaluation must be postponed.
- */
- boolean isPostponed();
-
- /**
- * This method returns true if the Condition is satisfied.
- */
- boolean isSatisfied();
-
- /**
- * This method returns true if the satisfiability may change.
- */
- boolean isMutable();
-
- /**
- * This method returns true if the set of Conditions are satisfied. Although
- * this method is not static, it should be implemented as if it were static.
- * All of the passed Conditions will have the same type and will correspond
- * to the class type of the object on which this method is invoked.
- *
- * @param conds the array of Conditions that must be satisfied
- * @param context a Dictionary object that implementors can use to track
- * state. If this method is invoked multiple times in the same permission
- * evaluation, the same Dictionary will be passed multiple times. The
- * SecurityManager treats this Dictionary as an opaque object simply
- * creates an empty dictionary and passes it to subsequent invocations
- * if multiple invocatios are needed.
- * @return true if all the Conditions are satisfied.
- */
- boolean isSatisfied(Condition conds[], Dictionary context);
-
- /**
- * Package internal class used to define the {@link Condition#FALSE} and
- * {@link Condition#TRUE} constants.
- */
- final static class BooleanCondition implements Condition {
- boolean satisfied;
- BooleanCondition(boolean satisfied) {
- this.satisfied = satisfied;
- }
- public boolean isPostponed() {
- return false;
- }
- public boolean isSatisfied() {
- return satisfied;
- }
- public boolean isMutable() {
- return false;
- }
- public boolean isSatisfied(Condition[] conds, Dictionary context) {
- for(int i = 0; i < conds.length; i++) {
- if (!conds[i].isSatisfied())
- return false;
- }
- return true;
- }
-
- }
-}
+/*
+ * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/Condition.java,v 1.12 2006/03/14 01:20:40 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.service.condpermadmin;
+
+import java.util.Dictionary;
+
+/**
+ * The interface implemented by a Condition. Conditions are bound to Permissions
+ * using Conditional Permission Info. The Permissions of a ConditionalPermission
+ * Info can only be used if the associated Conditions are satisfied.
+ *
+ * @version $Revision: 1.12 $
+ */
+public interface Condition {
+ /**
+ * A Condition object that will always evaluate to true and that is never
+ * postponed.
+ */
+ public final static Condition TRUE = new BooleanCondition(true);
+
+ /**
+ * A Condition object that will always evaluate to false and that is never
+ * postponed.
+ */
+ public final static Condition FALSE = new BooleanCondition(false);
+
+ /**
+ * Returns whether the evaluation must be postponed until the end of the
+ * permission check. This method returns <code>true</code> if the
+ * evaluation of the Condition must be postponed until the end of the
+ * permission check. If this method returns <code>false</code>, this
+ * Condition must be able to directly answer the {@link #isSatisfied()}
+ * method. In other words, isSatisfied() will return very quickly since no
+ * external sources, such as for example users, need to be consulted.
+ *
+ * @return <code>true</code> to indicate the evaluation must be postponed.
+ * Otherwise, <code>false</code> if the evaluation can be
+ * immediately performed.
+ */
+ boolean isPostponed();
+
+ /**
+ * Returns whether the Condition is satisfied.
+ *
+ * @return <code>true</code> to indicate the Conditions is satisfied.
+ * Otherwise, <code>false</code> if the Condition is not satisfied.
+ */
+ boolean isSatisfied();
+
+ /**
+ * Returns whether the Condition is mutable.
+ *
+ * @return <code>true</code> to indicate the value returned by
+ * {@link #isSatisfied()} can change. Otherwise, <code>false</code>
+ * if the value returned by {@link #isSatisfied()} will not change.
+ */
+ boolean isMutable();
+
+ /**
+ * Returns whether a the set of Conditions are satisfied. Although this
+ * method is not static, it must be implemented as if it were static. All of
+ * the passed Conditions will be of the same type and will correspond to the
+ * class type of the object on which this method is invoked.
+ *
+ * @param conditions The array of Conditions.
+ * @param context A Dictionary object that implementors can use to track
+ * state. If this method is invoked multiple times in the same
+ * permission evaluation, the same Dictionary will be passed multiple
+ * times. The SecurityManager treats this Dictionary as an opaque
+ * object and simply creates an empty dictionary and passes it to
+ * subsequent invocations if multiple invocatios are needed.
+ * @return <code>true</code> if all the Conditions are satisfied.
+ * Otherwise, <code>false</code> if one of the Conditions is not
+ * satisfied.
+ */
+ boolean isSatisfied(Condition conditions[], Dictionary context);
+
+}
+
+/**
+ * Package internal class used to define the {@link Condition#FALSE} and
+ * {@link Condition#TRUE} constants.
+ */
+final class BooleanCondition implements Condition {
+ final boolean satisfied;
+
+ BooleanCondition(boolean satisfied) {
+ this.satisfied = satisfied;
+ }
+
+ public boolean isPostponed() {
+ return false;
+ }
+
+ public boolean isSatisfied() {
+ return satisfied;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public boolean isSatisfied(Condition[] conds, Dictionary context) {
+ for (int i = 0; i < conds.length; i++) {
+ if (!conds[i].isSatisfied())
+ return false;
+ }
+ return true;
+ }
+
+}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionInfo.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionInfo.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionInfo.java Thu Mar 16 07:57:37 2006
@@ -1,314 +1,349 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionInfo.java,v 1.6 2005/05/13 20:33:31 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.condpermadmin;
-
-import java.util.Vector;
-
-/**
- * Condition representation used by the Conditional Permission Admin service.
- *
- * <p>
- * This class encapsulates two pieces of information: a Condition <i>type</i>
- * (class name), which must implement <tt>Condition</tt>, and the arguments
- * passed to its constructor.
- *
- * <p>
- * In order for a Condition represented by a <tt>ConditionInfo</tt> to be
- * instantiated and considered during a permission check, its Condition class
- * must be available from the system classpath.
- *
- */
-
-public class ConditionInfo {
-
- private String type;
-
- private String args[];
-
- /**
- * Constructs a <tt>ConditionInfo</tt> from the given type and args.
- *
- * @param type
- * The fully qualified class name of the condition represented by
- * this <tt>ConditionInfo</tt>. The class must implement
- * <tt>Condition</tt> and must define a constructor that takes
- * a <tt>Bundle</tt> and the correct number of argument
- * strings.
- *
- * @param args
- * The arguments that will be passed to the constructor of the
- * <tt>Conditon</tt> class identified by <tt>type</tt>.
- *
- * @exception java.lang.NullPointerException
- * if <tt>type</tt> is <tt>null</tt>.
- */
- public ConditionInfo(String type, String args[]) {
- this.type = type;
- this.args = args;
- if (type == null) {
- throw new NullPointerException("type is null");
- }
- }
-
- /**
- * Constructs a <tt>ConditionInfo</tt> object from the given encoded
- * <tt>ConditionInfo</tt> string.
- *
- * @param encodedCondition
- * The encoded <tt>ConditionInfo</tt>.
- * @see #getEncoded
- * @exception java.lang.IllegalArgumentException
- * if <tt>encodedCondition</tt> is not properly formatted.
- */
- public ConditionInfo(String encodedCondition) {
- if (encodedCondition == null) {
- throw new NullPointerException("missing encoded permission");
- }
- if (encodedCondition.length() == 0) {
- throw new IllegalArgumentException("empty encoded permission");
- }
-
- try {
- char[] encoded = encodedCondition.toCharArray();
-
- /* the first character must be '[' */
- if (encoded[0] != '[') {
- throw new IllegalArgumentException(
- "first character not open bracket");
- }
-
- /* type is not quoted or encoded */
- int end = 1;
- int begin = end;
-
- while ((encoded[end] != ' ') && (encoded[end] != ')')) {
- end++;
- }
-
- if (end == begin) {
- throw new IllegalArgumentException("expecting type");
- }
-
- this.type = new String(encoded, begin, end - begin);
-
- Vector args = new Vector();
- /* type may be followed by name which is quoted and encoded */
- while (encoded[end] == ' ') {
- end++;
-
- if (encoded[end] != '"') {
- throw new IllegalArgumentException("expecting quoted name");
- }
-
- end++;
- begin = end;
-
- while (encoded[end] != '"') {
- if (encoded[end] == '\\') {
- end++;
- }
-
- end++;
- }
-
- args.add(decodeString(encoded, begin, end));
- end++;
- }
- this.args = (String[]) args.toArray(new String[0]);
- /* the final character must be ')' */
- if ((encoded[end] != ']') || (end + 1 != encoded.length)) {
- throw new IllegalArgumentException("last character not "
- + "close bracket");
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new IllegalArgumentException("parsing terminated abruptly");
- }
- }
-
- /**
- * Returns the string encoding of this <tt>ConditionInfo</tt> in a form
- * suitable for restoring this <tt>ConditionInfo</tt>.
- *
- * <p>
- * The encoding format is:
- *
- * <pre>
- *
- * [type "arg0" "arg1" ...]
- *
- * </pre>
- *
- * where <i>argX</i> are strings that are encoded for proper parsing.
- * Specifically, the <tt>"</tt>, <tt>\</tt>, carriage return, and
- * linefeed characters are escaped using <tt>\"</tt>, <tt>\\</tt>,
- * <tt>\r</tt>, and <tt>\n</tt>, respectively.
- *
- * <p>
- * The encoded string must contain no leading or trailing whitespace
- * characters. A single space character must be used between type and "<i>arg0</i>"
- * and between all arguments.
- *
- * @return The string encoding of this <tt>ConditionInfo</tt>.
- */
- public final String getEncoded() {
- StringBuffer output = new StringBuffer();
- output.append('[');
- output.append(type);
-
- for (int i = 0; i < args.length; i++) {
- output.append(" \"");
- encodeString(args[i], output);
- output.append('\"');
- }
-
- output.append(']');
-
- return (output.toString());
- }
-
- /**
- * Returns the string representation of this <tt>ConditionInfo</tt>. The
- * string is created by calling the <tt>getEncoded</tt> method on this
- * <tt>ConditionInfo</tt>.
- *
- * @return The string representation of this <tt>ConditionInfo</tt>.
- */
- public String toString() {
- return (getEncoded());
- }
-
- /**
- * Returns the fully qualified class name of the condition represented by
- * this <tt>ConditionInfo</tt>.
- *
- * @return The fully qualified class name of the condition represented by
- * this <tt>ConditionInfo</tt>.
- */
- public final String getType() {
- return (type);
- }
-
- /**
- * Returns arguments of this <tt>ConditionInfo</tt>.
- *
- * @return The arguments of this <tt>ConditionInfo</tt>. have a name.
- */
- public final String[] getArgs() {
- return (args);
- }
-
- /**
- * Determines the equality of two <tt>ConditionInfo</tt> objects.
- *
- * This method checks that specified object has the same type and args as
- * this <tt>ConditionInfo</tt> object.
- *
- * @param obj
- * The object to test for equality with this
- * <tt>ConditionInfo</tt> object.
- * @return <tt>true</tt> if <tt>obj</tt> is a <tt>ConditionInfo</tt>,
- * and has the same type and args as this <tt>ConditionInfo</tt>
- * object; <tt>false</tt> otherwise.
- */
- public boolean equals(Object obj) {
- if (obj == this) {
- return (true);
- }
-
- if (!(obj instanceof ConditionInfo)) {
- return (false);
- }
-
- ConditionInfo other = (ConditionInfo) obj;
-
- if (!type.equals(other.type) || args.length != other.args.length)
- return false;
-
- for (int i = 0; i < args.length; i++) {
- if (!args[i].equals(other.args[i]))
- return false;
- }
- return true;
- }
-
- /**
- * Returns the hash code value for this object.
- *
- * @return A hash code value for this object.
- */
-
- public int hashCode() {
- int hash = type.hashCode();
-
- for (int i = 0; i < args.length; i++) {
- hash ^= args[i].hashCode();
- }
- return (hash);
- }
-
- /**
- * This escapes the quotes, backslashes, \n, and \r in the string using a
- * backslash and appends the newly escaped string to a StringBuffer.
- */
- private static void encodeString(String str, StringBuffer output) {
- int len = str.length();
-
- for (int i = 0; i < len; i++) {
- char c = str.charAt(i);
-
- switch (c) {
- case '"':
- case '\\':
- output.append('\\');
- output.append(c);
- break;
- case '\r':
- output.append("\\r");
- break;
- case '\n':
- output.append("\\n");
- break;
- default:
- output.append(c);
- break;
- }
- }
- }
-
- /**
- * Takes an encoded character array and decodes it into a new String.
- */
- private static String decodeString(char[] str, int begin, int end) {
- StringBuffer output = new StringBuffer(end - begin);
-
- for (int i = begin; i < end; i++) {
- char c = str[i];
-
- if (c == '\\') {
- i++;
-
- if (i < end) {
- c = str[i];
-
- if (c == 'n') {
- c = '\n';
- } else if (c == 'r') {
- c = '\r';
- }
- }
- }
-
- output.append(c);
- }
-
- return (output.toString());
- }
-}
+/*
+ * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionInfo.java,v 1.12 2006/03/14 01:20:40 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.service.condpermadmin;
+
+import java.util.ArrayList;
+
+/**
+ * Condition representation used by the Conditional Permission Admin service.
+ *
+ * <p>
+ * This class encapsulates two pieces of information: a Condition <i>type</i>
+ * (class name), which must implement <code>Condition</code>, and the
+ * arguments passed to its constructor.
+ *
+ * <p>
+ * In order for a Condition represented by a <code>ConditionInfo</code> to be
+ * instantiated and considered during a permission check, its Condition class
+ * must be available from the system classpath.
+ *
+ * <p>
+ * The Condition class must either:
+ * <ul>
+ * <li>Declare a public static <code>getCondition</code> method that takes a
+ * <code>Bundle</code> object and a <code>ConditionInfo</code> object as
+ * arguments. That method must return an object that implements the
+ * <code>Condition</code> interface.</li>
+ * <li>Implement the <code>Condition</code> interface and define a public
+ * constructor that takes a <code>Bundle</code> object and a
+ * <code>ConditionInfo</code> object as arguments.
+ * </ul>
+ *
+ * @version $Revision: 1.12 $
+ */
+public class ConditionInfo {
+ private String type;
+ private String[] args;
+
+ /**
+ * Constructs a <code>ConditionInfo</code> from the specified type and
+ * args.
+ *
+ * @param type The fully qualified class name of the Condition represented
+ * by this <code>ConditionInfo</code>.
+ * @param args The arguments for the Condition. These arguments are
+ * available to the newly created Condition by calling the
+ * {@link #getArgs()} method.
+ * @throws java.lang.NullPointerException If <code>type</code> is
+ * <code>null</code>.
+ */
+ public ConditionInfo(String type, String[] args) {
+ this.type = type;
+ this.args = args != null ? args : new String[0];
+ if (type == null) {
+ throw new NullPointerException("type is null");
+ }
+ }
+
+ /**
+ * Constructs a <code>ConditionInfo</code> object from the specified
+ * encoded <code>ConditionInfo</code> string. White space in the encoded
+ * <code>ConditionInfo</code> string is ignored.
+ *
+ * @param encodedCondition The encoded <code>ConditionInfo</code>.
+ * @see #getEncoded
+ * @throws java.lang.IllegalArgumentException If the
+ * <code>encodedCondition</code> is not properly formatted.
+ */
+ public ConditionInfo(String encodedCondition) {
+ if (encodedCondition == null) {
+ throw new NullPointerException("missing encoded condition");
+ }
+ if (encodedCondition.length() == 0) {
+ throw new IllegalArgumentException("empty encoded condition");
+ }
+ try {
+ char[] encoded = encodedCondition.toCharArray();
+ int length = encoded.length;
+ int pos = 0;
+
+ /* skip whitespace */
+ while (Character.isWhitespace(encoded[pos])) {
+ pos++;
+ }
+
+ /* the first character must be '[' */
+ if (encoded[pos] != '[') {
+ throw new IllegalArgumentException("expecting open bracket");
+ }
+ pos++;
+
+ /* skip whitespace */
+ while (Character.isWhitespace(encoded[pos])) {
+ pos++;
+ }
+
+ /* type is not quoted or encoded */
+ int begin = pos;
+ while (!Character.isWhitespace(encoded[pos])
+ && (encoded[pos] != ']')) {
+ pos++;
+ }
+ if (pos == begin || encoded[begin] == '"') {
+ throw new IllegalArgumentException("expecting type");
+ }
+ this.type = new String(encoded, begin, pos - begin);
+
+ /* skip whitespace */
+ while (Character.isWhitespace(encoded[pos])) {
+ pos++;
+ }
+
+ /* type may be followed by args which are quoted and encoded */
+ ArrayList argsList = new ArrayList();
+ while (encoded[pos] == '"') {
+ pos++;
+ begin = pos;
+ while (encoded[pos] != '"') {
+ if (encoded[pos] == '\\') {
+ pos++;
+ }
+ pos++;
+ }
+ argsList.add(unescapeString(encoded, begin, pos));
+ pos++;
+
+ if (Character.isWhitespace(encoded[pos])) {
+ /* skip whitespace */
+ while (Character.isWhitespace(encoded[pos])) {
+ pos++;
+ }
+ }
+ }
+ this.args = (String[]) argsList
+ .toArray(new String[argsList.size()]);
+
+ /* the final character must be ']' */
+ char c = encoded[pos];
+ pos++;
+ while ((pos < length) && Character.isWhitespace(encoded[pos])) {
+ pos++;
+ }
+ if ((c != ']') || (pos != length)) {
+ throw new IllegalArgumentException("expecting close bracket");
+ }
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ throw new IllegalArgumentException("parsing terminated abruptly");
+ }
+ }
+
+ /**
+ * Returns the string encoding of this <code>ConditionInfo</code> in a
+ * form suitable for restoring this <code>ConditionInfo</code>.
+ *
+ * <p>
+ * The encoding format is:
+ *
+ * <pre>
+ * [type "arg0" "arg1" ...]
+ * </pre>
+ *
+ * where <i>argN</i> are strings that are encoded for proper parsing.
+ * Specifically, the <code>"</code>, <code>\</code>, carriage return,
+ * and linefeed characters are escaped using <code>\"</code>,
+ * <code>\\</code>, <code>\r</code>, and <code>\n</code>,
+ * respectively.
+ *
+ * <p>
+ * The encoded string contains no leading or trailing whitespace characters.
+ * A single space character is used between type and "<i>arg0</i>" and
+ * between the arguments.
+ *
+ * @return The string encoding of this <code>ConditionInfo</code>.
+ */
+ public final String getEncoded() {
+ StringBuffer output = new StringBuffer();
+ output.append('[');
+ output.append(type);
+
+ for (int i = 0; i < args.length; i++) {
+ output.append(" \"");
+ escapeString(args[i], output);
+ output.append('\"');
+ }
+
+ output.append(']');
+
+ return output.toString();
+ }
+
+ /**
+ * Returns the string representation of this <code>ConditionInfo</code>.
+ * The string is created by calling the <code>getEncoded</code> method on
+ * this <code>ConditionInfo</code>.
+ *
+ * @return The string representation of this <code>ConditionInfo</code>.
+ */
+ public String toString() {
+ return getEncoded();
+ }
+
+ /**
+ * Returns the fully qualified class name of the condition represented by
+ * this <code>ConditionInfo</code>.
+ *
+ * @return The fully qualified class name of the condition represented by
+ * this <code>ConditionInfo</code>.
+ */
+ public final String getType() {
+ return type;
+ }
+
+ /**
+ * Returns arguments of this <code>ConditionInfo</code>.
+ *
+ * @return The arguments of this <code>ConditionInfo</code>. An empty
+ * array is returned if the <code>ConditionInfo</code> has no
+ * arguments.
+ */
+ public final String[] getArgs() {
+ return args;
+ }
+
+ /**
+ * Determines the equality of two <code>ConditionInfo</code> objects.
+ *
+ * This method checks that specified object has the same type and args as
+ * this <code>ConditionInfo</code> object.
+ *
+ * @param obj The object to test for equality with this
+ * <code>ConditionInfo</code> object.
+ * @return <code>true</code> if <code>obj</code> is a
+ * <code>ConditionInfo</code>, and has the same type and args as
+ * this <code>ConditionInfo</code> object; <code>false</code>
+ * otherwise.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof ConditionInfo)) {
+ return false;
+ }
+
+ ConditionInfo other = (ConditionInfo) obj;
+
+ if (!type.equals(other.type) || args.length != other.args.length)
+ return false;
+
+ for (int i = 0; i < args.length; i++) {
+ if (!args[i].equals(other.args[i]))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns the hash code value for this object.
+ *
+ * @return A hash code value for this object.
+ */
+
+ public int hashCode() {
+ int hash = type.hashCode();
+
+ for (int i = 0; i < args.length; i++) {
+ hash ^= args[i].hashCode();
+ }
+ return hash;
+ }
+
+ /**
+ * This escapes the quotes, backslashes, \n, and \r in the string using a
+ * backslash and appends the newly escaped string to a StringBuffer.
+ */
+ private static void escapeString(String str, StringBuffer output) {
+ int len = str.length();
+ for (int i = 0; i < len; i++) {
+ char c = str.charAt(i);
+ switch (c) {
+ case '"' :
+ case '\\' :
+ output.append('\\');
+ output.append(c);
+ break;
+ case '\r' :
+ output.append("\\r");
+ break;
+ case '\n' :
+ output.append("\\n");
+ break;
+ default :
+ output.append(c);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Takes an encoded character array and decodes it into a new String.
+ */
+ private static String unescapeString(char[] str, int begin, int end) {
+ StringBuffer output = new StringBuffer(end - begin);
+ for (int i = begin; i < end; i++) {
+ char c = str[i];
+ if (c == '\\') {
+ i++;
+ if (i < end) {
+ c = str[i];
+ switch (c) {
+ case '"' :
+ case '\\' :
+ break;
+ case 'r' :
+ c = '\r';
+ break;
+ case 'n' :
+ c = '\n';
+ break;
+ default :
+ c = '\\';
+ i--;
+ break;
+ }
+ }
+ }
+ output.append(c);
+ }
+
+ return output.toString();
+ }
+}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java Thu Mar 16 07:57:37 2006
@@ -1,89 +1,104 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java,v 1.6 2005/07/14 10:47:13 pkriens Exp $
- *
- * Copyright (c) OSGi Alliance (2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.condpermadmin;
-
-import java.security.AccessControlContext;
-import java.util.Enumeration;
-import org.osgi.service.permissionadmin.PermissionInfo;
-
-/**
- * This is a framework service that allows ConditionalPermissionInfos to be
- * added to, retrieved from, and removed from the framework.
- *
- * @version $Revision: 1.6 $
- */
-public interface ConditionalPermissionAdmin {
- /**
- * Add a new Conditional Permission Info to the repository.
- *
- * The Conditional Permission Info will be given a unique, never reused name.
- *
- * @param conds the Conditions that need to be satisfied to enable the
- * corresponding Permissions.
- * @param perms the Permissions that are enable when the corresponding
- * Conditions are satisfied.
- * @return the ConditionalPermissionInfo that for the newly added Conditions
- * and Permissions.
- */
- ConditionalPermissionInfo addConditionalPermissionInfo(
- ConditionInfo conds[], PermissionInfo perms[]);
-
- /**
- * Set or create a Conditional Permission Info with conditions and
- * permissions.
- *
- * If the given <code>name</code> is null or not used in the repository
- * yet, a new Conditional Permission Info must be created, otherwise the
- * existing Conditional Permission Info must be reused.
- *
- * @param name the name of this Conditional Permission Info, or
- * <code>null</code>.
- * @param conds the Conditions that need to be satisfied to enable the
- * corresponding Permissions.
- * @param perms the Permissions that are enable when the corresponding
- * Conditions are satisfied.
- * @return the ConditionalPermissionInfo that for the newly added Conditions
- * and Permissions.
- */
- ConditionalPermissionInfo setConditionalPermissionInfo(String name,
- ConditionInfo conds[], PermissionInfo perms[]);
-
- /**
- * Returns the ConditionalPermissionInfos that are currently managed by
- * ConditionalPermissionAdmin. The Enumeration is made up of
- * ConditionalPermissionInfos. Calling ConditionalPermissionInfo.delete()
- * will remove the ConditionalPermissionInfo from
- * ConditionalPermissionAdmin.
- *
- * @return the ConditionalPermissionInfos that are currently managed by
- * ConditionalPermissionAdmin. The Enumeration is made up of
- * ConditionalPermissionInfos.
- */
- Enumeration getConditionalPermissionInfos();
-
- /**
- * Return the the Conditional Permission Info with the given name.
- *
- * @param name the name of the Conditional Permission Info that must be
- * returned
- */
- ConditionalPermissionInfo getConditionalPermissionInfo(String name);
-
- /**
- * Returns the AccessControlContext that corresponds to the given signers.
- *
- * @param signers the signers that will be checked agains
- * BundleSignerCondition.
- * @return an AccessControlContext that has the Permissions associated with
- * the signer.
- */
- AccessControlContext getAccessControlContext(String signers[]);
-}
+/*
+ * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionalPermissionAdmin.java,v 1.12 2006/03/14 01:20:40 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2005). 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.service.condpermadmin;
+
+import java.security.AccessControlContext;
+import java.util.Enumeration;
+
+import org.osgi.service.permissionadmin.PermissionInfo;
+
+/**
+ * Framework service to administer Conditional Permissions. Conditional
+ * Permissions can be added to, retrieved from, and removed from the framework.
+ *
+ * @version $Revision: 1.12 $
+ */
+public interface ConditionalPermissionAdmin {
+ /**
+ * Create a new Conditional Permission Info.
+ *
+ * The Conditional Permission Info will be given a unique, never reused
+ * name.
+ *
+ * @param conds The Conditions that need to be satisfied to enable the
+ * corresponding Permissions.
+ * @param perms The Permissions that are enable when the corresponding
+ * Conditions are satisfied.
+ * @return The ConditionalPermissionInfo for the specified Conditions and
+ * Permissions.
+ * @throws SecurityException If the caller does not have
+ * <code>AllPermission</code>.
+ */
+ public ConditionalPermissionInfo addConditionalPermissionInfo(
+ ConditionInfo conds[], PermissionInfo perms[]);
+
+ /**
+ * Set or create a Conditional Permission Info with a specified name.
+ *
+ * If the specified name is <code>null</code>, a new Conditional
+ * Permission Info must be created and will be given a unique, never reused
+ * name. If there is currently no Conditional Permission Info with the
+ * specified name, a new Conditional Permission Info must be created with
+ * the specified name. Otherwise, the Conditional Permission Info with the
+ * specified name must be updated with the specified Conditions and
+ * Permissions.
+ *
+ * @param name The name of the Conditional Permission Info, or
+ * <code>null</code>.
+ * @param conds The Conditions that need to be satisfied to enable the
+ * corresponding Permissions.
+ * @param perms The Permissions that are enable when the corresponding
+ * Conditions are satisfied.
+ * @return The ConditionalPermissionInfo that for the specified name,
+ * Conditions and Permissions.
+ * @throws SecurityException If the caller does not have
+ * <code>AllPermission</code>.
+ */
+ public ConditionalPermissionInfo setConditionalPermissionInfo(String name,
+ ConditionInfo conds[], PermissionInfo perms[]);
+
+ /**
+ * Returns the Conditional Permission Infos that are currently managed by
+ * Conditional Permission Admin. Calling
+ * {@link ConditionalPermissionInfo#delete()} will remove the Conditional
+ * Permission Info from Conditional Permission Admin.
+ *
+ * @return An enumeration of the Conditional Permission Infos that are
+ * currently managed by Conditional Permission Admin.
+ */
+ public Enumeration getConditionalPermissionInfos();
+
+ /**
+ * Return the Conditional Permission Info with the specified name.
+ *
+ * @param name The name of the Conditional Permission Info to be returned.
+ * @return The Conditional Permission Info with the specified name.
+ */
+ public ConditionalPermissionInfo getConditionalPermissionInfo(String name);
+
+ /**
+ * Returns the Access Control Context that corresponds to the specified
+ * signers.
+ *
+ * @param signers The signers for which to return an Access Control Context.
+ * @return An <code>AccessControlContext</code> that has the Permissions
+ * associated with the signer.
+ */
+ public AccessControlContext getAccessControlContext(String[] signers);
+}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java Thu Mar 16 07:57:37 2006
@@ -1,45 +1,63 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java,v 1.7 2005/07/14 10:47:13 pkriens Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.condpermadmin;
-
-import org.osgi.service.permissionadmin.PermissionInfo;
-
-/**
- * This interface describes a binding of a set of Conditions to a set of
- * Permissions. Instances of this interface are obtained from the
- * ConditionalPermissionAdmin service. This interface is also used to remove
- * ConditionalPermissionCollections from ConditionPermissionAdmin.
- */
-public interface ConditionalPermissionInfo {
- /**
- * Returns the ConditionInfos for the Conditions that must be satisfied to
- * enable this ConditionalPermissionCollection.
- */
- ConditionInfo[] getConditionInfos();
-
- /**
- * Returns the PermissionInfos for the Permission in this
- * ConditionalPermissionCollection.
- */
- PermissionInfo[] getPermissionInfos();
-
- /**
- * Removes the ConditionalPermissionCollection from the
- * ConditionalPermissionAdmin.
- */
- void delete();
-
- /**
- * Return the name of this Conditional Permission Info object.
- *
- */
- String getName();
-}
+/*
+ * $Header: /cvshome/build/org.osgi.service.condpermadmin/src/org/osgi/service/condpermadmin/ConditionalPermissionInfo.java,v 1.10 2006/03/14 01:20:40 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2004, 2005). 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.service.condpermadmin;
+
+import org.osgi.service.permissionadmin.PermissionInfo;
+
+/**
+ * A binding of a set of Conditions to a set of Permissions. Instances of this
+ * interface are obtained from the Conditional Permission Admin service.
+ *
+ * @version $Revision: 1.10 $
+ */
+public interface ConditionalPermissionInfo {
+ /**
+ * Returns the Condition Infos for the Conditions that must be satisfied to
+ * enable the Permissions.
+ *
+ * @return The Condition Infos for the Conditions in this Conditional
+ * Permission Info.
+ */
+ public ConditionInfo[] getConditionInfos();
+
+ /**
+ * Returns the Permission Infos for the Permission in this Conditional
+ * Permission Info.
+ *
+ * @return The Permission Infos for the Permission in this Conditional
+ * Permission Info.
+ */
+ public PermissionInfo[] getPermissionInfos();
+
+ /**
+ * Removes this Conditional Permission Info from the Conditional Permission
+ * Admin.
+ *
+ * @throws SecurityException If the caller does not have
+ * <code>AllPermission</code>.
+ */
+ public void delete();
+
+ /**
+ * Returns the name of this Conditional Permission Info.
+ *
+ * @return The name of this Conditional Permission Info.
+ */
+ public String getName();
+}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/ExportedPackage.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/ExportedPackage.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/ExportedPackage.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/ExportedPackage.java Thu Mar 16 07:57:37 2006
@@ -1,90 +1,111 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.packageadmin/src/org/osgi/service/packageadmin/ExportedPackage.java,v 1.8 2005/05/13 20:32:34 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2001, 2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.packageadmin;
-
-import org.osgi.framework.Bundle;
-
-/**
- * An exported package.
- *
- * Instances implementing this interface are created by the Package Admin
- * service.
- *
- * <p>
- * The information about an exported package provided by this object is valid
- * only until the next time <code>PackageAdmin.refreshPackages()</code> is called.
- * If an <code>ExportedPackage</code> object becomes stale (that is, the package
- * it references has been updated or removed as a result of calling
- * <code>PackageAdmin.refreshPackages()</code>), its <code>getName()</code> and
- * <code>getSpecificationVersion()</code> continue to return their old values,
- * <code>isRemovalPending()</code> returns <code>true</code>, and
- * <code>getExportingBundle()</code> and <code>getImportingBundles()</code> return
- * <code>null</code>.
- *
- * @version $Revision: 1.8 $
- */
-public interface ExportedPackage {
- /**
- * Returns the name of the package associated with this
- * <code>ExportedPackage</code> object.
- *
- * @return The name of this <code>ExportedPackage</code> object.
- */
- public String getName();
-
- /**
- * Returns the bundle exporting the package associated with this
- * <code>ExportedPackage</code> object.
- *
- * @return The exporting bundle, or <code>null</code> if this
- * <code>ExportedPackage</code> object has become stale.
- */
- public Bundle getExportingBundle();
-
- /**
- * Returns the resolved bundles that are currently importing the package
- * associated with this <code>ExportedPackage</code> object.
- *
- * <p>
- * Bundles which require the exporting bundle associated with this
- * <code>ExportedPackage</code> object are considered to be importing bundles
- * and are included in the returned array. See
- * {@link RequiredBundle#getRequiringBundles()}
- *
- * @return The array of resolved bundles currently importing the package
- * associated with this <code>ExportedPackage</code> object, or
- * <code>null</code> if this <code>ExportedPackage</code> object has
- * become stale.
- */
- public Bundle[] getImportingBundles();
-
- /**
- * Returns the specification version of this <code>ExportedPackage</code>, as
- * specified in the exporting bundle's manifest file.
- *
- * @return The specification version of this <code>ExportedPackage</code>
- * object, or <code>null</code> if no version information is
- * available.
- */
- public String getSpecificationVersion();
-
- /**
- * Returns <code>true</code> if the package associated with this
- * <code>ExportedPackage</code> object has been exported by a bundle that has
- * been updated or uninstalled.
- *
- * @return <code>true</code> if the associated package is being exported by a
- * bundle that has been updated or uninstalled, or if this
- * <code>ExportedPackage</code> object has become stale;
- * <code>false</code> otherwise.
- */
- public boolean isRemovalPending();
+/*
+ * $Header: /cvshome/build/org.osgi.service.packageadmin/src/org/osgi/service/packageadmin/ExportedPackage.java,v 1.12 2006/03/14 01:20:05 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2005). 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.service.packageadmin;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * An exported package.
+ *
+ * Objects implementing this interface are created by the Package Admin service.
+ *
+ * <p>
+ * The term <i>exported package</i> refers to a package that has been exported
+ * from a resolved bundle. This package may or may not be currently wired to
+ * other bundles.
+ *
+ * <p>
+ * The information about an exported package provided by this object may change.
+ * An <code>ExportedPackage</code> object becomes stale if the package it
+ * references has been updated or removed as a result of calling
+ * <code>PackageAdmin.refreshPackages()</code>.
+ *
+ * If this object becomes stale, its <code>getName()</code> and
+ * <code>getVersion()</code> methods continue to return their original values,
+ * <code>isRemovalPending()</code> returns <code>true</code>, and
+ * <code>getExportingBundle()</code> and <code>getImportingBundles()</code>
+ * return <code>null</code>.
+ *
+ * @version $Revision: 1.12 $
+ */
+public interface ExportedPackage {
+ /**
+ * Returns the name of the package associated with this exported package.
+ *
+ * @return The name of this exported package.
+ */
+ public String getName();
+
+ /**
+ * Returns the bundle exporting the package associated with this exported
+ * package.
+ *
+ * @return The exporting bundle, or <code>null</code> if this
+ * <code>ExportedPackage</code> object has become stale.
+ */
+ public Bundle getExportingBundle();
+
+ /**
+ * Returns the resolved bundles that are currently wired to this exported
+ * package.
+ *
+ * <p>
+ * Bundles which require the exporting bundle associated with this exported
+ * package are considered to be wired to this exported package are included
+ * in the returned array. See {@link RequiredBundle#getRequiringBundles()}.
+ *
+ * @return The array of resolved bundles currently wired to this exported
+ * package, or <code>null</code> if this
+ * <code>ExportedPackage</code> object has become stale.
+ */
+ public Bundle[] getImportingBundles();
+
+ /**
+ * Returns the version of this exported package.
+ *
+ * @return The version of this exported package, or <code>null</code> if
+ * no version information is available.
+ * @deprecated Since 1.2. This method has been replaced by
+ * {@link #getVersion}.
+ */
+ public String getSpecificationVersion();
+
+ /**
+ * Returns the version of this exported package.
+ *
+ * @return The version of this exported package, or
+ * {@link Version#emptyVersion} if no version information is
+ * available.
+ * @since 1.2
+ */
+ public Version getVersion();
+
+ /**
+ * Returns <code>true</code> if the package associated with this
+ * <code>ExportedPackage</code> object has been exported by a bundle that
+ * has been updated or uninstalled.
+ *
+ * @return <code>true</code> if the associated package is being exported
+ * by a bundle that has been updated or uninstalled, or if this
+ * <code>ExportedPackage</code> object has become stale;
+ * <code>false</code> otherwise.
+ */
+ public boolean isRemovalPending();
}
Modified: incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/PackageAdmin.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/PackageAdmin.java?rev=386363&r1=386362&r2=386363&view=diff
==============================================================================
--- incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/PackageAdmin.java (original)
+++ incubator/felix/trunk/org.osgi/src/main/java/org/osgi/service/packageadmin/PackageAdmin.java Thu Mar 16 07:57:37 2006
@@ -1,289 +1,278 @@
-/*
- * $Header: /cvshome/build/org.osgi.service.packageadmin/src/org/osgi/service/packageadmin/PackageAdmin.java,v 1.10 2005/05/13 20:32:34 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2001, 2005). All Rights Reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this
- * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
- */
-
-package org.osgi.service.packageadmin;
-
-import org.osgi.framework.Bundle;
-
-/**
- * Framework service which allows bundle programmers to inspect the packages
- * exported in the Framework and eagerly update or uninstall bundles.
- *
- * If present, there will only be a single instance of this service registered
- * with the Framework.
- *
- * <p>
- * The term <i>exported package </i> (and the corresponding interface
- * {@link ExportedPackage})refers to a package that has actually been exported
- * (as opposed to one that is available for export).
- *
- * <p>
- * The information about exported packages returned by this service is valid
- * only until the next time {@link #refreshPackages}is called. If an
- * <code>ExportedPackage</code> object becomes stale, (that is, the package it
- * references has been updated or removed as a result of calling
- * <code>PackageAdmin.refreshPackages()</code>), its <code>getName()</code> and
- * <code>getSpecificationVersion()</code> continue to return their old values,
- * <code>isRemovalPending()</code> returns <code>true</code>, and
- * <code>getExportingBundle()</code> and <code>getImportingBundles()</code> return
- * <code>null</code>.
- *
- * @version $Revision: 1.10 $
- */
-public interface PackageAdmin {
- /**
- * Gets the packages exported by the specified bundle.
- *
- * @param bundle The bundle whose exported packages are to be returned, or
- * <code>null</code> if all the packages currently exported in the
- * Framework are to be returned. If the specified bundle is the
- * system bundle (that is, the bundle with id zero), this method
- * returns all the packages on the system classpath whose name does
- * not start with "java.". In an environment where the exhaustive
- * list of packages on the system classpath is not known in advance,
- * this method will return all currently known packages on the system
- * classpath, that is, all packages on the system classpath that
- * contains one or more classes that have been loaded.
- *
- * @return The array of packages exported by the specified bundle, or
- * <code>null</code> if the specified bundle has not exported any
- * packages.
- */
- public ExportedPackage[] getExportedPackages(Bundle bundle);
-
- /**
- * Gets the <code>ExportedPackage</code> object with the specified package
- * name. All exported packages will be checked for the specified name. The
- * exported package with the highest version will be returned.
- * <p>
- * In an environment where the exhaustive list of packages on the system
- * classpath is not known in advance, this method attempts to see if the
- * named package is on the system classpath. This means that this method may
- * discover an <code>ExportedPackage</code> object that was not present in the
- * list returned by a prior call to <code>getExportedPackages()</code>.
- *
- * @param name The name of the exported package to be returned.
- *
- * @return The exported package with the specified name, or <code>null</code>
- * if no exported packages with that name exists.
- */
- public ExportedPackage getExportedPackage(String name);
-
- /**
- * Forces the update (replacement) or removal of packages exported by the
- * specified bundles.
- *
- * <p>
- * If no bundles are specified, this method will update or remove any
- * packages exported by any bundles that were previously updated or
- * uninstalled since the last call to this method. The technique by which
- * this is accomplished may vary among different Framework implementations.
- * One permissible implementation is to stop and restart the Framework.
- *
- * <p>
- * This method returns to the caller immediately and then performs the
- * following steps in its own thread:
- *
- * <ol>
- * <li>Compute a graph of bundles starting with the specified bundles. If
- * no bundles are specified, compute a graph of bundles starting with
- * previously updated or uninstalled ones. Add to the graph any bundle that
- * imports a package that is currently exported by a bundle in the graph.
- * The graph is fully constructed when there is no bundle outside the graph
- * that imports a package from a bundle in the graph. The graph may contain
- * <code>UNINSTALLED</code> bundles that are currently still exporting
- * packages.
- *
- * <li>Each bundle in the graph that is in the <code>ACTIVE</code> state will
- * be stopped as described in the <code>Bundle.stop</code> method.
- *
- * <li>Each bundle in the graph that is in the <code>RESOLVED</code> state is
- * moved to the <code>INSTALLED</code> state. The effect of this step is that
- * bundles in the graph are no longer <code>RESOLVED</code>.
- *
- * <li>Each bundle in the graph that is in the <code>UNINSTALLED</code> state
- * is removed from the graph and is now completely removed from the
- * Framework.
- *
- * <li>Each bundle in the graph that was in the <code>ACTIVE</code> state
- * prior to Step 2 is started as described in the <code>Bundle.start</code>
- * method, causing all bundles required for the restart to be resolved. It
- * is possible that, as a result of the previous steps, packages that were
- * previously exported no longer are. Therefore, some bundles may be
- * unresolvable until another bundle offering a compatible package for
- * export has been installed in the Framework.
- * <li>A framework event of type <code>FrameworkEvent.PACKAGES_REFRESHED</code>
- * is broadcast.
- * </ol>
- *
- * <p>
- * For any exceptions that are thrown during any of these steps, a
- * <code>FrameworkEvent</code> of type <code>ERROR</code> is broadcast,
- * containing the exception. The source bundle for these events should be
- * the specific bundle to which the exception is related. If no specific
- * bundle can be associated with the exception then the System Bundle must
- * be used as the source bundle for the event.
- *
- * @param bundles the bundles whose exported packages are to be updated or
- * removed, or <code>null</code> for all previously updated or
- * uninstalled bundles.
- *
- * @exception SecurityException if the caller does not have the
- * <code>AdminPermission</code> and the Java runtime environment
- * supports permissions.
- */
- public void refreshPackages(Bundle[] bundles);
-
- /**
- * Get the <code>ExportedPackage</code> objects with the specified
- * package name. All exported packages will be checked for the specified
- * name.
- * <p>
- * In an environment where the exhaustive list of packages on the system
- * classpath is not known in advance, this method attempts to see if the
- * named package is on the system classpath. This means that this method may
- * discover an <code>ExportedPackage</code> object that was not present in the
- * list returned by a prior call to <code>getExportedPackages()</code>.
- *
- * @param name The name of the exported packages to be returned.
- *
- * @return An array of the exported packages with the specified name, or
- * <code>null</code> if no exported packages with that name exists.
- * @since 1.2
- */
- public ExportedPackage[] getExportedPackages(String name);
-
- /**
- * Resolve the specified bundles. The Framework must attempt to resolve the
- * specified bundles that are unresolved. Additional bundles that are not
- * included in the specified bundles may be resolved as a result of calling
- * this method. A permissible implementation of this method is to attempt to
- * resolve all unresolved bundles installed in the framework.
- *
- * <p>
- * If <code>null</code> is specified then the Framework will attempt to
- * resolve all unresolved bundles. This method must not cause any bundle to
- * be refreshed, stopped, or started. This method will not return until the
- * operation has completed.
- *
- * @param bundles The bundles to resolve or <code>null</code> to resolve all
- * unresolved bundles installed in the Framework.
- * @return <code>true</code> if all specified bundles are resolved;
- * @since 1.2
- */
- public boolean resolveBundles(Bundle[] bundles);
-
- /**
- * Returns an array of RequiredBundles with the specified symbolic name. If
- * the symbolic name argument is <code>null</code> then all RequiredBundles
- * are returned.
- *
- * @param symbolicName The symbolic name of the RequiredBundle or
- * <code>null</code> for all RequiredBundles in the Framework.
- * @return An array of RequiredBundles with the specified symbolic name or
- * <code>null</code> if no RequiredBundles exist with that symbolic
- * name.
- * @since 1.2
- */
- public RequiredBundle[] getRequiredBundles(String symbolicName);
-
- /**
- * Returns the bundles with the specified symbolic name within the specified
- * version range. If no bundles are installed that have the specified
- * symbolic name, then <code>null</code> is returned. If a version range is
- * specified, then only the bundles that have the specified symbolic name
- * and belong to the specified version range are returned. The returned
- * bundles are ordered by version in descending version order so that the
- * first element of the array contains the bundle with the highest version.
- *
- * @see org.osgi.framework.Constants#BUNDLE_VERSION_ATTRIBUTE
- * @param symbolicName The symbolic name of the desired bundles.
- * @param versionRange The version range of the desired bundles, or
- * <code>null</code> if all versions are desired.
- * @return An array of bundles with the specified name belonging to the
- * specified version range ordered in descending version order, or
- * <code>null</code> if no bundles are found.
- * @since 1.2
- */
- public Bundle[] getBundles(String symbolicName, String versionRange);
-
- /**
- * Returns an array of attached fragment bundles for the specified bundle.
- * If the specified bundle is a fragment then <code>null</code> is returned.
- * If no fragments are attached to the specified bundle then <code>null</code>
- * is returned.
- * <p>
- * This method does not attempt to resolve the specified bundle. If the
- * specified bundle is not resolved then <code>null</code> is returned.
- *
- * @param bundle The bundle whose attached fragment bundles are to be
- * returned.
- * @return An array of fragment bundles or <code>null</code> if the bundle
- * does not have any attached fragment bundles or the bundle is not
- * resolved.
- * @since 1.2
- */
- public Bundle[] getFragments(Bundle bundle);
-
- /**
- * Returns an array of host bundles to which the specified fragment bundle
- * is attached or <code>null</code> if the specified bundle is not attached to
- * a host or is not a fragment bundle.
- *
- * @param bundle The bundle whose host bundles are to be returned.
- * @return An array of host bundles or <code>null</code> if the bundle does
- * not have any host bundles.
- * @since 1.2
- */
- public Bundle[] getHosts(Bundle bundle);
-
- /**
- * Returns the bundle for which the specified class is loaded from. The
- * classloader of the bundle returned must have been used to load the
- * specified class. If the class was not loaded by a bundle classloader then
- * <code>null</code> is returned.
- *
- * @param clazz the class object to get a bundle for
- * @return the bundle from which the specified class is loaded or
- * <code>null</code> if the class was not loaded by a bundle
- * classloader
- * @since 1.2
- */
- public Bundle getBundle(Class clazz);
-
- /**
- * The bundle is a fragment bundle.
- *
- * <p>
- * The value of <code>BUNDLE_TYPE_FRAGMENT</code> is 0x00000001.
- *
- * @since 1.2
- */
- public static final int BUNDLE_TYPE_FRAGMENT = 0x00000001;
-
- /**
- * Returns the special type of the specified bundle. The bundle type values
- * are:
- * <ul>
- * <li>{@link #BUNDLE_TYPE_FRAGMENT}
- * </ul>
- *
- * A bundle may be more than one type at a time. A type code is used to
- * identify the bundle type for future extendability.
- *
- * <p>
- * If a bundle is not one or more of the defined types then 0x00000000 is
- * returned.
- *
- * @return The special type of the bundle.
- * @since 1.2
- */
- public int getBundleType(Bundle bundle);
+/*
+ * $Header: /cvshome/build/org.osgi.service.packageadmin/src/org/osgi/service/packageadmin/PackageAdmin.java,v 1.18 2006/03/14 01:20:05 hargrave Exp $
+ *
+ * Copyright (c) OSGi Alliance (2001, 2005). 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.service.packageadmin;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * Framework service which allows bundle programmers to inspect the package
+ * wiring state of bundles in the Framework as well as other functions related
+ * to the class loader network among bundles.
+ *
+ * <p>
+ * If present, there will only be a single instance of this service registered
+ * with the Framework.
+ *
+ * @version $Revision: 1.18 $
+ * @see org.osgi.service.packageadmin.ExportedPackage
+ * @see org.osgi.service.packageadmin.RequiredBundle
+ */
+public interface PackageAdmin {
+ /**
+ * Gets the exported packages for the specified bundle.
+ *
+ * @param bundle The bundle whose exported packages are to be returned, or
+ * <code>null</code> if all exported packages are to be returned.
+ * If the specified bundle is the system bundle (that is, the bundle
+ * with id zero), this method returns all the packages known to be
+ * exported by the system bundle. This will include the package
+ * specified by the <code>org.osgi.framework.system.packages</code>
+ * system property as well as any other package exported by the
+ * framework implementation.
+ *
+ * @return An array of exported packages, or <code>null</code> if the
+ * specified bundle has no exported packages.
+ */
+ public ExportedPackage[] getExportedPackages(Bundle bundle);
+
+ /**
+ * Gets the exported packages for the specified package name.
+ *
+ * @param name The name of the exported packages to be returned.
+ *
+ * @return An array of the exported packages, or <code>null</code> if no
+ * exported packages with the specified name exists.
+ * @since 1.2
+ */
+ public ExportedPackage[] getExportedPackages(String name);
+
+ /**
+ * Gets the exported package for the specified package name.
+ *
+ * <p>
+ * If there are multiple exported packages with specified name, the exported
+ * package with the highest version will be returned.
+ *
+ * @param name The name of the exported package to be returned.
+ *
+ * @return The exported package, or <code>null</code> if no exported
+ * package with the specified name exists.
+ * @see #getExportedPackages(String)
+ */
+ public ExportedPackage getExportedPackage(String name);
+
+ /**
+ * Forces the update (replacement) or removal of packages exported by the
+ * specified bundles.
+ *
+ * <p>
+ * If no bundles are specified, this method will update or remove any
+ * packages exported by any bundles that were previously updated or
+ * uninstalled since the last call to this method. The technique by which
+ * this is accomplished may vary among different Framework implementations.
+ * One permissible implementation is to stop and restart the Framework.
+ *
+ * <p>
+ * This method returns to the caller immediately and then performs the
+ * following steps on a separate thread:
+ *
+ * <ol>
+ * <li>Compute a graph of bundles starting with the specified bundles. If
+ * no bundles are specified, compute a graph of bundles starting with bundle
+ * updated or uninstalled since the last call to this method. Add to the
+ * graph any bundle that is wired to a package that is currently exported by
+ * a bundle in the graph. The graph is fully constructed when there is no
+ * bundle outside the graph that is wired to a bundle in the graph. The
+ * graph may contain <code>UNINSTALLED</code> bundles that are currently
+ * still exporting packages.
+ *
+ * <li>Each bundle in the graph that is in the <code>ACTIVE</code> state
+ * will be stopped as described in the <code>Bundle.stop</code> method.
+ *
+ * <li>Each bundle in the graph that is in the <code>RESOLVED</code>
+ * state is unresolved and thus moved to the <code>INSTALLED</code> state.
+ * The effect of this step is that bundles in the graph are no longer
+ * <code>RESOLVED</code>.
+ *
+ * <li>Each bundle in the graph that is in the <code>UNINSTALLED</code>
+ * state is removed from the graph and is now completely removed from the
+ * Framework.
+ *
+ * <li>Each bundle in the graph that was in the <code>ACTIVE</code> state
+ * prior to Step 2 is started as described in the <code>Bundle.start</code>
+ * method, causing all bundles required for the restart to be resolved. It
+ * is possible that, as a result of the previous steps, packages that were
+ * previously exported no longer are. Therefore, some bundles may be
+ * unresolvable until another bundle offering a compatible package for
+ * export has been installed in the Framework.
+ * <li>A framework event of type
+ * <code>FrameworkEvent.PACKAGES_REFRESHED</code> is fired.
+ * </ol>
+ *
+ * <p>
+ * For any exceptions that are thrown during any of these steps, a
+ * <code>FrameworkEvent</code> of type <code>ERROR</code> is fired
+ * containing the exception. The source bundle for these events should be
+ * the specific bundle to which the exception is related. If no specific
+ * bundle can be associated with the exception then the System Bundle must
+ * be used as the source bundle for the event.
+ *
+ * @param bundles The bundles whose exported packages are to be updated or
+ * removed, or <code>null</code> for all bundles updated or
+ * uninstalled since the last call to this method.
+ * @throws SecurityException If the caller does not have
+ * <code>AdminPermission[System Bundle,RESOLVE]</code> and the
+ * Java runtime environment supports permissions.
+ */
+ public void refreshPackages(Bundle[] bundles);
+
+ /**
+ * Resolve the specified bundles. The Framework must attempt to resolve the
+ * specified bundles that are unresolved. Additional bundles that are not
+ * included in the specified bundles may be resolved as a result of calling
+ * this method. A permissible implementation of this method is to attempt to
+ * resolve all unresolved bundles installed in the framework.
+ *
+ * <p>
+ * If <code>null</code> is specified then the Framework will attempt to
+ * resolve all unresolved bundles. This method must not cause any bundle to
+ * be refreshed, stopped, or started. This method will not return until the
+ * operation has completed.
+ *
+ * @param bundles The bundles to resolve or <code>null</code> to resolve
+ * all unresolved bundles installed in the Framework.
+ * @return <code>true</code> if all specified bundles are resolved;
+ * @throws SecurityException If the caller does not have
+ * <code>AdminPermission[System Bundle,RESOLVE]</code> and the
+ * Java runtime environment supports permissions.
+ * @since 1.2
+ */
+ public boolean resolveBundles(Bundle[] bundles);
+
+ /**
+ * Returns an array of required bundles having the specified symbolic name.
+ *
+ * <p>
+ * If <code>null</code> is specified, then all required bundles will be
+ * returned.
+ *
+ * @param symbolicName The bundle symbolic name or <code>null</code> for
+ * all required bundles.
+ * @return An array of required bundles or <code>null</code> if no
+ * required bundles exist for the specified symbolic name.
+ * @since 1.2
+ */
+ public RequiredBundle[] getRequiredBundles(String symbolicName);
+
+ /**
+ * Returns the bundles with the specified symbolic name whose bundle version
+ * is within the specified version range. If no bundles are installed that
+ * have the specified symbolic name, then <code>null</code> is returned.
+ * If a version range is specified, then only the bundles that have the
+ * specified symbolic name and whose bundle versions belong to the specified
+ * version range are returned. The returned bundles are ordered by version
+ * in descending version order so that the first element of the array
+ * contains the bundle with the highest version.
+ *
+ * @see org.osgi.framework.Constants#BUNDLE_VERSION_ATTRIBUTE
+ * @param symbolicName The symbolic name of the desired bundles.
+ * @param versionRange The version range of the desired bundles, or
+ * <code>null</code> if all versions are desired.
+ * @return An array of bundles with the specified name belonging to the
+ * specified version range ordered in descending version order, or
+ * <code>null</code> if no bundles are found.
+ * @since 1.2
+ */
+ public Bundle[] getBundles(String symbolicName, String versionRange);
+
+ /**
+ * Returns an array of attached fragment bundles for the specified bundle.
+ * If the specified bundle is a fragment then <code>null</code> is
+ * returned. If no fragments are attached to the specified bundle then
+ * <code>null</code> is returned.
+ * <p>
+ * This method does not attempt to resolve the specified bundle. If the
+ * specified bundle is not resolved then <code>null</code> is returned.
+ *
+ * @param bundle The bundle whose attached fragment bundles are to be
+ * returned.
+ * @return An array of fragment bundles or <code>null</code> if the bundle
+ * does not have any attached fragment bundles or the bundle is not
+ * resolved.
+ * @since 1.2
+ */
+ public Bundle[] getFragments(Bundle bundle);
+
+ /**
+ * Returns an array containing the host bundle to which the specified
+ * fragment bundle is attached or <code>null</code> if the specified
+ * bundle is not attached to a host or is not a fragment bundle. A fragment
+ * may only be attached to a single host bundle.
+ *
+ * @param bundle The bundle whose host bundle is to be returned.
+ * @return An array containing the host bundle or <code>null</code> if the
+ * bundle does not have a host bundle.
+ * @since 1.2
+ */
+ public Bundle[] getHosts(Bundle bundle);
+
+ /**
+ * Returns the bundle from which the specified class is loaded. The class
+ * loader of the returned bundle must have been used to load the specified
+ * class. If the class was not loaded by a bundle class loader then
+ * <code>null</code> is returned.
+ *
+ * @param clazz The class object from which to locate the bundle.
+ * @return The bundle from which the specified class is loaded or
+ * <code>null</code> if the class was not loaded by a bundle class
+ * loader.
+ * @since 1.2
+ */
+ public Bundle getBundle(Class clazz);
+
+ /**
+ * Bundle type indicating the bundle is a fragment bundle.
+ *
+ * <p>
+ * The value of <code>BUNDLE_TYPE_FRAGMENT</code> is 0x00000001.
+ *
+ * @since 1.2
+ */
+ public static final int BUNDLE_TYPE_FRAGMENT = 0x00000001;
+
+ /**
+ * Returns the special type of the specified bundle. The bundle type values
+ * are:
+ * <ul>
+ * <li>{@link #BUNDLE_TYPE_FRAGMENT}
+ * </ul>
+ *
+ * A bundle may be more than one type at a time. A type code is used to
+ * identify the bundle type for future extendability.
+ *
+ * <p>
+ * If a bundle is not one or more of the defined types then 0x00000000 is
+ * returned.
+ *
+ * @param bundle The bundle for which to return the special type.
+ * @return The special type of the bundle.
+ * @since 1.2
+ */
+ public int getBundleType(Bundle bundle);
}