Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2070 - in development/laboratory/plus/standard: builder/src/main/net/dpml/metro/builder/impl model/src/main/net/dpml/metro/meta model/src/main/net/dpml/metro/model model/src/main/net/dpml/metro/type

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: r2070 - in development/laboratory/plus/standard: builder/src/main/net/dpml/metro/builder/impl model/src/main/net/dpml/metro/meta model/src/main/net/dpml/metro/model model/src/main/net/dpml/metro/type
  • Date: Mon, 14 Mar 2005 14:16:53 -0500

Author: mcconnell AT dpml.net
Date: Mon Mar 14 14:16:52 2005
New Revision: 2070

Added:

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/SerializableObjectHelper.java
Removed:

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/MarshalledObjectHelper.java
Modified:

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/RegistryTask.java

development/laboratory/plus/standard/model/src/main/net/dpml/metro/meta/ComponentTypeHandler.java

development/laboratory/plus/standard/model/src/main/net/dpml/metro/model/ComponentPartHandler.java

development/laboratory/plus/standard/model/src/main/net/dpml/metro/type/Registry.java
Log:
updates to how serialized objects are handled

Modified:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
==============================================================================
---
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
(original)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
Mon Mar 14 14:16:52 2005
@@ -240,11 +240,11 @@
{
URI uri = getPartHandlerURI();
Part part = buildPart( classloader );
- byte[] bytes = MarshalledObjectHelper.writeToByteArray( part );
+ byte[] bytes = SerializableObjectHelper.writeToByteArray( part );
PartHolder holder = new PartHolder( uri, bytes );

File output = getOutputFile();
- MarshalledObjectHelper.write( holder, output );
+ SerializableObjectHelper.write( holder, output );
}
catch( BuildException e )
{

Modified:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
==============================================================================
---
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
(original)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
Mon Mar 14 14:16:52 2005
@@ -286,7 +286,7 @@
String path = getEmbeddedResourcePath( method );
File output = getEmbeddedOutputFile( path );
System.out.println( "### saving part to: " + output );
- MarshalledObjectHelper.write( part, output );
+ SerializableObjectHelper.write( part, output );
}

private Part constructPart( ClassLoader classloader, PartDescriptor
descriptor, PartBuilder builder )

Modified:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/RegistryTask.java
==============================================================================
---
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/RegistryTask.java
(original)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/RegistryTask.java
Mon Mar 14 14:16:52 2005
@@ -162,33 +162,18 @@
path.createPathElement().setLocation( classes );
ClassLoader classloader = new AntClassLoader( project, path );
Registry registry = buildRegistry( classloader );
- writeRegistry( registry );
- }
-
- private void writeRegistry( Registry registry )
- {
- ObjectOutputStream output = null;
- FileOutputStream stream = null;
File file = getOutputFile();
try
{
- MarshalledObject marshalled = new MarshalledObject( registry );
- stream = new FileOutputStream( file );
- output = new ObjectOutputStream( stream );
- output.writeObject( marshalled );
+ SerializableObjectHelper.write( registry, file );
}
- catch( Throwable e )
+ catch( IOException ioe )
{
final String error =
- "Unexpected error while attempting to externalize a registry."
- + "\ndestination: " + file
- + "\nclass: " + registry.getClass().getName()
- + "\nreason: " + e.toString();
- throw new BuildException( error, e, getLocation() );
- }
- finally
- {
- closeStream( output );
+ "Internal error while attempting to write registry to ["
+ + file
+ + "]";
+ throw new BuildException( error, ioe, getLocation() );
}
}

@@ -232,7 +217,7 @@
Type type = builder.buildType( classloader );
System.out.println( "# type " + type );
String classname = type.getClassname();
- byte[] bytes = MarshalledObjectHelper.writeToByteArray( type
);
+ byte[] bytes = SerializableObjectHelper.writeToByteArray(
type );
entries[i] = new TypeEntry( strategy, classname, bytes );
}
catch( IntrospectionException e )

