Skip to Content.
Sympa Menu

notify-dpml - r1133 - in trunk/main/depot: library/common/etc/main/net/dpml/library library/common/etc/test library/common/etc/test/dpml library/common/src/main/net/dpml/library/impl library/common/src/test/net/dpml/library/impl library/common/src/test/net/dpml/library/info tools/builder/src/main/net/dpml/tools/tasks

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1133 - in trunk/main/depot: library/common/etc/main/net/dpml/library library/common/etc/test library/common/etc/test/dpml library/common/src/main/net/dpml/library/impl library/common/src/test/net/dpml/library/impl library/common/src/test/net/dpml/library/info tools/builder/src/main/net/dpml/tools/tasks
  • Date: Fri, 24 Feb 2006 16:30:06 +0100

Author: mcconnell
Date: 2006-02-24 16:30:02 +0100 (Fri, 24 Feb 2006)
New Revision: 1133

Added:

trunk/main/depot/library/common/src/test/net/dpml/library/impl/ExportTestCase.java
Removed:

trunk/main/depot/library/common/src/test/net/dpml/library/info/BuilderTestCase.java
Modified:
trunk/main/depot/library/common/etc/main/net/dpml/library/library_1_0.dtd
trunk/main/depot/library/common/etc/test/dpml/module.xml
trunk/main/depot/library/common/etc/test/library.xml

trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultLibrary.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java

trunk/main/depot/library/common/src/main/net/dpml/library/impl/ModuleBuilder.java

trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultModuleTestCase.java

trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ModuleTask.java
Log:
complete read/write of exported modules using DTD-based XML schema

Modified:
trunk/main/depot/library/common/etc/main/net/dpml/library/library_1_0.dtd
===================================================================
--- trunk/main/depot/library/common/etc/main/net/dpml/library/library_1_0.dtd
2006-02-23 22:08:07 UTC (rev 1132)
+++ trunk/main/depot/library/common/etc/main/net/dpml/library/library_1_0.dtd
2006-02-24 15:30:02 UTC (rev 1133)
@@ -18,12 +18,10 @@
<!ELEMENT library ( imports?, properties?, modules? ) >

<!ELEMENT imports ( import* ) >
-
-<!ELEMENT modules ( module* ) >
-
<!ELEMENT import EMPTY >
<!ATTLIST import uri CDATA #REQUIRED >

+<!ELEMENT modules ( module* ) >
<!ELEMENT module ( properties?, types?, dependencies*, module*, project*,
resource* ) >
<!ATTLIST module name CDATA #IMPLIED >
<!ATTLIST module basedir CDATA #IMPLIED >
@@ -31,13 +29,11 @@
<!ATTLIST module version CDATA #IMPLIED >

<!ELEMENT types ( type* ) >
-
<!ELEMENT type ( property* ) >
<!ATTLIST type id CDATA #REQUIRED >
<!ATTLIST type alias CDATA #IMPLIED >

<!ELEMENT properties ( property* ) >
-
<!ELEMENT property EMPTY >
<!ATTLIST property name CDATA #REQUIRED >
<!ATTLIST property value CDATA #REQUIRED >

Modified: trunk/main/depot/library/common/etc/test/dpml/module.xml
===================================================================
--- trunk/main/depot/library/common/etc/test/dpml/module.xml 2006-02-23
22:08:07 UTC (rev 1132)
+++ trunk/main/depot/library/common/etc/test/dpml/module.xml 2006-02-24
15:30:02 UTC (rev 1133)
@@ -15,10 +15,6 @@

<module name="util" basedir="util">

- <dependencies scope="build">
- <include key="transit"/>
- </dependencies>
-
<project name="dpml-i18n" basedir="i18n">
<types>
<type id="jar"/>
@@ -28,98 +24,95 @@
</dependencies>
</project>

