Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2156 - in development/main/metro: . composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/impl/src/main/net/dpml/composition/model/impl meta/api/src/main/net/dpml/meta/info meta/impl/src/main/net/dpml/meta/info/builder/impl meta/spi/src/main/net/dpml/meta/info/builder

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2156 - in development/main/metro: . composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/impl/src/main/net/dpml/composition/model/impl meta/api/src/main/net/dpml/meta/info meta/impl/src/main/net/dpml/meta/info/builder/impl meta/spi/src/main/net/dpml/meta/info/builder
  • Date: Sun, 27 Mar 2005 13:14:54 -0500

Author: mcconnell AT dpml.net
Date: Sun Mar 27 13:14:52 2005
New Revision: 2156

Added:

development/main/metro/meta/spi/src/main/net/dpml/meta/info/builder/TypeHolder.java
Modified:

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
development/main/metro/index.xml

development/main/metro/meta/api/src/main/net/dpml/meta/info/ContextDescriptor.java

development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/SerializedTypeCreator.java
Log:
1. Add a TypeHolder with tagged handler.
2. Fix javadoc in construction exception
3. housekeeping
4. update the TypeBuilderTask so that is is not executable as a standalone
task
5. update TypesTask to create serialized TypeHolder instead of
TypeBuilderTask.java
6. imporve container model loading of parts

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
Sun Mar 27 13:14:52 2005
@@ -20,6 +20,7 @@

import java.io.File;
import java.io.Serializable;
+import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -72,6 +73,7 @@

import net.dpml.meta.info.Type;
import net.dpml.meta.info.InfoDescriptor;
+import net.dpml.meta.info.builder.TypeHolder;

import net.dpml.parameters.Parameters;
import net.dpml.parameters.impl.DefaultParameters;
@@ -371,6 +373,9 @@
dependencies, parameters, configuration, mode );
}

