[jboss-cvs] JBossAS SVN: r65457 - in trunk/system/src/main/org/jboss: profileservice/spi/repository and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 18 15:28:44 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-09-18 15:28:44 -0400 (Tue, 18 Sep 2007)
New Revision: 65457

Added:
   trunk/system/src/main/org/jboss/profileservice/spi/repository/
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Capability.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/CapabilityProvider.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/MutableRepository.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Repository.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/RepositoryAdmin.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Requirement.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Resolver.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Resource.java
   trunk/system/src/main/org/jboss/profileservice/spi/repository/Version.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java
Log:
JBAS-4362, validate the mapping of the DeploymentRepository to an osgi OBR like repository.

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Capability.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Capability.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Capability.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.util.Map;
+
+/**
+ * A named set of properties representing some capability that is provided by
+ * its owner.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Capability
+{
+   /**
+    * Return the name of the capability.
+    *
+    */
+   String getName();
+
+   /**
+    * Return the map of properties.
+    *
+    * @return a Map<String,Object>
+    */
+   Map<String, Object> getProperties();
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Capability.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/CapabilityProvider.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/CapabilityProvider.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/CapabilityProvider.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+/**
+ * Mirror the OBR Capability
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface CapabilityProvider
+{
+    /**
+     * Return a set of capabilities.
+     *
+     * These capabilities are considered part of the platform. Bundles can
+     * require these capabilities during selection. All capabilities from
+     * different providers are considered part of the platform.
+     *
+     * @return Set of capabilities
+     */
+    Capability[] getCapabilities();
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/CapabilityProvider.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/MutableRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/MutableRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/MutableRepository.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.util.Collection;
+
+/**
+ * A mutable extension of the OBR Repository
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface MutableRepository extends Repository
+{
+   public enum ModifyStatus {ADDED, MODIFIED, REMOVED};
+
+   public void addResource(Resource resource);
+   public Resource removeResource(String name);
+   /**
+    * Return a collection of resources that have been modified since
+    * the last call to this method. The returned resources contain
+    * a modifyStatus property of type ModifyStatus to indicate the
+    * type of change.
+    * 
+    * @return The Resources that have been modified.
+    * @throws Exception
+    */
+   public Collection<Resource> getModifiedResources() throws Exception;
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/MutableRepository.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Repository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Repository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Repository.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.net.URI;
+
+/**
+ * Mirror the OBR Repository
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Repository
+{
+    /**
+     * Return the associated URI for the repository.
+     *
+     */
+    URI getURI();
+
+    /**
+     * Return the resources for this repository.
+     */
+    Resource[] getResources();
+
+    /**
+     * Return the name of this reposotory.
+     *
+     * @return a non-null name
+     */
+    String getName();
+
+    long getLastModified();
+
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Repository.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/RepositoryAdmin.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/RepositoryAdmin.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/RepositoryAdmin.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.net.URI;
+
+/**
+ * Mirror the OBR RepositoryAdmin interface with URI instead of URL.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface RepositoryAdmin
+{
+    /**
+     * Discover any resources that match the given filter.
+     *
+     * This is not a detailed search, but a first scan of applicable resources.
+     *
+     * ### Checking the capabilities of the filters is not possible because that     * requires a new construct in the filter.
+     *
+     * The filter expression can assert any of the main headers of the resource.     * The attributes that can be checked are:
+     *
+     * <ol>
+     * <li>name</li>
+     * <li>version (uses filter matching rules)</li>
+     * <li>description</li>
+     * <li>category</li>
+     * <li>copyright</li>
+     * <li>license</li>
+     * <li>source</li>
+     * </ol>
+     *
+     * @param filterExpr
+     *            A standard OSGi filter
+     * @return List of resources matching the filters.
+     */
+    Resource[] discoverResources(String filterExpr);
+
+    /**
+     * Create a resolver.
+     *
+     * @param resource
+     * @return
+     */
+    Resolver resolver();
+
+    /**
+     * Add a new repository to the federation.
+     *
+     * The url must point to a repository XML file.
+     *
+     * @param repository
+     * @return
+     * @throws Exception
+     */
+    Repository addRepository(URI repository) throws Exception;
+
+    /**
+     * The OBR version does not include this.
+     * 
+     * @param repository
+     * @return the Repository instance for the 
+     * @throws Exception
+     */
+    Repository getRepository(URI repository) throws Exception;
+
+    boolean removeRepository(URI repository);
+
+    /**
+     * List all the repositories.
+     *
+     * @return
+     */
+    Repository[] listRepositories();
+
+    Resource getResource(String respositoryId);
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/RepositoryAdmin.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Requirement.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Requirement.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Requirement.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+/**
+ * Mirror the OBR Requirement
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Requirement
+{
+
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Requirement.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Resolver.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Resolver.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Resolver.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+/**
+ * Mirror the OBR Resolver
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Resolver
+{
+
+    void add(Resource resource);
+
+    Requirement[] getUnsatisfiedRequirements();
+
+    Resource[] getOptionalResources();
+
+    Requirement[] getReason(Resource resource);
+
+    Resource[] getResources(Requirement requirement);
+
+    Resource[] getRequiredResources();
+
+    Resource[] getAddedResources();
+
+    boolean resolve();
+
+    void deploy(boolean start);
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Resolver.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Resource.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Resource.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Resource.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * Mirror the OBR Resource view.
+ * A resource is an abstraction of a downloadable thing, like a bundle.
+ *
+ * Resources have capabilities and requirements. All a resource's requirements
+ * must be satisfied before it can be installed.
+ *
+ * @version $Revision$
+ */
+public interface Resource
+{
+    final String LICENSE_URL = "license";
+
+    final String DESCRIPTION = "description";
+
+    final String DOCUMENTATION_URL = "documentation";
+
+    final String COPYRIGHT = "copyright";
+
+    final String SOURCE_URL = "source";
+
+    final String SYMBOLIC_NAME = "symbolicname";
+
+    final String PRESENTATION_NAME = "presentationname";
+
+    final String ID = "id";
+
+    final String VERSION = "version";
+
+    final String URI = "uri";
+
+    final String SIZE = "size";
+
+    final static String[] KEYS = { DESCRIPTION, SIZE, ID, LICENSE_URL,
+            DOCUMENTATION_URL, COPYRIGHT, SOURCE_URL, PRESENTATION_NAME,
+            SYMBOLIC_NAME, VERSION, URI };
+
+    Map getProperties();
+
+    String getSymbolicName();
+
+    String getPresentationName();
+
+    Version getVersion();
+
+    String getId();
+
+    URI getURI();
+
+    Requirement[] getRequirements();
+
+    Capability[] getCapabilities();
+
+    String[] getCategories();
+
+    Repository getRepository();
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Resource.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/profileservice/spi/repository/Version.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/repository/Version.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/repository/Version.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,410 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi.repository;
+
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+/**
+ * OSGI version impl for now.
+ * 
+ * Version identifier for bundles and packages.
+ * 
+ * <p>
+ * Version identifiers have four components.
+ * <ol>
+ * <li>Major version. A non-negative integer.</li>
+ * <li>Minor version. A non-negative integer.</li>
+ * <li>Micro version. A non-negative integer.</li>
+ * <li>Qualifier. A text string. See <code>Version(String)</code> for the
+ * format of the qualifier string.</li>
+ * </ol>
+ * 
+ * <p>
+ * <code>Version</code> objects are immutable.
+ * 
+ * @version $Revision$
+ * @since 1.3
+ * @author Scott.Stark at jboss.org
+ * @author Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
+ */
+public class Version implements Comparable
+{
+   private final int major;
+
+   private final int minor;
+
+   private final int micro;
+
+   private final String qualifier;
+
+   private static final String SEPARATOR = "."; //$NON-NLS-1$
+
+   /**
+    * The empty version "0.0.0". Equivalent to calling
+    * <code>new Version(0,0,0)</code>.
+    */
+   public static final Version emptyVersion = new Version(0, 0, 0);
+
+   /**
+    * Creates a version identifier from the specified numerical components. *
+    * <p>
+    * The qualifier is set to the empty string.
+    * 
+    * @param major
+    *           Major component of the version identifier.
+    * @param minor
+    *           Minor component of the version identifier.
+    * @param micro
+    *           Micro component of the version identifier.
+    * @throws IllegalArgumentException
+    *            If the numerical components are negative.
+    */
+   public Version(int major, int minor, int micro)
+   {
+      this(major, minor, micro, null);
+   }
+
+   /**
+    * Creates a version identifier from the specifed components.
+    * 
+    * @param major
+    *           Major component of the version identifier.
+    * @param minor
+    *           Minor component of the version identifier.
+    * @param micro
+    *           Micro component of the version identifier.
+    * @param qualifier
+    *           Qualifier component of the version identifier. If
+    *           <code>null</code> is specified, then the qualifier will be set *
+    *           to the empty string.
+    * @throws IllegalArgumentException
+    *            If the numerical components are negative or the qualifier
+    *            string is invalid.
+    */
+   public Version(int major, int minor, int micro, String qualifier)
+   {
+      if (qualifier == null)
+      {
+         qualifier = ""; //$NON-NLS-1$
+      }
+
+      this.major = major;
+      this.minor = minor;
+      this.micro = micro;
+      this.qualifier = qualifier;
+      validate();
+   }
+
+   /**
+    * Created a version identifier from the specified string.
+    * 
+    * <p>
+    * Here is the grammar for version strings.
+    * 
+    * <pre>
+    * version ::= major('.'minor('.'micro('.'qualifier)?)?)?
+    * major ::= digit+
+    * minor ::= digit+
+    * micro ::= digit+
+    * qualifier ::= (alpha|digit|'_'|'-')+
+    * digit ::= [0..9]
+    * alpha ::= [a..zA..Z]
+    * </pre>
+    * 
+    * There must be no whitespace in version.
+    * 
+    * @param version
+    *           String representation of the version identifier.
+    * @throws IllegalArgumentException
+    *            If <code>version</code> is improperly formatted.
+    */
+   public Version(String version)
+   {
+      int major = 0;
+      int minor = 0;
+      int micro = 0;
+      String qualifier = ""; //$NON-NLS-1$
+
+      try
+      {
+         StringTokenizer st = new StringTokenizer(version, SEPARATOR, true);
+         major = Integer.parseInt(st.nextToken());
+
+         if (st.hasMoreTokens())
+         {
+            st.nextToken(); // consume delimiter
+            minor = Integer.parseInt(st.nextToken());
+
+            if (st.hasMoreTokens())
+            {
+               st.nextToken(); // consume delimiter
+               micro = Integer.parseInt(st.nextToken());
+
+               if (st.hasMoreTokens())
+               {
+                  st.nextToken(); // consume delimiter
+                  qualifier = st.nextToken();
+
+                  if (st.hasMoreTokens())
+                  {
+                     throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
+                  }
+               }
+            }
+         }
+      }
+      catch (NoSuchElementException e)
+      {
+         throw new IllegalArgumentException("invalid format"); //$NON-NLS-1$
+      }
+
+      this.major = major;
+      this.minor = minor;
+      this.micro = micro;
+      this.qualifier = qualifier;
+      validate();
+   }
+
+   /**
+    * Called by the Version constructors to validate the version components.
+    * 
+    * @throws IllegalArgumentException
+    *            If the numerical components are negative or the qualifier
+    *            string is invalid.
+    */
+   private void validate()
+   {
+      if (major < 0)
+      {
+         throw new IllegalArgumentException("negative major"); //$NON-NLS-1$
+      }
+      if (minor < 0)
+      {
+         throw new IllegalArgumentException("negative minor"); //$NON-NLS-1$
+      }
+      if (micro < 0)
+      {
+         throw new IllegalArgumentException("negative micro"); //$NON-NLS-1$
+      }
+      int length = qualifier.length();
+      for (int i = 0; i < length; i++)
+      {
+         if ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-".indexOf(qualifier.charAt(i)) == -1) { //$NON-NLS-1$
+            throw new IllegalArgumentException("invalid qualifier"); //$NON-NLS-1$
+         }
+      }
+   }
+
+   /**
+    * Parses a version identifier from the specified string.
+    * 
+    * <p>
+    * See <code>Version(String)</code> for the format of the version string.
+    * 
+    * @param version
+    *           String representation of the version identifier. Leading and
+    *           trailing whitespace will be ignored.
+    * @return A <code>Version</code> object representing the version
+    *         identifier. If <code>version</code> is <code>null</code> or
+    *         the empty string then <code>emptyVersion</code> will be
+    *         returned.
+    * @throws IllegalArgumentException
+    *            If <code>version</code> is improperly formatted.
+    */
+   public static Version parseVersion(String version)
+   {
+      if (version == null)
+      {
+         return emptyVersion;
+      }
+
+      version = version.trim();
+      if (version.length() == 0)
+      {
+         return emptyVersion;
+      }
+
+      return new Version(version);
+   }
+
+   /**
+    * Returns the major component of this version identifier.
+    * 
+    * @return The major component.
+    */
+   public int getMajor()
+   {
+      return major;
+   }
+
+   /**
+    * Returns the minor component of this version identifier.
+    * 
+    * @return The minor component.
+    */
+   public int getMinor()
+   {
+      return minor;
+   }
+
+   /**
+    * Returns the micro component of this version identifier.
+    * 
+    * @return The micro component.
+    */
+   public int getMicro()
+   {
+      return micro;
+   }
+
+   /**
+    * Returns the qualifier component of this version identifier.
+    * 
+    * @return The qualifier component.
+    */
+   public String getQualifier()
+   {
+      return qualifier;
+   }
+
+   /**
+    * Returns the string representation of this version identifier.
+    * 
+    * <p>
+    * The format of the version string will be <code>major.minor.micro</code>
+    * if qualifier is the empty string or
+    * <code>major.minor.micro.qualifier</code> otherwise.
+    * 
+    * @return The string representation of this version identifier.
+    */
+   public String toString()
+   {
+      String base = major + SEPARATOR + minor + SEPARATOR + micro;
+      if (qualifier.length() == 0)
+      { //$NON-NLS-1$
+         return base;
+      }
+      else
+      {
+         return base + SEPARATOR + qualifier;
+      }
+   }
+
+   /**
+    * Returns a hash code value for the object.
+    * 
+    * @return An integer which is a hash code value for this object.
+    */
+   public int hashCode()
+   {
+      return (major << 24) + (minor << 16) + (micro << 8)
+            + qualifier.hashCode();
+   }
+
+   /**
+    * Compares this <code>Version</code> object to another object.
+    * 
+    * <p>
+    * A version is considered to be <b>equal to </b> another version if the *
+    * major, minor and micro components are equal and the qualifier component is
+    * equal (using <code>String.equals</code>).
+    * 
+    * @param object
+    *           The <code>Version</code> object to be compared.
+    * @return <code>true</code> if <code>object</code> is a
+    *         <code>Version</code> and is equal to this object;
+    *         <code>false</code> otherwise.
+    */
+   public boolean equals(Object object)
+   {
+      if (object == this)
+      { // quicktest
+         return true;
+      }
+
+      if (!(object instanceof Version))
+      {
+         return false;
+      }
+
+      Version other = (Version) object;
+      return (major == other.major) && (minor == other.minor)
+            && (micro == other.micro) && qualifier.equals(other.qualifier);
+   }
+
+   /**
+    * Compares this <code>Version</code> object to another object.
+    * 
+    * <p>
+    * A version is considered to be <b>less than </b> another version if its
+    * major component is less than the other version's major component, or the
+    * major components are equal and its minor component is less than the other
+    * version's minor component, or the major and minor components are equal and
+    * its micro component is less than the other version's micro component, or
+    * the major, minor and micro components are equal and it's qualifier *
+    * component is less than the other version's qualifier component (using *
+    * <code>String.compareTo</code>).
+    * 
+    * <p>
+    * A version is considered to be <b>equal to</b> another version if the
+    * major, minor and micro components are equal and the qualifier component is
+    * equal (using <code>String.compareTo</code>).
+    * 
+    * @param object
+    *           The <code>Version</code> object to be compared.
+    * @return A negative integer, zero, or a positive integer if this object is
+    *         less than, equal to, or greater than the specified
+    *         <code>Version</code> object.
+    * @throws ClassCastException
+    *            If the specified object is not a <code>Version</code>.
+    */
+   public int compareTo(Object object)
+   {
+      if (object == this)
+      { // quicktest
+         return 0;
+      }
+
+      Version other = (Version) object;
+
+      int result = major - other.major;
+      if (result != 0)
+      {
+         return result;
+      }
+
+      result = minor - other.minor;
+      if (result != 0)
+      {
+         return result;
+      }
+
+      result = micro - other.micro;
+      if (result != 0)
+      {
+         return result;
+      }
+
+      return qualifier.compareTo(other.qualifier);
+   }
+}


Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/repository/Version.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.deployers.spi.attachments.Attachments;
+import org.jboss.profileservice.spi.repository.Capability;
+import org.jboss.profileservice.spi.repository.Repository;
+import org.jboss.profileservice.spi.repository.Requirement;
+import org.jboss.profileservice.spi.repository.Resource;
+import org.jboss.profileservice.spi.repository.Version;
+
+/**
+ * A Resource implementation for a VFSDeployment attachments.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AttachmentsResource implements Resource
+{
+   private String vfsPath;
+   private Repository repository;
+   private String[] categories = {};
+   private Capability[] capabilities = {};
+   private Map<String, Object> props;
+
+   public AttachmentsResource(String vfsPath, Attachments edits, Repository repository)
+   {
+      this.vfsPath = vfsPath;
+      this.repository = repository;
+      this.props = Collections.singletonMap("attachments", (Object)edits);
+   }
+
+   public Capability[] getCapabilities()
+   {
+      return capabilities;
+   }
+
+   public String[] getCategories()
+   {
+      return categories;
+   }
+
+   public String getId()
+   {
+      return vfsPath;
+   }
+
+   public String getPresentationName()
+   {
+      return vfsPath;
+   }
+
+   public Map getProperties()
+   {
+      return props;
+   }
+
+   public Repository getRepository()
+   {
+      return repository;
+   }
+
+   public Requirement[] getRequirements()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public String getSymbolicName()
+   {
+      return vfsPath;
+   }
+
+   public URI getURI()
+   {
+      URI repoURI = repository.getURI();
+      URI uri = null;
+      try
+      {
+         // TODO: this probably does not work
+         uri = repoURI.resolve(vfsPath);
+      }
+      catch(Exception e)
+      {
+         throw new IllegalStateException(e);
+      }
+      return uri;
+   }
+
+   public Version getVersion()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }  
+}


Property changes on: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AttachmentsResource.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.profileservice.spi.repository.Capability;
+
+/**
+ * Default Capability implementation
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class CapabilityImpl implements Capability
+{
+   private String name;
+   private Map<String, Object> props;
+
+   public CapabilityImpl(String name)
+   {
+      this(name, Collections.EMPTY_MAP);
+   }
+   public CapabilityImpl(String name, Map<String, Object> props)
+   {
+      this.name = name;
+      this.props = props;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Map<String, Object> getProperties()
+   {
+      return props;
+   }
+   public void setProperties(Map<String, Object> props)
+   {
+      this.props = props;
+   }
+   public Object addProperty(String name, Object value)
+   {
+      return props.put(name, value);
+   }
+}


Property changes on: trunk/system/src/main/org/jboss/system/server/profileservice/repository/CapabilityImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java	2007-09-18 19:28:44 UTC (rev 65457)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.repository;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.repository.Capability;
+import org.jboss.profileservice.spi.repository.Repository;
+import org.jboss.profileservice.spi.repository.Requirement;
+import org.jboss.profileservice.spi.repository.Resource;
+import org.jboss.profileservice.spi.repository.Version;
+
+/**
+ * TODO: scan deployment for manifest with osgi header info like
+ * the version, requirements.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class VFSDeploymentResource
+   implements Resource
+{
+   private VFSDeployment deployment;
+   private Repository repository;
+   private String[] categories = {};
+   private Capability[] capabilities;
+   private Map<String, Object> props;
+
+   public VFSDeploymentResource(VFSDeployment deployment, DeploymentPhase phase,
+         Repository repository)
+   {
+      this.deployment = deployment;
+      this.repository = repository;
+      CapabilityImpl ci = new CapabilityImpl("deployment");
+      ci.addProperty("phase", phase);
+      this.capabilities = new Capability[]{ci};
+      this.props = Collections.singletonMap("deployment", (Object)deployment);
+   }
+
+   public Capability[] getCapabilities()
+   {
+      return capabilities;
+   }
+
+   public String[] getCategories()
+   {
+      return categories;
+   }
+
+   public String getId()
+   {
+      return deployment.getName();
+   }
+
+   public String getPresentationName()
+   {
+      return deployment.getSimpleName();
+   }
+
+   public Map getProperties()
+   {
+      return props;
+   }
+
+   public Repository getRepository()
+   {
+      return repository;
+   }
+
+   public Requirement[] getRequirements()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public String getSymbolicName()
+   {
+      return deployment.getName();
+   }
+
+   public URI getURI()
+   {
+      URI uri = null;
+      try
+      {
+         uri = deployment.getRoot().toURI();
+      }
+      catch(Exception e)
+      {
+         throw new IllegalStateException(e);
+      }
+      return uri;
+   }
+
+   public Version getVersion()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }  
+}


Property changes on: trunk/system/src/main/org/jboss/system/server/profileservice/repository/VFSDeploymentResource.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list