- </module>
-
- <module name="transit">
-
- <properties>
- <property name="project.test.fork" value="true"/>
- </properties>
-
- <project name="dpml-transit-main" basedir="transit/core/handler">
- <properties>
- <property name="project.template" value="${basedir}/build.xml"/>
- </properties>
+ <project name="dpml-activity-api" basedir="activity">
<types>
<type id="jar"/>
</types>
- <dependencies scope="TEST">
- <include ref="ant/ant-junit"/>
- </dependencies>
</project>

- <project name="dpml-transit-tools" basedir="transit/core/tools">
- <properties>
- <property name="project.template" value="${basedir}/build.xml"/>
- </properties>
+ <project name="dpml-logging-api" basedir="logging">
<types>
<type id="jar"/>
</types>
- <dependencies scope="RUNTIME">
- <include key="dpml-transit-main"/>
- <include ref="ant/ant"/>
- </dependencies>
- <dependencies scope="TEST">
- <include ref="ant/ant-junit"/>
- </dependencies>
</project>

- </module>
-
- <module name="metro" basedir="metro">
-
- <project name="dpml-activity-api" basedir="activity">
+ <project name="dpml-configuration-api" basedir="configuration/api">
<types>
<type id="jar"/>
</types>
</project>

- <project name="dpml-logging-api" basedir="logging">
+ <project name="dpml-configuration-impl" basedir="configuration/impl">
<types>
<type id="jar"/>
</types>
<dependencies>
- <include ref="dpml/transit/dpml-transit-main"/>
+ <include key="dpml-configuration-api"/>
</dependencies>
+ <dependencies scope="test">
+ <include ref="ant/ant-junit"/>
+ </dependencies>
</project>

- <project name="dpml-configuration-api" basedir="configuration/api">
+ <project name="dpml-parameters-api" basedir="parameters/api">
<types>
<type id="jar"/>
</types>
</project>

- <project name="dpml-configuration-impl" basedir="configuration/impl">
+ <project name="dpml-parameters-impl" basedir="parameters/impl">
<types>
<type id="jar"/>
</types>
<dependencies>
- <include key="dpml-configuration-api"/>
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-configuration-api" tag="private"/>
</dependencies>
<dependencies scope="test">
<include ref="ant/ant-junit"/>
</dependencies>
</project>

- <project name="dpml-parameters-api" basedir="parameters/api">
+ </module>
+
+ <module name="transit">
+
+ <properties>
+ <property name="project.test.fork" value="true"/>
+ </properties>
+
+ <project name="dpml-transit-main" basedir="transit/core/handler">
+ <properties>
+ <property name="project.template" value="${basedir}/build.xml"/>
+ </properties>
<types>
<type id="jar"/>
</types>
+ <dependencies scope="TEST">
+ <include ref="ant/ant-junit"/>
+ </dependencies>
</project>

- <project name="dpml-parameters-impl" basedir="parameters/impl">
+ <project name="dpml-transit-tools" basedir="transit/core/tools">
+ <properties>
+ <property name="project.template" value="${basedir}/build.xml"/>
+ </properties>
<types>
<type id="jar"/>
</types>
- <dependencies>
- <include key="dpml-parameters-api"/>
- <include key="dpml-configuration-api" tag="private"/>
+ <dependencies scope="RUNTIME">
+ <include key="dpml-transit-main"/>
+ <include ref="ant/ant"/>
</dependencies>
- <dependencies scope="test">
+ <dependencies scope="TEST">
<include ref="ant/ant-junit"/>
</dependencies>
</project>

+ </module>
+
+ <module name="metro" basedir="metro">
+
<project name="dpml-state-api" basedir="state/api">
<types>
<type id="jar"/>
@@ -138,7 +131,7 @@
</types>
<dependencies>
<include key="dpml-state-api" tag="public"/>
- <include key="dpml-configuration-impl"/>
+ <include ref="dpml/util/dpml-configuration-impl"/>
</dependencies>
<dependencies scope="test">
<include ref="ant/ant-junit"/>
@@ -173,16 +166,16 @@
<type id="jar"/>
</types>
<dependencies>
+ <include ref="dpml/util/dpml-parameters-api" tag="public"/>
+ <include ref="dpml/util/dpml-configuration-api" tag="public"/>
<include key="dpml-state-api" tag="public"/>
- <include key="dpml-parameters-api" tag="public"/>
- <include key="dpml-configuration-api" tag="public"/>
<include key="dpml-part-api" tag="public"/>
</dependencies>
<dependencies scope="test">
<include ref="ant/ant-junit"/>
<include key="dpml-state-impl"/>
- <include key="dpml-parameters-impl"/>
- <include key="dpml-configuration-impl"/>
+ <include ref="dpml/util/dpml-parameters-impl"/>
+ <include ref="dpml/util/dpml-configuration-impl"/>
</dependencies>
</project>