+ /**
+ * TODO: move this to a part controller
+ */
private Type loadType( ClassLoader classloader, String classname )
{
String path = classname.replace( '.', '/' ) + ".type";
@@ -383,7 +388,11 @@
throw new TypeNotFoundException( url.toString() );
}
ObjectInputStream stream = new ObjectInputStream( input );
- return (Type) stream.readObject();
+ TypeHolder holder = (TypeHolder) stream.readObject();
+ byte[] bytes = holder.getByteArray();
+ ByteArrayInputStream byteinput = new ByteArrayInputStream( bytes
);
+ ObjectInputStream bytestream = new ObjectInputStream( byteinput
);
+ return (Type) bytestream.readObject();
}
catch( Exception e )
{

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java
Sun Mar 27 13:14:52 2005
@@ -64,6 +64,7 @@
/**
* Creation of a new construction exception.
* @param message the exception message
+ * @param cause the causal exception
* @param location location of the task
*/
public ConstructionException( String message, Throwable cause, Location
location )

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
Sun Mar 27 13:14:52 2005
@@ -28,7 +28,6 @@
import java.io.ObjectOutputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.rmi.MarshalledObject;
import java.util.Arrays;
import java.util.Properties;
import java.util.List;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
Sun Mar 27 13:14:52 2005
@@ -154,51 +154,10 @@

public void execute()
{
- Project project = getProject();
- Path path = getDefinition().getPath( project, Policy.RUNTIME );
- File classes = getContext().getClassesDirectory();
- path.createPathElement().setLocation( classes );
- ClassLoader classloader = new AntClassLoader( project, path );
- Class subject = loadSubjectClass( classloader );
- String resource = getEmbeddedResourcePath( subject );
- File file = getEmbeddedOutputFile( resource );
- try
- {
- Type type = buildType( subject );
- SerializableObjectHelper.write( type, file );
- }
- catch( IOException ioe )
- {
- final String error =
- "Internal error while attempting to write type to file ["
- + file
- + "]";
- throw new BuildException( error, ioe, getLocation() );
- }
- catch( IntrospectionException e )
- {
- final String error =
- "Introdspection error while attempting to construct type ["
- + m_classname
- + "]. "
- + e.getMessage();
- throw new BuildException( error, e, getLocation() );
- }
- }
-
- private String getEmbeddedResourcePath( Class subject )
- {
- String classname = subject.getName();
- String path = classname.replace( '.', '/' );
- String filename = path + ".type";
- return filename;
- }
-
- private File getEmbeddedOutputFile( String filename )
- {
- File classes = getContext().getClassesDirectory();
- File destination = new File( classes, filename );
- return destination;
+ final String error =
+ "The type builder task does not support standalone operation. "
+ + "Please use the 'types' task instead.";
+ throw new UnsupportedOperationException( error );
}

//---------------------------------------------------------------

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
Sun Mar 27 13:14:52 2005
@@ -27,7 +27,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.URI;
-import java.rmi.MarshalledObject;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Properties;
import java.util.List;
@@ -35,6 +35,7 @@
import java.util.ArrayList;

import net.dpml.meta.info.Type;
+import net.dpml.meta.info.builder.TypeHolder;

import net.dpml.builder.IntrospectionException;

@@ -54,7 +55,7 @@
import org.apache.tools.ant.DynamicElementNS;

/**
- * Task that handles the construction of catalogof type entries.
+ * Task that handles the construction of catalog of type entries.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
@@ -102,24 +103,24 @@

private void buildTypes( ClassLoader classloader )
{
- TypeBuilder[] builders = (TypeBuilder[]) m_builders.toArray( new
TypeBuilder[0] );
+ final TypeBuilder[] builders = (TypeBuilder[]) m_builders.toArray(
new TypeBuilder[0] );
for( int i=0; i<builders.length; i++ )
{
- TypeBuilder builder = builders[i];
+ final TypeBuilder builder = builders[i];
if( builder instanceof Task )
{
((Task)builder).setTaskName( "type" );
}
-
- URI strategy = builder.getTypeHandlerURI();
-
try
{
- Type type = builder.buildType( classloader );
- String classname = type.getInfo().getClassname();
- String resource = getEmbeddedResourcePath( classname );
- File file = getEmbeddedOutputFile( resource );
- SerializableObjectHelper.write( type, file );
+ final Type type = builder.buildType( classloader );
+ final String classname = type.getInfo().getClassname();
+ final String resource = getEmbeddedResourcePath( classname );
+ final File file = getEmbeddedOutputFile( resource );
+ final URI handler = builder.getTypeHandlerURI();
+ final byte[] bytes =
SerializableObjectHelper.writeToByteArray( type );
+ final TypeHolder holder = new TypeHolder( handler, bytes );
+ SerializableObjectHelper.write( holder, file );
}
catch( Exception e )
{

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
Sun Mar 27 13:14:52 2005
@@ -60,7 +60,6 @@
DependencyDataType dep = deps[i];
DependencyDirective directive = dep.getDependencyDirective();
dependencies[i] = directive;
- System.out.println( "# DEP: " + directive );
}
return dependencies;
}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
Sun Mar 27 13:14:52 2005
@@ -89,6 +89,7 @@
import net.dpml.system.SystemContext;

import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.artifact.ArtifactNotFoundException;


/**
@@ -605,6 +606,14 @@
throw new ModelException( error );
}
}
+ catch( ArtifactNotFoundException e )
+ {
+ final String error =
+ "Part not found ["
+ + uri
+ + "].";
+ throw new ModelException( error, e );
+ }
catch( ModelException e )
{
throw e;

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Sun Mar 27 13:14:52 2005
@@ -459,6 +459,7 @@
</info>
<dependencies>
<include key="dpml-meta-api"/>
+ <include key="dpml-meta-spi"/>
<include key="dpml-meta-tools"/>
<include key="dpml-automation-builder"/>
<include key="dpml-magic-core"/>

Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/ContextDescriptor.java
==============================================================================
---
development/main/metro/meta/api/src/main/net/dpml/meta/info/ContextDescriptor.java
(original)
+++
development/main/metro/meta/api/src/main/net/dpml/meta/info/ContextDescriptor.java
Sun Mar 27 13:14:52 2005
@@ -254,18 +254,13 @@
*/
public int hashCode()
{
-System.out.print( "hashCode() compute:" );
int hash = super.hashCode();
-System.out.print( hash + ", " );
hash ^= m_classname.hashCode();
-System.out.print( hash + ", " );
for( int i = 0; i < m_entries.length; i++ )
{
hash = hash + 65152197;
hash ^= m_entries[i].hashCode();
-System.out.print( hash + ", " );
}
-System.out.println( hash + ", " );
return hash;
}
}

