svn commit: rev 22402 - avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Wed Jun 30 22:07:39 2004
New Revision: 22402

Modified:
   avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
Log:
Update meta-data gene4rator to support unified artifact protocol on import declarations.

Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java	(original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/data/builder/XMLContainmentProfileCreator.java	Wed Jun 30 22:07:39 2004
@@ -263,19 +263,50 @@
 
         return (Artifact[]) list.toArray( new Artifact[0] );
     }
-
+
+   /**
+    * Convert a configuration fragement with an 'artifact' or 'id' 
+    * attribute to an Artifact instance.
+    */
     private Artifact createResourceDirective( Configuration config )
        throws ConfigurationException
-    {
-        String id = config.getAttribute( "id" );
-        String version = config.getAttribute( "version", null );
-        if( version == null )
-        {
-            return Artifact.createArtifact( id );
-        }
-        else
+    {
+        String spec = config.getAttribute( "artifact", null );
+        if( null != spec )
+        {
+            //
+            // we are dealing with the new artifact protocol
+            // within which the # identifies the version
+            //
+ 
+            return Artifact.createArtifact( spec );
+        }
+        else
         {
-            return Artifact.createArtifact( id + ";" + version );
+            String id = config.getAttribute( "id", null );
+            if( null == id )
+            {
+                final String error = 
+                  "Missing 'artifact' or 'id' attribute.";
+                throw new ConfigurationException( error );
+            }
+            else
+            {
+                //
+                // check for the depricated version attribute and use
+                // the depricated technical of [group]:[name];[version]
+                //
+
+                String version = config.getAttribute( "version", null );
+                if( version == null )
+                {
+                    return Artifact.createArtifact( id );
+                }
+                else
+                {
+                    return Artifact.createArtifact( id + ";" + version );
+                }
+            }
         }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.