@@ -230,11 +223,11 @@
</type>
</types>
<dependencies>
- <include key="dpml-logging-api" tag="public"/>
- <include key="dpml-activity-api" tag="public"/>
+ <include ref="dpml/util/dpml-logging-api" tag="public"/>
+ <include ref="dpml/util/dpml-activity-api" tag="public"/>
+ <include ref="dpml/util/dpml-parameters-impl"/>
+ <include ref="dpml/util/dpml-configuration-impl"/>
<include key="dpml-component-control" tag="protected"/>
- <include key="dpml-parameters-impl"/>
- <include key="dpml-configuration-impl"/>
<include key="dpml-state-impl"/>
</dependencies>
</project>
@@ -268,7 +261,7 @@
<type id="jar"/>
</types>
<dependencies>
- <include key="dpml-logging-api"/>
+ <include ref="dpml/util/dpml-logging-api"/>
</dependencies>
<dependencies scope="test">
<include key="dpml-metro-tools"/>

Modified: trunk/main/depot/library/common/etc/test/library.xml
===================================================================
--- trunk/main/depot/library/common/etc/test/library.xml 2006-02-23
22:08:07 UTC (rev 1132)
+++ trunk/main/depot/library/common/etc/test/library.xml 2006-02-24
15:30:02 UTC (rev 1133)
@@ -9,14 +9,6 @@
<property name="project.template" value="${project.standard.template}"/>
</properties>

- <!--
- <builder uri="link:plugin:dpml/tools/dpml-tools-builder">
- <parameters>
- <param value="abc"/>
- </parameters>
- </builder>
- -->
-
<modules>
<module file="junit/module.xml"/>
<module file="commons-cli/module.xml"/>

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultLibrary.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultLibrary.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultLibrary.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -51,6 +51,8 @@
*/
public final class DefaultLibrary extends DefaultDictionary implements
Library
{
+ private static final ModuleBuilder BUILDER = new ModuleBuilder();
+
private final LibraryDirective m_directive;
private final DefaultModule m_module;
private final DefaultModule m_imports;
@@ -112,8 +114,10 @@
URI uri = new URI( path );
getLogger().debug( "loading external import: " + uri );
URL url = Artifact.createArtifact( uri ).toURL();
- InputStream input = url.openStream();
- importModuleDirectives[i] =
LibraryDirectiveBuilder.buildModuleDirective( input );
+ importModuleDirectives[i] = BUILDER.load( url );
+
+ //InputStream input = url.openStream();
+ //importModuleDirectives[i] =
LibraryDirectiveBuilder.buildModuleDirective( input );
}
}
DefaultModule[] importModules = new DefaultModule[
importModuleDirectives.length ];

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/DefaultResource.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -462,6 +462,15 @@
}