Modified:
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/SerializedTypeCreator.java
==============================================================================
---
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/SerializedTypeCreator.java
(original)
+++
development/main/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/SerializedTypeCreator.java
Sun Mar 27 13:14:52 2005
@@ -22,14 +22,21 @@

import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;

import net.dpml.meta.info.Type;
import net.dpml.meta.info.builder.TypeCreator;
+import net.dpml.meta.info.builder.TypeHolder;
+import net.dpml.meta.info.builder.BuildException;

/**
* Create {@link Type} from stream made up of
* serialized object.
*
+ * TODO: refactor this so that the type builder functionality is moved into
the
+ * controller. Current implementation is brain dead with respect to the type
+ * handler uri exposed by the holder.
+ *
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
@@ -48,8 +55,20 @@
final InputStream inputStream )
throws Exception
{
- final ObjectInputStream ois = new ObjectInputStream( inputStream );
- return (Type)ois.readObject();
+ final ObjectInputStream stream = new ObjectInputStream( inputStream
);
+ TypeHolder holder = (TypeHolder) stream.readObject();
+ byte[] bytes = holder.getByteArray();
+ try
+ {
+ ByteArrayInputStream input = new ByteArrayInputStream( bytes );
+ ObjectInputStream bytestream = new ObjectInputStream( input );
+ return (Type) bytestream.readObject();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to load a type from a byte
array.";
+ throw new BuildException( error, e );
+ }
}
-
}

Added:
development/main/metro/meta/spi/src/main/net/dpml/meta/info/builder/TypeHolder.java
==============================================================================
--- (empty file)
+++
development/main/metro/meta/spi/src/main/net/dpml/meta/info/builder/TypeHolder.java
Sun Mar 27 13:14:52 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 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.meta.info.builder;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Properties;
+import java.io.Serializable;
+
+/**
+ *
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class TypeHolder implements Serializable
+{
+ static final long serialVersionUID = 1L;
+
+ private final URI m_handler;
+ private final byte[] m_type;
+
+ public TypeHolder( URI handler, byte[] part )
+ {
+ m_handler = handler;
+ m_type = part;
+ }
+
+ public URI getTypeHandlerURI()
+ {
+ return m_handler;
+ }
+
+ public byte[] getByteArray()
+ {
+ return m_type;
+ }
+
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_handler.hashCode();
+ for( int i=0; i<m_type.length; i++ )
+ {
+ hash ^= new Byte( m_type[i] ).hashCode();
+ }
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof TypeHolder )
+ {
+ TypeHolder holder = (TypeHolder) other;
+ if( getTypeHandlerURI().equals( holder.getTypeHandlerURI() ) ==
false )
+ {
+ return false;
+ }
+ else if( Arrays.equals( getByteArray(), holder.getByteArray() )
== false )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public String toString()
+ {
+ return "[type-holder handler:" + m_handler + " size:" +
m_type.length + "]";
+ }
+
+}
+



  • svn commit: r2156 - in development/main/metro: . composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/impl/src/main/net/dpml/composition/model/impl meta/api/src/main/net/dpml/meta/info meta/impl/src/main/net/dpml/meta/info/builder/impl meta/spi/src/main/net/dpml/meta/info/builder, mcconnell, 03/27/2005

Archive powered by MHonArc 2.6.24.

Top of Page