Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 47064 invoked from network); 4 Dec 2007 16:09:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2007 16:09:45 -0000 Received: (qmail 20114 invoked by uid 500); 4 Dec 2007 16:09:33 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 20094 invoked by uid 500); 4 Dec 2007 16:09:33 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 20085 invoked by uid 99); 4 Dec 2007 16:09:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 08:09:33 -0800 X-ASF-Spam-Status: No, hits=-98.9 required=10.0 tests=ALL_TRUSTED,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 16:09:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5155E1A9838; Tue, 4 Dec 2007 08:09:12 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r600988 - in /felix/trunk/maven-obr-plugin/src/main/java/org: apache/felix/sandbox/obr/plugin/ osgi/impl/bundle/obr/resource/ Date: Tue, 04 Dec 2007 16:09:04 -0000 To: commits@felix.apache.org From: clement@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071204160914.5155E1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: clement Date: Tue Dec 4 08:09:03 2007 New Revision: 600988 URL: http://svn.apache.org/viewvc?rev=600988&view=rev Log: Update to use the new Bindex version. Fix the Id bug. Removed: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionImpl.java Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ExtractBindexInfo.java Tue Dec 4 08:09:03 2007 @@ -33,7 +33,7 @@ import org.osgi.impl.bundle.obr.resource.RepositoryImpl; import org.osgi.impl.bundle.obr.resource.RequirementImpl; import org.osgi.impl.bundle.obr.resource.ResourceImpl; -import org.osgi.impl.bundle.obr.resource.VersionImpl; +import org.osgi.impl.bundle.obr.resource.VersionRange; /** * this class is used to configure bindex and get information built by bindex about targeted bundle. @@ -121,7 +121,7 @@ if (value instanceof Number) { type = "number"; } else { - if (value.getClass() == VersionImpl.class) { type = "version"; } + if (value.getClass() == VersionRange.class) { type = "version"; } } if (type != null) { p.setT(type); @@ -234,6 +234,18 @@ public String getSource() { if (m_resource.getSource() != null) { return m_resource.getSource().toString(); + } else { + return null; + } + } + + /** + * extract source from bindex information. + * @return bundle source + */ + public String getId() { + if (m_resource.getId() != null) { + return m_resource.getId(); } else { return null; } Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ObrUpdate.java Tue Dec 4 08:09:03 2007 @@ -100,11 +100,6 @@ private Document m_repoDoc; /** - * used to determine the first free id. - */ - private boolean[] m_idTab; - - /** * first Node on repository descriptor tree. */ private Node m_root; @@ -143,8 +138,6 @@ this.m_logger = log; this.m_userConfig = userConfig; - // init the tab - m_idTab = new boolean[0]; m_resourceBundle = new ResourcesBundle(log); @@ -153,7 +146,6 @@ } else { this.m_repo = repoFilename; } - // System.err.println("Construct: "+repoFilename.getAbsoluteFilename()); } /** @@ -217,15 +209,7 @@ if (!walkOnTree(m_root)) { // the correct resource node was not found, we must create it // we compute the new id - int id = -1; - for (int i = 1; i < m_idTab.length; i++) { - if (!m_idTab[i]) { - id = i; - break; - } - } - if (id == -1) { id = m_idTab.length; } - + String id = m_resourceBundle.getId(); searchRepository(m_root, id); } @@ -263,7 +247,6 @@ if (!fout.exists()) { // create the repository.xml try { - fout.createNewFile(); m_logger.info("Created "+fout.getAbsolutePath()); } catch (IOException e) { @@ -465,12 +448,12 @@ * @param node Node on the xml file * @param id id of the bundle ressource */ - private void searchRepository(Node node, int id) { + private void searchRepository(Node node, String id) { if (node.getNodeName().compareTo("repository") == 0) { - m_resourceBundle.setId(String.valueOf(id)); node.appendChild(m_resourceBundle.getNode(m_repoDoc)); return; } else { + System.out.println("Second branch..."); NodeList list = node.getChildNodes(); if (list.getLength() > 0) { for (int i = 0; i < list.getLength(); i++) { @@ -489,25 +472,10 @@ private boolean resource(Node node) { // this part save all the id free if we need to add resource - int id = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue()); - if (id >= m_idTab.length) { - // resize tab - boolean[] bt = new boolean[id + 1]; - for (int i = 0; i < id + 1; i++) { - if (m_idTab.length > i && m_idTab[i]) { - bt[i] = true; - } else { - bt[i] = false; - } - } - - m_idTab = bt; - } - m_idTab[id] = true; - + String id = node.getAttributes().getNamedItem("id").getNodeValue(); NamedNodeMap map = node.getAttributes(); - if (m_resourceBundle.isSameBundleResource(map.getNamedItem("symbolicname").getNodeValue(), map.getNamedItem("presentationname").getNodeValue(), map.getNamedItem("version").getNodeValue())) { + if (m_resourceBundle.isSameBundleResource(map.getNamedItem("symbolicname").getNodeValue(), map.getNamedItem("version").getNodeValue())) { m_resourceBundle.setId(String.valueOf(id)); node.getParentNode().replaceChild(m_resourceBundle.getNode(m_repoDoc), node); return true; Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/sandbox/obr/plugin/ResourcesBundle.java Tue Dec 4 08:09:03 2007 @@ -332,6 +332,10 @@ } else { this.setVersion(project.getVersion()); } + + if (ebi.getId() != null) { + this.setId(ebi.getId()); + } if (ebi.getDescription() != null) { this.setDescription(ebi.getDescription()); @@ -427,7 +431,7 @@ * @return false if an information is missing, else true */ public boolean isValid() { - // we must verify require properties are present + // we must verify required properties are present return this.getPresentationName() != null && this.getSymbolicName() != null && this.getVersion() != null @@ -436,18 +440,15 @@ } /** - * test if this bundle has the same symbolicname, presentationname and version number. + * test if this bundle has the same symbolicname, and version number. * @param symbolicName symbolicName to compare with current bundle * @param presentationName presentationName to compare with current bundlde * @param version version to compare with current bundle * @return true if the information are the same, else false */ - public boolean isSameBundleResource(String symbolicName, String presentationName, String version) { + public boolean isSameBundleResource(String symbolicName, String version) { if (this.isValid()) { - boolean result; - result = (symbolicName.compareTo(this.getSymbolicName()) == 0) && (version.compareTo(this.getVersion()) == 0) && (presentationName.compareTo(this.getPresentationName()) == 0); - return result; - + return (symbolicName.compareTo(this.getSymbolicName()) == 0) && (version.compareTo(this.getVersion()) == 0); } else { return false; } Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/BundleInfo.java Tue Dec 4 08:09:03 2007 @@ -1,3 +1,20 @@ +/* + * $Id: BundleInfo.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.io.*; @@ -11,7 +28,7 @@ * Convert a bundle to a generic resource description and store its local * dependencies (like for example a license file in the JAR) in a zip file. * - * @version $Revision: 1.18 $ + * @version $Revision: 44 $ */ public class BundleInfo { Manifest manifest; @@ -191,8 +208,8 @@ ri.setComment("Import Service " + entry.getName()); // TODO the following is arbitrary - ri.setOptional(true); - ri.setMultiple(false); + ri.setOptional(false); + ri.setMultiple(true); resource.addRequirement(ri); } } @@ -326,22 +343,21 @@ filter.append("="); filter.append(pack.getName()); filter.append(")"); - VersionImpl version = pack.getVersion(); + VersionRange version = pack.getVersion(); if (version != null) { - VersionRange range = version.getRange(); - if (range != null) { + if ( version.isRange() ) { filter.append("(version"); filter.append(">"); - if (range.getIncludeMinimum()) + if (version.includeLow()) filter.append("="); - filter.append(range.getMinimum()); + filter.append(version.low); filter.append(")"); filter.append("(version"); filter.append("<"); - if (range.getIncludeMaximum()) + if (version.includeHigh()) filter.append("="); - filter.append(range.getMaximum()); + filter.append(version.high); filter.append(")"); } else { Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/CapabilityImpl.java Tue Dec 4 08:09:03 2007 @@ -1,3 +1,20 @@ +/* + * $Id: CapabilityImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.util.*; @@ -28,7 +45,7 @@ if ( "nummeric".equals(type)) v = new Long(value); else if ( "version".equals(type)) - v = new VersionImpl(value); + v = new VersionRange(value); addProperty(name,v); } parser.next(); @@ -70,7 +87,7 @@ String type = null; if (value instanceof Number ) type = "number"; - else if (value.getClass() == VersionImpl.class) + else if (value.getClass() == VersionRange.class) type = "version"; if (type != null) p.addAttribute("t", type); Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/FilterImpl.java Tue Dec 4 08:09:03 2007 @@ -1,15 +1,21 @@ -/** +/* + * $Id: FilterImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * * Copyright (c) 2000 Gatespace AB. All Rights Reserved. + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. * - * Gatespace grants Open Services Gateway Initiative (OSGi) an irrevocable, - * perpetual, non-exclusive, worldwide, paid-up right and license to - * reproduce, display, perform, prepare and have prepared derivative works - * based upon and distribute and sublicense this material and derivative - * works thereof as set out in the OSGi MEMBER AGREEMENT as of January 24 - * 2000, for use in accordance with Section 2.2 of the BY-LAWS of the - * OSGi MEMBER AGREEMENT. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ - package org.osgi.impl.bundle.obr.resource; import java.lang.reflect.*; Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Manifest.java Tue Dec 4 08:09:03 2007 @@ -1,12 +1,28 @@ +/* + * $Id: Manifest.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.io.*; import java.util.*; -import org.osgi.impl.bundle.obr.resource.VersionImpl; - public class Manifest extends Hashtable { + static final long serialVersionUID = 1L; List imports; List exports; ManifestEntry name; @@ -18,7 +34,7 @@ Vector duplicates = new Vector(); final static String wordparts = "~!@#$%^&*_:/?><.-+"; ManifestEntry bsn; - VersionImpl version; + VersionRange version; ManifestEntry host; List require; @@ -91,10 +107,10 @@ } if (header.equals("bundle-version")) { try { - version = new VersionImpl(value.trim()); + version = new VersionRange(value.trim()); } catch (Exception e) { - version = new VersionImpl("0"); + version = new VersionRange("0"); System.err.println("Invalid version attr for: " + bsn + " value is " + value); } @@ -295,9 +311,9 @@ return null; } - public VersionImpl getVersion() { + public VersionRange getVersion() { if (version == null) - return new VersionImpl("0"); + return new VersionRange("0"); return version; } @@ -305,12 +321,10 @@ ManifestEntry bsn = getBsn(); if (bsn == null) { - //nox if the symbolic name is not define in manifest fils, we take the - //artefactId from the pom.xml file - /*String name = getValue("Bundle-Name"); + String name = getValue("Bundle-Name"); if (name == null) - name = "Untitled-" + hashCode();*/ - return null; + name = "Untitled-" + hashCode(); + return name; } else return bsn.getName(); Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ManifestEntry.java Tue Dec 4 08:09:03 2007 @@ -1,13 +1,28 @@ +/* + * $Id: ManifestEntry.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.util.*; -import org.osgi.impl.bundle.obr.resource.VersionImpl; - public class ManifestEntry implements Comparable { String name; - VersionImpl version; + VersionRange version; Map attributes; public Map directives; public Set uses; @@ -16,7 +31,7 @@ this.name = name; } - public ManifestEntry(String name, VersionImpl version) { + public ManifestEntry(String name, VersionRange version) { this.name = name; this.version = version; } @@ -31,10 +46,10 @@ return name; } - public VersionImpl getVersion() { + public VersionRange getVersion() { if (version != null) return version; - return new VersionImpl("0"); + return new VersionRange("0"); } /* @@ -74,7 +89,7 @@ if (parameter.key.equalsIgnoreCase("version") || parameter.key .equalsIgnoreCase("specification-version")) - this.version = new VersionImpl(parameter.value); + this.version = new VersionRange(parameter.value); break; case Parameter.DIRECTIVE : Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Parameter.java Tue Dec 4 08:09:03 2007 @@ -1,30 +1,20 @@ /* - * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/Parameter.java,v 1.1 2006/07/27 10:31:02 pkriens Exp $ + * $Id: Parameter.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ * - * Copyright (c) The OSGi Alliance (2005). All Rights Reserved. + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. * - * Implementation of certain elements of the OSGi Specification may be subject - * to third party intellectual property rights, including without limitation, - * patent rights (such a third party may or may not be a member of the OSGi - * Alliance). The OSGi Alliance is not responsible and shall not be held - * responsible in any manner for identifying or failing to identify any or all - * such third party intellectual property rights. - * - * This document and the information contained herein are provided on an "AS IS" - * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE - * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF - * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR - * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN - * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. - * - * All Company, brand and product names may be trademarks that are the sole - * property of their respective owners. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ - package org.osgi.impl.bundle.obr.resource; class Parameter { Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RepositoryImpl.java Tue Dec 4 08:09:03 2007 @@ -1,28 +1,19 @@ /* - * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/RepositoryImpl.java,v 1.11 2006/04/27 09:00:16 pkriens Exp $ + * $Id: RepositoryImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ * - * Copyright (c) The OSGi Alliance (2005). All Rights Reserved. + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. * - * Implementation of certain elements of the OSGi Specification may be subject - * to third party intellectual property rights, including without limitation, - * patent rights (such a third party may or may not be a member of the OSGi - * Alliance). The OSGi Alliance is not responsible and shall not be held - * responsible in any manner for identifying or failing to identify any or all - * such third party intellectual property rights. - * - * This document and the information contained herein are provided on an "AS IS" - * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE - * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF - * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR - * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN - * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. - * - * All Company, brand and product names may be trademarks that are the sole - * property of their respective owners. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.osgi.impl.bundle.obr.resource; @@ -33,16 +24,14 @@ import java.util.zip.*; import org.kxml2.io.KXmlParser; -import org.osgi.service.obr.Repository; -import org.osgi.service.obr.Resource; - +import org.osgi.service.obr.*; import org.xmlpull.v1.*; /** * Implements the basic repository. A repository holds a set of resources. * * - * @version $Revision: 1.11 $ + * @version $Revision: 44 $ */ public class RepositoryImpl implements Repository { transient Set resources = new HashSet(); @@ -184,10 +173,10 @@ sb.append(")"); String version = parser.getAttributeValue(null, "specification-version"); - VersionImpl v = new VersionImpl("0"); + VersionRange v = new VersionRange("0"); if (version != null) { sb.append("(version="); - sb.append(v= new VersionImpl(version)); + sb.append(v= new VersionRange(version)); sb.append(")"); } sb.append(")"); @@ -205,7 +194,7 @@ String version = parser.getAttributeValue(null, "specification-version"); if (version != null) { - capability.addProperty("version", new VersionImpl( + capability.addProperty("version", new VersionRange( version)); } resource.addCapability(capability); @@ -228,7 +217,7 @@ resource.setPresentationName(value); } else if (key.equals("bundle-version")) - resource.setVersion(new VersionImpl(value)); + resource.setVersion(new VersionRange(value)); else { resource.put(key, value); } Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/RequirementImpl.java Tue Dec 4 08:09:03 2007 @@ -1,3 +1,20 @@ +/* + * $Id: RequirementImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import org.osgi.service.obr.*; @@ -9,7 +26,7 @@ * Implements the Requirement interface. * * - * @version $Revision: 1.8 $ + * @version $Revision: 44 $ */ public class RequirementImpl implements Requirement { int id; Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/ResourceImpl.java Tue Dec 4 08:09:03 2007 @@ -1,3 +1,20 @@ +/* + * $Id: ResourceImpl.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.io.File; @@ -13,7 +30,7 @@ List requirements = new ArrayList(); URL url; String symbolicName; - VersionImpl version; + VersionRange version; List categories = new ArrayList(); long size = -1; String id; @@ -23,13 +40,12 @@ String presentationName; File file; - { - id = Integer.toString(ID++); - } public ResourceImpl(RepositoryImpl repository, String name, - VersionImpl version) { + VersionRange version) { this.version = version; + if ( version == null) + this.version = new VersionRange("0"); this.symbolicName = name; this.repository = repository; } @@ -49,9 +65,9 @@ map.put(PRESENTATION_NAME, presentationName); String v = parser.getAttributeValue(null, "version"); if (v == null) - setVersion(new VersionImpl("0")); + setVersion(new VersionRange("0")); else - setVersion(new VersionImpl(v)); + setVersion(new VersionRange(v)); setURL(toURL(parser.getAttributeValue(null, "uri"))); @@ -221,13 +237,13 @@ public Version getVersion() { if (version == null) - version = new VersionImpl("0"); - return version; + version = new VersionRange("0"); + return version.low; } - void setVersion(VersionImpl version) { + void setVersion(VersionRange version) { if (version == null) - this.version = new VersionImpl("0"); + this.version = new VersionRange("0"); else this.version = version; } @@ -308,7 +324,9 @@ return Collections.unmodifiableMap(map); } - public String getId() { + public synchronized String getId() { + if ( id == null ) + id = symbolicName + "/" + version; return id; } Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/StringSet.java Tue Dec 4 08:09:03 2007 @@ -1,35 +1,28 @@ /* - * $Header: /cvshome/bundles/bundles.obr/src/bundles/obr/resource/StringSet.java,v 1.1 2006/01/03 16:22:46 pkriens Exp $ + * $Id: StringSet.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ * - * Copyright (c) The OSGi Alliance (2006). All Rights Reserved. + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. * - * Implementation of certain elements of the OSGi Specification may be subject - * to third party intellectual property rights, including without limitation, - * patent rights (such a third party may or may not be a member of the OSGi - * Alliance). The OSGi Alliance is not responsible and shall not be held - * responsible in any manner for identifying or failing to identify any or all - * such third party intellectual property rights. - * - * This document and the information contained herein are provided on an "AS IS" - * basis and THE OSGI ALLIANCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - * HEREIN WILL NOT INFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OF - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL THE - * OSGI ALLIANCE BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF - * USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR - * EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN - * CONNECTION WITH THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. - * - * All Company, brand and product names may be trademarks that are the sole - * property of their respective owners. All rights reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package org.osgi.impl.bundle.obr.resource; import java.util.*; public class StringSet extends HashSet { + static final long serialVersionUID = 1L; public StringSet(String set) { StringTokenizer st = new StringTokenizer(set, ","); Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/Tag.java Tue Dec 4 08:09:03 2007 @@ -1,3 +1,20 @@ +/* + * $Id: Tag.java 44 2007-07-13 20:49:41Z hargrave@us.ibm.com $ + * + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.osgi.impl.bundle.obr.resource; import java.io.*; @@ -267,7 +284,7 @@ */ String escape(String s) { if ( s == null ) - System.out.println("??"); + return "?null?"; StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { Modified: felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java?rev=600988&r1=600987&r2=600988&view=diff ============================================================================== --- felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java (original) +++ felix/trunk/maven-obr-plugin/src/main/java/org/osgi/impl/bundle/obr/resource/VersionRange.java Tue Dec 4 08:09:03 2007 @@ -1,166 +1,119 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * $Id: VersionRange.java 45 2007-10-01 12:56:02Z peter.kriens@aqute.biz $ * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ + * Copyright (c) OSGi Alliance (2002, 2006, 2007). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.osgi.impl.bundle.obr.resource; -import org.osgi.framework.Version; +import java.util.regex.*; -/** - * This class represents a version range. - * @since 3.1 - */ -public class VersionRange { - private static final Version versionMax = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - /** - * An empty version - */ - public static final VersionRange emptyRange = new VersionRange(null); - - private Version minVersion; - private boolean includeMin; - private Version maxVersion; - private boolean includeMax; - - /** - * Constructs a VersionRange with the specified minVersion and maxVersion. - * @param minVersion the minimum version of the range - * @param maxVersion the maximum version of the range - */ - public VersionRange(Version minVersion, boolean includeMin, Version maxVersion, boolean includeMax) { - this.minVersion = minVersion; - this.includeMin = includeMin; - this.maxVersion = maxVersion; - this.includeMax = includeMax; - } - - /** - * Constructs a VersionRange from the given versionRange String. - * @param versionRange a version range String that specifies a range of - * versions. - */ - public VersionRange(String versionRange) { - if (versionRange == null || versionRange.length() == 0) { - minVersion = Version.emptyVersion; - includeMin = true; - maxVersion = VersionRange.versionMax; - includeMax = true; - return; - } - versionRange = versionRange.trim(); - if (versionRange.charAt(0) == '[' || versionRange.charAt(0) == '(') { - int comma = versionRange.indexOf(','); - if (comma < 0) - throw new IllegalArgumentException(); - char last = versionRange.charAt(versionRange.length() - 1); - if (last != ']' && last != ')') - throw new IllegalArgumentException(); - - minVersion = Version.parseVersion(versionRange.substring(1, comma).trim()); - includeMin = versionRange.charAt(0) == '['; - maxVersion = Version.parseVersion(versionRange.substring(comma + 1, versionRange.length() - 1).trim()); - includeMax = last == ']'; - } else { - minVersion = Version.parseVersion(versionRange.trim()); - includeMin = true; - maxVersion = VersionRange.versionMax; - includeMax = true; - } +import org.osgi.framework.*; + +public class VersionRange implements Comparable { + Version high; + Version low; + char start = '['; + char end = ']'; + + static String V = "[0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[a-zA-Z0-9_-]+)?)?)?"; + static Pattern RANGE = Pattern.compile("(\\(|\\[)(" + V + "),(" + V + + ")(\\)|\\])"); + + public VersionRange(String string) { + string = string.trim(); + Matcher m = RANGE.matcher(string); + if (m.matches()) { + start = m.group(1).charAt(0); + low = new Version(m.group(2)); + high = new Version(m.group(6)); + end = m.group(10).charAt(0); + if (low.compareTo(high) >= 0) + throw new IllegalArgumentException( + "Low Range is higher than High Range: " + low + "-" + + high); + + } else + high = low = new Version(string); } - /** - * Returns the minimum Version of this VersionRange - * @return the minimum Version of this VersionRange - */ - public Version getMinimum() { - return minVersion; - } - - /** - * Indicates if the minimum version is included in the version range. - * @return true if the minimum version is included in the version range; - * otherwise false is returned - */ - public boolean getIncludeMinimum() { - return includeMin; - } - - /** - * Returns the maximum Version of this VersionRange - * @return the maximum Version of this VersionRange - */ - public Version getMaximum() { - return maxVersion; - } - - /** - * Indicates if the maximum version is included in the version range. - * @return true if the maximum version is included in the version range; - * otherwise false is returned - */ - public boolean getIncludeMaximum() { - return includeMax; - } - - /** - * Returns whether the given version is included in this VersionRange. - * This will depend on the minimum and maximum versions of this VersionRange - * and the given version. - * - * @param version a version to be tested for inclusion in this VersionRange. - * (may be null) - * @return true if the version is include, - * false otherwise - */ - public boolean isIncluded(Version version) { - Version minRequired = getMinimum(); - if (minRequired == null) - return true; - if (version == null) - return false; - Version maxRequired = getMaximum() == null ? VersionRange.versionMax : getMaximum(); - int minCheck = includeMin ? 0 : 1; - int maxCheck = includeMax ? 0 : -1; - return version.compareTo(minRequired) >= minCheck && version.compareTo(maxRequired) <= maxCheck; - - } - - public boolean equals(Object object) { - if (!(object instanceof VersionRange)) - return false; - VersionRange vr = (VersionRange) object; - if (minVersion != null && vr.getMinimum() != null) { - if (minVersion.equals(vr.getMinimum()) && includeMin == vr.includeMin) - if (maxVersion != null && vr.getMaximum() != null) { - if (maxVersion.equals(vr.getMaximum()) && includeMax == vr.includeMax) - return true; - } - else - return maxVersion == vr.getMaximum(); - } - else { - return minVersion == vr.getMinimum(); + public boolean isRange() { + return high != low; + } + + public boolean includeLow() { + return start == '['; + } + + public boolean includeHigh() { + return end == ']'; + } + + public String toString() { + if (high == low) + return high.toString(); + + StringBuffer sb = new StringBuffer(); + sb.append(start); + sb.append(low); + sb.append(','); + sb.append(high); + sb.append(end); + return sb.toString(); + } + + public boolean equals(Object other) { + if (other instanceof VersionRange) { + return compareTo(other)==0; } return false; } - public String toString() { - if (minVersion == null) - return Version.emptyVersion.toString(); - if (VersionRange.versionMax.equals(maxVersion)) - return minVersion.toString(); - StringBuffer result = new StringBuffer(); - result.append(includeMin ? '[' : '('); - result.append(minVersion); - result.append(','); - result.append(maxVersion); - result.append(includeMax ? ']' : ')'); - return result.toString(); + public int hashCode() { + return low.hashCode() * high.hashCode(); + } + + public int compareTo(Object other) { + VersionRange range = (VersionRange) other; + VersionRange a = this, b = range; + if (range.isRange()) { + a = range; + b = this; + } else { + if ( !isRange() ) + return low.compareTo(range.high); + } + int l = a.low.compareTo(b.low); + boolean ll = false; + if (a.includeLow()) + ll = l <= 0; + else + ll = l < 0; + + if (!ll) + return -1; + + int h = a.high.compareTo(b.high); + if (a.includeHigh()) + ll = h >= 0; + else + ll = h > 0; + + if (ll) + return 0; + else + return 1; } -} +} \ No newline at end of file