/**
+ * Return the underlying resource defintion.
+ * @return the resource directive
+ */
+ public ResourceDirective getResourceDirective()
+ {
+ return m_directive;
+ }
+
+ /**
* Return a directive suitable for publication as an external description.
* @param module the enclosing module
* @return the resource directive
@@ -478,20 +487,32 @@
String version = getVersion();
String basedir = null;
TypeDirective[] types = m_directive.getTypeDirectives();
+ DependencyDirective[] dependencies = createDeps( module );
+ Properties properties = getExportProperties();
+ return new ResourceDirective(
+ name, version, Classifier.EXTERNAL, basedir,
+ types, dependencies, properties );
+ }
+
+ private DependencyDirective[] createDeps( DefaultModule module )
+ {
ArrayList list = new ArrayList();
createIncludeDirectives( module, list, Category.SYSTEM );
createIncludeDirectives( module, list, Category.PUBLIC );
createIncludeDirectives( module, list, Category.PROTECTED );
createIncludeDirectives( module, list, Category.PRIVATE );
- IncludeDirective[] includes =
- (IncludeDirective[]) list.toArray( new IncludeDirective[0] );
- DependencyDirective runtime =
- new DependencyDirective( Scope.RUNTIME, includes );
- DependencyDirective[] dependencies = new
DependencyDirective[]{runtime};
- Properties properties = getExportProperties();
- return new ResourceDirective(
- name, version, Classifier.EXTERNAL, basedir,
- types, dependencies, properties );
+ if( list.size() == 0 )
+ {
+ return new DependencyDirective[0];
+ }
+ else
+ {
+ IncludeDirective[] includes =
+ (IncludeDirective[]) list.toArray( new IncludeDirective[0] );
+ DependencyDirective runtime =
+ new DependencyDirective( Scope.RUNTIME, includes );
+ return new DependencyDirective[]{runtime};
+ }
}

boolean isaDescendant( DefaultModule module )

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/LibraryDirectiveBuilder.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -290,6 +290,7 @@
* @return the module directive
* @exception Exception if an exception occurs
*/
+ /*
public static ModuleDirective buildModuleDirective( InputStream input )
throws Exception
{
final ClassLoader loader =
Thread.currentThread().getContextClassLoader();
@@ -314,6 +315,7 @@
input.close();
}
}
+ */

/**
* Build a module using an XML element.

Modified:
trunk/main/depot/library/common/src/main/net/dpml/library/impl/ModuleBuilder.java
===================================================================
---
trunk/main/depot/library/common/src/main/net/dpml/library/impl/ModuleBuilder.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/main/net/dpml/library/impl/ModuleBuilder.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -180,7 +180,7 @@
Properties properties = module.getProperties();
String basedir = module.getBasedir();
TypeDirective[] types = module.getTypeDirectives();
- DependencyDirective[] dependencies = new DependencyDirective[0];
+ DependencyDirective[] dependencies =
module.getDependencyDirectives();
ResourceDirective[] resources = module.getResourceDirectives();

writer.write( "\n" + lead + "<" + NAME );
@@ -301,8 +301,13 @@
if( properties.size() > 0 )
{
writer.write( ">" );
- writeProperties( writer, properties, lead + " ", false
);
+ writeProperties( writer, properties, lead + " ",
false );
+ writer.write( "\n" + lead + " </type>" );
}
+ else
+ {
+ writer.write( "/>" );
+ }
}
writer.write( "\n" + lead + "</types>" );
}

Modified:
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultModuleTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultModuleTestCase.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultModuleTestCase.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -48,7 +48,7 @@
{
Module metro = getLibrary().getModule( "dpml/metro" );
Resource[] resources = metro.getResources();
- assertEquals( "nested-expanded-resource-count", 15, resources.length
);
+ assertEquals( "nested-expanded-resource-count", 9, resources.length
);
}

/**

Modified:
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/impl/DefaultResourceTestCase.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -349,7 +349,7 @@
*/
public void testClassloaderChainConstruction() throws Exception
{
- doClasspathChainTest( "dpml/metro/dpml-composition-runtime", 0, 3,
6, 3 );
+ doClasspathChainTest( "dpml/metro/dpml-composition-runtime", 0, 2,
7, 3 );
doClasspathChainTest( "dpml/tools/dpml-tools-ant", 4, 0, 0, 5 );
doClasspathChainTest( "dpml/transit/dpml-transit-tools", 0, 0, 0, 3
);
}
@@ -363,7 +363,7 @@
String path = "dpml/transit/dpml-transit-main";
Resource resource = getLibrary().getResource( path );
Resource[] consumers = resource.getConsumers( false, false );
- assertEquals( "consumer-count", 6, consumers.length );
+ assertEquals( "consumer-count", 5, consumers.length );
}

