You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2012/04/20 17:41:40 UTC
svn commit: r1328415 [2/2] - in /aries/trunk/subsystem: ./
subsystem-api/src/main/java/org/osgi/service/repository/
subsystem-api/src/main/java/org/osgi/service/resolver/
subsystem-api/src/main/java/org/osgi/service/subsystem/
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java?rev=1328415&r1=1328414&r2=1328415&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java Fri Apr 20 15:41:40 2012
@@ -13,166 +13,205 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.osgi.service.subsystem;
-import org.osgi.framework.namespace.IdentityNamespace;
/**
- * Defines the constants used by subsystems.
+ * Defines the constants used by Subsystem service property, manifest header,
+ * attribute and directive keys.
+ * <p>
+ * The values associated with these keys are of type {@code String}, unless
+ * otherwise indicated.
+ *
+ * @Immutable
+ * @version $Id: 53f0bd1ccdd14681f09adc3c9dde8e0b95154b71 $
*/
public class SubsystemConstants {
+ private SubsystemConstants() {
+ // non-instantiable
+ }
+
/**
* Manifest header identifying the resources to be deployed.
*/
- public static final String DEPLOYED_CONTENT = "Deployed-Content";
+ public static final String DEPLOYED_CONTENT = "Deployed-Content";
/**
* Manifest header attribute identifying the deployed version.
*/
- public static final String DEPLOYED_VERSION_ATTRIBUTE = "deployed-version";
+ public static final String DEPLOYED_VERSION_ATTRIBUTE = "deployed-version";
/**
- * Manifest header identifying the deployment manifest version. If not present, the default value is 1.
+ * Manifest header identifying the deployment manifest version. If not
+ * present, the default value is {@code 1}.
*/
- public static final String DEPLOYMENT_MANIFESTVERSION = "Deployment-ManifestVersion";
+ public static final String DEPLOYMENT_MANIFESTVERSION = "Deployment-ManifestVersion";
/**
* Manifest header used to express a preference for particular resources to
* satisfy implicit package dependencies.
*/
- public static final String PREFERRED_PROVIDER = "Preferred-Provider";
-
+ public static final String PREFERRED_PROVIDER = "Preferred-Provider";
+
/**
- * A value for the {@link #PROVISION_POLICY_DIRECTIVE provision-policy}
- * directive indicating the subsystem accepts dependency resources. The root
- * subsystem has this provision policy.
+ * Manifest header directive identifying the provision policy. The default
+ * value is {@link #PROVISION_POLICY_REJECT_DEPENDENCIES rejectDependencies}
+ *
+ * @see #PROVISION_POLICY_ACCEPT_DEPENDENCIES
+ * @see #PROVISION_POLICY_REJECT_DEPENDENCIES
*/
- public static final String PROVISION_POLICY_ACCEPT_DEPENDENCIES = "acceptDependencies";
-
+ public static final String PROVISION_POLICY_DIRECTIVE = "provision-policy";
+
/**
- * Manifest header directive identifying the provision policy. The default
- * value is {@link #PROVISION_POLICY_REJECT_DEPENDENCIES rejectDependencies}.
+ * A value for the {@link #PROVISION_POLICY_DIRECTIVE provision-policy}
+ * directive indicating the subsystem accepts dependency resources. The root
+ * subsystem has this provision policy.
*/
- public static final String PROVISION_POLICY_DIRECTIVE = "provision-policy";
-
+ public static final String PROVISION_POLICY_ACCEPT_DEPENDENCIES = "acceptDependencies";
+
/**
* A value for the {@link #PROVISION_POLICY_DIRECTIVE provision-policy}
* directive indicating the subsystem does not accept dependency resources.
* This is the default value.
*/
- public static final String PROVISION_POLICY_REJECT_DEPENDENCIES = "rejectDependencies";
+ public static final String PROVISION_POLICY_REJECT_DEPENDENCIES = "rejectDependencies";
/**
- * Manifest header identifying the resources to be deployed to satisfy the
+ * Manifest header identifying the resources to be deployed to satisfy the
* dependencies of a subsystem.
*/
- public static final String PROVISION_RESOURCE = "Provision-Resource";
+ public static final String PROVISION_RESOURCE = "Provision-Resource";
/**
- * Manifest header directive identifying the start level.
+ * Manifest header directive identifying the start order of subsystem
+ * contents. There is no default value. Specified values are of type
+ * {@code String} and must represent an integer.
*/
- public static final String START_LEVEL_DIRECTIVE = "start-level";
-
+ public static final String START_ORDER_DIRECTIVE = "start-order";
+
/**
- * Manifest header identifying the list of subsystem contents identified by a symbolic name and version.
+ * Manifest header identifying the list of subsystem contents identified by
+ * a symbolic name and version.
*/
- public static final String SUBSYSTEM_CONTENT = "Subsystem-Content";
-
+ public static final String SUBSYSTEM_CONTENT = "Subsystem-Content";
+
/**
* Manifest header identifying the human readable description.
*/
- public static final String SUBSYSTEM_DESCRIPTION = "Subsystem-Description";
-
+ public static final String SUBSYSTEM_DESCRIPTION = "Subsystem-Description";
+
/**
* Manifest header identifying services offered for export.
*/
- public static final String SUBSYSTEM_EXPORTSERVICE = "Subsystem-ExportService";
-
+ public static final String SUBSYSTEM_EXPORTSERVICE = "Subsystem-ExportService";
+
/**
- * The name of the service property for the {@link
- * Subsystem#getSubsystemId() subsystem ID}.
- * It is defined to be "subsystem.id".
+ * The name of the service property for the
+ * {@link Subsystem#getSubsystemId() subsystem ID}. The value of this
+ * property must be of type {@code Long}.
*/
- public static final String SUBSYSTEM_ID_PROPERTY = "subsystem.id";
-
+ public static final String SUBSYSTEM_ID_PROPERTY = "subsystem.id";
+
/**
* Manifest header identifying services required for import.
*/
- public static final String SUBSYSTEM_IMPORTSERVICE = "Subsystem-ImportService";
-
+ public static final String SUBSYSTEM_IMPORTSERVICE = "Subsystem-ImportService";
+
/**
- * Manifest header identifying the subsystem manifest version. If not present, the default value is 1.
+ * Manifest header identifying the subsystem manifest version. If not
+ * present, the default value is {@code 1}.
*/
- public static final String SUBSYSTEM_MANIFESTVERSION = "Subsystem-ManifestVersion";
-
+ public static final String SUBSYSTEM_MANIFESTVERSION = "Subsystem-ManifestVersion";
+
/**
* Manifest header identifying the human readable subsystem name.
*/
- public static final String SUBSYSTEM_NAME = "Subsystem-Name";
-
+ public static final String SUBSYSTEM_NAME = "Subsystem-Name";
+
/**
- * The name of the service property for the subsystem {@link
- * Subsystem#getState() state}.
- * It is defined to be "subsystem.state".
+ * The name of the service property for the subsystem
+ * {@link Subsystem#getState() state}. The value of this property must be of
+ * type {@link Subsystem.State}.
*/
- public static final String SUBSYSTEM_STATE_PROPERTY = "subsystem.state";
-
+ public static final String SUBSYSTEM_STATE_PROPERTY = "subsystem.state";
+
/**
- * Manifest header value identifying the symbolic name for the subsystem. Must be present.
+ * Manifest header value identifying the symbolic name for the subsystem.
+ * Must be present.
*/
- public static final String SUBSYSTEM_SYMBOLICNAME = "Subsystem-SymbolicName";
-
+ public static final String SUBSYSTEM_SYMBOLICNAME = "Subsystem-SymbolicName";
+
+ /**
+ * The name of the service property for the subsystem
+ * {@link Subsystem#getSymbolicName() symbolic name}.
+ */
+ public static final String SUBSYSTEM_SYMBOLICNAME_PROPERTY = "subsystem.symbolicName";
+
/**
- * The name of the service property for the subsystem {@link
- * Subsystem#getSymbolicName() symbolic name}.
- * It is defined to be "subsystem.symbolicName".
+ * The symbolic name of the root subsystem.
*/
- public static final String SUBSYSTEM_SYMBOLICNAME_PROPERTY = "subsystem.symbolicName";
-
+ public static final String ROOT_SUBSYSTEM_SYMBOLICNAME = "org.osgi.service.subsystem.root";
+
/**
* Manifest header identifying the subsystem type.
+ *
+ * @see #SUBSYSTEM_TYPE_APPLICATION
+ * @see #SUBSYSTEM_TYPE_COMPOSITE
+ * @see #SUBSYSTEM_TYPE_FEATURE
*/
- public static final String SUBSYSTEM_TYPE = "Subsystem-Type";
-
+ public static final String SUBSYSTEM_TYPE = "Subsystem-Type";
+
/**
- * The name of the service property for the subsystem {@link #SUBSYSTEM_TYPE
+ * The name of the service property for the {@link #SUBSYSTEM_TYPE subsystem
* type}.
- * It is defined to be "subsystem.type".
+ *
+ * @see #SUBSYSTEM_TYPE_APPLICATION
+ * @see #SUBSYSTEM_TYPE_COMPOSITE
+ * @see #SUBSYSTEM_TYPE_FEATURE
*/
- public static final String SUBSYSTEM_TYPE_PROPERTY = "subsystem.type";
-
+ public static final String SUBSYSTEM_TYPE_PROPERTY = "subsystem.type";
+
/**
- * An identity {@link IdentityNamespace#CAPABILITY_TYPE_ATTRIBUTE type}
- * attribute and subsystem {@link #SUBSYSTEM_TYPE type} manifest header
- * value identifying an application subsystem. It is defined to be
- * "osgi.subsystem.application".
+ * The resource type value identifying an application subsystem.
+ *
+ * <p>
+ * This value is used for the {@code osgi.identity} capability attribute
+ * {@code type}, the {@link #SUBSYSTEM_TYPE} manifest header and the
+ * {@link #SUBSYSTEM_TYPE_PROPERTY} service property.
*/
- public static final String SUBSYSTEM_TYPE_APPLICATION = "osgi.subsystem.application";
-
+ public static final String SUBSYSTEM_TYPE_APPLICATION = "osgi.subsystem.application";
+
/**
- * An identity {@link IdentityNamespace#CAPABILITY_TYPE_ATTRIBUTE type}
- * attribute and subsystem {@link #SUBSYSTEM_TYPE type} manifest header
- * value identifying a composite subsystem. It is defined to be
- * "osgi.subsystem.composite".
+ * The resource type value identifying an composite subsystem.
+ *
+ * <p>
+ * This value is used for the {@code osgi.identity} capability attribute
+ * {@code type}, the {@link #SUBSYSTEM_TYPE} manifest header and the
+ * {@link #SUBSYSTEM_TYPE_PROPERTY} service property.
*/
- public static final String SUBSYSTEM_TYPE_COMPOSITE = "osgi.subsystem.composite";
-
+ public static final String SUBSYSTEM_TYPE_COMPOSITE = "osgi.subsystem.composite";
+
/**
- * An identity {@link IdentityNamespace#CAPABILITY_TYPE_ATTRIBUTE type}
- * attribute and subsystem {@link #SUBSYSTEM_TYPE type} manifest header
- * value identifying a feature subsystem. It is defined to be
- * "osgi.subsystem.feature".
+ * The resource type value identifying an feature subsystem.
+ *
+ * <p>
+ * This value is used for the {@code osgi.identity} capability attribute
+ * {@code type}, the {@link #SUBSYSTEM_TYPE} manifest header and the
+ * {@link #SUBSYSTEM_TYPE_PROPERTY} service property.
*/
- public static final String SUBSYSTEM_TYPE_FEATURE = "osgi.subsystem.feature";
-
+ public static final String SUBSYSTEM_TYPE_FEATURE = "osgi.subsystem.feature";
+
/**
- * Manifest header value identifying the version of the subsystem. If not present, the default value is 0.0.0.
+ * Manifest header value identifying the version of the subsystem. If not
+ * present, the default value is {@code 0.0.0}.
*/
- public static final String SUBSYSTEM_VERSION = "Subsystem-Version";
-
+ public static final String SUBSYSTEM_VERSION = "Subsystem-Version";
+
/**
- * The name of the service property for the subsystem {@link
- * Subsystem#getVersion() version}.
+ * The name of the service property for the subsystem
+ * {@link Subsystem#getVersion() version}. The value of this property must
+ * be of type {@code Version}.
*/
- public static final String SUBSYSTEM_VERSION_PROPERTY = "subsystem.version";
+ public static final String SUBSYSTEM_VERSION_PROPERTY = "subsystem.version";
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemException.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemException.java?rev=1328415&r1=1328414&r2=1328415&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemException.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemException.java Fri Apr 20 15:41:40 2012
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2011). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2011, 2012). 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.
@@ -13,22 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.osgi.service.subsystem;
/**
- * Exception thrown by Subsystem when a problem occurs.
+ * A Subsystem exception used to indicate a problem.
+ *
+ * @version $Id: 06542037c2bdaa7d328a368223b4f71b7a1c3dea $
*/
public class SubsystemException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
- * Construct a subsystem exception with no message.
+ * Construct a Subsystem exception with no message.
*/
public SubsystemException() {
+ super();
}
/**
- * Construct a subsystem exception specifying a message.
+ * Construct a Subsystem exception specifying a message.
+ *
* @param message The message to include in the exception.
*/
public SubsystemException(String message) {
@@ -36,7 +41,8 @@ public class SubsystemException extends
}
/**
- * Construct a subsystem exception wrapping an existing exception.
+ * Construct a Subsystem exception specifying a cause.
+ *
* @param cause The cause of the exception.
*/
public SubsystemException(Throwable cause) {
@@ -44,8 +50,8 @@ public class SubsystemException extends
}
/**
- * Construct a subsystem exception specifying a message and wrapping an
- * existing exception.
+ * Construct a Subsystem exception specifying a message and a cause.
+ *
* @param message The message to include in the exception.
* @param cause The cause of the exception.
*/
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemPermission.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemPermission.java?rev=1328415&r1=1328414&r2=1328415&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemPermission.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemPermission.java Fri Apr 20 15:41:40 2012
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2000, 2011). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2012). 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.
@@ -33,7 +33,6 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
@@ -42,18 +41,18 @@ import org.osgi.framework.InvalidSyntaxE
* A bundle's authority to perform specific privileged administrative operations
* on or to get sensitive information about a subsystem. The actions for this
* permission are:
- *
+ *
* <pre>
- * Action Methods
- * context Subsystem.getBundleContext
- * execute Subsystem.start
- * Subsystem.stop
- * lifecycle Subsystem.install
- * Subsystem.uninstall
- * metadata Subsystem.getHeaders
- * Subsystem.getLocation
+ * Action Methods
+ * context Subsystem.getBundleContext
+ * execute Subsystem.start
+ * Subsystem.stop
+ * lifecycle Subsystem.install
+ * Subsystem.uninstall
+ * metadata Subsystem.getHeaders
+ * Subsystem.getLocation
* </pre>
- *
+ *
* <p>
* The name of this permission is a filter expression. The filter gives access
* to the following attributes:
@@ -63,63 +62,61 @@ import org.osgi.framework.InvalidSyntaxE
* <li>name - The symbolic name of a subsystem.</li>
* </ul>
* Filter attribute names are processed in a case sensitive manner.
- *
+ *
* @ThreadSafe
- * @version $Id: 54ab1f9f1c80794d27dcf8c72e8720a4c582d229 $
+ * @version $Id: 6674ee12cbc60cedd5392edc39793df91aac4a1e $
*/
public final class SubsystemPermission extends BasicPermission {
- static final long serialVersionUID = 307051004521261705L;
+ static final long serialVersionUID = 307051004521261705L;
/**
* The action string {@code execute}.
*/
- public final static String EXECUTE = "execute";
+ public final static String EXECUTE = "execute";
/**
* The action string {@code lifecycle}.
*/
- public final static String LIFECYCLE = "lifecycle";
+ public final static String LIFECYCLE = "lifecycle";
/**
* The action string {@code metadata}.
*/
- public final static String METADATA = "metadata";
+ public final static String METADATA = "metadata";
/**
* The action string {@code context}.
*/
- public final static String CONTEXT = "context";
+ public final static String CONTEXT = "context";
- private final static int ACTION_EXECUTE = 0x00000002;
- private final static int ACTION_LIFECYCLE = 0x00000004;
- private final static int ACTION_METADATA = 0x00000010;
- private final static int ACTION_CONTEXT = 0x00000400;
- private final static int ACTION_ALL = ACTION_EXECUTE
- | ACTION_LIFECYCLE
- | ACTION_METADATA
- | ACTION_CONTEXT;
- final static int ACTION_NONE = 0;
+ private final static int ACTION_EXECUTE = 0x00000001;
+ private final static int ACTION_LIFECYCLE = 0x00000002;
+ private final static int ACTION_METADATA = 0x00000004;
+ private final static int ACTION_CONTEXT = 0x00000008;
+ private final static int ACTION_ALL = ACTION_EXECUTE | ACTION_LIFECYCLE | ACTION_METADATA | ACTION_CONTEXT;
+ final static int ACTION_NONE = 0;
/**
* The actions in canonical form.
- *
+ *
* @serial
*/
- private volatile String actions = null;
+ private volatile String actions = null;
/**
* The actions mask.
*/
- transient int action_mask;
+ transient int action_mask;
/**
* If this SubsystemPermission was constructed with a filter, this holds a
* Filter matching object used to evaluate the filter in implies.
*/
- transient Filter filter;
+ transient Filter filter;
/**
- * The subsystem governed by this SubsystemPermission - only used if filter == null
+ * The subsystem governed by this SubsystemPermission - only used if filter
+ * == null
*/
- transient final Subsystem subsystem;
+ transient final Subsystem subsystem;
/**
* This map holds the properties of the permission, used to match a filter
@@ -132,21 +129,21 @@ public final class SubsystemPermission e
* ThreadLocal used to determine if we have recursively called
* getProperties.
*/
- private static final ThreadLocal<Subsystem> recurse = new ThreadLocal<Subsystem>();
+ private static final ThreadLocal<Subsystem> recurse = new ThreadLocal<Subsystem>();
/**
* Create a new SubsystemPermission.
- *
+ *
* This constructor must only be used to create a permission that is going
* to be checked.
* <p>
* Examples:
- *
+ *
* <pre>
* (name=com.acme.*)(location=http://www.acme.com/subsystems/*))
* (id>=1)
* </pre>
- *
+ *
* @param filter A filter expression that can use, location, id, and name
* keys. Filter attribute names are processed in a case sensitive
* manner. A special value of {@code "*"} can be used to match all
@@ -160,11 +157,11 @@ public final class SubsystemPermission e
}
/**
- * Creates a new requested {@code SubsystemPermission} object to be used by the
- * code that must perform {@code checkPermission}. {@code SubsystemPermission}
- * objects created with this constructor cannot be added to an
- * {@code SubsystemPermission} permission collection.
- *
+ * Creates a new requested {@code SubsystemPermission} object to be used by
+ * the code that must perform {@code checkPermission}.
+ * {@code SubsystemPermission} objects created with this constructor cannot
+ * be added to an {@code SubsystemPermission} permission collection.
+ *
* @param subsystem A subsystem.
* @param actions {@code execute}, {@code lifecycle}, {@code metadata}, or
* {@code context}.
@@ -177,7 +174,7 @@ public final class SubsystemPermission e
/**
* Create a permission name from a Subsystem
- *
+ *
* @param subsystem Subsystem to use to create permission name.
* @return permission name.
*/
@@ -193,7 +190,7 @@ public final class SubsystemPermission e
/**
* Package private constructor used by SubsystemPermissionCollection.
- *
+ *
* @param filter name filter or {@code null} for wildcard.
* @param mask action mask
*/
@@ -205,7 +202,7 @@ public final class SubsystemPermission e
/**
* Called by constructors and when deserialized.
- *
+ *
* @param filter Permission's filter or {@code null} for wildcard.
* @param mask action mask
*/
@@ -219,7 +216,7 @@ public final class SubsystemPermission e
/**
* Parse action string into action mask.
- *
+ *
* @param actions Action string.
* @return action mask.
*/
@@ -242,74 +239,63 @@ public final class SubsystemPermission e
char c;
// skip whitespace
- while ((i != -1)
- && ((c = a[i]) == ' ' || c == '\r' || c == '\n'
- || c == '\f' || c == '\t'))
+ while ((i != -1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t'))
i--;
// check for the known strings
int matchlen;
- if (i >= 6 && (a[i - 6] == 'e' || a[i - 6] == 'E')
- && (a[i - 5] == 'x' || a[i - 5] == 'X')
- && (a[i - 4] == 'e' || a[i - 4] == 'E')
- && (a[i - 3] == 'c' || a[i - 3] == 'C')
- && (a[i - 2] == 'u' || a[i - 2] == 'U')
- && (a[i - 1] == 't' || a[i - 1] == 'T')
+ if (i >= 6 && (a[i - 6] == 'e' || a[i - 6] == 'E')
+ && (a[i - 5] == 'x' || a[i - 5] == 'X')
+ && (a[i - 4] == 'e' || a[i - 4] == 'E')
+ && (a[i - 3] == 'c' || a[i - 3] == 'C')
+ && (a[i - 2] == 'u' || a[i - 2] == 'U')
+ && (a[i - 1] == 't' || a[i - 1] == 'T')
+ && (a[i] == 'e' || a[i] == 'E')) {
+ matchlen = 7;
+ mask |= ACTION_EXECUTE;
+ } else
+ if (i >= 8 && (a[i - 8] == 'l' || a[i - 8] == 'L')
+ && (a[i - 7] == 'i' || a[i - 7] == 'I')
+ && (a[i - 6] == 'f' || a[i - 6] == 'F')
+ && (a[i - 5] == 'e' || a[i - 5] == 'E')
+ && (a[i - 4] == 'c' || a[i - 4] == 'C')
+ && (a[i - 3] == 'y' || a[i - 3] == 'Y')
+ && (a[i - 2] == 'c' || a[i - 2] == 'C')
+ && (a[i - 1] == 'l' || a[i - 1] == 'L')
&& (a[i] == 'e' || a[i] == 'E')) {
- matchlen = 7;
- mask |= ACTION_EXECUTE;
-
- }
- else
- if (i >= 8 && (a[i - 8] == 'l' || a[i - 8] == 'L')
- && (a[i - 7] == 'i' || a[i - 7] == 'I')
- && (a[i - 6] == 'f' || a[i - 6] == 'F')
- && (a[i - 5] == 'e' || a[i - 5] == 'E')
- && (a[i - 4] == 'c' || a[i - 4] == 'C')
- && (a[i - 3] == 'y' || a[i - 3] == 'Y')
- && (a[i - 2] == 'c' || a[i - 2] == 'C')
- && (a[i - 1] == 'l' || a[i - 1] == 'L')
- && (a[i] == 'e' || a[i] == 'E')) {
- matchlen = 9;
- mask |= ACTION_LIFECYCLE;
-
- }
- else
- if (i >= 7
- && (a[i - 7] == 'm' || a[i - 7] == 'M')
- && (a[i - 6] == 'e' || a[i - 6] == 'E')
- && (a[i - 5] == 't' || a[i - 5] == 'T')
- && (a[i - 4] == 'a' || a[i - 4] == 'A')
- && (a[i - 3] == 'd' || a[i - 3] == 'D')
- && (a[i - 2] == 'a' || a[i - 2] == 'A')
- && (a[i - 1] == 't' || a[i - 1] == 'T')
- && (a[i] == 'a' || a[i] == 'A')) {
- matchlen = 8;
- mask |= ACTION_METADATA;
-
- }
- else
- if (i >= 6
- && (a[i - 6] == 'c' || a[i - 6] == 'C')
- && (a[i - 5] == 'o' || a[i - 5] == 'O')
- && (a[i - 4] == 'n' || a[i - 4] == 'N')
- && (a[i - 3] == 't' || a[i - 3] == 'T')
- && (a[i - 2] == 'e' || a[i - 2] == 'E')
- && (a[i - 1] == 'x' || a[i - 1] == 'X')
- && (a[i] == 't' || a[i] == 'T')) {
- matchlen = 7;
- mask |= ACTION_CONTEXT;
-
- }
- else {
+ matchlen = 9;
+ mask |= ACTION_LIFECYCLE;
+ } else
+ if (i >= 7
+ && (a[i - 7] == 'm' || a[i - 7] == 'M')
+ && (a[i - 6] == 'e' || a[i - 6] == 'E')
+ && (a[i - 5] == 't' || a[i - 5] == 'T')
+ && (a[i - 4] == 'a' || a[i - 4] == 'A')
+ && (a[i - 3] == 'd' || a[i - 3] == 'D')
+ && (a[i - 2] == 'a' || a[i - 2] == 'A')
+ && (a[i - 1] == 't' || a[i - 1] == 'T')
+ && (a[i] == 'a' || a[i] == 'A')) {
+ matchlen = 8;
+ mask |= ACTION_METADATA;
+ } else
+ if (i >= 6
+ && (a[i - 6] == 'c' || a[i - 6] == 'C')
+ && (a[i - 5] == 'o' || a[i - 5] == 'O')
+ && (a[i - 4] == 'n' || a[i - 4] == 'N')
+ && (a[i - 3] == 't' || a[i - 3] == 'T')
+ && (a[i - 2] == 'e' || a[i - 2] == 'E')
+ && (a[i - 1] == 'x' || a[i - 1] == 'X')
+ && (a[i] == 't' || a[i] == 'T')) {
+ matchlen = 7;
+ mask |= ACTION_CONTEXT;
+ } else {
// parse error
- throw new IllegalArgumentException(
- "invalid permission: " + actions);
+ throw new IllegalArgumentException("invalid permission: " + actions);
}
// make sure we didn't just match the tail of a word
- // like "ackbarfstartlevel". Also, skip to the comma.
+ // like "ackbarfexecute". Also, skip to the comma.
seencomma = false;
while (i >= matchlen && !seencomma) {
switch (a[i - matchlen]) {
@@ -323,8 +309,7 @@ public final class SubsystemPermission e
case '\t' :
break;
default :
- throw new IllegalArgumentException(
- "invalid permission: " + actions);
+ throw new IllegalArgumentException("invalid permission: " + actions);
}
i--;
}
@@ -334,8 +319,7 @@ public final class SubsystemPermission e
}
if (seencomma) {
- throw new IllegalArgumentException("invalid permission: " +
- actions);
+ throw new IllegalArgumentException("invalid permission: " + actions);
}
return mask;
@@ -357,10 +341,8 @@ public final class SubsystemPermission e
try {
return FrameworkUtil.createFilter(filterString);
- }
- catch (InvalidSyntaxException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "invalid filter");
+ } catch (InvalidSyntaxException e) {
+ IllegalArgumentException iae = new IllegalArgumentException("invalid filter");
iae.initCause(e);
throw iae;
}
@@ -370,7 +352,7 @@ public final class SubsystemPermission e
* Determines if the specified permission is implied by this object. This
* method throws an exception if the specified permission was not
* constructed with a subsystem.
- *
+ *
* <p>
* This method returns {@code true} if the specified permission is a
* SubsystemPermission AND
@@ -383,10 +365,10 @@ public final class SubsystemPermission e
* actions.
* <p>
* Special case: if the specified permission was constructed with "*"
- * filter, then this method returns {@code true} if this object's
- * filter is "*" and this object's actions include all of the specified
- * permission's actions
- *
+ * filter, then this method returns {@code true} if this object's filter is
+ * "*" and this object's actions include all of the specified permission's
+ * actions
+ *
* @param p The requested permission.
* @return {@code true} if the specified permission is implied by this
* object; {@code false} otherwise.
@@ -409,10 +391,10 @@ public final class SubsystemPermission e
/**
* Internal implies method. Used by the implies and the permission
* collection implies methods.
- *
+ *
* @param requested The requested SubsystemPermision which has already been
- * validated as a proper argument. The requested SubsystemPermission must
- * not have a filter expression.
+ * validated as a proper argument. The requested SubsystemPermission
+ * must not have a filter expression.
* @param effective The effective actions with which to start.
* @return {@code true} if the specified permission is implied by this
* object; {@code false} otherwise.
@@ -435,14 +417,13 @@ public final class SubsystemPermission e
if (requested.subsystem == null) {
return false;
}
- Map<String, Object> requestedProperties = requested
- .getProperties();
+ Map<String, Object> requestedProperties = requested.getProperties();
if (requestedProperties == null) {
/*
* If the requested properties are null, then we have detected a
* recursion getting the subsystem location. So we return true to
- * permit the subsystem location request in the SubsystemPermission check
- * up the stack to succeed.
+ * permit the subsystem location request in the SubsystemPermission
+ * check up the stack to succeed.
*/
return true;
}
@@ -452,14 +433,14 @@ public final class SubsystemPermission e
/**
* Returns the canonical string representation of the
* {@code SubsystemPermission} actions.
- *
+ *
* <p>
- * Always returns present {@code SubsystemPermission} actions in the following
- * order: {@code execute}, {@code lifecycle}, {@code metadata},
+ * Always returns present {@code SubsystemPermission} actions in the
+ * following order: {@code execute}, {@code lifecycle}, {@code metadata},
* {@code context}.
- *
- * @return Canonical string representation of the {@code SubsystemPermission}
- * actions.
+ *
+ * @return Canonical string representation of the
+ * {@code SubsystemPermission} actions.
*/
public String getActions() {
String result = actions;
@@ -478,7 +459,6 @@ public final class SubsystemPermission e
sb.append(',');
}
-
if ((mask & ACTION_METADATA) == ACTION_METADATA) {
sb.append(METADATA);
sb.append(',');
@@ -500,9 +480,9 @@ public final class SubsystemPermission e
}
/**
- * Returns a new {@code PermissionCollection} object suitable for
- * storing {@code SubsystemPermission}s.
- *
+ * Returns a new {@code PermissionCollection} object suitable for storing
+ * {@code SubsystemPermission}s.
+ *
* @return A new {@code PermissionCollection} object.
*/
public PermissionCollection newPermissionCollection() {
@@ -511,7 +491,7 @@ public final class SubsystemPermission e
/**
* Determines the equality of two {@code SubsystemPermission} objects.
- *
+ *
* @param obj The object being compared for equality with this object.
* @return {@code true} if {@code obj} is equivalent to this
* {@code SubsystemPermission}; {@code false} otherwise.
@@ -527,16 +507,13 @@ public final class SubsystemPermission e
SubsystemPermission sp = (SubsystemPermission) obj;
- return (action_mask == sp.action_mask)
- && ((subsystem == sp.subsystem) || ((subsystem != null) && subsystem
- .equals(sp.subsystem)))
- && (filter == null ? sp.filter == null : filter
- .equals(sp.filter));
+ return (action_mask == sp.action_mask) && ((subsystem == sp.subsystem) || ((subsystem != null) && subsystem.equals(sp.subsystem)))
+ && (filter == null ? sp.filter == null : filter.equals(sp.filter));
}
/**
* Returns the hash code value for this object.
- *
+ *
* @return Hash code value for this object.
*/
public int hashCode() {
@@ -553,8 +530,7 @@ public final class SubsystemPermission e
* stream. The actions are serialized, and the superclass takes care of the
* name.
*/
- private synchronized void writeObject(java.io.ObjectOutputStream s)
- throws IOException {
+ private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException {
if (subsystem != null) {
throw new NotSerializableException("cannot serialize");
}
@@ -569,22 +545,21 @@ public final class SubsystemPermission e
* readObject is called to restore the state of this permission from a
* stream.
*/
- private synchronized void readObject(java.io.ObjectInputStream s)
- throws IOException, ClassNotFoundException {
+ private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
// Read in the data, then initialize the transients
s.defaultReadObject();
setTransients(parseFilter(getName()), parseActions(actions));
}
/**
- * Called by {@code implies0} on an SubsystemPermission which was constructed
- * with a Subsystem. This method loads a map with the filter-matchable
- * properties of this subsystem. The map is cached so this lookup only happens
- * once.
- *
+ * Called by {@code implies0} on an SubsystemPermission which was
+ * constructed with a Subsystem. This method loads a map with the
+ * filter-matchable properties of this subsystem. The map is cached so this
+ * lookup only happens once.
+ *
* This method should only be called on an SubsystemPermission which was
* constructed with a subsystem
- *
+ *
* @return a map of properties for this subsystem
*/
private Map<String, Object> getProperties() {
@@ -593,9 +568,9 @@ public final class SubsystemPermission e
return result;
}
/*
- * We may have recursed here due to the Subsystem.getLocation call in the
- * doPrivileged below. If this is the case, return null to allow implies
- * to return true.
+ * We may have recursed here due to the Subsystem.getLocation call in
+ * the doPrivileged below. If this is the case, return null to allow
+ * implies to return true.
*/
final Object mark = recurse.get();
if (mark == subsystem) {
@@ -613,8 +588,7 @@ public final class SubsystemPermission e
}
});
return properties = map;
- }
- finally {
+ } finally {
recurse.set(null);
}
}
@@ -624,25 +598,25 @@ public final class SubsystemPermission e
* Stores a collection of {@code SubsystemPermission}s.
*/
final class SubsystemPermissionCollection extends PermissionCollection {
- private static final long serialVersionUID = 3906372644575328048L;
+ private static final long serialVersionUID = 3906372644575328048L;
/**
* Collection of permissions.
- *
+ *
* @GuardedBy this
*/
private transient Map<String, SubsystemPermission> permissions;
/**
* Boolean saying if "*" is in the collection.
- *
+ *
* @serial
* @GuardedBy this
*/
- private boolean all_allowed;
+ private boolean all_allowed;
/**
* Create an empty SubsystemPermissionCollection object.
- *
+ *
*/
public SubsystemPermissionCollection() {
permissions = new HashMap<String, SubsystemPermission>();
@@ -650,7 +624,7 @@ final class SubsystemPermissionCollectio
/**
* Adds a permission to this permission collection.
- *
+ *
* @param permission The {@code SubsystemPermission} object to add.
* @throws IllegalArgumentException If the specified permission is not an
* {@code SubsystemPermission} instance or was constructed with a
@@ -660,17 +634,14 @@ final class SubsystemPermissionCollectio
*/
public void add(Permission permission) {
if (!(permission instanceof SubsystemPermission)) {
- throw new IllegalArgumentException("invalid permission: "
- + permission);
+ throw new IllegalArgumentException("invalid permission: " + permission);
}
if (isReadOnly()) {
- throw new SecurityException("attempt to add a Permission to a "
- + "readonly PermissionCollection");
+ throw new SecurityException("attempt to add a Permission to a " + "readonly PermissionCollection");
}
final SubsystemPermission sp = (SubsystemPermission) permission;
if (sp.subsystem != null) {
- throw new IllegalArgumentException("cannot add to collection: "
- + sp);
+ throw new IllegalArgumentException("cannot add to collection: " + sp);
}
final String name = sp.getName();
synchronized (this) {
@@ -681,11 +652,9 @@ final class SubsystemPermissionCollectio
int newMask = sp.action_mask;
if (oldMask != newMask) {
- pc.put(name, new SubsystemPermission(existing.filter, oldMask
- | newMask));
+ pc.put(name, new SubsystemPermission(existing.filter, oldMask | newMask));
}
- }
- else {
+ } else {
pc.put(name, sp);
}
if (!all_allowed) {
@@ -699,12 +668,12 @@ final class SubsystemPermissionCollectio
/**
* Determines if the specified permissions implies the permissions expressed
* in {@code permission}.
- *
+ *
* @param permission The Permission object to compare with the
* {@code SubsystemPermission} objects in this collection.
* @return {@code true} if {@code permission} is implied by an
- * {@code SubsystemPermission} in this collection,
- * {@code false} otherwise.
+ * {@code SubsystemPermission} in this collection, {@code false}
+ * otherwise.
*/
public boolean implies(Permission permission) {
if (!(permission instanceof SubsystemPermission)) {
@@ -746,7 +715,7 @@ final class SubsystemPermissionCollectio
/**
* Returns an enumeration of all {@code SubsystemPermission} objects in the
* container.
- *
+ *
* @return Enumeration of all {@code SubsystemPermission} objects.
*/
public synchronized Enumeration<Permission> elements() {
@@ -755,24 +724,18 @@ final class SubsystemPermissionCollectio
}
/* serialization logic */
- private static final ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("permissions", HashMap.class),
- new ObjectStreamField("all_allowed", Boolean.TYPE) };
+ private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("permissions", HashMap.class), new ObjectStreamField("all_allowed", Boolean.TYPE)};
- private synchronized void writeObject(ObjectOutputStream out)
- throws IOException {
+ private synchronized void writeObject(ObjectOutputStream out) throws IOException {
ObjectOutputStream.PutField pfields = out.putFields();
pfields.put("permissions", permissions);
pfields.put("all_allowed", all_allowed);
out.writeFields();
}
- private synchronized void readObject(java.io.ObjectInputStream in)
- throws IOException,
- ClassNotFoundException {
+ private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField gfields = in.readFields();
- HashMap<String, SubsystemPermission> p = (HashMap<String, SubsystemPermission>) gfields
- .get("permissions", null);
+ HashMap<String, SubsystemPermission> p = (HashMap<String, SubsystemPermission>) gfields.get("permissions", null);
permissions = p;
all_allowed = gfields.get("all_allowed", false);
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/package-info.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/package-info.java?rev=1328415&r1=1328414&r2=1328415&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/package-info.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/package-info.java Fri Apr 20 15:41:40 2012
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2010, 2012). 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.
@@ -15,7 +15,7 @@
*/
/**
- * Subsystem Package Version 1.0.
+ * Subsystem Service Package Version 1.0.
*
* <p>
* Bundles wishing to use this package must list the package in the
@@ -32,7 +32,8 @@
* <p>
* {@code Import-Package: org.osgi.service.subsystem; version="[1.0,1.1)"}
*
- * @version $Id: c92a6ccec8a36b4507b349e8d539a327fd2515d3 $
+ * @version $Id: 3d0a1cfa6351c5c269c23358cfe3cc21403ba453 $
*/
package org.osgi.service.subsystem;
+