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 2005/08/19 21:54:41 UTC
svn commit: r233548 [1/6] - in /incubator/felix/trunk: ./
src/org/apache/felix/ src/org/apache/felix/bundlerepository/
src/org/apache/felix/bundlerepository/impl/
src/org/apache/felix/bundlerepository/impl/kxmlsax/
src/org/apache/felix/bundlerepository...
Author: rickhall
Date: Fri Aug 19 12:53:58 2005
New Revision: 233548
URL: http://svn.apache.org/viewcvs?rev=233548&view=rev
Log:
Renamed packages to the new package structure and update source code to match.
Added:
incubator/felix/trunk/src/org/apache/felix/
incubator/felix/trunk/src/org/apache/felix/bundlerepository/
incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/ObrCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/R4Attribute.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/R4Directive.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/R4Package.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/R4Version.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/RepositoryState.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Util.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/kxmlsax/
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/kxmlsax/KXmlSAXHandler.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/kxmlsax/KXmlSAXParser.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/manifest.mf
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/metadataparser/
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/metadataparser/ClassUtility.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/metadataparser/KXmlMetadataHandler.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/metadataparser/MultivalueMap.java (with props)
incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/metadataparser/XmlCommonHandler.java (with props)
incubator/felix/trunk/src/org/apache/felix/framework/
- copied from r233470, incubator/felix/trunk/src/org/apache/osgi/framework/
incubator/felix/trunk/src/org/apache/felix/moduleloader/
- copied from r233470, incubator/felix/trunk/src/org/apache/osgi/moduleloader/
incubator/felix/trunk/src/org/apache/felix/shell/
incubator/felix/trunk/src/org/apache/felix/shell/CdCommand.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/Command.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/ShellService.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/
incubator/felix/trunk/src/org/apache/felix/shell/impl/Activator.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/BundleLevelCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/CdCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/HeadersCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/HelpCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/InstallCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/PackagesCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/PsCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/RefreshCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/ServicesCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/ShutdownCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/StartCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/StartLevelCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/StopCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/UninstallCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/UpdateCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/Util.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/VersionCommandImpl.java (with props)
incubator/felix/trunk/src/org/apache/felix/shell/impl/manifest.mf
incubator/felix/trunk/src/org/apache/felix/shelltui/
incubator/felix/trunk/src/org/apache/felix/shelltui/Activator.java (with props)
incubator/felix/trunk/src/org/apache/felix/shelltui/manifest.mf
Removed:
incubator/felix/trunk/src/org/apache/osgi/
Modified:
incubator/felix/trunk/build.xml
incubator/felix/trunk/src/org/apache/felix/framework/BundleContextImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/BundleImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/BundleInfo.java
incubator/felix/trunk/src/org/apache/felix/framework/BundleURLConnection.java
incubator/felix/trunk/src/org/apache/felix/framework/BundleURLStreamHandler.java
incubator/felix/trunk/src/org/apache/felix/framework/ExportedPackageImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/FakeURLStreamHandler.java
incubator/felix/trunk/src/org/apache/felix/framework/Felix.java
incubator/felix/trunk/src/org/apache/felix/framework/FilterImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/FrameworkUtil.java
incubator/felix/trunk/src/org/apache/felix/framework/LogWrapper.java
incubator/felix/trunk/src/org/apache/felix/framework/Main.java
incubator/felix/trunk/src/org/apache/felix/framework/OSGiLibrarySource.java
incubator/felix/trunk/src/org/apache/felix/framework/OSGiURLPolicy.java
incubator/felix/trunk/src/org/apache/felix/framework/PackageAdminActivator.java
incubator/felix/trunk/src/org/apache/felix/framework/PackageAdminImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/ServiceReferenceImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/ServiceRegistrationImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/ServiceRegistry.java
incubator/felix/trunk/src/org/apache/felix/framework/StartLevelActivator.java
incubator/felix/trunk/src/org/apache/felix/framework/StartLevelImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/SystemBundle.java
incubator/felix/trunk/src/org/apache/felix/framework/SystemBundleActivator.java
incubator/felix/trunk/src/org/apache/felix/framework/SystemBundleArchive.java
incubator/felix/trunk/src/org/apache/felix/framework/cache/BundleArchive.java
incubator/felix/trunk/src/org/apache/felix/framework/cache/BundleCache.java
incubator/felix/trunk/src/org/apache/felix/framework/cache/DefaultBundleArchive.java
incubator/felix/trunk/src/org/apache/felix/framework/cache/DefaultBundleCache.java
incubator/felix/trunk/src/org/apache/felix/framework/ext/FelixBundleContext.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/Artifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/BooleanProperty.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/Install.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/Property.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/PropertyPanel.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/Status.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/StringProperty.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/AbstractArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/AbstractFileArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/AbstractJarArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/ResourceFileArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/ResourceJarArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/URLFileArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/artifact/URLJarArtifact.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/editor/BooleanEditor.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/editor/BooleanStringEditor.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/editor/FileEditor.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/editor/StringEditor.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/property/BooleanPropertyImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/property/BooleanStringPropertyImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/property/NotBooleanPropertyImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/property/StringPropertyImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/installer/resource/ResourceLoader.java
incubator/felix/trunk/src/org/apache/felix/framework/manifest.mf
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4Attribute.java
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4Directive.java
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4Package.java
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4SearchPolicy.java
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4Version.java
incubator/felix/trunk/src/org/apache/felix/framework/searchpolicy/R4Wire.java
incubator/felix/trunk/src/org/apache/felix/framework/util/BundleListenerWrapper.java
incubator/felix/trunk/src/org/apache/felix/framework/util/CaseInsensitiveMap.java
incubator/felix/trunk/src/org/apache/felix/framework/util/DispatchQueue.java
incubator/felix/trunk/src/org/apache/felix/framework/util/Dispatcher.java
incubator/felix/trunk/src/org/apache/felix/framework/util/FelixConstants.java
incubator/felix/trunk/src/org/apache/felix/framework/util/FelixDispatchQueue.java
incubator/felix/trunk/src/org/apache/felix/framework/util/FrameworkListenerWrapper.java
incubator/felix/trunk/src/org/apache/felix/framework/util/IteratorToEnumeration.java
incubator/felix/trunk/src/org/apache/felix/framework/util/LibraryInfo.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ListenerWrapper.java
incubator/felix/trunk/src/org/apache/felix/framework/util/MapToDictionary.java
incubator/felix/trunk/src/org/apache/felix/framework/util/MutablePropertyResolver.java
incubator/felix/trunk/src/org/apache/felix/framework/util/MutablePropertyResolverImpl.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ObjectInputStreamX.java
incubator/felix/trunk/src/org/apache/felix/framework/util/PropertyResolver.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ServiceListenerWrapper.java
incubator/felix/trunk/src/org/apache/felix/framework/util/Util.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/AttributeNotFoundException.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Driver.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/EvaluationException.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Evaluator.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/LdapLexer.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Mapper.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Operator.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/ParseException.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Parser.java
incubator/felix/trunk/src/org/apache/felix/framework/util/ldap/Unknown.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/DefaultURLPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/JarResourceSource.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/LibrarySource.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/Module.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleClassLoader.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleEvent.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleListener.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleManager.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleURLConnection.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ModuleURLStreamHandler.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ResourceNotFoundException.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/ResourceSource.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/SearchPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/URLPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/Util.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/CompatibilityPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ExhaustiveSearchPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ImportSearchPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ResolveException.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ResolveListener.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/SelectionPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/SelfContainedSearchPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ValidationException.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/ValidationListener.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/compatibility/ExactCompatibilityPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/selection/InteractiveSelectionPolicy.java
incubator/felix/trunk/src/org/apache/felix/moduleloader/search/selection/SimpleSelectionPolicy.java
incubator/felix/trunk/src/org/osgi/framework/AdminPermission.java
incubator/felix/trunk/src/org/osgi/framework/FrameworkUtil.java
incubator/felix/trunk/src/org/ungoverned/osgi/service/shell/CdCommand.java
incubator/felix/trunk/src/org/ungoverned/osgi/service/shell/Command.java
incubator/felix/trunk/src/org/ungoverned/osgi/service/shell/ShellService.java
Modified: incubator/felix/trunk/build.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/build.xml?rev=233548&r1=233547&r2=233548&view=diff
==============================================================================
--- incubator/felix/trunk/build.xml (original)
+++ incubator/felix/trunk/build.xml Fri Aug 19 12:53:58 2005
@@ -50,7 +50,7 @@
<target name="moduleloader" depends="compile">
<jar jarfile="${lib.dir}/moduleloader.jar"
basedir="${output.dir}">
- <include name="org/apache/osgi/moduleloader/"/>
+ <include name="org/apache/felix/moduleloader/"/>
</jar>
</target>
@@ -65,42 +65,40 @@
<!-- Create Felix JAR file. -->
<target name="felix" depends="compile">
- <jar manifest="${src.dir}/org/apache/osgi/framework/manifest.mf"
+ <jar manifest="${src.dir}/org/apache/felix/framework/manifest.mf"
jarfile="${lib.dir}/felix.jar"
basedir="${output.dir}">
- <include name="org/apache/osgi/framework/"/>
- <exclude name="org/apache/osgi/framework/installer/"/>
+ <include name="org/apache/felix/framework/"/>
+ <exclude name="org/apache/felix/framework/installer/"/>
</jar>
</target>
- <!-- Create shell bundle JAR files. -->
+ <!-- Create impl bundle JAR files. -->
<target name="bundle" depends="compile">
<!-- Shell -->
- <jar manifest="${src.dir}/org/apache/osgi/bundle/shell/manifest.mf"
+ <jar manifest="${src.dir}/org/apache/felix/shell/impl/manifest.mf"
jarfile="${bundle.dir}/shell.jar"
basedir="${output.dir}">
- <include name="org/apache/osgi/service/shell/**"/>
+ <include name="org/apache/felix/shell/**"/>
<include name="org/ungoverned/osgi/service/shell/**"/>
- <include name="org/apache/osgi/bundle/shell/**"/>
</jar>
<!-- Shell TUI -->
- <jar manifest="${src.dir}/org/apache/osgi/bundle/shelltui/manifest.mf"
+ <jar manifest="${src.dir}/org/apache/felix/shelltui/manifest.mf"
jarfile="${bundle.dir}/shelltui.jar"
basedir="${output.dir}">
- <include name="org/apache/osgi/bundle/shelltui/**"/>
+ <include name="org/apache/felix/shelltui/**"/>
</jar>
<!-- OBR -->
<copy file="${lib.dir}/kxml.jar"
- todir="${output.dir}/org/apache/osgi/bundle/bundlerepository/"/>
+ todir="${output.dir}/org/apache/felix/bundlerepository/impl/"/>
- <jar manifest="${src.dir}/org/apache/osgi/bundle/bundlerepository/manifest.mf"
+ <jar manifest="${src.dir}/org/apache/felix/bundlerepository/impl/manifest.mf"
jarfile="${bundle.dir}/bundlerepository.jar"
basedir="${output.dir}">
- <include name="org/apache/osgi/bundle/bundlerepository/**"/>
- <include name="org/apache/osgi/service/bundlerepository/**"/>
+ <include name="org/apache/felix/bundlerepository/**"/>
</jar>
</target>
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+import java.io.PrintStream;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * A simple interface used to hold meta-data about bundles
+ * contained in a bundle repository.
+**/
+public class BundleRecord
+{
+ public static final String BUNDLE_NAME = "Bundle-Name";
+ public static final String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
+ public static final String BUNDLE_VERSION = "Bundle-Version";
+ public static final String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
+ public static final String BUNDLE_URL = "Bundle-URL";
+ public static final String BUNDLE_SOURCEURL = "Bundle-SourceURL";
+ public static final String BUNDLE_DOCURL = "Bundle-DocURL";
+ public static final String BUNDLE_LICENSEURL = "Bundle-LicenseURL";
+ public static final String BUNDLE_DESCRIPTION = "Bundle-Description";
+ public static final String BUNDLE_CATEGORY = "Bundle-Category";
+ public static final String BUNDLE_VENDOR = "Bundle-Vendor";
+ public static final String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
+ public static final String BUNDLE_COPYRIGHT = "Bundle-Copyright";
+ public static final String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
+ public static final String BUNDLE_NATIVECODE = "Bundle-NativeCode";
+ public static final String IMPORT_PACKAGE = "Import-Package";
+ public static final String EXPORT_PACKAGE = "Export-Package";
+ public static final String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
+ public static final String REQUIRE_SERVICE = "Require-Service";
+ public static final String PROVIDE_SERVICE = "Provide-Service";
+
+ private Map m_attrMap = null;
+ private Dictionary m_dict = null;
+
+ /**
+ * <p>
+ * Constructs a bundle record using the values of the supplied
+ * map as the meta-data values for the bundle. The supplied map
+ * is copied, but its values are not.
+ * </p>
+ * @param attrMap a map containing attribute-value pairs of meta-data
+ * for a bundle.
+ **/
+ public BundleRecord(Map attrMap)
+ {
+ // Create a case insensitive map.
+ m_attrMap = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2)
+ {
+ return o1.toString().compareToIgnoreCase(o2.toString());
+ }
+ });
+ m_attrMap.putAll(attrMap);
+ }
+
+ /**
+ * <p>
+ * Returns a dictionary object which can be used with
+ * <tt>org.osgi.framework.Filter</tt>, for example. The returned
+ * dictionary object is a minimum implementation, where only
+ * the <tt>get()</tt>, <tt>size()</tt>, and <tt>isEmpty()</tt>
+ * methods do anything useful.
+ * </p>
+ * @return a dictionary object for accessing the bundle record attributes.
+ **/
+ public synchronized Dictionary getDictionary()
+ {
+ if (m_dict == null)
+ {
+ m_dict = new Dictionary() {
+ public int size()
+ {
+ return m_attrMap.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return m_attrMap.isEmpty();
+ }
+
+ public Enumeration elements()
+ {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ public Enumeration keys()
+ {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ public Object get(Object key)
+ {
+ return m_attrMap.get(key);
+ }
+
+ public Object remove(Object key)
+ {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+
+ public Object put(Object key, Object value)
+ {
+ throw new UnsupportedOperationException("Not implemented.");
+ }
+ };
+ }
+
+ return m_dict;
+ }
+
+ /**
+ * <p>
+ * Returns an array containing all attribute names associated with
+ * the bundle record. The return array is a copy and can be freely
+ * modified.
+ * </p>
+ * @return an array containing the attribute names contained in the
+ * bundle record.
+ **/
+ public String[] getAttributes()
+ {
+ return (String[]) m_attrMap.keySet().toArray(new String[m_attrMap.size()]);
+ }
+
+ /**
+ * <p>
+ * Returns the value of the specified attribute. If the value is an array,
+ * then a copy is returned.
+ * </p>
+ * @param name the attribute name for which to retrieve its value.
+ * @return the value of the specified attribute or <tt>null</tt> if
+ * the specified attribute does not exist.
+ **/
+ public Object getAttribute(String name)
+ {
+ Object obj = m_attrMap.get(name);
+ // If the value is an array, then make a copy
+ // since arrays are mutable.
+ if ((obj != null) && obj.getClass().isArray())
+ {
+ Class clazz = obj.getClass().getComponentType();
+ int len = Array.getLength(obj);
+ Object copy = Array.newInstance(obj.getClass().getComponentType(), len);
+ System.arraycopy(obj, 0, copy, 0, len);
+ obj = copy;
+ }
+ return obj;
+ }
+
+ /**
+ * <p>
+ * Dumps the contents of the bundle record to the specified print stream.
+ * </p>
+ * @param out the print stream to use for printing.
+ **/
+ public void printAttributes(PrintStream out)
+ {
+ String[] attrs = getAttributes();
+ if (attrs != null)
+ {
+ Arrays.sort(attrs);
+ for (int i = 0; (attrs != null) && (i < attrs.length); i++)
+ {
+ Object obj = getAttribute(attrs[i]);
+ if (obj.getClass().isArray())
+ {
+ out.println(attrs[i] + ":");
+ for (int j = 0; j < Array.getLength(obj); j++)
+ {
+ out.println(" " + Array.get(obj, j));
+ }
+ }
+ else
+ {
+ out.println(attrs[i] + ": " + getAttribute(attrs[i]));
+ }
+ }
+ }
+ }
+
+ public String toString()
+ {
+ return (String) m_attrMap.get(BUNDLE_NAME);
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRecord.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+import java.io.PrintStream;
+
+/**
+ * This interface defines a simple bundle repository service.
+**/
+public interface BundleRepository
+{
+ /**
+ * Get URL list of repositories.
+ * @return a space separated list of URLs to use or <tt>null</tt>
+ * to refresh the cached list of bundles.
+ **/
+ public String[] getRepositoryURLs();
+
+ /**
+ * Set URL list of repositories.
+ * @param url a space separated list of URLs to use or <tt>null</tt>
+ * to refresh the cached list of bundles.
+ **/
+ public void setRepositoryURLs(String[] urls);
+
+ /**
+ * Returns an array of the bundle symbolic names available
+ * in the repository.
+ * @return An arry of available bundle symbolic names.
+ **/
+ public BundleRecord[] getBundleRecords();
+
+ /**
+ * Get the specified bundle record from the repository.
+ * @param i the bundle record index to retrieve.
+ * @return the associated bundle record or <tt>null</tt>.
+ **/
+ public BundleRecord[] getBundleRecords(String symname);
+
+ /**
+ * Get bundle record for the bundle with the specified name
+ * and version from the repository.
+ * @param name the bundle record name to retrieve.
+ * @param version three-interger array of the version associated with
+ * the name to retrieve.
+ * @return the associated bundle record or <tt>null</tt>.
+ **/
+ public BundleRecord getBundleRecord(String symname, int[] version);
+
+ /**
+ * Deploys the bundle in the repository that corresponds to
+ * the specified update location. The action taken depends on
+ * whether the specified bundle is already installed in the local
+ * framework. If the bundle is already installed, then this
+ * method will attempt to update it. If the bundle is not already
+ * installed, then this method will attempt to install it.
+ * @param out the stream to use for informational messages.
+ * @param err the stream to use for error messages.
+ * @param symname the symbolic name of the bundle to deploy.
+ * @param isResolve a flag to indicates whether dependencies should
+ * should be resolved.
+ * @param isStart a flag to indicate whether installed bundles should
+ * be started.
+ * @return <tt>true</tt> if successful, <tt>false</tt> otherwise.
+ **/
+ public boolean deployBundle(
+ PrintStream out, PrintStream err, String symname, int[] version,
+ boolean isResolve, boolean isStart);
+
+ /**
+ * Returns an array containing all bundle records in the
+ * repository that resolve the transitive closure of the
+ * passed in array of package declarations.
+ * @param pkgs an array of package declarations to resolve.
+ * @return an array containing all bundle records in the
+ * repository that resolve the transitive closure of
+ * the passed in array of package declarations.
+ * @throws ResolveException if any packages in the transitive
+ * closure of packages cannot be resolved.
+ **/
+ public BundleRecord[] resolvePackages(IPackage[] pkgs)
+ throws ResolveException;
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/BundleRepository.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+public interface IAttribute
+{
+ public String getName();
+
+ public String getValue();
+
+ public boolean isMandatory();
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IAttribute.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+public interface IDirective
+{
+ public String getName();
+
+ public String getValue();
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IDirective.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+public interface IPackage
+{
+ public String getId();
+
+ public IDirective[] getDirectives();
+
+ public IAttribute[] getAttributes();
+
+ public IVersion getVersionLow();
+
+ public IVersion getVersionHigh();
+
+ public boolean isOptional();
+
+ public boolean doesSatisfy(IPackage pkg);
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IPackage.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+public interface IVersion extends Comparable
+{
+ public boolean equals(Object object);
+
+ public int getMajorComponent();
+
+ public int getMinorComponent();
+
+ public int getMicroComponent();
+
+ public String getQualifierComponent();
+
+ public boolean isInclusive();
+
+ public int compareTo(Object o);
+
+ public String toString();
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/IVersion.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository;
+
+public class ResolveException extends Exception
+{
+ private IPackage m_pkg = null;
+
+ public ResolveException(IPackage pkg)
+ {
+ m_pkg = pkg;
+ }
+
+ public IPackage getPackage()
+ {
+ return m_pkg;
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/ResolveException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator
+{
+ private transient BundleContext m_context = null;
+ private transient BundleRepositoryImpl m_br = null;
+
+ public void start(BundleContext context)
+ {
+ m_context = context;
+
+ // Register bundle repository service.
+ m_br = new BundleRepositoryImpl(m_context);
+ context.registerService(
+ org.apache.felix.bundlerepository.BundleRepository.class.getName(),
+ m_br, null);
+
+ // We dynamically import the impl service API, so it
+ // might not actually be available, so be ready to catch
+ // the exception when we try to register the command service.
+ try
+ {
+ // Register "obr" impl command service as a
+ // wrapper for the bundle repository service.
+ context.registerService(
+ org.apache.felix.shell.Command.class.getName(),
+ new ObrCommandImpl(m_context, m_br), null);
+ }
+ catch (Throwable th)
+ {
+ // Ignore.
+ }
+ }
+
+ public void stop(BundleContext context)
+ {
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/Activator.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,274 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import java.io.PrintStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.bundlerepository.*;
+import org.osgi.framework.*;
+
+public class BundleRepositoryImpl implements BundleRepository
+{
+ private BundleContext m_context = null;
+ private RepositoryState m_repo = null;
+
+ public BundleRepositoryImpl(BundleContext context)
+ {
+ m_context = context;
+ m_repo = new RepositoryState(m_context);
+ }
+
+ public String[] getRepositoryURLs()
+ {
+ return m_repo.getURLs();
+ }
+
+ public synchronized void setRepositoryURLs(String[] urls)
+ {
+ m_repo.setURLs(urls);
+ }
+
+ /**
+ * Get the number of bundles available in the repository.
+ * @return the number of available bundles.
+ **/
+ public synchronized BundleRecord[] getBundleRecords()
+ {
+ return m_repo.getRecords();
+ }
+
+ /**
+ * Get the specified bundle record from the repository.
+ * @param i the bundle record index to retrieve.
+ * @return the associated bundle record or <tt>null</tt>.
+ **/
+ public synchronized BundleRecord[] getBundleRecords(String symName)
+ {
+ return m_repo.getRecords(symName);
+ }
+
+ /**
+ * Get bundle record for the bundle with the specified name
+ * and version from the repository.
+ * @param name the bundle record name to retrieve.
+ * @param version three-interger array of the version associated with
+ * the name to retrieve.
+ * @return the associated bundle record or <tt>null</tt>.
+ **/
+ public synchronized BundleRecord getBundleRecord(String symName, int[] version)
+ {
+ return m_repo.getRecord(symName, version);
+ }
+
+ public boolean deployBundle(
+ PrintStream out, PrintStream err, String symName, int[] version,
+ boolean isResolve, boolean isStart)
+ {
+ // List to hold bundles that need to be started.
+ List startList = null;
+
+ // Get the bundle record of the remote bundle to be deployed.
+ BundleRecord targetRecord = m_repo.getRecord(symName, version);
+ if (targetRecord == null)
+ {
+ err.println("No such bundle in repository.");
+ return false;
+ }
+
+ // Create an editable snapshot of the current set of
+ // locally installed bundles.
+ LocalState localState = new LocalState(m_context);
+
+ // If the precise bundle is already deployed, then we are done.
+ if (localState.findBundle(symName, version) != null)
+ {
+ return true;
+ }
+
+ // Create the transitive closure all bundles that must be
+ // deployed as a result of deploying the target bundle;
+ // use a list because this will keep everything in order.
+ BundleRecord[] deployRecords = null;
+ // If the resolve flag is set, then get its imports to
+ // calculate the transitive closure of its dependencies.
+ if (isResolve)
+ {
+// Package[] imports = (Package[])
+// targetRecord.getAttribute(BundleRecord.IMPORT_PACKAGE);
+ Filter[] reqs = (Filter[])
+ targetRecord.getAttribute("requirement");
+ try
+ {
+ deployRecords = m_repo.resolvePackages(localState, reqs);
+ }
+ catch (ResolveException ex)
+ {
+ err.println("Resolve error: " + ex.getPackage());
+ return false;
+ }
+ }
+
+ // Add the target bundle since it will not be
+ // included in the array of records to deploy.
+ if (deployRecords == null)
+ {
+ deployRecords = new BundleRecord[] { targetRecord };
+ }
+ else
+ {
+ // Create a new array containing the target and put it first,
+ // since the array will be process in reverse order.
+ BundleRecord[] newRecs = new BundleRecord[deployRecords.length + 1];
+ newRecs[0] = targetRecord;
+ System.arraycopy(deployRecords, 0, newRecs, 1, deployRecords.length);
+ deployRecords = newRecs;
+ }
+
+ // Now iterate through all bundles in the deploy list
+ // in reverse order and deploy each; the order is not
+ // so important, but by reversing them at least the
+ // dependencies will be printed first and perhaps it
+ // will avoid some ordering issues when we are starting
+ // bundles.
+ for (int i = 0; i < deployRecords.length; i++)
+ {
+ LocalState.LocalBundleRecord updateRecord =
+ localState.findUpdatableBundle(deployRecords[i]);
+ if (updateRecord != null)
+ {
+// TODO: Should check to make sure that update bundle isn't already the
+// correct version.
+ // Modify our copy of the local state to reflect
+ // that the bundle is now updated.
+ localState.update(updateRecord, deployRecords[i]);
+
+ // Print out an "updating" message.
+ if (deployRecords[i] != targetRecord)
+ {
+ out.print("Updating dependency: ");
+ }
+ else
+ {
+ out.print("Updating: ");
+ }
+ out.println(Util.getBundleName(updateRecord.getBundle()));
+
+ // Actually perform the update.
+ try
+ {
+ URL url = new URL(
+ (String) deployRecords[i].getAttribute(BundleRecord.BUNDLE_URL));
+ updateRecord.getBundle().update(url.openStream());
+
+ // If necessary, save the updated bundle to be
+ // started later.
+ if (isStart)
+ {
+ if (startList == null)
+ {
+ startList = new ArrayList();
+ }
+ startList.add(updateRecord.getBundle());
+ }
+ }
+ catch (Exception ex)
+ {
+ err.println("Update error: " + Util.getBundleName(updateRecord.getBundle()));
+ ex.printStackTrace(err);
+ return false;
+ }
+ }
+ else
+ {
+ // Print out an "installing" message.
+ if (deployRecords[i] != targetRecord)
+ {
+ out.print("Installing dependency: ");
+ }
+ else
+ {
+ out.print("Installing: ");
+ }
+ out.println(deployRecords[i].getAttribute(BundleRecord.BUNDLE_NAME));
+
+ try
+ {
+ // Actually perform the install, but do not use the actual
+ // bundle JAR URL for the bundle location, since this will
+ // limit OBR's ability to manipulate bundle versions. Instead,
+ // use a unique timestamp as the bundle location.
+ URL url = new URL(
+ (String) deployRecords[i].getAttribute(BundleRecord.BUNDLE_URL));
+ Bundle bundle = m_context.installBundle(
+ "obr://"
+ + deployRecords[i].getAttribute(BundleRecord.BUNDLE_NAME)
+ + "/" + System.currentTimeMillis(),
+ url.openStream());
+
+ // If necessary, save the installed bundle to be
+ // started later.
+ if (isStart)
+ {
+ if (startList == null)
+ {
+ startList = new ArrayList();
+ }
+ startList.add(bundle);
+ }
+ }
+ catch (Exception ex)
+ {
+ err.println("Install error: "
+ + deployRecords[i].getAttribute(BundleRecord.BUNDLE_NAME));
+ ex.printStackTrace(err);
+ return false;
+ }
+ }
+ }
+
+ // If necessary, start bundles after installing them all.
+ if (isStart)
+ {
+ for (int i = 0; (startList != null) && (i < startList.size()); i++)
+ {
+ Bundle bundle = (Bundle) startList.get(i);
+ try
+ {
+ bundle.start();
+ }
+ catch (BundleException ex)
+ {
+ err.println("Update error: " + Util.getBundleName(bundle));
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public BundleRecord[] resolvePackages(IPackage[] pkgs)
+ throws ResolveException
+ {
+// TODO: FIX
+// return m_repo.resolvePackages(new LocalState(m_context), pkgs);
+ return null;
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/BundleRepositoryImpl.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+public class FileUtil
+{
+ public static void downloadSource(
+ PrintStream out, PrintStream err,
+ String srcURL, String dirStr, boolean extract)
+ {
+ // Get the file name from the URL.
+ String fileName = (srcURL.lastIndexOf('/') > 0)
+ ? srcURL.substring(srcURL.lastIndexOf('/') + 1)
+ : srcURL;
+
+ try
+ {
+ out.println("Connecting...");
+
+ File dir = new File(dirStr);
+ if (!dir.exists())
+ {
+ err.println("Destination directory does not exist.");
+ }
+ File file = new File(dir, fileName);
+
+ OutputStream os = new FileOutputStream(file);
+ URLConnection conn = new URL(srcURL).openConnection();
+ int total = conn.getContentLength();
+ InputStream is = conn.getInputStream();
+
+ if (total > 0)
+ {
+ out.println("Downloading " + fileName
+ + " ( " + total + " bytes ).");
+ }
+ else
+ {
+ out.println("Downloading " + fileName + ".");
+ }
+ byte[] buffer = new byte[4096];
+ int count = 0;
+ for (int len = is.read(buffer); len > 0; len = is.read(buffer))
+ {
+ count += len;
+ os.write(buffer, 0, len);
+ }
+
+ os.close();
+ is.close();
+
+ if (extract)
+ {
+ is = new FileInputStream(file);
+ JarInputStream jis = new JarInputStream(is);
+ out.println("Extracting...");
+ unjar(jis, dir);
+ jis.close();
+ file.delete();
+ }
+ }
+ catch (Exception ex)
+ {
+ err.println(ex);
+ }
+ }
+
+ public static void unjar(JarInputStream jis, File dir)
+ throws IOException
+ {
+ // Reusable buffer.
+ byte[] buffer = new byte[4096];
+
+ // Loop through JAR entries.
+ for (JarEntry je = jis.getNextJarEntry();
+ je != null;
+ je = jis.getNextJarEntry())
+ {
+ if (je.getName().startsWith("/"))
+ {
+ throw new IOException("JAR resource cannot contain absolute paths.");
+ }
+
+ File target = new File(dir, je.getName());
+
+ // Check to see if the JAR entry is a directory.
+ if (je.isDirectory())
+ {
+ if (!target.exists())
+ {
+ if (!target.mkdirs())
+ {
+ throw new IOException("Unable to create target directory: "
+ + target);
+ }
+ }
+ // Just continue since directories do not have content to copy.
+ continue;
+ }
+
+ int lastIndex = je.getName().lastIndexOf('/');
+ String name = (lastIndex >= 0) ?
+ je.getName().substring(lastIndex + 1) : je.getName();
+ String destination = (lastIndex >= 0) ?
+ je.getName().substring(0, lastIndex) : "";
+
+ // JAR files use '/', so convert it to platform separator.
+ destination = destination.replace('/', File.separatorChar);
+ copy(jis, dir, name, destination, buffer);
+ }
+ }
+
+ public static void copy(
+ InputStream is, File dir, String destName, String destDir, byte[] buffer)
+ throws IOException
+ {
+ if (destDir == null)
+ {
+ destDir = "";
+ }
+
+ // Make sure the target directory exists and
+ // that is actually a directory.
+ File targetDir = new File(dir, destDir);
+ if (!targetDir.exists())
+ {
+ if (!targetDir.mkdirs())
+ {
+ throw new IOException("Unable to create target directory: "
+ + targetDir);
+ }
+ }
+ else if (!targetDir.isDirectory())
+ {
+ throw new IOException("Target is not a directory: "
+ + targetDir);
+ }
+
+ BufferedOutputStream bos = new BufferedOutputStream(
+ new FileOutputStream(new File(targetDir, destName)));
+ int count = 0;
+ while ((count = is.read(buffer)) > 0)
+ {
+ bos.write(buffer, 0, count);
+ }
+ bos.close();
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/FileUtil.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+public class IteratorToEnumeration implements Enumeration
+{
+ private Iterator m_iter = null;
+
+ public IteratorToEnumeration(Iterator iter)
+ {
+ m_iter = iter;
+ }
+
+ public boolean hasMoreElements()
+ {
+ if (m_iter == null)
+ return false;
+ return m_iter.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ if (m_iter == null)
+ return null;
+ return m_iter.next();
+ }
+}
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/IteratorToEnumeration.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,378 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import java.util.*;
+
+import org.apache.felix.bundlerepository.BundleRecord;
+import org.apache.felix.bundlerepository.IPackage;
+import org.osgi.framework.*;
+
+public class LocalState
+{
+ private BundleContext m_context = null;
+ private List m_localRecordList = new ArrayList();
+
+ public LocalState(BundleContext context)
+ {
+ m_context = context;
+ initialize();
+ }
+
+ public BundleRecord findBundle(String symName, int[] version)
+ {
+ for (int i = 0; i < m_localRecordList.size(); i++)
+ {
+ BundleRecord brLocal = (BundleRecord) m_localRecordList.get(i);
+ String localSymName = (String)
+ brLocal.getAttribute(BundleRecord.BUNDLE_SYMBOLICNAME);
+ int[] localVersion = Util.parseVersionString((String)
+ brLocal.getAttribute(BundleRecord.BUNDLE_VERSION));
+ if ((localSymName != null) &&
+ localSymName.equals(symName) &&
+ (Util.compareVersion(localVersion, version) == 0))
+ {
+ return brLocal;
+ }
+ }
+ return null;
+ }
+
+ public BundleRecord[] findBundles(String symName)
+ {
+ List matchList = new ArrayList();
+ for (int i = 0; i < m_localRecordList.size(); i++)
+ {
+ BundleRecord brLocal = (BundleRecord) m_localRecordList.get(i);
+ String localSymName = (String)
+ brLocal.getAttribute(BundleRecord.BUNDLE_SYMBOLICNAME);
+ if ((localSymName != null) && localSymName.equals(symName))
+ {
+ matchList.add(brLocal);
+ }
+ }
+ return (BundleRecord[]) matchList.toArray(new BundleRecord[matchList.size()]);
+ }
+
+ public void update(BundleRecord oldRecord, BundleRecord newRecord)
+ {
+ // To update the old record we need to replace it with
+ // a new one, since BundleRecords are immutable. Make
+ // a new record that contains the attributes of the new
+ // record, but is associated with the local bundle of
+ // the old record.
+ if (oldRecord instanceof LocalBundleRecord)
+ {
+ String[] keys = newRecord.getAttributes();
+ Map map = new HashMap();
+ for (int i = 0; i < keys.length; i++)
+ {
+ map.put(keys, newRecord.getAttribute(keys[i]));
+ }
+ BundleRecord updatedRecord =
+ new LocalBundleRecord(
+ map, ((LocalBundleRecord) oldRecord).getBundle());
+ int idx = m_localRecordList.indexOf(oldRecord);
+ if (idx >= 0)
+ {
+ m_localRecordList.set(idx, updatedRecord);
+ }
+ }
+ }
+
+ public LocalBundleRecord findUpdatableBundle(BundleRecord record)
+ {
+ // Determine if any bundles with the specified symbolic
+ // name are already installed locally.
+ BundleRecord[] localRecords = findBundles(
+ (String)record.getAttribute(BundleRecord.BUNDLE_SYMBOLICNAME));
+ if (localRecords != null)
+ {
+ // Since there are local bundles with the same symbolic
+ // name installed, then we must determine if we can
+ // update an existing bundle or if we must install
+ // another one. Loop through all local bundles with same
+ // symbolic name and find the first one that can be updated
+ // without breaking constraints of existing bundles.
+ for (int i = 0; i < localRecords.length; i++)
+ {
+ // Check to make sure that the version of the target
+ // record is greater than the local bundle version,
+ // since we do not want to perform a downgrade.
+// int[] vLocal = Util.parseVersionString((String)
+// localRecords[i].getAttribute(BundleRecord.BUNDLE_VERSION));
+// int[] vTarget = Util.parseVersionString((String)
+// record.getAttribute(BundleRecord.BUNDLE_VERSION));
+// TODO: VERIFY WHAT IS GOING ON HERE.
+ // If the target bundle is a newer version and it is
+ // export compatible with the local bundle, then return it.
+ if (isUpdatable(localRecords[i], record))
+ {
+ return (LocalBundleRecord) localRecords[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isUpdatable(BundleRecord oldVersion, BundleRecord newVersion)
+ {
+ // First get all of the potentially resolvable package declarations
+ // from the local bundles for the old version of the bundle.
+ Filter[] reqFilters = getResolvableImportDeclarations(oldVersion);
+ if (reqFilters == null)
+ {
+ return true;
+ }
+ // Now make sure that all of the resolvable import declarations
+ // for the old version of the bundle can also be satisfied by
+ // the new version of the bundle.
+ Map[] capMaps = (Map[])
+ newVersion.getAttribute("capability");
+ if (capMaps == null)
+ {
+ return false;
+ }
+ MapToDictionary mapDict = new MapToDictionary(null);
+ for (int reqIdx = 0; reqIdx < reqFilters.length; reqIdx++)
+ {
+ boolean satisfied = false;
+ for (int capIdx = 0; !satisfied && (capIdx < capMaps.length); capIdx++)
+ {
+ mapDict.setSourceMap(capMaps[capIdx]);
+ if (reqFilters[reqIdx].match(mapDict))
+ {
+ satisfied = true;
+ }
+ }
+
+ // If any of the previously resolvable package declarations
+ // cannot be resolved, then the bundle is not updatable.
+ if (!satisfied)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Filter[] getResolvableImportDeclarations(BundleRecord record)
+ {
+ Map[] capMaps = (Map[])
+ record.getAttribute("capability");
+ if ((capMaps != null) && (capMaps.length > 0))
+ {
+ List filterList = new ArrayList();
+ // Use brute force to determine if any of the exports
+ // could possibly resolve any of the imports.
+ MapToDictionary mapDict = new MapToDictionary(null);
+ for (int capIdx = 0; capIdx < capMaps.length; capIdx++)
+ {
+ boolean added = false;
+ for (int recIdx = 0; !added && (recIdx < m_localRecordList.size()); recIdx++)
+ {
+ BundleRecord brLocal = (BundleRecord) m_localRecordList.get(recIdx);
+ Filter[] reqFilters = (Filter[])
+ brLocal.getAttribute("requirement");
+ for (int reqIdx = 0;
+ (reqFilters != null) && (reqIdx < reqFilters.length);
+ reqIdx++)
+ {
+ mapDict.setSourceMap(capMaps[capIdx]);
+ if (reqFilters[reqIdx].match(mapDict))
+ {
+ added = true;
+ filterList.add(reqFilters[reqIdx]);
+ }
+ }
+ }
+ }
+ return (Filter[])
+ filterList.toArray(new Filter[filterList.size()]);
+ }
+ return null;
+ }
+
+ public boolean isResolvable(Filter reqFilter)
+ {
+ MapToDictionary mapDict = new MapToDictionary(null);
+ for (int brIdx = 0; brIdx < m_localRecordList.size(); brIdx++)
+ {
+ BundleRecord brLocal = (BundleRecord) m_localRecordList.get(brIdx);
+ Map[] capMaps = (Map[]) brLocal.getAttribute("capability");
+ for (int capIdx = 0; (capMaps != null) && (capIdx < capMaps.length); capIdx++)
+ {
+ mapDict.setSourceMap(capMaps[capIdx]);
+ if (reqFilter.match(mapDict))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void initialize()
+ {
+ Bundle[] bundles = m_context.getBundles();
+ for (int i = 0; (bundles != null) && (i < bundles.length); i++)
+ {
+ Dictionary dict = bundles[i].getHeaders();
+ // Create a case-insensitive map.
+ Map bundleMap = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2)
+ {
+ return o1.toString().compareToIgnoreCase(o2.toString());
+ }
+ });
+
+ for (Enumeration keys = dict.keys(); keys.hasMoreElements(); )
+ {
+ Object key = keys.nextElement();
+ bundleMap.put(key, dict.get(key));
+ }
+
+ // Remove and convert any import package declarations
+ // into requirement filters.
+ String target = (String) bundleMap.remove(BundleRecord.IMPORT_PACKAGE);
+ if (target != null)
+ {
+ IPackage[] pkgs = R4Package.parseImportOrExportHeader(target);
+ Filter[] filters = new Filter[(pkgs == null) ? 0 : pkgs.length];
+ for (int pkgIdx = 0; (pkgs != null) && (pkgIdx < pkgs.length); pkgIdx++)
+ {
+ try
+ {
+ String low = pkgs[pkgIdx].getVersionLow().isInclusive()
+ ? "(version>=" + pkgs[pkgIdx].getVersionLow() + ")"
+ : "(!(version<=" + pkgs[pkgIdx].getVersionLow() + ")";
+
+ if (pkgs[pkgIdx].getVersionHigh() != null)
+ {
+ String high = pkgs[pkgIdx].getVersionHigh().isInclusive()
+ ? "(version<=" + pkgs[pkgIdx].getVersionHigh() + ")"
+ : "(!(version>=" + pkgs[pkgIdx].getVersionHigh() + ")";
+ filters[pkgIdx] = m_context.createFilter(
+ "(&(type=Export-Package)(name="
+ + pkgs[pkgIdx].getId() + ")"
+ + low + high + ")");
+ }
+ else
+ {
+ filters[pkgIdx] = m_context.createFilter(
+ "(&(type=Export-Package)(name="
+ + pkgs[pkgIdx].getId() + ")"
+ + low + ")");
+ }
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // Ignore, since it should not happen.
+ }
+ }
+ bundleMap.put("requirement", filters);
+ }
+
+ // Remove and convert any export package declarations
+ // into capability maps.
+ target = (String) bundleMap.remove(BundleRecord.EXPORT_PACKAGE);
+ if (target != null)
+ {
+ IPackage[] pkgs = R4Package.parseImportOrExportHeader(target);
+ Map[] capMaps = new Map[(pkgs == null) ? 0 : pkgs.length];
+ for (int pkgIdx = 0; (pkgs != null) && (pkgIdx < pkgs.length); pkgIdx++)
+ {
+ // Create a case-insensitive map.
+ capMaps[pkgIdx] = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2)
+ {
+ return o1.toString().compareToIgnoreCase(o2.toString());
+ }
+ });
+ capMaps[pkgIdx].put("type", "Export-Package");
+ capMaps[pkgIdx].put("name", pkgs[pkgIdx].getId());
+ capMaps[pkgIdx].put("version", pkgs[pkgIdx].getVersionLow());
+ }
+ bundleMap.put("capability", capMaps);
+ }
+
+ // For the system bundle, add a special platform capability.
+ if (bundles[i].getBundleId() == 0)
+ {
+ // Create a case-insensitive map.
+ Map map = new TreeMap(new Comparator() {
+ public int compare(Object o1, Object o2)
+ {
+ return o1.toString().compareToIgnoreCase(o2.toString());
+ }
+ });
+ map.put(
+ Constants.FRAMEWORK_VERSION,
+ m_context.getProperty(Constants.FRAMEWORK_VERSION));
+ map.put(
+ Constants.FRAMEWORK_VENDOR,
+ m_context.getProperty(Constants.FRAMEWORK_VENDOR));
+ map.put(
+ Constants.FRAMEWORK_LANGUAGE,
+ m_context.getProperty(Constants.FRAMEWORK_LANGUAGE));
+ map.put(
+ Constants.FRAMEWORK_OS_NAME,
+ m_context.getProperty(Constants.FRAMEWORK_OS_NAME));
+ map.put(
+ Constants.FRAMEWORK_OS_VERSION,
+ m_context.getProperty(Constants.FRAMEWORK_OS_VERSION));
+ map.put(
+ Constants.FRAMEWORK_PROCESSOR,
+ m_context.getProperty(Constants.FRAMEWORK_PROCESSOR));
+// map.put(
+// FelixConstants.FELIX_VERSION_PROPERTY,
+// m_context.getProperty(FelixConstants.FELIX_VERSION_PROPERTY));
+ Map[] capMaps = (Map[]) bundleMap.get("capability");
+ if (capMaps == null)
+ {
+ capMaps = new Map[] { map };
+ }
+ else
+ {
+ Map[] newCaps = new Map[capMaps.length + 1];
+ newCaps[0] = map;
+ System.arraycopy(capMaps, 0, newCaps, 1, capMaps.length);
+ capMaps = newCaps;
+ }
+ bundleMap.put("capability", capMaps);
+ }
+ m_localRecordList.add(new LocalBundleRecord(bundleMap, bundles[i]));
+ }
+ }
+
+ public static class LocalBundleRecord extends BundleRecord
+ {
+ private Bundle m_bundle = null;
+
+ LocalBundleRecord(Map attrMap, Bundle bundle)
+ {
+ super(attrMap);
+ m_bundle = bundle;
+ }
+
+ public Bundle getBundle()
+ {
+ return m_bundle;
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/LocalState.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java?rev=233548&view=auto
==============================================================================
--- incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java (added)
+++ incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java Fri Aug 19 12:53:58 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.bundlerepository.impl;
+
+import java.util.*;
+
+
+/**
+ * This is a simple class that implements a <tt>Dictionary</tt>
+ * from a <tt>Map</tt>. The resulting dictionary is immutatable.
+**/
+public class MapToDictionary extends Dictionary
+{
+ /**
+ * Map source.
+ **/
+ private Map m_map = null;
+
+ public MapToDictionary(Map map)
+ {
+ m_map = map;
+ }
+
+ public void setSourceMap(Map map)
+ {
+ m_map = map;
+ }
+
+ public Enumeration elements()
+ {
+ if (m_map == null)
+ {
+ return null;
+ }
+ return new IteratorToEnumeration(m_map.values().iterator());
+ }
+
+ public Object get(Object key)
+ {
+ if (m_map == null)
+ {
+ return null;
+ }
+ return m_map.get(key);
+ }
+
+ public boolean isEmpty()
+ {
+ if (m_map == null)
+ {
+ return true;
+ }
+ return m_map.isEmpty();
+ }
+
+ public Enumeration keys()
+ {
+ if (m_map == null)
+ {
+ return null;
+ }
+ return new IteratorToEnumeration(m_map.keySet().iterator());
+ }
+
+ public Object put(Object key, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object remove(Object key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size()
+ {
+ if (m_map == null)
+ {
+ return 0;
+ }
+ return m_map.size();
+ }
+}
\ No newline at end of file
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/felix/trunk/src/org/apache/felix/bundlerepository/impl/MapToDictionary.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"