You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/07/01 07:05:40 UTC

svn commit: rev 22400 - avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks

Author: mcconnell
Date: Wed Jun 30 22:05:40 2004
New Revision: 22400

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
Log:
Add the "spec" feature to the property task and update the block task to handle the declaration of imports.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	Wed Jun 30 22:05:40 2004
@@ -48,20 +48,25 @@
     private static final String MAIN = "main";
     private static final String TEST = "test";
 
-    public static class Component
+    public static class Identifiable
     {
         private String m_name;
-        private String m_classname;
-        private String m_profile;
 
-        public Component()
+        public void setName( final String name )
         {
+            m_name = name;
         }
 
-        public void setName( final String name )
+        public String getName()
         {
-            m_name = name;
+            return m_name;
         }
+    }
+
+    public static class Component extends Identifiable
+    {
+        private String m_classname;
+        private String m_profile;
 
         public void setClass( final String classname )
         {
@@ -73,11 +78,6 @@
             m_profile = profile;
         }
 
-        public String getName()
-        {
-            return m_name;
-        }
-
         public String getClassname()
         {
             return m_classname;
@@ -89,9 +89,24 @@
         }
     }
 
+    public static class Include extends Identifiable
+    {
+        private String m_artifact;
+
+        public void setArtifact( final String spec )
+        {
+            m_artifact = spec;
+        }
+
+        public String getArtifact()
+        {
+            return m_artifact;
+        }
+    }
+
     private String m_target;
     private String m_container;
-    private List m_components = new ArrayList();
+    private List m_content = new ArrayList();
     private boolean m_standalone = true;
 
     public void setName( final String name )
@@ -173,10 +188,17 @@
     public Component createComponent()
     {
         final Component component = new Component();
-        m_components.add( component );
+        m_content.add( component );
         return component;
     }
 
+    public Include createInclude()
+    {
+        final Include include = new Include();
+        m_content.add( include );
+        return include;
+    }
+
     public void init()
     {
         super.init();
@@ -208,12 +230,19 @@
         writer.write( "\n  </classloader>" );
         writer.write( "\n" );
 
-        Component[] components = 
-          (Component[]) m_components.toArray( new Component[0] );
+        Identifiable[] components = 
+          (Identifiable[]) m_content.toArray( new Identifiable[0] );
         for( int i=0; i<components.length; i++ )
         {
-            Component component = components[i];
-            writeComponent( writer, component );
+            Identifiable identifiable = components[i];
+            if( identifiable instanceof Component )
+            {
+                writeComponent( writer, (Component) identifiable );
+            }
+            else if( identifiable instanceof Include )
+            {
+                writeInclude( writer, (Include) identifiable );
+            }
         }
 
         writer.write( "\n</container>\n" );
@@ -235,5 +264,14 @@
               + component.getProfile() + "\"\n    class=\""
               + component.getClassname() + "\"/>\n" );
         }
+    }
+
+    private void writeInclude( final Writer writer, final Include include )
+        throws IOException
+    {
+        writer.write( 
+          "\n  <include name=\"" 
+          + include.getName() + "\" artifact=\"" 
+          + include.getArtifact() + "\"/>\n" );
     }
 }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	Wed Jun 30 22:05:40 2004
@@ -114,6 +114,10 @@
         {
             return resource.getInfo().getURI();
         }
+        else if( m_feature.equals( "spec" ) )
+        {
+            return resource.getInfo().getSpec();
+        }
         else if( resource instanceof Definition )
         {
             final Definition def = (Definition) resource;

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org