notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1946 - in development/main: central/site transit/core/tools/src/main/net/dpml/transit/tools transit/util/exception/src/main/net/dpml/exception
- From: mcconnell AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1946 - in development/main: central/site transit/core/tools/src/main/net/dpml/transit/tools transit/util/exception/src/main/net/dpml/exception
- Date: Fri, 04 Mar 2005 09:42:14 +0100
Author: mcconnell
Date: Fri Mar 4 09:42:14 2005
New Revision: 1946
Modified:
development/main/central/site/build.xml
development/main/transit/core/tools/src/main/net/dpml/transit/tools/PluginTask.java
development/main/transit/core/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
development/main/transit/util/exception/src/main/net/dpml/exception/ExceptionHelper.java
Log:
Update transit's handling of plugins to anchor off the context clasloader.
Update the plugin task to include the build location in thrown exceptions.
Update the site build to replicate to
Thread.currentThread().setContextClassLoader( Parts.class.getClassLoader() );
ml.site}.
Modified: development/main/central/site/build.xml
==============================================================================
--- development/main/central/site/build.xml (original)
+++ development/main/central/site/build.xml Fri Mar 4 09:42:14 2005
@@ -53,6 +53,9 @@
<task class="net.dpml.magic.doc.DocTask" name="docs"/>
</transit:plugin>
<docs/>
+ <copy todir="${dpml.docs}">
+ <fileset dir="${basedir}/target/docs"/>
+ </copy>
</target>
</project>
Modified:
development/main/transit/core/tools/src/main/net/dpml/transit/tools/PluginTask.java
==============================================================================
---
development/main/transit/core/tools/src/main/net/dpml/transit/tools/PluginTask.java
(original)
+++
development/main/transit/core/tools/src/main/net/dpml/transit/tools/PluginTask.java
Fri Mar 4 09:42:14 2005
@@ -145,7 +145,7 @@
"Cound not convert the supplied uri spec ["
+ m_uri
+ "] to a formal URI.";
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
@@ -200,7 +200,7 @@
+ "] from the plugin ["
+ uri
+ "].";
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
}
@@ -228,7 +228,7 @@
+ "] could not be registered as a project listener
because it does not implement the ["
+ BuildListener.class.getName()
+ "] interface.";
- throw new BuildException( error );
+ throw new BuildException( error, getLocation() );
}
}
@@ -248,7 +248,7 @@
+ m_uri
+ "] due to "
+ e.toString();
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
@@ -275,7 +275,7 @@
+ "or antlib directive ["
+ uri
+ "]";
- throw new BuildException( error );
+ throw new BuildException( error, getLocation() );
}
String urn = antlib.getURN();
@@ -290,7 +290,7 @@
+ "or antlib directive ["
+ uri
+ "]";
- throw new BuildException( error );
+ throw new BuildException( error, getLocation() );
}
InputStream input = classloader.getResourceAsStream( resource );
@@ -343,7 +343,7 @@
"Unable to load task [" + name + "] from class [" + classname
+ "] due to the following error: "
+ e.toString();
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
@@ -375,7 +375,7 @@
"Unable to load type [" + name + "] from class [" + classname
+ "] due to the following error: "
+ e.toString();
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
@@ -533,7 +533,7 @@
* @return the path (possibly null in which case the resource
reference
* must exist in the polugin descriptor)
*/
- public String getPath() throws BuildException
+ public String getPath()
{
return m_path;
}
@@ -558,7 +558,7 @@
{
final String error =
"Internal error while attemting to resolve Transit
repository.";
- throw new BuildException( error, e );
+ throw new BuildException( error, e, getLocation() );
}
}
}
Modified:
development/main/transit/core/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
==============================================================================
---
development/main/transit/core/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
(original)
+++
development/main/transit/core/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
Fri Mar 4 09:42:14 2005
@@ -309,7 +309,7 @@
StandardLoader loader = new StandardLoader();
Plugin descriptor = loader.getPluginDescriptor( uri );
- ClassLoader current = getClass().getClassLoader();
+ ClassLoader current =
Thread.currentThread().getContextClassLoader();
ClassLoader classloader = loader.getPluginClassLoader( current,
uri );
if( null != descriptor.getClassname() )
{
Modified:
development/main/transit/util/exception/src/main/net/dpml/exception/ExceptionHelper.java
==============================================================================
---
development/main/transit/util/exception/src/main/net/dpml/exception/ExceptionHelper.java
(original)
+++
development/main/transit/util/exception/src/main/net/dpml/exception/ExceptionHelper.java
Fri Mar 4 09:42:14 2005
@@ -192,6 +192,11 @@
buffer.append( "Exception: " + e.getClass().getName() + "\n" );
buffer.append( "Message: " + e.getMessage() + "\n" );
+ String location = getLocation( e );
+ if( null != location )
+ {
+ buffer.append( "Location: " + location.toString() + "\n" );
+ }
packCause( buffer, getCause( e ) ).toString();
Throwable root = getLastThrowable( e );
if( ( root != null ) && stack )
@@ -220,6 +225,12 @@
buffer.append( getLine( CAUSE ) );
buffer.append( "Exception: " + cause.getClass().getName() + "\n" );
buffer.append( "Message: " + cause.getMessage() + "\n" );
+
+ String location = getLocation( cause );
+ if( null != location )
+ {
+ buffer.append( "Location: " + location + "\n" );
+ }
return packCause( buffer, getCause( cause ) );
}
@@ -265,6 +276,33 @@
}
}
+ /**
+ * Get a esception location by reflection.
+ * @param exception the exception
+ * @return the location as a string
+ */
+ private static String getLocation( Throwable exception )
+ {
+ if( exception == null )
+ {
+ throw new NullPointerException( "exception" );
+ }
+
+ try
+ {
+ Method method =
+ exception.getClass().getMethod( "getLocation", new Class[0] );
+ Object location = method.invoke( exception, new Object[0] );
+System.out.println( "## LOC CLASS: " + location.getClass().getName() );
+ return "[" + location.toString() + "]";
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+
+
/**
* Captures the stack trace associated with this exception.
*
- svn commit: r1946 - in development/main: central/site transit/core/tools/src/main/net/dpml/transit/tools transit/util/exception/src/main/net/dpml/exception, mcconnell, 03/04/2005
Archive powered by MHonArc 2.6.24.