/**
@@ -375,7 +375,7 @@
String path = "dpml/transit/dpml-transit-main";
Resource resource = getLibrary().getResource( path );
Resource[] consumers = resource.getConsumers( true, true );
- assertEquals( "consumer-count", 20, consumers.length );
+ assertEquals( "consumer-count", 18, consumers.length );
}


//-------------------------------------------------------------------------------
@@ -414,7 +414,7 @@
int j = chain.length;
if( n > -1 )
{
- assertEquals( "chain-length", n, j );
+ assertEquals( "chain-length in " + path, n, j );
}
else
{

Added:
trunk/main/depot/library/common/src/test/net/dpml/library/impl/ExportTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/impl/ExportTestCase.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/impl/ExportTestCase.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * 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 net.dpml.library.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import net.dpml.library.model.Module;
+import net.dpml.library.model.Resource;
+import net.dpml.library.model.Type;
+import net.dpml.library.info.ModuleDirective;
+import net.dpml.library.info.ResourceDirective;
+
+/**
+ * Test DefaultLibrary implementation.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ExportTestCase extends AbstractTestCase
+{
+ /**
+ * Test library properties.
+ */
+ public void testExport() throws Exception
+ {
+ String spec = "dpml";
+ Module module = getLibrary().getModule( spec );
+ ModuleDirective directive = module.export();
+ ModuleBuilder builder = new ModuleBuilder();
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File export = new File( test, "export.xml" );
+ builder.write( directive, new FileOutputStream( export ) );
+ ModuleDirective result = builder.load( export.toURL() );
+ assertEquals( "export", directive, result );
+ }
+
+ /*
+ private void compareModuleDirective( ModuleDirective a, ModuleDirective
b )
+ {
+ ResourceDirective[] ar = a.getResourceDirectives();
+ ResourceDirective[] br = b.getResourceDirectives();
+ for( int i=0; i<ar.length; i++ )
+ {
+ ResourceDirective r = ar[i];
+ ResourceDirective rx = br[i];
+ boolean equal = r.equals( rx );
+ if( !equal )
+ {
+ compareResourceDirective( r, rx );
+ }
+ }
+ }
+
+ private void compareResourceDirective( ResourceDirective a,
ResourceDirective b )
+ {
+ System.out.println( a.getName() + " is not equal" );
+ if( a instanceof ModuleDirective )
+ {
+ compareModuleDirective( (ModuleDirective) a, (ModuleDirective) b
);
+ }
+
+ if( !a.getName().equals( b.getName() ) )
+ {
+ System.out.println( "different names" );
+ }
+ if( !a.getVersion().equals( b.getVersion() ) )
+ {
+ System.out.println( "different versions" );
+ }
+ if( !a.getClassifier().equals( b.getClassifier() ) )
+ {
+ System.out.println( "different classifiers" );
+ }
+ if( a.getTypeDirectives().length != b.getTypeDirectives().length )
+ {
+ System.out.println( "different types length" );
+ }
+ if( a.getDependencyDirectives().length !=
b.getDependencyDirectives().length )
+ {
+ System.out.println( "different dependency length in " +
a.getName() );
+ System.out.println( "A: " + a.getDependencyDirectives().length );
+ System.out.println( "B: " + b.getDependencyDirectives().length );
+ }
+ }
+ */
+}

