You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/08/25 22:30:34 UTC
svn commit: r807795 [3/5] - in /felix/sandbox/rickhall/resolver: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/felix/ src/main/java/org/apache/felix/resolver/
src/main/java/org/apache/felix/resol...
Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Constants.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Constants.java?rev=807795&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Constants.java (added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Constants.java Tue Aug 25 20:30:33 2009
@@ -0,0 +1,1312 @@
+/*
+ * Copyright (c) OSGi Alliance (2000, 2009). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.apache.felix.resolver.manifestparser;
+
+/**
+ * Defines standard names for the OSGi environment system properties, service
+ * properties, and Manifest header attribute keys.
+ *
+ * <p>
+ * The values associated with these keys are of type
+ * <code>String</code>, unless otherwise indicated.
+ *
+ * @since 1.1
+ * @version $Revision: 6552 $
+ */
+
+public interface Constants {
+ /**
+ * Location identifier of the OSGi <i>system bundle </i>, which is defined
+ * to be "System Bundle".
+ */
+ public static final String SYSTEM_BUNDLE_LOCATION = "System Bundle";
+
+ /**
+ * Alias for the symbolic name of the OSGi <i>system bundle </i>. It is
+ * defined to be "system.bundle".
+ *
+ * @since 1.3
+ */
+ public static final String SYSTEM_BUNDLE_SYMBOLICNAME = "system.bundle";
+
+ /**
+ * Manifest header identifying the bundle's category.
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_CATEGORY = "Bundle-Category";
+
+ /**
+ * Manifest header identifying a list of directories and embedded JAR files,
+ * which are bundle resources used to extend the bundle's classpath.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_CLASSPATH = "Bundle-ClassPath";
+
+ /**
+ * Manifest header identifying the bundle's copyright information.
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_COPYRIGHT = "Bundle-Copyright";
+
+ /**
+ * Manifest header containing a brief description of the bundle's
+ * functionality.
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_DESCRIPTION = "Bundle-Description";
+
+ /**
+ * Manifest header identifying the bundle's name.
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_NAME = "Bundle-Name";
+
+ /**
+ * Manifest header identifying a number of hardware environments and the
+ * native language code libraries that the bundle is carrying for each of
+ * these environments.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_NATIVECODE = "Bundle-NativeCode";
+
+ /**
+ * Manifest header identifying the packages that the bundle offers to the
+ * Framework for export.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String EXPORT_PACKAGE = "Export-Package";
+
+ /**
+ * Manifest header identifying the fully qualified class names of the
+ * services that the bundle may register (used for informational purposes
+ * only).
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @deprecated As of 1.2.
+ */
+ public static final String EXPORT_SERVICE = "Export-Service";
+
+ /**
+ * Manifest header identifying the packages on which the bundle depends.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String IMPORT_PACKAGE = "Import-Package";
+
+ /**
+ * Manifest header identifying the packages that the bundle may dynamically
+ * import during execution.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.2
+ */
+ public static final String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
+
+ /**
+ * Manifest header identifying the fully qualified class names of the
+ * services that the bundle requires (used for informational purposes only).
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @deprecated As of 1.2.
+ */
+ public static final String IMPORT_SERVICE = "Import-Service";
+
+ /**
+ * Manifest header identifying the bundle's vendor.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_VENDOR = "Bundle-Vendor";
+
+ /**
+ * Manifest header identifying the bundle's version.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_VERSION = "Bundle-Version";
+
+ /**
+ * Manifest header identifying the bundle's documentation URL, from which
+ * further information about the bundle may be obtained.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_DOCURL = "Bundle-DocURL";
+
+ /**
+ * Manifest header identifying the contact address where problems with the
+ * bundle may be reported; for example, an email address.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
+
+ /**
+ * Manifest header attribute identifying the bundle's activator class.
+ *
+ * <p>
+ * If present, this header specifies the name of the bundle resource class
+ * that implements the <code>BundleActivator</code> interface and whose
+ * <code>start</code> and <code>stop</code> methods are called by the
+ * Framework when the bundle is started and stopped, respectively.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_ACTIVATOR = "Bundle-Activator";
+
+ /**
+ * Manifest header identifying the location from which a new bundle version
+ * is obtained during a bundle update operation.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ */
+ public static final String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
+
+ /**
+ * Manifest header attribute identifying the version of a package specified
+ * in the Export-Package or Import-Package manifest header.
+ *
+ * @deprecated As of 1.3. This has been replaced by
+ * {@link #VERSION_ATTRIBUTE}.
+ */
+ public static final String PACKAGE_SPECIFICATION_VERSION = "specification-version";
+
+ /**
+ * Manifest header attribute identifying the processor required to run
+ * native bundle code specified in the Bundle-NativeCode manifest header).
+ *
+ * <p>
+ * The attribute value is encoded in the Bundle-NativeCode manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-NativeCode: http.so ; processor=x86 ...
+ * </pre>
+ *
+ * @see #BUNDLE_NATIVECODE
+ */
+ public static final String BUNDLE_NATIVECODE_PROCESSOR = "processor";
+
+ /**
+ * Manifest header attribute identifying the operating system required to
+ * run native bundle code specified in the Bundle-NativeCode manifest
+ * header).
+ * <p>
+ * The attribute value is encoded in the Bundle-NativeCode manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-NativeCode: http.so ; osname=Linux ...
+ * </pre>
+ *
+ * @see #BUNDLE_NATIVECODE
+ */
+ public static final String BUNDLE_NATIVECODE_OSNAME = "osname";
+
+ /**
+ * Manifest header attribute identifying the operating system version
+ * required to run native bundle code specified in the Bundle-NativeCode
+ * manifest header).
+ * <p>
+ * The attribute value is encoded in the Bundle-NativeCode manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-NativeCode: http.so ; osversion="2.34" ...
+ * </pre>
+ *
+ * @see #BUNDLE_NATIVECODE
+ */
+ public static final String BUNDLE_NATIVECODE_OSVERSION = "osversion";
+
+ /**
+ * Manifest header attribute identifying the language in which the native
+ * bundle code is written specified in the Bundle-NativeCode manifest
+ * header. See ISO 639 for possible values.
+ * <p>
+ * The attribute value is encoded in the Bundle-NativeCode manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-NativeCode: http.so ; language=nl_be ...
+ * </pre>
+ *
+ * @see #BUNDLE_NATIVECODE
+ */
+ public static final String BUNDLE_NATIVECODE_LANGUAGE = "language";
+
+ /**
+ * Manifest header identifying the required execution environment for the
+ * bundle. The service platform may run this bundle if any of the execution
+ * environments named in this header matches one of the execution
+ * environments it implements.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.2
+ */
+ public static final String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
+
+ /**
+ * Manifest header identifying the bundle's symbolic name.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.3
+ */
+ public final static String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
+
+ /**
+ * Manifest header directive identifying whether a bundle is a singleton.
+ * The default value is <code>false</code>.
+ *
+ * <p>
+ * The directive value is encoded in the Bundle-SymbolicName manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-SymbolicName: com.acme.module.test; singleton:=true
+ * </pre>
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @see #BUNDLE_SYMBOLICNAME
+ * @since 1.3
+ */
+ public final static String SINGLETON_DIRECTIVE = "singleton";
+
+ /**
+ * Manifest header directive identifying if and when a fragment may attach
+ * to a host bundle. The default value is
+ * {@link #FRAGMENT_ATTACHMENT_ALWAYS always}.
+ *
+ * <p>
+ * The directive value is encoded in the Bundle-SymbolicName manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-SymbolicName: com.acme.module.test; fragment-attachment:="never"
+ * </pre>
+ *
+ * @see #BUNDLE_SYMBOLICNAME
+ * @see #FRAGMENT_ATTACHMENT_ALWAYS
+ * @see #FRAGMENT_ATTACHMENT_RESOLVETIME
+ * @see #FRAGMENT_ATTACHMENT_NEVER
+ * @since 1.3
+ */
+ public final static String FRAGMENT_ATTACHMENT_DIRECTIVE = "fragment-attachment";
+
+ /**
+ * Manifest header directive value identifying a fragment attachment type of
+ * always. A fragment attachment type of always indicates that fragments are
+ * allowed to attach to the host bundle at any time (while the host is
+ * resolved or during the process of resolving the host bundle).
+ *
+ * <p>
+ * The directive value is encoded in the Bundle-SymbolicName manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-SymbolicName: com.acme.module.test; fragment-attachment:="always"
+ * </pre>
+ *
+ * @see #FRAGMENT_ATTACHMENT_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String FRAGMENT_ATTACHMENT_ALWAYS = "always";
+
+ /**
+ * Manifest header directive value identifying a fragment attachment type of
+ * resolve-time. A fragment attachment type of resolve-time indicates that
+ * fragments are allowed to attach to the host bundle only during the
+ * process of resolving the host bundle.
+ *
+ * <p>
+ * The directive value is encoded in the Bundle-SymbolicName manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-SymbolicName: com.acme.module.test; fragment-attachment:="resolve-time"
+ * </pre>
+ *
+ * @see #FRAGMENT_ATTACHMENT_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String FRAGMENT_ATTACHMENT_RESOLVETIME = "resolve-time";
+
+ /**
+ * Manifest header directive value identifying a fragment attachment type of
+ * never. A fragment attachment type of never indicates that no fragments
+ * are allowed to attach to the host bundle at any time.
+ *
+ * <p>
+ * The directive value is encoded in the Bundle-SymbolicName manifest header
+ * like:
+ *
+ * <pre>
+ * Bundle-SymbolicName: com.acme.module.test; fragment-attachment:="never"
+ * </pre>
+ *
+ * @see #FRAGMENT_ATTACHMENT_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String FRAGMENT_ATTACHMENT_NEVER = "never";
+
+ /**
+ * Manifest header identifying the base name of the bundle's localization
+ * entries.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @see #BUNDLE_LOCALIZATION_DEFAULT_BASENAME
+ * @since 1.3
+ */
+ public final static String BUNDLE_LOCALIZATION = "Bundle-Localization";
+
+ /**
+ * Default value for the <code>Bundle-Localization</code> manifest header.
+ *
+ * @see #BUNDLE_LOCALIZATION
+ * @since 1.3
+ */
+ public final static String BUNDLE_LOCALIZATION_DEFAULT_BASENAME = "OSGI-INF/l10n/bundle";
+
+ /**
+ * Manifest header identifying the symbolic names of other bundles required
+ * by the bundle.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.3
+ */
+ public final static String REQUIRE_BUNDLE = "Require-Bundle";
+
+ /**
+ * Manifest header attribute identifying a range of versions for a bundle
+ * specified in the <code>Require-Bundle</code> or
+ * <code>Fragment-Host</code> manifest headers. The default value is
+ * <code>0.0.0</code>.
+ *
+ * <p>
+ * The attribute value is encoded in the Require-Bundle manifest header
+ * like:
+ *
+ * <pre>
+ * Require-Bundle: com.acme.module.test; bundle-version="1.1"
+ * Require-Bundle: com.acme.module.test; bundle-version="[1.0,2.0)"
+ * </pre>
+ *
+ * <p>
+ * The bundle-version attribute value uses a mathematical interval notation
+ * to specify a range of bundle versions. A bundle-version attribute value
+ * specified as a single version means a version range that includes any
+ * bundle version greater than or equal to the specified version.
+ *
+ * @see #REQUIRE_BUNDLE
+ * @since 1.3
+ */
+ public static final String BUNDLE_VERSION_ATTRIBUTE = "bundle-version";
+
+ /**
+ * Manifest header identifying the symbolic name of another bundle for which
+ * that the bundle is a fragment.
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.3
+ */
+ public final static String FRAGMENT_HOST = "Fragment-Host";
+
+ /**
+ * Manifest header attribute is used for selection by filtering based upon
+ * system properties.
+ *
+ * <p>
+ * The attribute value is encoded in manifest headers like:
+ *
+ * <pre>
+ * Bundle-NativeCode: libgtk.so; selection-filter="(ws=gtk)"; ...
+ * </pre>
+ *
+ * @see #BUNDLE_NATIVECODE
+ * @since 1.3
+ */
+ public final static String SELECTION_FILTER_ATTRIBUTE = "selection-filter";
+
+ /**
+ * Manifest header identifying the bundle manifest version. A bundle
+ * manifest may express the version of the syntax in which it is written by
+ * specifying a bundle manifest version. Bundles exploiting OSGi Release 4,
+ * or later, syntax must specify a bundle manifest version.
+ * <p>
+ * The bundle manifest version defined by OSGi Release 4 or, more
+ * specifically, by version 1.3 of the OSGi Core Specification is "2".
+ *
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.3
+ */
+ public final static String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion";
+
+ /**
+ * Manifest header attribute identifying the version of a package specified
+ * in the Export-Package or Import-Package manifest header.
+ *
+ * <p>
+ * The attribute value is encoded in the Export-Package or Import-Package
+ * manifest header like:
+ *
+ * <pre>
+ * Import-Package: org.osgi.framework; version="1.1"
+ * </pre>
+ *
+ * @see #EXPORT_PACKAGE
+ * @see #IMPORT_PACKAGE
+ * @since 1.3
+ */
+ public final static String VERSION_ATTRIBUTE = "version";
+
+ /**
+ * Manifest header attribute identifying the symbolic name of a bundle that
+ * exports a package specified in the Import-Package manifest header.
+ *
+ * <p>
+ * The attribute value is encoded in the Import-Package manifest header
+ * like:
+ *
+ * <pre>
+ * Import-Package: org.osgi.framework; bundle-symbolic-name="com.acme.module.test"
+ * </pre>
+ *
+ * @see #IMPORT_PACKAGE
+ * @since 1.3
+ */
+ public final static String BUNDLE_SYMBOLICNAME_ATTRIBUTE = "bundle-symbolic-name";
+
+ /**
+ * Manifest header directive identifying the resolution type in the
+ * Import-Package or Require-Bundle manifest header. The default value is
+ * {@link #RESOLUTION_MANDATORY mandatory}.
+ *
+ * <p>
+ * The directive value is encoded in the Import-Package or Require-Bundle
+ * manifest header like:
+ *
+ * <pre>
+ * Import-Package: org.osgi.framework; resolution:="optional"
+ * Require-Bundle: com.acme.module.test; resolution:="optional"
+ * </pre>
+ *
+ * @see #IMPORT_PACKAGE
+ * @see #REQUIRE_BUNDLE
+ * @see #RESOLUTION_MANDATORY
+ * @see #RESOLUTION_OPTIONAL
+ * @since 1.3
+ */
+ public final static String RESOLUTION_DIRECTIVE = "resolution";
+
+ /**
+ * Manifest header directive value identifying a mandatory resolution type.
+ * A mandatory resolution type indicates that the import package or require
+ * bundle must be resolved when the bundle is resolved. If such an import or
+ * require bundle cannot be resolved, the module fails to resolve.
+ *
+ * <p>
+ * The directive value is encoded in the Import-Package or Require-Bundle
+ * manifest header like:
+ *
+ * <pre>
+ * Import-Package: org.osgi.framework; resolution:="manditory"
+ * Require-Bundle: com.acme.module.test; resolution:="manditory"
+ * </pre>
+ *
+ * @see #RESOLUTION_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String RESOLUTION_MANDATORY = "mandatory";
+
+ /**
+ * Manifest header directive value identifying an optional resolution type.
+ * An optional resolution type indicates that the import or require bundle
+ * is optional and the bundle may be resolved without the import or require
+ * bundle being resolved. If the import or require bundle is not resolved
+ * when the bundle is resolved, the import or require bundle may not be
+ * resolved before the bundle is refreshed.
+ *
+ * <p>
+ * The directive value is encoded in the Import-Package or Require-Bundle
+ * manifest header like:
+ *
+ * <pre>
+ * Import-Package: org.osgi.framework; resolution:="optional"
+ * Require-Bundle: com.acme.module.test; resolution:="optional"
+ * </pre>
+ *
+ * @see #RESOLUTION_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String RESOLUTION_OPTIONAL = "optional";
+
+ /**
+ * Manifest header directive identifying a list of packages that an exported
+ * package uses.
+ *
+ * <p>
+ * The directive value is encoded in the Export-Package manifest header
+ * like:
+ *
+ * <pre>
+ * Export-Package: org.osgi.util.tracker; uses:="org.osgi.framework"
+ * </pre>
+ *
+ * @see #EXPORT_PACKAGE
+ * @since 1.3
+ */
+ public final static String USES_DIRECTIVE = "uses";
+
+ /**
+ * Manifest header directive identifying a list of classes to include in the
+ * exported package.
+ *
+ * <p>
+ * This directive is used by the Export-Package manifest header to identify
+ * a list of classes of the specified package which must be allowed to be
+ * exported. The directive value is encoded in the Export-Package manifest
+ * header like:
+ *
+ * <pre>
+ * Export-Package: org.osgi.framework; include:="MyClass*"
+ * </pre>
+ *
+ * <p>
+ * This directive is also used by the Bundle-ActivationPolicy manifest
+ * header to identify the packages from which class loads will trigger lazy
+ * activation. The directive value is encoded in the Bundle-ActivationPolicy
+ * manifest header like:
+ *
+ * <pre>
+ * Bundle-ActivationPolicy: lazy; include:="org.osgi.framework"
+ * </pre>
+ *
+ * @see #EXPORT_PACKAGE
+ * @see #BUNDLE_ACTIVATIONPOLICY
+ * @since 1.3
+ */
+ public final static String INCLUDE_DIRECTIVE = "include";
+
+ /**
+ * Manifest header directive identifying a list of classes to exclude in the
+ * exported package..
+ * <p>
+ * This directive is used by the Export-Package manifest header to identify
+ * a list of classes of the specified package which must not be allowed to
+ * be exported. The directive value is encoded in the Export-Package
+ * manifest header like:
+ *
+ * <pre>
+ * Export-Package: org.osgi.framework; exclude:="*Impl"
+ * </pre>
+ *
+ * <p>
+ * This directive is also used by the Bundle-ActivationPolicy manifest
+ * header to identify the packages from which class loads will not trigger
+ * lazy activation. The directive value is encoded in the
+ * Bundle-ActivationPolicy manifest header like:
+ *
+ * <pre>
+ * Bundle-ActivationPolicy: lazy; exclude:="org.osgi.framework"
+ * </pre>
+ *
+ * @see #EXPORT_PACKAGE
+ * @see #BUNDLE_ACTIVATIONPOLICY
+ * @since 1.3
+ */
+ public final static String EXCLUDE_DIRECTIVE = "exclude";
+
+ /**
+ * Manifest header directive identifying names of matching attributes which
+ * must be specified by matching Import-Package statements in the
+ * Export-Package manifest header.
+ *
+ * <p>
+ * The directive value is encoded in the Export-Package manifest header
+ * like:
+ *
+ * <pre>
+ * Export-Package: org.osgi.framework; mandatory:="bundle-symbolic-name"
+ * </pre>
+ *
+ * @see #EXPORT_PACKAGE
+ * @since 1.3
+ */
+ public final static String MANDATORY_DIRECTIVE = "mandatory";
+
+ /**
+ * Manifest header directive identifying the visibility of a required bundle
+ * in the Require-Bundle manifest header. The default value is
+ * {@link #VISIBILITY_PRIVATE private}.
+ *
+ * <p>
+ * The directive value is encoded in the Require-Bundle manifest header
+ * like:
+ *
+ * <pre>
+ * Require-Bundle: com.acme.module.test; visibility:="reexport"
+ * </pre>
+ *
+ * @see #REQUIRE_BUNDLE
+ * @see #VISIBILITY_PRIVATE
+ * @see #VISIBILITY_REEXPORT
+ * @since 1.3
+ */
+ public final static String VISIBILITY_DIRECTIVE = "visibility";
+
+ /**
+ * Manifest header directive value identifying a private visibility type. A
+ * private visibility type indicates that any packages that are exported by
+ * the required bundle are not made visible on the export signature of the
+ * requiring bundle.
+ *
+ * <p>
+ * The directive value is encoded in the Require-Bundle manifest header
+ * like:
+ *
+ * <pre>
+ * Require-Bundle: com.acme.module.test; visibility:="private"
+ * </pre>
+ *
+ * @see #VISIBILITY_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String VISIBILITY_PRIVATE = "private";
+
+ /**
+ * Manifest header directive value identifying a reexport visibility type. A
+ * reexport visibility type indicates any packages that are exported by the
+ * required bundle are re-exported by the requiring bundle. Any arbitrary
+ * arbitrary matching attributes with which they were exported by the
+ * required bundle are deleted.
+ *
+ * <p>
+ * The directive value is encoded in the Require-Bundle manifest header
+ * like:
+ *
+ * <pre>
+ * Require-Bundle: com.acme.module.test; visibility:="reexport"
+ * </pre>
+ *
+ * @see #VISIBILITY_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String VISIBILITY_REEXPORT = "reexport";
+
+ /**
+ * Manifest header directive identifying the type of the extension fragment.
+ *
+ * <p>
+ * The directive value is encoded in the Fragment-Host manifest header like:
+ *
+ * <pre>
+ * Fragment-Host: system.bundle; extension:="framework"
+ * </pre>
+ *
+ * @see #FRAGMENT_HOST
+ * @see #EXTENSION_FRAMEWORK
+ * @see #EXTENSION_BOOTCLASSPATH
+ * @since 1.3
+ */
+ public final static String EXTENSION_DIRECTIVE = "extension";
+
+ /**
+ * Manifest header directive value identifying the type of extension
+ * fragment. An extension fragment type of framework indicates that the
+ * extension fragment is to be loaded by the framework's class loader.
+ *
+ * <p>
+ * The directive value is encoded in the Fragment-Host manifest header like:
+ *
+ * <pre>
+ * Fragment-Host: system.bundle; extension:="framework"
+ * </pre>
+ *
+ * @see #EXTENSION_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String EXTENSION_FRAMEWORK = "framework";
+
+ /**
+ * Manifest header directive value identifying the type of extension
+ * fragment. An extension fragment type of bootclasspath indicates that the
+ * extension fragment is to be loaded by the boot class loader.
+ *
+ * <p>
+ * The directive value is encoded in the Fragment-Host manifest header like:
+ *
+ * <pre>
+ * Fragment-Host: system.bundle; extension:="bootclasspath"
+ * </pre>
+ *
+ * @see #EXTENSION_DIRECTIVE
+ * @since 1.3
+ */
+ public final static String EXTENSION_BOOTCLASSPATH = "bootclasspath";
+
+ /**
+ * Manifest header identifying the bundle's activation policy.
+ * <p>
+ * The attribute value may be retrieved from the <code>Dictionary</code>
+ * object returned by the <code>Bundle.getHeaders</code> method.
+ *
+ * @since 1.4
+ * @see #ACTIVATION_LAZY
+ * @see #INCLUDE_DIRECTIVE
+ * @see #EXCLUDE_DIRECTIVE
+ */
+ public final static String BUNDLE_ACTIVATIONPOLICY = "Bundle-ActivationPolicy";
+
+ /**
+ * Bundle activation policy declaring the bundle must be activated when the
+ * first class load is made from the bundle.
+ * <p>
+ * A bundle with the lazy activation policy that is started with the
+ * {@link Bundle#START_ACTIVATION_POLICY START_ACTIVATION_POLICY} option
+ * will wait in the {@link Bundle#STARTING STARTING} state until the first
+ * class load from the bundle occurs. The bundle will then be activated
+ * before the class is returned to the requester.
+ * <p>
+ * The activation policy value is specified as in the
+ * Bundle-ActivationPolicy manifest header like:
+ *
+ * <pre>
+ * Bundle-ActivationPolicy: lazy
+ * </pre>
+ *
+ * @see #BUNDLE_ACTIVATIONPOLICY
+ * @see Bundle#start(int)
+ * @see Bundle#START_ACTIVATION_POLICY
+ * @since 1.4
+ */
+ public final static String ACTIVATION_LAZY = "lazy";
+
+ /**
+ * Framework environment property identifying the Framework version.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_VERSION = "org.osgi.framework.version";
+
+ /**
+ * Framework environment property identifying the Framework implementation
+ * vendor.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_VENDOR = "org.osgi.framework.vendor";
+
+ /**
+ * Framework environment property identifying the Framework implementation
+ * language (see ISO 639 for possible values).
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_LANGUAGE = "org.osgi.framework.language";
+
+ /**
+ * Framework environment property identifying the Framework host-computer's
+ * operating system.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_OS_NAME = "org.osgi.framework.os.name";
+
+ /**
+ * Framework environment property identifying the Framework host-computer's
+ * operating system version number.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_OS_VERSION = "org.osgi.framework.os.version";
+
+ /**
+ * Framework environment property identifying the Framework host-computer's
+ * processor name.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ */
+ public static final String FRAMEWORK_PROCESSOR = "org.osgi.framework.processor";
+
+ /**
+ * Framework environment property identifying execution environments
+ * provided by the Framework.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.2
+ */
+ public static final String FRAMEWORK_EXECUTIONENVIRONMENT = "org.osgi.framework.executionenvironment";
+
+ /**
+ * Framework environment property identifying packages for which the
+ * Framework must delegate class loading to the parent class loader of the
+ * bundle.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @see #FRAMEWORK_BUNDLE_PARENT
+ * @since 1.3
+ */
+ public static final String FRAMEWORK_BOOTDELEGATION = "org.osgi.framework.bootdelegation";
+
+ /**
+ * Framework environment property identifying packages which the system
+ * bundle must export.
+ *
+ * <p>
+ * If this property is not specified then the framework must calculate a
+ * reasonable default value for the current execution environment.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.3
+ */
+ public static final String FRAMEWORK_SYSTEMPACKAGES = "org.osgi.framework.system.packages";
+
+ /**
+ * Framework environment property identifying extra packages which the
+ * system bundle must export from the current execution environment.
+ *
+ * <p>
+ * This property is useful for configuring extra system packages in addition
+ * to the system packages calculated by the framework.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @see #FRAMEWORK_SYSTEMPACKAGES
+ * @since 1.5
+ */
+ public static final String FRAMEWORK_SYSTEMPACKAGES_EXTRA = "org.osgi.framework.system.packages.extra";
+
+ /**
+ * Framework environment property identifying whether the Framework supports
+ * framework extension bundles.
+ *
+ * <p>
+ * As of version 1.4, the value of this property must be <code>true</code>.
+ * The Framework must support framework extension bundles.
+ *
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.3
+ */
+ public static final String SUPPORTS_FRAMEWORK_EXTENSION = "org.osgi.supports.framework.extension";
+
+ /**
+ * Framework environment property identifying whether the Framework supports
+ * bootclasspath extension bundles.
+ *
+ * <p>
+ * If the value of this property is <code>true</code>, then the Framework
+ * supports bootclasspath extension bundles. The default value is
+ * <code>false</code>.
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.3
+ */
+ public static final String SUPPORTS_BOOTCLASSPATH_EXTENSION = "org.osgi.supports.bootclasspath.extension";
+
+ /**
+ * Framework environment property identifying whether the Framework supports
+ * fragment bundles.
+ *
+ * <p>
+ * As of version 1.4, the value of this property must be <code>true</code>.
+ * The Framework must support fragment bundles.
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.3
+ */
+ public static final String SUPPORTS_FRAMEWORK_FRAGMENT = "org.osgi.supports.framework.fragment";
+
+ /**
+ * Framework environment property identifying whether the Framework supports
+ * the {@link #REQUIRE_BUNDLE Require-Bundle} manifest header.
+ *
+ * <p>
+ * As of version 1.4, the value of this property must be <code>true</code>.
+ * The Framework must support the <code>Require-Bundle</code> manifest
+ * header.
+ * <p>
+ * The value of this property may be retrieved by calling the
+ * <code>BundleContext.getProperty</code> method.
+ *
+ * @since 1.3
+ */
+ public static final String SUPPORTS_FRAMEWORK_REQUIREBUNDLE = "org.osgi.supports.framework.requirebundle";
+
+ /**
+ * Specifies the type of security manager the framework must use. If not
+ * specified then the framework will not set the VM security manager.
+ *
+ * @see #FRAMEWORK_SECURITY_OSGI
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_SECURITY = "org.osgi.framework.security";
+
+ /**
+ * Specifies that a security manager that supports all security aspects of
+ * the OSGi core specification including postponed conditions must be
+ * installed.
+ *
+ * <p>
+ * If this value is specified and there is a security manager already
+ * installed, then a <code>SecurityException</code> must be thrown when the
+ * Framework is initialized.
+ *
+ * @see #FRAMEWORK_SECURITY
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_SECURITY_OSGI = "osgi";
+
+ /**
+ * Specified the persistent storage area used by the framework. The value of
+ * this property must be a valid file path in the file system to a
+ * directory. If the specified directory does not exist then the framework
+ * will create the directory. If the specified path exists but is not a
+ * directory or if the framework fails to create the storage directory, then
+ * framework initialization must fail. The framework is free to use this
+ * directory as it sees fit. This area can not be shared with anything else.
+ * <p>
+ * If this property is not set, the framework should use a reasonable
+ * platform default for the persistent storage area.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_STORAGE = "org.osgi.framework.storage";
+
+ /**
+ * Specifies if and when the persistent storage area for the framework
+ * should be cleaned. If this property is not set, then the framework
+ * storage area must not be cleaned.
+ *
+ * @see #FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_STORAGE_CLEAN = "org.osgi.framework.storage.clean";
+
+ /**
+ * Specifies that the framework storage area must be cleaned before the
+ * framework is initialized for the first time. Subsequent inits, starts or
+ * updates of the framework will not result in cleaning the framework
+ * storage area.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
+
+ /**
+ * Specifies a comma separated list of additional library file extensions
+ * that must be used when a bundle's class loader is searching for native
+ * libraries. If this property is not set, then only the library name
+ * returned by <code>System.mapLibraryName(String)</code> will be used to
+ * search. This is needed for certain operating systems which allow more
+ * than one extension for a library. For example, AIX allows library
+ * extensions of <code>.a</code> and <code>.so</code>, but
+ * <code>System.mapLibraryName(String)</code> will only return names with
+ * the <code>.a</code> extension.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_LIBRARY_EXTENSIONS = "org.osgi.framework.library.extensions";
+
+ /**
+ * Specifies an optional OS specific command to set file permissions on
+ * extracted native code. On some operating systems, it is required that
+ * native libraries be set to executable. This optional property allows you
+ * to specify the command. For example, on a UNIX style OS, this property
+ * could have the following value.
+ *
+ * <pre>
+ * chmod +rx ${abspath}
+ * </pre>
+ *
+ * The <code>${abspath}</code> is used by the framework to substitute the
+ * actual absolute file path.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_EXECPERMISSION = "org.osgi.framework.command.execpermission";
+
+ /**
+ * Specifies the trust repositories used by the framework. The value is a
+ * <code>java.io.File.pathSeparator</code> separated list of valid file
+ * paths to files that contain key stores of type <code>JKS</code>. The
+ * framework will use the key stores as trust repositories to authenticate
+ * certificates of trusted signers. The key stores are only used as
+ * read-only trust repositories to access public keys. No passwords are
+ * required to access the key stores' public keys.
+ * <p>
+ * Note that framework implementations are allowed to use other trust
+ * repositories in addition to the trust repositories specified by this
+ * property. How these other trust repositories are configured and populated
+ * is implementation specific.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_TRUST_REPOSITORIES = "org.osgi.framework.trust.repositories";
+
+ /**
+ * Specifies the current windowing system. The framework should provide a
+ * reasonable default if this is not set.
+ *
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_WINDOWSYSTEM = "org.osgi.framework.windowsystem";
+
+ /**
+ * Specifies the beginning start level of the framework.
+ *
+ * @see "Core Specification, section 8.2.3."
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_BEGINNING_STARTLEVEL = "org.osgi.framework.startlevel.beginning";
+
+ /**
+ * Specifies the parent class loader type for all bundle class loaders.
+ * Default value is {@link #FRAMEWORK_BUNDLE_PARENT_BOOT boot}.
+ *
+ * @see #FRAMEWORK_BUNDLE_PARENT_BOOT
+ * @see #FRAMEWORK_BUNDLE_PARENT_EXT
+ * @see #FRAMEWORK_BUNDLE_PARENT_APP
+ * @see #FRAMEWORK_BUNDLE_PARENT_FRAMEWORK
+ * @since 1.5
+ */
+ public final static String FRAMEWORK_BUNDLE_PARENT = "org.osgi.framework.bundle.parent";
+
+ /**
+ * Specifies to use of the boot class loader as the parent class loader for
+ * all bundle class loaders.
+ *
+ * @since 1.5
+ * @see #FRAMEWORK_BUNDLE_PARENT
+ */
+ public final static String FRAMEWORK_BUNDLE_PARENT_BOOT = "boot";
+
+ /**
+ * Specifies to use the extension class loader as the parent class loader
+ * for all bundle class loaders.
+ *
+ * @since 1.5
+ * @see #FRAMEWORK_BUNDLE_PARENT
+ */
+ public final static String FRAMEWORK_BUNDLE_PARENT_EXT = "ext";
+
+ /**
+ * Specifies to use the application class loader as the parent class loader
+ * for all bundle class loaders. Depending on how the framework is
+ * launched, this may refer to the same class loader as
+ * {@link #FRAMEWORK_BUNDLE_PARENT_FRAMEWORK}.
+ *
+ * @since 1.5
+ * @see #FRAMEWORK_BUNDLE_PARENT
+ */
+ public final static String FRAMEWORK_BUNDLE_PARENT_APP = "app";
+
+ /**
+ * Specifies to use the framework class loader as the parent class loader
+ * for all bundle class loaders. The framework class loader is the class
+ * loader used to load the framework implementation. Depending on how the
+ * framework is launched, this may refer to the same class loader as
+ * {@link #FRAMEWORK_BUNDLE_PARENT_APP}.
+ *
+ * @since 1.5
+ * @see #FRAMEWORK_BUNDLE_PARENT
+ */
+ public final static String FRAMEWORK_BUNDLE_PARENT_FRAMEWORK = "framework";
+
+ /*
+ * Service properties.
+ */
+
+ /**
+ * Service property identifying all of the class names under which a service
+ * was registered in the Framework. The value of this property must be of
+ * type <code>String[]</code>.
+ *
+ * <p>
+ * This property is set by the Framework when a service is registered.
+ */
+ public static final String OBJECTCLASS = "objectClass";
+
+ /**
+ * Service property identifying a service's registration number. The value
+ * of this property must be of type <code>Long</code>.
+ *
+ * <p>
+ * The value of this property is assigned by the Framework when a service is
+ * registered. The Framework assigns a unique value that is larger than all
+ * previously assigned values since the Framework was started. These values
+ * are NOT persistent across restarts of the Framework.
+ */
+ public static final String SERVICE_ID = "service.id";
+
+ /**
+ * Service property identifying a service's persistent identifier.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties</code>
+ * <code>Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>String</code>, <code>String[]</code>, or
+ * <code>Collection</code> of <code>String</code>.
+ *
+ * <p>
+ * A service's persistent identifier uniquely identifies the service and
+ * persists across multiple Framework invocations.
+ *
+ * <p>
+ * By convention, every bundle has its own unique namespace, starting with
+ * the bundle's identifier (see {@link Bundle#getBundleId}) and followed by
+ * a dot (.). A bundle may use this as the prefix of the persistent
+ * identifiers for the services it registers.
+ */
+ public static final String SERVICE_PID = "service.pid";
+
+ /**
+ * Service property identifying a service's ranking number.
+ *
+ * <p>
+ * This property may be supplied in the <code>properties
+ * Dictionary</code> object passed to the
+ * <code>BundleContext.registerService</code> method. The value of this
+ * property must be of type <code>Integer</code>.
+ *
+ * <p>
+ * The service ranking is used by the Framework to determine the <i>natural
+ * order</i> of services, see {@link ServiceReference#compareTo(Object)},
+ * and the <i>default</i> service to be returned from a call to the
+ * {@link BundleContext#getServiceReference} method.
+ *
+ * <p>
+ * The default ranking is zero (0). A service with a ranking of
+ * <code>Integer.MAX_VALUE</code> is very likely to be returned as the
+ * default service, whereas a service with a ranking of
+ * <code>Integer.MIN_VALUE</code> is very unlikely to be returned.
+ *
+ * <p>
+ * If the supplied property value is not of type <code>Integer</code>, it is
+ * deemed to have a ranking value of zero.
+ */
+ public static final String SERVICE_RANKING = "service.ranking";
+
+ /**
+ * Service property identifying a service's vendor.
+ *
+ * <p>
+ * This property may be supplied in the properties <code>Dictionary</code>
+ * object passed to the <code>BundleContext.registerService</code> method.
+ */
+ public static final String SERVICE_VENDOR = "service.vendor";
+
+ /**
+ * Service property identifying a service's description.
+ *
+ * <p>
+ * This property may be supplied in the properties <code>Dictionary</code>
+ * object passed to the <code>BundleContext.registerService</code> method.
+ */
+ public static final String SERVICE_DESCRIPTION = "service.description";
+}
Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java?rev=807795&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java (added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java Tue Aug 25 20:30:33 2009
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.felix.resolver.manifestparser;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.jar.JarFile;
+import org.apache.felix.resolver.ExportedPackage;
+import org.apache.felix.resolver.ImportedPackage;
+import org.apache.felix.resolver.Module;
+import org.apache.felix.resolver.Resolver;
+import org.apache.felix.resolver.Wire;
+import org.apache.felix.resolver.prototype.ProtoResolver;
+import org.apache.felix.resolver.felix.FelixResolver;
+
+public class Main
+{
+ public static void main(String[] args) throws IOException, Exception
+ {
+ if ((args.length < 1) || (args.length > 2))
+ {
+ System.err.println("usage: [-legacy] <bundle-dir>");
+ System.exit(0);
+ }
+
+ String choice = "";
+ String dir = args[0];
+ if (args.length == 2)
+ {
+ choice = args[0];
+ dir = args[1];
+ }
+
+ // Look in the specified bundle directory to create a list
+ // of all JAR files to install.
+ File[] files = new File(dir).listFiles();
+ List<File> jarList = new ArrayList();
+ if (files != null)
+ {
+ Arrays.sort(files);
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].getName().endsWith(".jar"))
+ {
+ jarList.add(files[i]);
+ }
+ }
+ }
+
+ List<Module> moduleList = new ArrayList<Module>();
+
+ moduleList.add(new Module("system.bundle")
+ .exporting(new ExportedPackage("javax.activation").with("version=1.1.0"))
+ .exporting(new ExportedPackage("javax.crypto"))
+ .exporting(new ExportedPackage("javax.crypto.spec"))
+ .exporting(new ExportedPackage("javax.imageio"))
+ .exporting(new ExportedPackage("javax.imageio.stream"))
+ .exporting(new ExportedPackage("javax.jws").with("version=2.0.0"))
+ .exporting(new ExportedPackage("javax.jws.soap"))
+ .exporting(new ExportedPackage("javax.management"))
+ .exporting(new ExportedPackage("javax.management.loading"))
+ .exporting(new ExportedPackage("javax.management.modelmbean"))
+ .exporting(new ExportedPackage("javax.management.openmbean"))
+ .exporting(new ExportedPackage("javax.management.remote"))
+ .exporting(new ExportedPackage("javax.naming"))
+ .exporting(new ExportedPackage("javax.naming.directory"))
+ .exporting(new ExportedPackage("javax.naming.ldap"))
+ .exporting(new ExportedPackage("javax.naming.spi"))
+ .exporting(new ExportedPackage("javax.net"))
+ .exporting(new ExportedPackage("javax.net.ssl"))
+ .exporting(new ExportedPackage("javax.rmi"))
+ .exporting(new ExportedPackage("javax.rmi.CORBA"))
+ .exporting(new ExportedPackage("javax.security.auth"))
+ .exporting(new ExportedPackage("javax.security.auth.callback"))
+ .exporting(new ExportedPackage("javax.security.auth.kerberos"))
+ .exporting(new ExportedPackage("javax.security.auth.login"))
+ .exporting(new ExportedPackage("javax.security.auth.spi"))
+ .exporting(new ExportedPackage("javax.security.auth.x500"))
+ .exporting(new ExportedPackage("javax.security.cert"))
+ .exporting(new ExportedPackage("javax.security.sasl"))
+ .exporting(new ExportedPackage("javax.sql"))
+ .exporting(new ExportedPackage("javax.swing"))
+ .exporting(new ExportedPackage("javax.swing.border"))
+ .exporting(new ExportedPackage("javax.swing.tree"))
+ .exporting(new ExportedPackage("javax.xml"))
+ .exporting(new ExportedPackage("javax.xml.bind").with("version=2.2.0"))
+ .exporting(new ExportedPackage("javax.xml.bind.annotation"))
+ .exporting(new ExportedPackage("javax.xml.bind.annotation.adapters"))
+ .exporting(new ExportedPackage("javax.xml.bind.attachment"))
+ .exporting(new ExportedPackage("javax.xml.bind.helpers"))
+ .exporting(new ExportedPackage("javax.xml.bind.util"))
+ .exporting(new ExportedPackage("javax.xml.datatype"))
+ .exporting(new ExportedPackage("javax.xml.namespace"))
+ .exporting(new ExportedPackage("javax.xml.parsers"))
+ .exporting(new ExportedPackage("javax.xml.registry"))
+ .exporting(new ExportedPackage("javax.xml.registry.infomodel"))
+ .exporting(new ExportedPackage("javax.xml.rpc").with("version=1.1.0"))
+ .exporting(new ExportedPackage("javax.xml.rpc.encoding"))
+ .exporting(new ExportedPackage("javax.xml.rpc.handler.soap").with("version=1.1.0"))
+ .exporting(new ExportedPackage("javax.xml.rpc.holders"))
+ .exporting(new ExportedPackage("javax.xml.rpc.server").with("version=1.1.0"))
+ .exporting(new ExportedPackage("javax.xml.rpc.soap").with("version=1.1.0"))
+ .exporting(new ExportedPackage("javax.xml.soap").with("version=1.3.0"))
+ .exporting(new ExportedPackage("javax.xml.stream").with("version=1.0.0"))
+ .exporting(new ExportedPackage("javax.xml.stream.events"))
+ .exporting(new ExportedPackage("javax.xml.stream.util").with("version=1.0.0"))
+ .exporting(new ExportedPackage("javax.xml.transform"))
+ .exporting(new ExportedPackage("javax.xml.transform.dom"))
+ .exporting(new ExportedPackage("javax.xml.transform.sax"))
+ .exporting(new ExportedPackage("javax.xml.transform.stream"))
+ .exporting(new ExportedPackage("javax.xml.validation"))
+ .exporting(new ExportedPackage("javax.xml.ws").with("version=2.1.0"))
+ .exporting(new ExportedPackage("javax.xml.ws.handler").with("version=2.1.0"))
+ .exporting(new ExportedPackage("javax.xml.ws.handler.soap").with("version=2.1.0"))
+ .exporting(new ExportedPackage("javax.xml.ws.http"))
+ .exporting(new ExportedPackage("javax.xml.ws.soap").with("version=2.1.0"))
+ .exporting(new ExportedPackage("javax.xml.ws.spi").with("version=2.1.0"))
+ .exporting(new ExportedPackage("javax.xml.ws.spi.http"))
+ .exporting(new ExportedPackage("javax.xml.ws.wsaddressing"))
+ .exporting(new ExportedPackage("javax.xml.xpath"))
+ .exporting(new ExportedPackage("org.ietf.jgss"))
+ .exporting(new ExportedPackage("org.omg.CORBA_2_3"))
+ .exporting(new ExportedPackage("org.omg.CORBA_2_3.portable"))
+ .exporting(new ExportedPackage("org.omg.CORBA.DynAnyPackage"))
+ .exporting(new ExportedPackage("org.omg.CORBA.ORBPackage"))
+ .exporting(new ExportedPackage("org.omg.CORBA.portable"))
+ .exporting(new ExportedPackage("org.omg.CORBA.TypeCodePackage"))
+ .exporting(new ExportedPackage("org.omg.CosNaming"))
+ .exporting(new ExportedPackage("org.omg.IOP"))
+ .exporting(new ExportedPackage("org.omg.PortableInterceptor"))
+ .exporting(new ExportedPackage("org.omg.PortableServer"))
+ .exporting(new ExportedPackage("org.osgi.framework").with("version=1.3.0"))
+ .exporting(new ExportedPackage("org.osgi.service.packageadmin").with("version=1.2.0"))
+ .exporting(new ExportedPackage("org.osgi.util.tracker"))
+ .exporting(new ExportedPackage("org.w3c.dom"))
+ .exporting(new ExportedPackage("org.w3c.dom.ls"))
+ .exporting(new ExportedPackage("org.xml.sax"))
+ .exporting(new ExportedPackage("org.xml.sax.ext"))
+ .exporting(new ExportedPackage("org.xml.sax.helpers"))
+// Optional
+ .exporting(new ExportedPackage("com.sun.enterprise.security.jauth.callback"))
+ .exporting(new ExportedPackage("com.sun.enterprise.web.connector.grizzly.algorithms"))
+ .exporting(new ExportedPackage("com.sun.enterprise.web.connector.grizzly.ssl"))
+ .exporting(new ExportedPackage("com.sun.enterprise.web.portunif"))
+ .exporting(new ExportedPackage("com.sun.enterprise.web.portunif.util"))
+ .exporting(new ExportedPackage("com.sun.enterprise.webservice.monitoring"))
+ .exporting(new ExportedPackage("com.sun.msv.datatype"))
+ .exporting(new ExportedPackage("com.sun.msv.datatype.xsd"))
+ .exporting(new ExportedPackage("com.sun.msv.grammar"))
+ .exporting(new ExportedPackage("com.sun.msv.grammar.trex"))
+ .exporting(new ExportedPackage("com.sun.msv.reader"))
+ .exporting(new ExportedPackage("com.sun.msv.reader.trex.ng"))
+ .exporting(new ExportedPackage("com.sun.msv.reader.util"))
+ .exporting(new ExportedPackage("com.sun.msv.util"))
+ .exporting(new ExportedPackage("com.sun.msv.verifier"))
+ .exporting(new ExportedPackage("com.sun.msv.verifier.regexp"))
+ .exporting(new ExportedPackage("com.sun.xml.bind.serializer"))
+ .exporting(new ExportedPackage("com.sun.xml.bind.validator"))
+ .exporting(new ExportedPackage("com.sun.xml.ws.spi.runtime"))
+ .exporting(new ExportedPackage("org.apache.coyote"))
+ .exporting(new ExportedPackage("org.apache.log4j"))
+ .exporting(new ExportedPackage("org.apache.tomcat.util.buf"))
+ .exporting(new ExportedPackage("org.iso_relax.verifier.impl"))
+ );
+
+ Module maxImporter = null;
+
+ for (int jarIdx = 0; jarIdx < jarList.size(); jarIdx++)
+ {
+ JarFile jarFile = new JarFile(jarList.get(jarIdx));
+ try
+ {
+ Map headerMap = new StringMap(jarFile.getManifest().getMainAttributes(), false);
+ if (headerMap.containsKey("Bundle-SymbolicName"))
+ {
+ ManifestParser mp = new ManifestParser(headerMap);
+ Module module = createModule(mp);
+ if (module != null)
+ {
+ moduleList.add(module);
+ if ((maxImporter == null)
+ || (maxImporter.getImports().size() < module.getImports().size()))
+ {
+ maxImporter = module;
+ }
+ }
+ }
+ }
+ finally
+ {
+ jarFile.close();
+ }
+ }
+
+ System.out.println("Generated " + moduleList.size() + " modules.");
+ System.out.println("Max importer: " + maxImporter + " (" + maxImporter.getImports().size() + ")");
+
+ Resolver resolver;
+ if (choice.equals("-legacy"))
+ {
+ resolver = new FelixResolver(moduleList);
+ }
+ else
+ {
+ resolver = new ProtoResolver(moduleList);
+ }
+
+ try
+ {
+ long starttime = System.currentTimeMillis();
+ Map<Module, List<Wire>> wireMap = resolver.resolve(maxImporter);
+// Map<Module, List<Wire>> wireMap = resolver.resolve(resolver.getModule("com.sun.enterprise.hk2-core"));
+// Map<Module, List<Wire>> wireMap = resolver.resolve(resolver.getModule("com.sun.pkg.client"));
+ long endtime = System.currentTimeMillis();
+ System.out.println("Resolve time: " + (endtime - starttime));
+ System.out.println("Modules resolved: " + wireMap.size());
+ System.out.println("Wires:");
+ for (Iterator<Entry<Module, List<Wire>>> it = wireMap.entrySet().iterator();
+ it.hasNext(); )
+ {
+ Entry<Module, List<Wire>> entry = it.next();
+ if (entry.getValue().size() > 0)
+ {
+// System.out.println(" " + entry.getKey());
+ for (int i = 0; i < entry.getValue().size(); i++)
+ {
+// System.out.println(" " + entry.getValue().get(i));
+ System.out.println(" " + entry.getKey() + " - " + entry.getValue().get(i));
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.out);
+ }
+ }
+
+ private static Module createModule(ManifestParser mp)
+ {
+ Module module = new Module(mp.getSymbolicName());
+ try
+ {
+ addCapabilities(module, mp.getCapabilities());
+ addRequirements(module, mp.getRequirements());
+ }
+ catch (RuntimeException ex)
+ {
+ System.out.println("Invalid module " + mp.getSymbolicName() + ": " + ex);
+ return null;
+ }
+ return module;
+ }
+
+ private static void addCapabilities(Module module, Capability[] caps)
+ {
+ for (int capIdx = 0; (caps != null) && (capIdx < caps.length); capIdx++)
+ {
+ if (caps[capIdx].getNamespace().equals(Capability.MODULE_NAMESPACE)
+ || caps[capIdx].getNamespace().equals(Capability.HOST_NAMESPACE))
+ {
+ continue;
+ }
+ else if (!caps[capIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+ {
+ throw new RuntimeException("Unsupported capability: " + caps[capIdx].getNamespace());
+ }
+
+ ExportedPackage ep = new ExportedPackage(caps[capIdx].getPackageName());
+
+ R4Directive[] dirs = caps[capIdx].getDirectives();
+ for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
+ {
+ if (dirs[dirIdx].getName().equals(Constants.INCLUDE_DIRECTIVE)
+ || dirs[dirIdx].getName().equals(Constants.MANDATORY_DIRECTIVE))
+ {
+ continue;
+ }
+ else if (!dirs[dirIdx].getName().equals(Constants.USES_DIRECTIVE))
+ {
+ throw new RuntimeException("Unsupported capability directive: " + dirs[dirIdx].getName());
+ }
+ ep.using(dirs[dirIdx].getValue());
+ }
+
+ R4Attribute[] attrs = caps[capIdx].getAttributes();
+ for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
+ {
+ if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
+ {
+ continue;
+ }
+ if (attrs[attrIdx].isMandatory())
+ {
+ ep.withMandatory(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+ }
+ else
+ {
+ ep.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+ }
+ }
+
+ module.exporting(ep);
+ }
+ }
+
+ private static void addRequirements(Module module, Requirement[] reqs)
+ {
+ for (int reqIdx = 0; (reqs != null) && (reqIdx < reqs.length); reqIdx++)
+ {
+ if (!reqs[reqIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+ {
+ // Generate invalid source for now.
+ throw new RuntimeException("Require-Bundle not supported.");
+ }
+ else if (!reqs[reqIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+ {
+ System.out.println("Unsupported requirement: " + reqs[reqIdx].getNamespace());
+ System.exit(0);
+ }
+
+ ImportedPackage ip = new ImportedPackage(reqs[reqIdx].getTargetName());
+
+ R4Directive[] dirs = reqs[reqIdx].getDirectives();
+ for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
+ {
+ if (!dirs[dirIdx].getName().equals(Constants.RESOLUTION_DIRECTIVE))
+ {
+ throw new RuntimeException("Unsupported requirement directive: " + dirs[dirIdx].getName());
+ }
+ if (dirs[dirIdx].getValue().equals(Constants.RESOLUTION_OPTIONAL))
+ {
+ ip.optional();
+ }
+ }
+
+ R4Attribute[] attrs = reqs[reqIdx].getAttributes();
+ for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
+ {
+ if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
+ {
+ continue;
+ }
+ else
+ {
+ ip.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+ }
+ }
+
+ module.importing(ip);
+ }
+ }
+}
\ No newline at end of file