Added:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/SerializableObjectHelper.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/SerializableObjectHelper.java
Mon Mar 14 14:16:52 2005
@@ -0,0 +1,119 @@
+/*
+ * 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.metro.builder.impl;
+
+import java.io.File;
+import java.io.Serializable;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.net.URI;
+import java.rmi.MarshalledObject;
+
+import net.dpml.metro.builder.BuilderRuntimeException;
+
+/**
+ * A datatype that enables custom part builders.
+ *
+ * @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 SerializableObjectHelper
+{
+ private SerializableObjectHelper()
+ {
+ // static utility class
+ }
+
+ public static void write( Serializable object, File file ) throws
IOException
+ {
+ ObjectOutputStream output = null;
+ FileOutputStream stream = null;
+ try
+ {
+ stream = new FileOutputStream( file );
+ output = new ObjectOutputStream( stream );
+ output.writeObject( object );
+ }
+ catch( IOException ioe )
+ {
+ throw ioe;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to write an object."
+ + "\ndestination: " + file
+ + "\nclass: " + object.getClass().getName()
+ + "\nreason: " + e.toString();
+ throw new BuilderRuntimeException( error, e );
+ }
+ finally
+ {
+ closeStream( output );
+ }
+ }
+
+ public static byte[] writeToByteArray( Serializable object ) throws
IOException
+ {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ObjectOutputStream output = null;
+ try
+ {
+ output = new ObjectOutputStream( stream );
+ output.writeObject( object );
+ return stream.toByteArray();
+ }
+ catch( IOException ioe )
+ {
+ throw ioe;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to write out object to a
byte array."
+ + "\nclass: " + object.getClass().getName()
+ + "\nreason: " + e.toString();
+ throw new BuilderRuntimeException( error, e );
+ }
+ finally
+ {
+ closeStream( output );
+ }
+ }
+
+ private static void closeStream( OutputStream out )
+ {
+ if( null != out )
+ {
+ try
+ {
+ out.close();
+ }
+ catch( IOException ioe )
+ {
+ boolean ignoreMe = true;
+ }
+ }
+ }
+}

Modified:
development/laboratory/plus/standard/model/src/main/net/dpml/metro/meta/ComponentTypeHandler.java
==============================================================================
---
development/laboratory/plus/standard/model/src/main/net/dpml/metro/meta/ComponentTypeHandler.java
(original)
+++
development/laboratory/plus/standard/model/src/main/net/dpml/metro/meta/ComponentTypeHandler.java
Mon Mar 14 14:16:52 2005
@@ -76,8 +76,7 @@
{
ByteArrayInputStream input = new ByteArrayInputStream( bytes );
ObjectInputStream stream = new ObjectInputStream( input );
- MarshalledObject marshalled = (MarshalledObject)
stream.readObject();
- return (ComponentDescriptor) marshalled.get();
+ return (ComponentDescriptor) stream.readObject();
}
catch( IOException e )
{

Modified:
development/laboratory/plus/standard/model/src/main/net/dpml/metro/model/ComponentPartHandler.java
==============================================================================
---
development/laboratory/plus/standard/model/src/main/net/dpml/metro/model/ComponentPartHandler.java
(original)
+++
development/laboratory/plus/standard/model/src/main/net/dpml/metro/model/ComponentPartHandler.java
Mon Mar 14 14:16:52 2005
@@ -65,8 +65,7 @@
ObjectInputStream stream = new ObjectInputStream( input );
try
{
- MarshalledObject marshalled = (MarshalledObject)
stream.readObject();
- PartHolder holder = (PartHolder) marshalled.get();
+ PartHolder holder = (PartHolder) stream.readObject();
URI handler = holder.getPartHandlerURI();
return loadPart( handler, holder.getByteArray() );
}

Modified:
development/laboratory/plus/standard/model/src/main/net/dpml/metro/type/Registry.java
==============================================================================
---
development/laboratory/plus/standard/model/src/main/net/dpml/metro/type/Registry.java
(original)
+++
development/laboratory/plus/standard/model/src/main/net/dpml/metro/type/Registry.java
Mon Mar 14 14:16:52 2005
@@ -50,8 +50,7 @@
throw new RegistryNotFoundException( url );
}
ObjectInputStream stream = new ObjectInputStream( input );
- MarshalledObject marshalled = (MarshalledObject)
stream.readObject();
- return (Registry) marshalled.get();
+ return (Registry) stream.readObject();
}
catch( RegistryNotFoundException rnfe )
{



  • svn commit: r2070 - in development/laboratory/plus/standard: builder/src/main/net/dpml/metro/builder/impl model/src/main/net/dpml/metro/meta model/src/main/net/dpml/metro/model model/src/main/net/dpml/metro/type, mcconnell, 03/14/2005

Archive powered by MHonArc 2.6.24.

Top of Page