svn commit: rev 22404 - in avalon/trunk/tools/magic: . src/main/org/apache/avalon/tools/model src/main/org/apache/avalon/tools/tasks

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Wed Jun 30 23:43:48 2004
New Revision: 22404

Modified:
   avalon/trunk/tools/magic/build.properties
   avalon/trunk/tools/magic/build.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
Log:
Improve the management of import tags to eliminate duplicate import scenarios.

Modified: avalon/trunk/tools/magic/build.properties
==============================================================================
--- avalon/trunk/tools/magic/build.properties	(original)
+++ avalon/trunk/tools/magic/build.properties	Wed Jun 30 23:43:48 2004
@@ -1,3 +1,4 @@
 #project.name = avalon-tools-magic
-project.home = ../../central/system
+project.home = ..
+project.system = ../../central/system
 

Modified: avalon/trunk/tools/magic/build.xml
==============================================================================
--- avalon/trunk/tools/magic/build.xml	(original)
+++ avalon/trunk/tools/magic/build.xml	Wed Jun 30 23:43:48 2004
@@ -4,7 +4,7 @@
     xmlns:x="antlib:org.apache.avalon.tools">
 
   <property file="build.properties"/>
-  <import file="${project.home}/build/standard.xml"/>
+  <import file="${project.system}/build/standard.xml"/>
 
   <target name="javadoc" depends="prepare">
     <x:javadoc title="Avalon Magic" id="avalon-tools-magic">

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	Wed Jun 30 23:43:48 2004
@@ -74,7 +74,6 @@
     protected Home( Project project, Magic system, File index )
     {
         setProject( project );
-        project.log( "index: " + index );
         m_index = index;
         m_system = system;
         buildList( index );
@@ -214,6 +213,14 @@
 
         File source = resolveIndex( index );
 
+        if( m_includes.contains( source.toString() ) )
+        {
+            return;
+        }
+
+        m_includes.add( source.toString() );
+        log( "import: " + source );
+
         try
         {
             final Element root = ElementHelper.getRootElement( source );
@@ -264,12 +271,7 @@
                 if(( null != filename ) && ( !"".equals( filename )))
                 {
                     final File index = Context.getFile( anchor, filename );
-                    if( !m_includes.contains( index.toString() ) )
-                    {
-                        m_includes.add( index );
-                        log( "import: " + index );
-                        buildList( index );
-                    }
+                    buildList( index );
                 }
                 else if(( null != path ) && ( !"".equals( path )))
                 {

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 23:43:48 2004
@@ -104,10 +104,37 @@
         }
     }
 
+    public static class Service
+    {
+        private String m_type;
+        private String m_source;
+
+        public void setType( final String type )
+        {
+            m_type = type;
+        }
+
+        public String getType()
+        {
+            return m_type;
+        }
+
+        public void setSource( final String source )
+        {
+            m_source = source;
+        }
+
+        public String getSource()
+        {
+            return m_source;
+        }
+    }
+
     private String m_target;
     private String m_container;
     private List m_content = new ArrayList();
     private boolean m_standalone = true;
+    private Service m_service;
 
     public void setName( final String name )
     {
@@ -199,6 +226,21 @@
         return include;
     }
 
+    public Service createService()
+    {
+        if( null == m_service )
+        {
+            m_service = new Service();
+            return m_service;
+        }
+        else
+        {
+            final String error = 
+              "Multiple service export not supported nor recomended.";
+            throw new BuildException( error );
+        }
+    }
+
     public void init()
     {
         super.init();
@@ -224,6 +266,12 @@
         final Info info = def.getInfo();
 
         writer.write( "\n\n<container name=\"" + getName( def ) + "\">" );
+
+        if( null != m_service )
+        {
+            writeService( writer, m_service );
+        }
+
         writer.write( "\n\n  <classloader>" );
         boolean standalone = (null == m_target);
         writeClasspath( writer, def, "    ", standalone );
@@ -273,5 +321,15 @@
           "\n  <include name=\"" 
           + include.getName() + "\" artifact=\"" 
           + include.getArtifact() + "\"/>\n" );
+    }
+
+    private void writeService( final Writer writer, final Service service )
+        throws IOException
+    {
+        writer.write( "\n  <services>" );
+        writer.write( "\n    <service type=\"" + service.getType() + "\">" );
+        writer.write( "\n      <source>" + service.getSource() + "</source>" );
+        writer.write( "\n    </service>" );
+        writer.write( "\n  </services>" );
     }
 }
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.