Deleted:
trunk/main/depot/library/common/src/test/net/dpml/library/info/BuilderTestCase.java
===================================================================
---
trunk/main/depot/library/common/src/test/net/dpml/library/info/BuilderTestCase.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/library/common/src/test/net/dpml/library/info/BuilderTestCase.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell
- *
- * 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 net.dpml.library.info;
-
-import java.io.File;
-import java.io.FileOutputStream;
-
-import net.dpml.library.impl.ModuleBuilder;
-
-/**
- * The ModuleDirective class describes a module data-structure.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class BuilderTestCase extends AbstractTestCase
-{
- public void testReadWrite() throws Exception
- {
- ModuleBuilder builder = new ModuleBuilder();
- String testPath = System.getProperty( "project.test.dir" );
- File test = new File( testPath );
- File file = new File( test, "dpml/module.xml" );
- ModuleDirective module = builder.load( file.toURL() );
-
- File destination = new File( test, "externalization.xml" );
- builder.write( module, new FileOutputStream( destination ) );
- }
-}

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ModuleTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ModuleTask.java
2006-02-23 22:08:07 UTC (rev 1132)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/ModuleTask.java
2006-02-24 15:30:02 UTC (rev 1133)
@@ -30,12 +30,13 @@
import net.dpml.library.model.Module;
import net.dpml.library.info.Scope;
import net.dpml.library.info.ModuleDirective;
+import net.dpml.library.impl.ModuleBuilder;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;

/**
- * Execute all plugins relative to the current build phase.
+ * Write a module to XML in a form suitable for publication.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -88,27 +89,30 @@

private void writeModuleDirective( ModuleDirective directive, File file )
{
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
ModuleDirective.class.getClassLoader() );
+ //ClassLoader current =
Thread.currentThread().getContextClassLoader();
+ //Thread.currentThread().setContextClassLoader(
ModuleDirective.class.getClassLoader() );
FileOutputStream output = null;
try
{
log( "Exporting module to: " + file );
+ ModuleBuilder builder = new ModuleBuilder();
file.getParentFile().mkdirs();
output = new FileOutputStream( file );
- final BufferedOutputStream buffer = new BufferedOutputStream(
output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setExceptionListener( new ModuleEncoderListener() );
- try
- {
- encoder.writeObject( directive );
+ builder.write( directive, output );
+
+ //final BufferedOutputStream buffer = new BufferedOutputStream(
output );
+ //XMLEncoder encoder = new XMLEncoder( buffer );
+ //encoder.setExceptionListener( new ModuleEncoderListener() );
+ //try
+ //{
+ // encoder.writeObject( directive );
checksum( file );
asc( file );
- }
- finally
- {
- encoder.close();
- }
+ //}
+ //finally
+ //{
+ // encoder.close();
+ //}
}
catch( Exception e )
{
@@ -118,7 +122,7 @@
}
finally
{
- Thread.currentThread().setContextClassLoader( current );
+ //Thread.currentThread().setContextClassLoader( current );
if( null != output )
{
try
@@ -131,59 +135,4 @@
}
}
}
-
- /**
- * Encoding listener.
- */
- private class ModuleEncoderListener implements ExceptionListener
- {
- /**
- * Monitor a thrown exception.
- * @param e the exception
- */
- public void exceptionThrown( Exception e )
- {
- Throwable cause = e.getCause();
- if( null != cause )
- {
- if( cause instanceof EncodingRuntimeException )
- {
- EncodingRuntimeException ere =
(EncodingRuntimeException) cause;
- throw ere;
- }
- else
- {
- final String error =
- "An error occured while attempting to encode module ["
- + getResource().getResourcePath()
- + "]\nCause: " + cause.toString();
- throw new EncodingRuntimeException( error, cause );
- }
- }
- else
- {
- final String error =
- "An unexpected error occured while attempting to encode
the type ["
- + getResource().getResourcePath()
- + "] due to: " + e.toString();
- throw new EncodingRuntimeException( error, e );
- }
- }
- }
-
- /**
- * Encoding runtime exception.
- */
- private static class EncodingRuntimeException extends RuntimeException
- {
- /**
- * Create a new encoding runtime exception.
- * @param message the message
- * @param cause the causal exception
- */
- public EncodingRuntimeException( String message, Throwable cause )
- {
- super( message, cause );
- }
- }
}




  • r1133 - in trunk/main/depot: library/common/etc/main/net/dpml/library library/common/etc/test library/common/etc/test/dpml library/common/src/main/net/dpml/library/impl library/common/src/test/net/dpml/library/impl library/common/src/test/net/dpml/library/info tools/builder/src/main/net/dpml/tools/tasks, mcconnell at BerliOS, 02/24/2006

Archive powered by MHonArc 2.6.24.

Top of Page