Skip to Content.
Sympa Menu

notify-dpml - r1835 - trunk/main/transit/core/src/main/net/dpml/util

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: r1835 - trunk/main/transit/core/src/main/net/dpml/util
  • Date: Fri, 9 Feb 2007 00:47:45 +0100

Author: mcconnell
Date: 2007-02-09 00:47:32 +0100 (Fri, 09 Feb 2007)
New Revision: 1835

Added:
trunk/main/transit/core/src/main/net/dpml/util/package-info.java
Removed:
trunk/main/transit/core/src/main/net/dpml/util/ConfigurationHandler.java

trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
trunk/main/transit/core/src/main/net/dpml/util/DOM3DocumentBuilder.java
trunk/main/transit/core/src/main/net/dpml/util/DOMInput.java
trunk/main/transit/core/src/main/net/dpml/util/Decoder.java
trunk/main/transit/core/src/main/net/dpml/util/DecoderFactory.java
trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
trunk/main/transit/core/src/main/net/dpml/util/DefaultLogger.java
trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
trunk/main/transit/core/src/main/net/dpml/util/Encoder.java
trunk/main/transit/core/src/main/net/dpml/util/EventHandler.java
trunk/main/transit/core/src/main/net/dpml/util/EventQueue.java
trunk/main/transit/core/src/main/net/dpml/util/ExceptionHelper.java
trunk/main/transit/core/src/main/net/dpml/util/LoggingService.java
trunk/main/transit/core/src/main/net/dpml/util/MimeTypeHandler.java
trunk/main/transit/core/src/main/net/dpml/util/PropertyResolver.java
trunk/main/transit/core/src/main/net/dpml/util/SimpleResolver.java
trunk/main/transit/core/src/main/net/dpml/util/StandardFormatter.java
trunk/main/transit/core/src/main/net/dpml/util/StreamUtils.java
trunk/main/transit/core/src/main/net/dpml/util/UnicastEventSource.java
trunk/main/transit/core/src/main/net/dpml/util/Util.java
trunk/main/transit/core/src/main/net/dpml/util/package.html
Modified:
trunk/main/transit/core/src/main/net/dpml/util/Resolver.java
Log:
SDK 2.X staged commit.

Deleted:
trunk/main/transit/core/src/main/net/dpml/util/ConfigurationHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/ConfigurationHandler.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/ConfigurationHandler.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import java.net.URL;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.util.Properties;
-import java.util.logging.LogManager;
-
-import net.dpml.transit.Transit;
-
-/**
- * Utility class used to establish the logging configuration.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ConfigurationHandler
-{
- static
- {
- Object prefs = Transit.DPML_PREFS;
- }
-
- /**
- * Creation of the logging controller.
- */
- public ConfigurationHandler()
- {
-
- //
- // customize the configuration based on a properties file declared
under
- // the 'dpml.logging.config' property
- //
-
- Properties properties = new Properties();
- String config = System.getProperty( "dpml.logging.config" );
- if( null != config )
- {
- String spec = PropertyResolver.resolve( config );
- try
- {
- URL url = new URL( spec );
- InputStream stream = url.openStream();
- properties.load( stream );
- PropertyResolver.resolve( properties );
- }
- catch( FileNotFoundException e )
- {
- final String error =
- "Logging configuration does not exist."
- + "\nURI: " + spec;
- System.err.println( error );
- }
- catch( Exception e )
- {
- System.out.println( "Error loading user properties: " +
config );
- e.printStackTrace();
- }
- }
-
- //
- // ensure that sensible defaults exist
- //
-
- if( null == properties.getProperty( ".level" ) )
- {
- String level = getDefaultLevel();
- properties.setProperty( ".level", level );
- }
-
- if( null == properties.getProperty( "handlers" ) )
- {
- setProperty( properties,
- "handlers",
- "java.util.logging.ConsoleHandler" );
- setProperty( properties,
- "java.util.logging.ConsoleHandler.formatter",
- "net.dpml.util.StandardFormatter" );
- setProperty( properties,
"java.util.logging.ConsoleHandler.level", "ALL" );
- }
-
- //
- // convert the resolved properties instance to an input stream
- // and supply this to the log manager
- //
-
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- properties.store( out, "DPML Logging Properties" );
- byte[] bytes = out.toByteArray();
- ByteArrayInputStream input = new ByteArrayInputStream( bytes );
- LogManager manager = LogManager.getLogManager();
- manager.readConfiguration( input );
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
-
- private void setProperty( Properties properties, String key, String
value )
- {
- properties.setProperty( key, System.getProperty( key, value ) );
- }
-
- private String getDefaultLevel()
- {
- //if( "true".equals( System.getProperty( "dpml.debug" ) ) )
- //{
- // return "FINE";
- //}
- //else
- //{
- return System.getProperty( "dpml.logging.level", "INFO"
).toUpperCase();
- //}
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
2007-02-08 23:46:20 UTC (rev 1834)
+++
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,180 +0,0 @@
-/*
- * Copyright 2004 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.util;
-
-import java.util.Map;
-import java.beans.Introspector;
-import java.beans.Expression;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-/**
- * Invoication handler utility for a Context inner-class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ContextInvocationHandler implements InvocationHandler
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- /**
- * Construct a new context instance implementing the supplied class
- * and backed by entries in the supplied map.
- *
- * @param clazz the context inner class
- * @param map a map of context entry keys to values
- * @return the proxied context instance
- */
- public static Object getProxiedInstance( Class clazz, Map map )
- {
- ClassLoader classloader = clazz.getClassLoader();
- ContextInvocationHandler handler = new ContextInvocationHandler( map
);
- return Proxy.newProxyInstance( classloader, new Class[]{clazz},
handler );
- }
-
- //-------------------------------------------------------------------
- // state
- //-------------------------------------------------------------------
-
- /**
- * A map containing key values.
- */
- private final Map m_map;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Create a context invocation handler.
- *
- * @param map a map containing context key/value pairs.
- */
- private ContextInvocationHandler( Map map )
- {
- m_map = map;
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- /**
- * Invoke the specified method on underlying object.
- * This is called by the proxy object.
- *
- * @param proxy the proxy object
- * @param method the method invoked on proxy object
- * @param args the arguments supplied to method
- * @return the return value of method
- * @throws Throwable if an error occurs
- */
- public Object invoke( final Object proxy, final Method method, final
Object[] args ) throws Throwable
- {
- Class source = method.getDeclaringClass();
- if( Object.class == source )
- {
- return method.invoke( this, args );
- }
- else
- {
- String name = method.getName();
- if( name.startsWith( "get" ) )
- {
- String key = Introspector.decapitalize( name.substring( 3 )
);
- Object value = m_map.get( key );
- if( null != value )
- {
- Class clazz = method.getReturnType();
- if( isAssignableFrom( clazz, value.getClass() ) )
- {
- return value;
- }
- else
- {
- Expression expression = new Expression( clazz,
"new", new Object[]{value} );
- return expression.getValue();
- }
- }
- else if( ( null != args ) && args.length > 0 )
- {
- return args[0];
- }
- else
- {
- final String error =
- "Unable to resolve a context entry value for the key
[" + key + "].";
- throw new IllegalStateException( error );
- }
- }
- throw new UnsupportedOperationException( name );
- }
- }
-
- private static boolean isAssignableFrom( Class clazz, Class c )
- {
- if( clazz.isPrimitive() )
- {
- if( Integer.TYPE == clazz )
- {
- return Integer.class.isAssignableFrom( c );
- }
- else if( Boolean.TYPE == clazz )
- {
- return Boolean.class.isAssignableFrom( c );
- }
- else if( Byte.TYPE == clazz )
- {
- return Byte.class.isAssignableFrom( c );
- }
- else if( Short.TYPE == clazz )
- {
- return Short.class.isAssignableFrom( c );
- }
- else if( Long.TYPE == clazz )
- {
- return Long.class.isAssignableFrom( c );
- }
- else if( Float.TYPE == clazz )
- {
- return Float.class.isAssignableFrom( c );
- }
- else if( Double.TYPE == clazz )
- {
- return Double.class.isAssignableFrom( c );
- }
- else
- {
- final String error =
- "Primitive type ["
- + c.getName()
- + "] not supported.";
- throw new RuntimeException( error );
- }
- }
- else
- {
- return clazz.isAssignableFrom( c );
- }
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/util/DOM3DocumentBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DOM3DocumentBuilder.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/DOM3DocumentBuilder.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,323 +0,0 @@
-/*
-/*
- * Copyright 2006 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.util;
-
-import java.net.URI;
-import java.net.URL;
-import java.net.URISyntaxException;
-import java.util.Hashtable;
-import java.util.Map;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.FileNotFoundException;
-
-import javax.xml.XMLConstants;
-
-import net.dpml.transit.Artifact;
-
-import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMLocator;
-import org.w3c.dom.bootstrap.DOMImplementationRegistry;
-import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.Document;
-import org.w3c.dom.ls.DOMImplementationLS;
-import org.w3c.dom.ls.LSOutput;
-import org.w3c.dom.ls.LSParser;
-import org.w3c.dom.ls.LSSerializer;
-import org.w3c.dom.ls.LSResourceResolver;
-import org.w3c.dom.ls.LSInput;
-
-/**
- * Utility class that creates a schema validating DOM3 parser.
- */
-public class DOM3DocumentBuilder
-{
- private final Map m_map;
- private final Logger m_logger;
-
- /**
- * Creation of a new DOM3 document builder.
- */
- public DOM3DocumentBuilder()
- {
- this( new DefaultLogger( "dom" ) );
- }
-
- /**
- * Creation of a new DOM3 document builder.
- * @param logger the assigned logging channel
- */
- public DOM3DocumentBuilder( Logger logger )
- {
- this( logger, new Hashtable() );
- }
-
- /**
- * Creation of a new DOM3 document builder.
- * @param logger the assigned logging channel
- * @param map namespace to builder uri map
- */
- public DOM3DocumentBuilder( Logger logger, Map map )
- {
- m_map = map;
- m_logger = logger;
- }
-
- /**
- * Parse an xml schema document.
- * @param uri the document uri
- * @return the validated document
- * @exception IOException if an IO error occurs
- */
- public Document parse( URI uri ) throws IOException
- {
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
- try
- {
- DOMImplementationRegistry registry =
- DOMImplementationRegistry.newInstance();
- DOMImplementationLS impl =
- (DOMImplementationLS) registry.getDOMImplementation( "LS" );
- if( null == impl )
- {
- final String error =
- "Unable to locate a DOM3 parser.";
- throw new IllegalStateException( error );
- }
- LSParser builder = impl.createLSParser(
DOMImplementationLS.MODE_SYNCHRONOUS, null );
- DOMConfiguration config = builder.getDomConfig();
- config.setParameter( "error-handler", new InternalErrorHandler(
m_logger, uri ) );
- config.setParameter( "resource-resolver", new
InternalResourceResolver( m_map ) );
- config.setParameter( "validate", Boolean.TRUE );
-
- DOMInput input = new DOMInput();
- URL url = Artifact.toURL( uri );
- InputStream stream = url.openStream();
- InputStreamReader reader = new InputStreamReader( stream );
- input.setCharacterStream( reader );
-
- return builder.parse( input );
- }
- catch( FileNotFoundException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error =
- "DOM3 error while attempting to parse document."
- + "\nSource: " + uri;
- //String message = ExceptionHelper.packException( error, e, true
);
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
-
- /**
- * Write a document to an output stream.
- * @param doc the document to write
- * @param output the output stream
- * @exception Exception if an error occurs
- */
- public void write( Document doc, OutputStream output ) throws Exception
- {
- DOMImplementationRegistry registry =
- DOMImplementationRegistry.newInstance();
- DOMImplementationLS impl =
- (DOMImplementationLS) registry.getDOMImplementation( "LS" );
- if( null == impl )
- {
- final String error =
- "Unable to locate a DOM3 implementation.";
- throw new IllegalStateException( error );
- }
- LSSerializer domWriter = impl.createLSSerializer();
- LSOutput lsOut = impl.createLSOutput();
- lsOut.setByteStream( output );
- domWriter.write( doc, lsOut );
- }
-
- /**
- * Utility class to handle namespace uri resolves.
- */
- private static class InternalResourceResolver implements
LSResourceResolver
- {
- private final Map m_map;
-
- /**
- * Creation of a new InternalResourceResolver.
- * @param map the namespace to builder map
- */
- InternalResourceResolver( Map map )
- {
- m_map = map;
- }
-
- /**
- * Resolve an LS input.
- * @param type the node type
- * @param namespace the node namespace
- * @param publicId the public id
- * @param systemId the system id
- * @param base the base value
- * @return the LS input instance
- */
- public LSInput resolveResource(
- String type, String namespace, String publicId, String systemId,
String base )
- {
- if( XMLConstants.W3C_XML_SCHEMA_NS_URI.equals( type ) )
- {
- DOMInput input = new DOMInput();
- input.setPublicId( publicId );
- input.setSystemId( systemId );
- input.setBaseURI( base );
-
- if( null == namespace )
- {
- return input;
- }
-
- try
- {
- URI uri = resolveURI( namespace );
- URL url = Artifact.toURL( uri );
- InputStream stream = url.openStream();
- InputStreamReader reader = new InputStreamReader( stream
);
- input.setCharacterStream( reader );
- }
- catch( URISyntaxException e )
- {
- // ignore
- }
- catch( IOException e )
- {
- // ignore
- }
- return input;
- }
- else
- {
- return null;
- }
- }
-
- private URI resolveURI( String namespace ) throws URISyntaxException
- {
- if( null == namespace )
- {
- throw new NullPointerException( "namespace" );
- }
- String value = System.getProperty( namespace );
- if( null != value )
- {
- return new URI( value );
- }
- if( m_map.containsKey( namespace ) )
- {
- return (URI) m_map.get( namespace );
- }
- else
- {
- return new URI( namespace );
- }
- }
- }
-
- /**
- * Internal error handler with lots of room for improvement.
- */
- private static final class InternalErrorHandler implements
DOMErrorHandler
- {
- private final URI m_uri;
- private final Logger m_logger;
-
- InternalErrorHandler( Logger logger, URI uri )
- {
- m_uri = uri;
- m_logger = logger;
- }
-
- /**
- * Handle the supplied error.
- * @param error the error
- * @return a boolean value
- */
- public boolean handleError( DOMError error )
- {
- DOMLocator locator = error.getLocation();
- int line = locator.getLineNumber();
- int column = locator.getColumnNumber();
- String uri = locator.getUri();
- if( null == uri )
- {
- uri = m_uri.toString();
- }
- String position = "[" + line + ":" + column + "]";
- String message = error.getMessage();
- if( null != message )
- {
- short severity = error.getSeverity();
- final String notice =
- "DOM3 Validation Error"
- + "\nSource: "
- + uri + ":" + position
- + "\nCause: "
- + message;
- if( severity == DOMError.SEVERITY_ERROR )
- {
- m_logger.error( notice );
- }
- else if( severity == DOMError.SEVERITY_WARNING )
- {
- m_logger.warn( notice );
- }
- else
- {
- m_logger.info( notice );
- }
- }
- return true;
- }
-
- private String getLabel( DOMError error )
- {
- short severity = error.getSeverity();
- if( severity == DOMError.SEVERITY_ERROR )
- {
- return "ERROR";
- }
- else if( severity == DOMError.SEVERITY_WARNING )
- {
- return "WARNING";
- }
- else
- {
- return "FATAL";
- }
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/DOMInput.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DOMInput.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/DOMInput.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,276 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.io.Reader;
-import java.io.InputStream;
-
-import org.w3c.dom.ls.LSInput;
-
-/**
- * This Class <code>DOMInput</code> represents a single input source for an
XML entity.
- * <p> This Class allows an application to encapsulate information about
- * an input source in a single object, which may include a public
- * identifier, a system identifier, a byte stream (possibly with a specified
- * encoding), and/or a character stream.
- * <p> The exact definitions of a byte stream and a character stream are
- * binding dependent.
- * <p> There are two places that the application will deliver this input
- * source to the parser: as the argument to the <code>parse</code> method,
- * or as the return value of the
<code>DOMResourceResolver.resolveEntity</code>
- * method.
- * <p> The <code>DOMParser</code> will use the <code>LSInput</code>
- * object to determine how to read XML input. If there is a character stream
- * available, the parser will read that stream directly; if not, the parser
- * will use a byte stream, if available; if neither a character stream nor a
- * byte stream is available, the parser will attempt to open a URI
- * connection to the resource identified by the system identifier.
- * <p> An <code>LSInput</code> object belongs to the application: the
- * parser shall never modify it in any way (it may modify a copy if
- * necessary). Eventhough all attributes in this interface are writable the
- * DOM implementation is expected to never mutate a LSInput.
- * <p>See also the <a
href='http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20011025'>Document Object
Model (DOM) Level 3 Abstract Schemas and Load
-and Save Specification</a>.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DOMInput implements LSInput
-{
- private String m_publicId = null;
- private String m_systemId = null;
- private String m_base = null;
- private InputStream m_byteStream = null;
- private Reader m_reader = null;
- private String m_data = null;
- private String m_encoding = null;
- private boolean m_certified = false;
-
- /**
- * Default constructor.
- */
- public DOMInput()
- {
- }
-
- /**
- * An attribute of a language-binding dependent type that represents a
- * stream of bytes.
- * <br>The parser will ignore this if there is also a character stream
- * specified, but it will use a byte stream in preference to opening a
- * URI connection itself.
- * <br>If the application knows the character encoding of the byte stream,
- * it should set the encoding property. Setting the encoding in this way
- * will override any encoding specified in the XML declaration itself.
- */
- public InputStream getByteStream()
- {
- return m_byteStream;
- }
-
- /**
- * An attribute of a language-binding dependent type that represents a
- * stream of bytes.
- * <br>The parser will ignore this if there is also a character stream
- * specified, but it will use a byte stream in preference to opening a
- * URI connection itself.
- * <br>If the application knows the character encoding of the byte stream,
- * it should set the encoding property. Setting the encoding in this way
- * will override any encoding specified in the XML declaration itself.
- */
- public void setByteStream( InputStream byteStream )
- {
- m_byteStream = byteStream;
- }
-
- /**
- * An attribute of a language-binding dependent type that represents a
- * stream of 16-bit units. Application must encode the stream using
- * UTF-16 (defined in and Amendment 1 of ).
- * <br>If a character stream is specified, the parser will ignore any byte
- * stream and will not attempt to open a URI connection to the system
- * identifier.
- */
- public Reader getCharacterStream()
- {
- return m_reader;
- }
- /**
- * An attribute of a language-binding dependent type that represents a
- * stream of 16-bit units. Application must encode the stream using
- * UTF-16 (defined in and Amendment 1 of ).
- * <br>If a character stream is specified, the parser will ignore any byte
- * stream and will not attempt to open a URI connection to the system
- * identifier.
- */
- public void setCharacterStream( Reader characterStream )
- {
- m_reader = characterStream;
- }
-
- /**
- * A string attribute that represents a sequence of 16 bit units (utf-16
- * encoded characters).
- * <br>If string data is available in the input source, the parser will
- * ignore the character stream and the byte stream and will not attempt
- * to open a URI connection to the system identifier.
- */
- public String getStringData()
- {
- return m_data;
- }
-
- /**
- * A string attribute that represents a sequence of 16 bit units (utf-16
- * encoded characters).
- * <br>If string data is available in the input source, the parser will
- * ignore the character stream and the byte stream and will not attempt
- * to open a URI connection to the system identifier.
- */
- public void setStringData( String stringData )
- {
- m_data = stringData;
- }
-
- /**
- * The character encoding, if known. The encoding must be a string
- * acceptable for an XML encoding declaration ( section 4.3.3 "Character
- * Encoding in Entities").
- * <br>This attribute has no effect when the application provides a
- * character stream. For other sources of input, an encoding specified
- * by means of this attribute will override any encoding specified in
- * the XML claration or the Text Declaration, or an encoding obtained
- * from a higher level protocol, such as HTTP .
- */
- public String getEncoding()
- {
- return m_encoding;
- }
-
- /**
- * The character encoding, if known. The encoding must be a string
- * acceptable for an XML encoding declaration ( section 4.3.3 "Character
- * Encoding in Entities").
- * <br>This attribute has no effect when the application provides a
- * character stream. For other sources of input, an encoding specified
- * by means of this attribute will override any encoding specified in
- * the XML claration or the Text Declaration, or an encoding obtained
- * from a higher level protocol, such as HTTP .
- */
- public void setEncoding( String encoding )
- {
- m_encoding = encoding;
- }
-
- /**
- * The public identifier for this input source. The public identifier is
- * always optional: if the application writer includes one, it will be
- * provided as part of the location information.
- */
- public String getPublicId()
- {
- return m_publicId;
- }
- /**
- * The public identifier for this input source. The public identifier is
- * always optional: if the application writer includes one, it will be
- * provided as part of the location information.
- */
- public void setPublicId( String publicId )
- {
- m_publicId = publicId;
- }
-
- /**
- * The system identifier, a URI reference , for this input source. The
- * system identifier is optional if there is a byte stream or a
- * character stream, but it is still useful to provide one, since the
- * application can use it to resolve relative URIs and can include it in
- * error messages and warnings (the parser will attempt to fetch the
- * ressource identifier by the URI reference only if there is no byte
- * stream or character stream specified).
- * <br>If the application knows the character encoding of the object
- * pointed to by the system identifier, it can register the encoding by
- * setting the encoding attribute.
- * <br>If the system ID is a relative URI reference (see section 5 in ),
- * the behavior is implementation dependent.
- */
- public String getSystemId()
- {
- return m_systemId;
- }
- /**
- * The system identifier, a URI reference , for this input source. The
- * system identifier is optional if there is a byte stream or a
- * character stream, but it is still useful to provide one, since the
- * application can use it to resolve relative URIs and can include it in
- * error messages and warnings (the parser will attempt to fetch the
- * ressource identifier by the URI reference only if there is no byte
- * stream or character stream specified).
- * <br>If the application knows the character encoding of the object
- * pointed to by the system identifier, it can register the encoding by
- * setting the encoding attribute.
- * <br>If the system ID is a relative URI reference (see section 5 in ),
- * the behavior is implementation dependent.
- */
- public void setSystemId( String systemId )
- {
- m_systemId = systemId;
- }
-
- /**
- * The base URI to be used (see section 5.1.4 in ) for resolving relative
- * URIs to absolute URIs. If the baseURI is itself a relative URI, the
- * behavior is implementation dependent.
- */
- public String getBaseURI()
- {
- return m_base;
- }
-
- /**
- * The base URI to be used (see section 5.1.4 in ) for resolving relative
- * URIs to absolute URIs. If the baseURI is itself a relative URI, the
- * behavior is implementation dependent.
- */
- public void setBaseURI( String baseURI )
- {
- m_base = baseURI;
- }
-
- /**
- * If set to true, assume that the input is certified (see section 2.13
- * in [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>]) when
- * parsing [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>].
- */
- public boolean getCertifiedText()
- {
- return m_certified;
- }
-
- /**
- * If set to true, assume that the input is certified (see section 2.13
- * in [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>]) when
- * parsing [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>].
- */
- public void setCertifiedText( boolean certifiedText )
- {
- m_certified = certifiedText;
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/Decoder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/Decoder.java 2007-02-08
23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/Decoder.java 2007-02-08
23:47:32 UTC (rev 1835)
@@ -1,39 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.io.IOException;
-
-import org.w3c.dom.Element;
-
-/**
- * Interface implemented by generic decoders.
- */
-public interface Decoder
-{
- /**
- * Create an object using a supplied classloader and DOM element.
- * @param element the DOM element
- * @param resolver build-time value resolver
- * @return the decoded object
- * @exception IOException if an error occurs in the evaluation
- * of the supplied element
- */
- Object decode( Element element, Resolver resolver ) throws IOException;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/DecoderFactory.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DecoderFactory.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/DecoderFactory.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,241 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-import java.util.Hashtable;
-
-import net.dpml.lang.Part;
-import net.dpml.lang.PartDecoder;
-
-import net.dpml.transit.Artifact;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.TypeInfo;
-
-/**
- * Utility class supporting resolution of element decoders.
- */
-public final class DecoderFactory
-{
- private static final String PART_XSD_URI = "@PART-XSD-URI@";
-
- private final Map m_map; // maps namespace uris to element handlers
-
- /**
- * Creation of a new helper factory using default mappings.
- */
- public DecoderFactory()
- {
- this( null );
- }
-
- /**
- * Creation of a new decoder factory. The supplied map contains the
mapping
- * of namespace urn to decoder plugin uris. If the "dpml/lang/dpml-part"
namespace
- * is not included in the map a special uri will be assigned associating
the namespace
- * with this package implementation.
- *
- * @param map the namespace to helper uri map
- */
- public DecoderFactory( Map map )
- {
- if( null == map )
- {
- m_map = new Hashtable();
- }
- else
- {
- m_map = map;
- }
- }
-
- /**
- * Get an element helper based on the namespace declared by the supplied
element. If
- * the element namespace is the dpml/part namespace then a local uri is
returned,
- * otherwise evaluation is based on namespace to hanlder mappings
supplied to
- * the factory constructor. If a map entry is resolved, a delegating
builder is
- * established with the resolved helper uri, otherwise a helper uri is
resolved
- * by substituting the namespace uri artifact type for "part" on the
assumption that
- * a part implemenation will be available.
- *
- * @param element the DOM element
- * @return the decoder
- * @exception Exception if an eror occurs
- */
- public Decoder loadDecoder( Element element ) throws Exception
- {
- TypeInfo info = element.getSchemaTypeInfo();
- String namespace = info.getTypeNamespace();
- if( PART_XSD_URI.equals( namespace ) )
- {
- return PartDecoder.getInstance();
- }
- else
- {
- URI uri = getDecoderURI( element );
- return new DelegatingDecoder( this, uri );
- }
- }
-
- /**
- * Resolve the decoder uri from a supplied element.
- *
- * @param element the DOM element
- * @return the decoder uri
- * @exception Exception if an error occurs
- */
- public URI getDecoderURI( Element element ) throws Exception
- {
- String uri = ElementHelper.getAttribute( element, "handler" );
- if( null != uri )
- {
- try
- {
- return new URI( uri );
- }
- catch( Exception e )
- {
- final String error =
- "Internal error while resolving handler attribute
(expecting uri value)";
- throw new DecodingException( element, error, e );
- }
- }
- TypeInfo info = element.getSchemaTypeInfo();
- String namespace = info.getTypeNamespace();
- if( m_map.containsKey( namespace ) )
- {
- return (URI) m_map.get( namespace );
- }
- else
- {
- return getDecoderURIFromNamespaceURI( namespace );
- }
- }
-
- /**
- * Resolve the part handler given an element namespace.
- * @param urn the namespace value
- * @return the decoder uri
- * @exception Exception if an error occurs
- */
- public static URI getDecoderURIFromNamespaceURI( String urn ) throws
Exception
- {
- URI raw = new URI( urn );
- Artifact artifact = Artifact.createArtifact( raw );
- String scheme = artifact.getScheme();
- String group = artifact.getGroup();
- String name = artifact.getName();
- String type = artifact.getType();
- String version = artifact.getVersion();
- String path = "link:part:" + group + "/" + name;
- Artifact link = Artifact.createArtifact( path );
- return link.toURI();
- }
-
-
- /**
- * Delegating builder that defers resolution until required.
- */
- private class DelegatingDecoder implements Decoder
- {
- private final DecoderFactory m_factory;
- private final URI m_uri;
- private Decoder m_delegate = null;
-
- /**
- * Creation of a new delegating builder instance.
- * @param uri the uri of the builder that operations will be
delegated to
- */
- DelegatingDecoder( DecoderFactory factory, URI uri )
- {
- m_uri = uri;
- m_factory = factory;
- }
-
- /**
- * Delegating implementation of the decode operation.
- * @param element the subject element
- * @return the resulting object
- * @exception IOException if an IO error occurs
- */
- public Object decode( Element element, Resolver resolver ) throws
IOException
- {
- Decoder decoder = getDelegateDecoder();
- return decoder.decode( element, resolver );
- }
-
- private Decoder getDelegateDecoder()
- {
- if( null != m_delegate )
- {
- return m_delegate;
- }
- else
- {
- Object instance = getInstance();
- if( instance instanceof Decoder )
- {
- m_delegate = (Decoder) instance;
- return m_delegate;
- }
- else
- {
- final String error =
- "Object resolved from the uri does not provide
decoding services."
- + "\nDelegate URI: " + m_uri
- + "\nDelegate Class: " + instance.getClass().getName();
- throw new IllegalStateException( error );
- }
- }
- }
-
- private Object getInstance()
- {
- try
- {
- Object[] args = new Object[]{m_factory};
- Part part = Part.load( m_uri );
- return part.instantiate( args );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error occured while attempting to establish
the delegate decoder."
- + "\nDelegate URI: " + m_uri;
- throw new RuntimeException( error, e ); // change to a
factory exception
- }
- }
- }
-
- private static URI createURI( String spec )
- {
- try
- {
- return new URI( spec );
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- return null;
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/DecodingException.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,148 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.io.IOException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Exception related to data decoding from a DOM element.
- */
-public class DecodingException extends IOException
-{
- private final Element m_element;
-
- /**
- * Create a new decoding exception.
- * @param element the element representing the source of the error
- * @param message the exception message
- */
- public DecodingException( Element element, String message )
- {
- this( element, message, null );
- }
-
- /**
- * Create a new decoding exception.
- * @param element the element representing the source of the error
- * @param message the exception message
- * @param cause the causal exception
- */
- public DecodingException( Element element, String message, Throwable
cause )
- {
- super( message );
- if( null != cause )
- {
- super.initCause( cause );
- }
- m_element = element;
- }
-
- /**
- * Get the element that is the subject of this exception.
- * @return the subject element
- */
- public Element getElement()
- {
- return m_element;
- }
-
- /**
- * Return a string representation of the exception.
- * @return the string value
- */
- public String getMessage()
- {
- try
- {
- String message = super.getMessage();
- StringBuffer buffer = new StringBuffer( message );
- buffer.append( "\n" );
- Element element = getElement();
- String listing = list( element );
- buffer.append( listing );
- Document document = element.getOwnerDocument();
- String uri = document.getDocumentURI();
- if( null != uri )
- {
- buffer.append( "\nDocument: " + uri );
- }
- return buffer.toString();
- }
- catch( Throwable e )
- {
- return super.getMessage();
- }
- }
-
- /**
- * Static utility operation that returns a syring representation of a DOM
element.
- * @param element the element to stringify
- * @return the string value
- */
- public static String list( Element element )
- {
- return list( element, "" );
- }
-
- /**
- * Static utility operation that returns a syring representation of a DOM
element.
- * @param element the element to stringify
- * @param pad padding offset
- * @return the string value
- */
- public static String list( Element element, String pad )
- {
- StringBuffer buffer = new StringBuffer();
- String tag = element.getTagName();
- buffer.append( pad + "<" );
- buffer.append( tag );
- NamedNodeMap map = element.getAttributes();
- for( int i=0; i<map.getLength(); i++ )
- {
- Node item = map.item( i );
- buffer.append( " " + item.getNodeName() + "=\"" );
- buffer.append( item.getNodeValue() );
- buffer.append( "\"" );
- }
-
- Element[] children = ElementHelper.getChildren( element );
- if( children.length > 0 )
- {
- buffer.append( ">" );
- for( int i=0; i<children.length; i++ )
- {
- Element child = children[i];
- String listing = list( child, pad + " " );
- String tagName = child.getTagName();
- buffer.append( "\n" + listing );
- }
- buffer.append( "\n" + pad + "</" + tag + ">" );
- }
- else
- {
- buffer.append( "/>" );
- }
- return buffer.toString();
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/DefaultLogger.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/DefaultLogger.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/DefaultLogger.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,266 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-import net.dpml.lang.PID;
-
-/**
- * Generic logging channel.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultLogger implements net.dpml.util.Logger
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- private static final PID ID = new PID();
-
- private static String clean( String category )
- {
- String result = category.replace( '/', '.' );
- if( result.startsWith( "." ) )
- {
- return clean( result.substring( 1 ) );
- }
- else if( result.endsWith( "." ) )
- {
- return clean( result.substring( 0, result.length() -1 ) );
- }
- else
- {
- return result;
- }
- }
-
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private Logger m_logger;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new console adapter that is used to redirect transit
events
- * the system output stream.
- */
- public DefaultLogger()
- {
- this( "" );
- }
-
- /**
- * Creation of a new console adapter that is used to redirect transit
events
- * the system output stream.
- * @param category the logging channel category name
- */
- public DefaultLogger( String category )
- {
- this( Logger.getLogger( clean( category ) ) );
- }
-
- /**
- * Creation of a new console adapter that is used to redirect transit
events
- * the system output stream.
- * @param logger the assigned logging channel
- */
- public DefaultLogger( Logger logger )
- {
- m_logger = logger;
- }
-
- //
------------------------------------------------------------------------
- // Logger
- //
------------------------------------------------------------------------
-
- /**
- * Return TRUE is trace level logging is enabled.
- * @return the enabled state of trace logging
- */
- public boolean isTraceEnabled()
- {
- return m_logger.isLoggable( Level.FINER );
- }
-
- /**
- * Return TRUE is debug level logging is enabled.
- * @return the enabled state of debug logging
- */
- public boolean isDebugEnabled()
- {
- return m_logger.isLoggable( Level.FINE );
- }
-
- /**
- * Return TRUE is info level logging is enabled.
- * @return the enabled state of info logging
- */
- public boolean isInfoEnabled()
- {
- return m_logger.isLoggable( Level.INFO );
- }
-
- /**
- * Return TRUE is error level logging is enabled.
- * @return the enabled state of error logging
- */
- public boolean isWarnEnabled()
- {
- return m_logger.isLoggable( Level.WARNING );
- }
-
- /**
- * Return TRUE is error level logging is enabled.
- * @return the enabled state of error logging
- */
- public boolean isErrorEnabled()
- {
- return m_logger.isLoggable( Level.SEVERE );
- }
-
- /**
- * Log a debug message is trace mode is enabled.
- * @param message the message to log
- */
- public void trace( String message )
- {
- if( isTraceEnabled() )
- {
- m_logger.finer( message );
- }
- }
-
- /**
- * Log a debug message is debug mode is enabled.
- * @param message the message to log
- */
- public void debug( String message )
- {
- if( isDebugEnabled() )
- {
- m_logger.fine( message );
- }
- }
-
- /**
- * Log a info level message.
- * @param message the message to log
- */
- public void info( String message )
- {
- if( isInfoEnabled() )
- {
- m_logger.info( message );
- }
- }
-
- /**
- * Record a warning message.
- * @param message the warning message to record
- */
- public void warn( String message )
- {
- if( isWarnEnabled() )
- {
- m_logger.warning( message );
- }
- }
-
- /**
- * Record a warning message.
- * @param message the warning message to record
- * @param cause the causal exception
- */
- public void warn( String message, Throwable cause )
- {
- if( isWarnEnabled() )
- {
- m_logger.log( Level.WARNING, message, cause );
- }
- }
-
- /**
- * Log a error message.
- * @param message the message to log
- */
- public void error( String message )
- {
- if( isErrorEnabled() )
- {
- m_logger.log( Level.SEVERE, message );
- }
- }
-
- /**
- * Log a error message.
- * @param message the message to log
- * @param e the causal exception
- */
- public void error( String message, Throwable e )
- {
- if( isErrorEnabled() )
- {
- m_logger.log( Level.SEVERE, message, e );
- }
- }
-
- /**
- * Return a child logger.
- * @param category the sub-category name.
- * @return the child logging channel
- */
- public net.dpml.util.Logger getChildLogger( String category )
- {
- if( ( null == category ) || "".equals( category ) )
- {
- return this;
- }
- else
- {
- String name = m_logger.getName();
- String path = trim( name + "." + category );
- return new DefaultLogger( Logger.getLogger( path ) );
- }
- }
-
- private String trim( String path )
- {
- if( path.startsWith( "." ) )
- {
- return trim( path.substring( 1 ) );
- }
- else if( ".".equals( path ) )
- {
- return "";
- }
- else
- {
- return path;
- }
- }
-}
-

Deleted: trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/ElementHelper.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,367 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen 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.util;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Utility class supporting the translation of DOM content into local child,
children,
- * attribute and value values.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ElementHelper
-{
- private static final Resolver SIMPLE_RESOLVER = new SimpleResolver();
-
- private ElementHelper()
- {
- // utility class
- }
-
- /**
- * Return the root element of the supplied file.
- * @param definition the file to load
- * @return the root element
- * @exception Exception if the error occurs during root element
establishment
- */
- public static Element getRootElement( final File definition )
- throws Exception
- {
- if( !definition.exists() )
- {
- throw new FileNotFoundException( definition.toString() );
- }
-
- if( !definition.isFile() )
- {
- final String error =
- "Source is not a file: " + definition;
- throw new IllegalArgumentException( error );
- }
-
- final DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setValidating( false );
- factory.setNamespaceAware( false );
- final Document document =
- factory.newDocumentBuilder().parse( definition );
- return document.getDocumentElement();
- }
-
- /**
- * Return the root element of the supplied input stream.
- * @param input the input stream containing a XML definition
- * @return the root element
- * @exception Exception if an error occurs
- */
- public static Element getRootElement( final InputStream input )
- throws Exception
- {
- final DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setValidating( false );
- factory.setNamespaceAware( false );
- factory.setExpandEntityReferences( false );
- DocumentBuilder builder = factory.newDocumentBuilder();
- return getRootElement( builder, input );
- }
-
- /**
- * Return the root element of the supplied input stream.
- * @param builder the document builder
- * @param input the input stream containing a XML definition
- * @return the root element
- * @exception Exception if an error occurs
- */
- public static Element getRootElement( final DocumentBuilder builder,
final InputStream input )
- throws Exception
- {
- final Document document = builder.parse( input );
- return document.getDocumentElement();
- }
-
- /**
- * Return a named child relative to a supplied element.
- * @param root the parent DOM element
- * @param name the name of a child element
- * @return the child element of null if the child does not exist
- */
- public static Element getChild( final Element root, final String name )
- {
- if( null == root )
- {
- return null;
- }
- Element[] children = getChildren( root );
- for( int i=0; i<children.length; i++ )
- {
- Element child = children[i];
- if( name.equals( child.getTagName() ) )
- {
- return child;
- }
- }
- return null;
- }
-
- /**
- * Return all children matching the supplied element name.
- * @param root the parent DOM element
- * @param name the name against which child element will be matched
- * @return the array of child elements with a matching name
- */
- public static Element[] getChildren( final Element root, final String
name )
- {
- if( null == root )
- {
- return new Element[0];
- }
- Element[] children = getChildren( root );
- final ArrayList result = new ArrayList();
- for( int i=0; i<children.length; i++ )
- {
- final Element child = children[i];
- if( name.equals( child.getTagName() ) )
- {
- result.add( child );
- }
- }
- return (Element[]) result.toArray( new Element[0] );
- }
-
- /**
- * Return all children of the supplied parent.
- * @param root the parent DOM element
- * @return the array of all children
- */
- public static Element[] getChildren( final Element root )
- {
- if( null == root )
- {
- return new Element[0];
- }
- final NodeList list = root.getChildNodes();
- final int n = list.getLength();
- if( n < 1 )
- {
- return new Element[0];
- }
- final ArrayList result = new ArrayList();
- for( int i=0; i < n; i++ )
- {
- final Node item = list.item( i );
- if( item instanceof Element )
- {
- result.add( item );
- }
- }
- return (Element[]) result.toArray( new Element[0] );
- }
-
- /**
- * Return the value of an element.
- * @param node the DOM node
- * @return the node value
- */
- public static String getValue( final Element node )
- {
- return getValue( node, null );
- }
-
- /**
- * Return the value of an element.
- * @param node the DOM node
- * @return the node value
- */
- public static String getValue( final Element node, Resolver resolver )
- {
- if( null == node )
- {
- return null;
- }
- String value;
- if( node.getChildNodes().getLength() > 0 )
- {
- value = node.getFirstChild().getNodeValue();
- }
- else
- {
- value = node.getNodeValue();
- }
- return normalize( resolver, value );
- }
-
- /**
- * Return the value of an element attribute.
- * @param node the DOM node
- * @param key the attribute key
- * @return the attribute value or null if the attribute is undefined
- */
- public static String getAttribute( final Element node, final String key )
- {
- return getAttribute( node, key, null );
- }
-
- /**
- * Return the value of an element attribute.
- * @param node the DOM node
- * @param key the attribute key
- * @param def the default value if the attribute is undefined
- * @return the attribute value or the default value if undefined
- */
- public static String getAttribute( final Element node, final String key,
final String def )
- {
- return getAttribute( node, key, def, null );
- }
-
- /**
- * Return the value of an element attribute.
- * @param node the DOM node
- * @param key the attribute key
- * @param def the default value if the attribute is undefined
- * @return the attribute value or the default value if undefined
- */
- public static String getAttribute( final Element node, final String key,
final String def, Resolver resolver )
- {
- if( null == node )
- {
- return def;
- }
- if( !node.hasAttribute( key ) )
- {
- return def;
- }
- String v = node.getAttribute( key );
- return normalize( resolver, v );
- }
-
- /**
- * Return the value of an element attribute as a boolean
- * @param node the DOM node
- * @param key the attribute key
- * @return the attribute value as a boolean or false if undefined
- */
- public static boolean getBooleanAttribute( final Element node, final
String key )
- {
- return getBooleanAttribute( node, key, false );
- }
-
- /**
- * Return the value of an element attribute as a boolean.
- * @param node the DOM node
- * @param key the attribute key
- * @param def the default value if the attribute is undefined
- * @return the attribute value or the default value if undefined
- */
- public static boolean getBooleanAttribute( final Element node, final
String key, final boolean def )
- {
- return getBooleanAttribute( node, key, def, null );
- }
-
- /**
- * Return the value of an element attribute as a boolean.
- * @param node the DOM node
- * @param key the attribute key
- * @param def the default value if the attribute is undefined
- * @return the attribute value or the default value if undefined
- */
- public static boolean getBooleanAttribute(
- final Element node, final String key, final boolean def, Resolver
resolver )
- {
- if( null == node )
- {
- return def;
- }
-
- if( !node.hasAttribute( key ) )
- {
- return def;
- }
-
- String value = node.getAttribute( key );
- value = normalize( resolver, value );
- if( value.equals( "" ) )
- {
- return def;
- }
- if( value.equalsIgnoreCase( "true" ) )
- {
- return true;
- }
- if( value.equalsIgnoreCase( "false" ) )
- {
- return false;
- }
- final String error =
- "Boolean argument [" + value + "] not recognized.";
- throw new IllegalArgumentException( error );
- }
-
- /**
- * Parse the value for any property tokens relative to system properties.
- * @param value the value to parse
- * @return the normalized string
- */
- static String normalize( String value )
- {
- return SIMPLE_RESOLVER.resolve( value );
- }
-
- /**
- * Parse the value for any property tokens relative to system properties.
- * @param value the value to parse
- * @return the normalized string
- */
- static String normalize( Resolver resolver, String value )
- {
- if( null != resolver )
- {
- return resolver.resolve( value );
- }
- else
- {
- return value;
- }
- }
-
- /**
- * Parse the value for any property tokens relative to the supplied
properties.
- * @param value the value to parse
- * @param props the reference properties
- * @return the normalized string
- */
- static String normalize( String value, Properties props )
- {
- return PropertyResolver.resolve( props, value );
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/Encoder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/Encoder.java 2007-02-08
23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/Encoder.java 2007-02-08
23:47:32 UTC (rev 1835)
@@ -1,37 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.io.Writer;
-import java.io.IOException;
-
-/**
- * Interface implemented by generic encoders.
- */
-public interface Encoder
-{
- /**
- * Externalize a object to XML.
- * @param writer the output stream writer
- * @param object the object to externalize
- * @param pad the character offset
- * @exception IOException if an IO error occurs
- */
- public void encode( Writer writer, Object object, String pad ) throws
IOException;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/EventHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/EventHandler.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/EventHandler.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,44 +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.util;
-
-import java.util.EventObject;
-import java.util.EventListener;
-
-/**
- * Interface implemented by objects that maintain a collection of event
listeners
- * and support for operational event propergation.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface EventHandler
-{
- /**
- * Return the associated event listeners.
- * @return the event listeners
- */
- EventListener[] getEventListeners();
-
- /**
- * Process the supplied event.
- * @param event the event to be processed
- */
- void processEvent( EventObject event );
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/EventQueue.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/EventQueue.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/EventQueue.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,292 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.util.EventObject;
-import java.util.List;
-import java.util.LinkedList;
-
-import net.dpml.transit.monitor.LoggingAdapter;
-
-/**
- * A abstract base class that established an event queue and handles event
dispatch
- * operations for listeners declared in classes extending this base class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class EventQueue
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private final EventDispatchThread m_thread;
-
- private final Logger m_logger;
-
- private final List m_queue;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new event queue.
- * @param category the name used to construct a logging channel
- * @deprecated Use new EventQueue( logger, "Thread name" ) instead.
- */
- public EventQueue( String category )
- {
- this( category, "Event Dispatch Thread" );
- }
-
- /**
- * Creation of a new model.
- * @param logger the assigned logging channel
- * @exception NullPointerException if the supplied logging channel is null
- * @deprecated Use new EventQueue( logger, "Thread name" ) instead.
- */
- public EventQueue( Logger logger )
- throws NullPointerException
- {
- this( logger, "Event Dispatch Thread" );
- }
-
- /**
- * Creation of a new event queue.
- * @param category the name used to construct a logging channel
- * @param name the name to assign to the thread
- */
- public EventQueue( String category, String name )
- {
- this( getLoggerForCategory( category ), name );
- }
-
- /**
- * Creation of a new model.
- * @param logger the assigned logging channel
- * @param name the name to assign to the thread
- * @exception NullPointerException if the supplied logging channel or
- * thread name is null
- */
- public EventQueue( Logger logger, String name )
- throws NullPointerException
- {
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
- if( null == name )
- {
- throw new NullPointerException( "name" );
- }
- m_logger = logger;
- m_queue = new LinkedList();
- m_thread = new EventDispatchThread();
- m_thread.setName( name );
- m_thread.setDaemon( true );
- m_thread.start();
- }
-
- //
------------------------------------------------------------------------
- // EventQueue
- //
------------------------------------------------------------------------
-
- /**
- * Terminate the dispatch thread.
- */
- public synchronized void terminateDispatchThread()
- {
- if( null != m_thread )
- {
- m_thread.dispose();
- }
- }
-
- /**
- * Return the assigned logging channel.
- * @return the logging channel
- */
- private Logger getLogger()
- {
- return m_logger;
- }
-
- /**
- * A single background thread ("the event notification thread") monitors
- * the event queue and delivers events that are placed on the queue.
- */
- private class EventDispatchThread extends Thread
- {
- private boolean m_continue = true;
-
- void dispose()
- {
- synchronized( m_queue )
- {
- m_continue = false;
- m_queue.notify();
- }
- }
-
- public void run()
- {
- while( m_continue )
- {
- // Wait on m_queue till an event is present
- EventObject event = null;
- synchronized( m_queue )
- {
- try
- {
- while( m_continue && m_queue.isEmpty() )
- {
- m_queue.wait();
- }
- if ( !m_continue )
- {
- break;
- }
- Object object = m_queue.remove( 0 );
- try
- {
- event = (EventObject) object;
- }
- catch( ClassCastException cce )
- {
- final String error =
- "Unexpected class cast exception while
processing an event."
- + "\nEvent: " + object;
- throw new IllegalStateException( error );
- }
- }
- catch( InterruptedException e )
- {
- return;
- }
- }
-
- Object source = event.getSource();
- if( source instanceof EventHandler )
- {
- EventHandler handler = (EventHandler) source;
- try
- {
- handler.processEvent( event );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while processing event."
- + "\nEvent: " + event
- + "\nSource: " + this;
- getLogger().error( error, e );
- }
- }
- else
- {
- final String error =
- "Event source is not an instance of "
- + EventHandler.class.getName();
- getLogger().error( error );
- }
- }
- }
- }
-
- /**
- * Enqueue an event for delivery to registered
- * listeners unless there are no registered
- * listeners.
- *
- * @param event the event object to add to the queue
- */
- public void enqueueEvent( EventObject event )
- {
- enqueueEvent( event, false );
- }
-
- /**
- * Enqueue an event for delivery to registered
- * listeners unless there are no registered
- * listeners.
- *
- * @param event the event object to add to the queue
- * @param waitForCompletion if TRUE the implementation will apply
- * the event to the event source event handler and return on
- * copmpletion of evetn delivery
- */
- public void enqueueEvent( EventObject event, boolean waitForCompletion )
- {
- if( !waitForCompletion )
- {
- synchronized( m_queue )
- {
- m_queue.add( event );
- m_queue.notify();
- }
- }
- else
- {
- Object source = event.getSource();
- if( source instanceof EventHandler )
- {
- EventHandler handler = (EventHandler) source;
- try
- {
- handler.processEvent( event );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while processing event."
- + "\nEvent: " + event
- + "\nSource: " + source;
- getLogger().error( error );
- }
- }
- else
- {
- final String error =
- "Event source is not an instance of "
- + EventHandler.class.getName()
- + "\nSource: " + source.getClass().getName();
- throw new IllegalStateException( error );
- }
- }
- }
-
- /**
- * Return a logging channel for the supplied name.
- * @param name the name to use in construction of the logging channel
- * @return the logging channel
- */
- static Logger getLoggerForCategory( String name )
- {
- if( null == name )
- {
- return new LoggingAdapter( "" );
- }
- else
- {
- return new LoggingAdapter( name );
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/ExceptionHelper.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/ExceptionHelper.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/ExceptionHelper.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,365 +0,0 @@
-/*
- * Copyright 2004 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.util;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.StringTokenizer;
-
-/**
- * General utilities supporting the packaging of exception messages.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ExceptionHelper
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param e the exception
- * @return String the formatting string
- */
- public static String packException( final Throwable e )
- {
- return packException( null, e );
- }
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param e the exception
- * @param stack TRUE to generate a stack trace
- * @return String the formatting string
- */
- public static String packException( final Throwable e, boolean stack )
- {
- return packException( null, e, stack );
- }
-
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param message the header message
- * @param e the exception
- * @return String the formatting string
- */
- public static String packException( final String message, final
Throwable e )
- {
- return packException( message, e, false );
- }
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param message the header message
- * @param e the exception
- * @param stack TRUE to generate a stack trace
- * @return String the formatting string
- */
- public static String packException(
- final String message, final Throwable e, boolean stack )
- {
- StringBuffer buffer = new StringBuffer();
- packException( buffer, 0, message, e, stack );
- buffer.append( getLine( END ) );
- return buffer.toString();
- }
-
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param message the header message
- * @param e the exceptions
- * @param stack TRUE to generate a stack trace
- * @return String the formatting string
- */
- public static String packException(
- final String message, final Throwable[] e, boolean stack )
- {
- final String lead = COMPOSITE + "(" + e.length + " entries) ";
- StringBuffer buffer = new StringBuffer( getLine( lead ) );
- if( null != message )
- {
- buffer.append( message );
- buffer.append( "\n" );
- }
- for( int i=0; i < e.length; i++ )
- {
- packException( buffer, i + 1, null, e[i], stack );
- }
- buffer.append( getLine( END ) );
- return buffer.toString();
- }
-
- //
------------------------------------------------------------------------
- // static implementation
- //
------------------------------------------------------------------------
-
- /**
- * Line separator character.
- */
- private static final String LINE_SEPARATOR =
- System.getProperty( "line.separator" );
-
- /**
- * Header token.
- */
- private static final String HEADER = "----";
-
- /**
- * Exception token.
- */
- private static final String EXCEPTION = HEADER + " exception report ";
-
- /**
- * Composite token.
- */
- private static final String COMPOSITE = HEADER + " composite report ";
-
- /**
- * Runtime token.
- */
- private static final String RUNTIME = HEADER + " runtime exception
report ";
-
- /**
- * Error token.
- */
- private static final String ERROR = HEADER + " error report ";
-
- /**
- * Cause token.
- */
- private static final String CAUSE = HEADER + " cause ";
-
- /**
- * Trace token.
- */
- private static final String TRACE = HEADER + " stack trace ";
-
- /**
- * End token.
- */
- private static final String END = "";
-
- /**
- * Nominal width of character display.
- */
- private static final int WIDTH = 80;
-
- /**
- * Returns the exception and causal exceptions as a formatted string.
- * @param buffer the string buffer
- * @param j the causal message sequence
- * @param message the header message
- * @param e the exception
- * @param stack TRUE to generate a stack trace
- */
- private static void packException(
- final StringBuffer buffer, int j, final String message, final
Throwable e, boolean stack )
- {
- if( e instanceof Error )
- {
- buffer.append( getLine( ERROR, j ) );
- }
- else if( e instanceof RuntimeException )
- {
- buffer.append( getLine( RUNTIME, j ) );
- }
- else
- {
- buffer.append( getLine( EXCEPTION, j ) );
- }
-
- if( null != message )
- {
- buffer.append( message );
- buffer.append( "\n" );
- }
-
- if( e == null )
- {
- return;
- }
-
- buffer.append( "Exception: " + e.getClass().getName() + "\n" );
- if( null != e.getMessage() )
- {
- buffer.append( "Message: " + e.getMessage() + "\n" );
- }
- packCause( buffer, getCause( e ) ).toString();
- Throwable root = getLastThrowable( e );
- if( ( root != null ) && stack )
- {
- buffer.append( getLine( TRACE ) );
- String[] trace = captureStackTrace( root );
- for( int i = 0; i < trace.length; i++ )
- {
- buffer.append( trace[i] + "\n" );
- }
- }
- }
-
- /**
- * Pack a causal exception.
- * @param buffer the buffer to pack the exception report
- * @param cause the causal exception to pack
- * @return the buffer
- */
- private static StringBuffer packCause( StringBuffer buffer, Throwable
cause )
- {
- if( cause == null )
- {
- return buffer;
- }
- buffer.append( getLine( CAUSE ) );
- buffer.append( "Exception: " + cause.getClass().getName() + "\n" );
- buffer.append( "Message: " + cause.getMessage() + "\n" );
- return packCause( buffer, getCause( cause ) );
- }
-
- /**
- * Return the last throwable in the chain.
- * @param exception the exception to extract the last throwable from
- * @return the initiating cause
- */
- private static Throwable getLastThrowable( Throwable exception )
- {
- Throwable cause = getCause( exception );
- if( cause != null )
- {
- return getLastThrowable( cause );
- }
- else
- {
- return exception;
- }
- }
-
- /**
- * Get a causal exception using reflection.
- * @param exception the exception
- * @return the causal exception
- */
- private static Throwable getCause( Throwable exception )
- {
- if( null == exception )
- {
- return null;
- }
-
- try
- {
- Class clazz = exception.getClass();
- Method method = clazz.getMethod( "getCause", new Class[0] );
- return (Throwable) method.invoke( exception, new Object[0] );
- }
- catch( Throwable e )
- {
- return null;
- }
- }
-
- /**
- * Captures the stack trace associated with this exception.
- *
- * @param throwable a <code>Throwable</code>
- * @return an array of Strings describing stack frames.
- */
- private static String[] captureStackTrace( final Throwable throwable )
- {
- final StringWriter sw = new StringWriter();
- throwable.printStackTrace( new PrintWriter( sw, true ) );
- return splitString( sw.toString(), LINE_SEPARATOR );
- }
-
- /**
- * Splits the string on every token into an array of stack frames.
- *
- * @param string the string to split
- * @param onToken the token to split on
- * @return the resultant array
- */
- private static String[] splitString( final String string, final String
onToken )
- {
- final int offset = 4;
- final StringTokenizer tokenizer = new StringTokenizer( string,
onToken );
- final String[] result = new String[tokenizer.countTokens()];
-
- for( int i = 0; i < result.length; i++ )
- {
- String token = tokenizer.nextToken();
- if( token.startsWith( "\tat " ) )
- {
- result[i] = token.substring( offset );
- }
- else
- {
- result[i] = token;
- }
- }
-
- return result;
- }
-
- /**
- * Return a line of '-' characters.
- * @param lead the lead
- * @return the line
- */
- private static String getLine( String lead )
- {
- return getLine( lead, 0 );
- }
-
- /**
- * Get a line of '-' characters with padded offset.
- * @param lead the leading characters
- * @param count the number of characters to fill
- * @return the filled out line
- */
- private static String getLine( String lead, int count )
- {
- StringBuffer buffer = new StringBuffer( lead );
- int q = 0;
- if( count > 0 )
- {
- String v = "" + count + " ";
- buffer.append( "" + count );
- buffer.append( " " );
- q = v.length() + 1;
- }
- int j = WIDTH - ( lead.length() + q );
- for( int i=0; i < j; i++ )
- {
- buffer.append( "-" );
- }
- buffer.append( "\n" );
- return buffer.toString();
- }
-
- /**
- * Disabled.
- */
- private ExceptionHelper()
- {
- // disable
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/LoggingService.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/LoggingService.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/LoggingService.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,47 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.util.logging.LogRecord;
-
-import net.dpml.lang.PID;
-
-/**
- * Interface exposed by a remote logging service to local log aggregation
handlers.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface LoggingService extends Remote
-{
- /**
- * Logging service key.
- */
- String LOGGING_KEY = "dpml/logging";
-
- /**
- * Register a log record with the log service.
- * @param process the process identifier
- * @param record the log record
- * @exception RemoteException if a remote exception occurs
- */
- void log( PID process, LogRecord record ) throws RemoteException;
-}
-

Deleted: trunk/main/transit/core/src/main/net/dpml/util/MimeTypeHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/MimeTypeHandler.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/MimeTypeHandler.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,85 +0,0 @@
-/*
- * Copyright 2004-2005 Niclas Hedhman.
- *
- * 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.util;
-
-import java.util.HashMap;
-
-/**
- * Mimetype utility handler.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class MimeTypeHandler
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * Static mime type table of artifact types to mimetype strings.
- */
- private static final HashMap MIME_TYPES = new HashMap();
-
- static
- {
- MIME_TYPES.put( "plugin", "text/x-dpml-plugin" );
- MIME_TYPES.put( "conf", "text/x-dpml-conf" );
- MIME_TYPES.put( "jar", "application/x-jar" );
- MIME_TYPES.put( "zip", "application/x-zip" );
- MIME_TYPES.put( "pdf", "application/pdf" );
- MIME_TYPES.put( "png", "image/png" );
- MIME_TYPES.put( "gif", "image/gif" );
- MIME_TYPES.put( "jpg", "image/jpg" );
- MIME_TYPES.put( "link", "application/x-dpml-link" );
- MIME_TYPES.put( "part", "application/x-dpml-part" );
- }
-
- /**
- * Return the mimetype given a artifact type.
- * @param artifactType the artifact type such as "part", "jar", etc.
- * @return the matching mimetype of null if unknown
- */
- public static String getMimeType( String artifactType )
- {
- return (String) MIME_TYPES.get( artifactType );
- }
-
- /**
- * Returns the number of MimeTypes that has been defined.
- *
- * Only for use with testcases.
- * @return the known mimetype count
- */
- public static int getMimeTypesSize()
- {
- return MIME_TYPES.size();
- }
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Disabled constructor.
- */
- private MimeTypeHandler()
- {
- // disable
- }
-}
\ No newline at end of file

Deleted: trunk/main/transit/core/src/main/net/dpml/util/PropertyResolver.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/PropertyResolver.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/PropertyResolver.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,201 +0,0 @@
-/*
- * Copyright 2006 Stephen McConnell
- * Copyright 2004 Niclas Hedhman
- *
- * 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.util;
-
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Stack;
-import java.util.StringTokenizer;
-
-import net.dpml.transit.Transit;
-
-/**
- * Utility class that handles substitution of property names in the string
- * for ${value} relative to a supplied set of properties.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PropertyResolver
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- static
- {
- Object xx = Transit.DPML_DATA;
- }
-
- /**
- * System property symbol substitution from properties.
- * Replace any occurances of ${[key]} with the value of the property
- * assigned to the [key] in the system properties.
- * @param value a string containing possibly multiple ${[value]} sequences
- * @return the expanded string
- */
- public static String resolve( String value )
- {
- Properties properties = System.getProperties();
- return resolve( properties, value );
- }
-
- /**
- * System property symbol substitution from properties.
- * Replace any occurances of ${[key]} with the value of the property
- * assigned to the [key] in the system properties or supplied properties.
- * @param properties an arbitary properties file containing unresolved
properties
- * @return the property file with expended properties
- */
- public static Properties resolve( Properties properties )
- {
- Properties system = System.getProperties();
- Enumeration names = properties.propertyNames();
- while( names.hasMoreElements() )
- {
- String name = (String) names.nextElement();
- String old = properties.getProperty( name );
- String value = resolve( old );
- String v2 = resolve( properties, value );
- if( !v2.equals( old ) )
- {
- properties.setProperty( name, v2 );
- }
- }
- return properties;
- }
-
- /**
- * Symbol substitution from properties.
- * Replace any occurances of ${[key]} with the value of the property
- * assigned to the [key] in the supplied properties argument.
- * @param props the source properties from which substitution is resolved
- * @param value a string containing possibly multiple ${[value]} sequences
- * @return the expanded string
- */
- public static String resolve( Properties props, String value )
- {
- if( value == null )
- {
- return null;
- }
-
- // optimization for common case.
- if( value.indexOf( '$' ) < 0 )
- {
- return value;
- }
- int pos1 = value.indexOf( "${" );
- if( pos1 < 0 )
- {
- return value;
- }
-
- Stack stack = new Stack();
- StringTokenizer st = new StringTokenizer( value, "${}", true );
-
- while ( st.hasMoreTokens() )
- {
- String token = st.nextToken();
- if( token.equals( "}" ) )
- {
- String name = (String) stack.pop();
- String open = (String) stack.pop();
- if( open.equals( "${" ) )
- {
- String propValue = System.getProperty( name );
- if( ( propValue == null ) && ( null != props ) )
- {
- propValue = props.getProperty( name );
- }
- if( propValue == null )
- {
- push( stack, "${" + name + "}" );
- }
- else
- {
- push( stack, propValue );
- }
- }
- else
- {
- push( stack, "${" + name + "}" );
- }
- }
- else
- {
- if( token.equals( "$" ) )
- {
- stack.push( "$" );
- }
- else
- {
- push( stack, token );
- }
- }
- }
- String result = "";
- while ( stack.size() > 0 )
- {
- result = stack.pop() + result;
- }
- return result;
- }
-
- /**
- * Pushes a value on a stack
- * @param stack the stack
- * @param value the value
- */
- private static void push( Stack stack , String value )
- {
- if( stack.size() > 0 )
- {
- String data = (String) stack.pop();
- if( data.equals( "$" ) && !"{".equals( value ) )
- {
- stack.push( value );
- }
- else if( data.equals( "${" ) )
- {
- stack.push( data );
- stack.push( value );
- }
- else
- {
- stack.push( data + value );
- }
- }
- else
- {
- stack.push( value );
- }
- }
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Null constructor.
- */
- private PropertyResolver()
- {
- }
-}
-

Modified: trunk/main/transit/core/src/main/net/dpml/util/Resolver.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/Resolver.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/Resolver.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -43,7 +43,7 @@
* @return the uri value
* @exception URISyntaxException if an error occurs during uri creation
*/
- URI toURI( String ref ) throws URISyntaxException;
+ //URI toURI( String ref ) throws URISyntaxException;

/**
* Return a property value.

Deleted: trunk/main/transit/core/src/main/net/dpml/util/SimpleResolver.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/SimpleResolver.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/SimpleResolver.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2006 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.util;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * Build-time value resolver.
- */
-public class SimpleResolver implements Resolver
-{
- /**
- * Utility function supporting resolution of uris containing 'resource'
or
- * 'alias' schemes. If the supplied uri scheme is 'resource' or 'alias'
the
- * reference is resolved to a artifact type, group and name from which a
- * resource is resolved and the uri returned. If the scheme is resource
- * the usi of the resource is returned. If the scheme is 'alias' a
- * link alias is returned. If the scheme is not 'resource' or 'alias'
- * the argument will be evaluated as a normal transit artifact uri
- * specification.
- *
- * @param ref the uri argument
- * @return the uri value
- * @exception URISyntaxException if an error occurs during uri creation
- */
- public URI toURI( String ref ) throws URISyntaxException
- {
- String value = resolve( ref );
- return new URI( value );
- }
-
- /**
- * Return a property value.
- * @param key the property key
- * @return the property value
- */
- public String getProperty( String key )
- {
- return System.getProperty( key );
- }
-
- /**
- * Return a property value.
- * @param key the property key
- * @param value the default value
- * @return the property value
- */
- public String getProperty( String key, String value )
- {
- return System.getProperty( key, value );
- }
-
- /**
- * Symbolic expansion of a supplied value.
- * Replace any occurances of ${[key]} with the value of the property
- * assigned to the [key] in system properties.
- * @param value a string containing possibly multiple ${[value]} sequences
- * @return the expanded string
- */
- public String resolve( String value )
- {
- return PropertyResolver.resolve( value );
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/StandardFormatter.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/StandardFormatter.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/StandardFormatter.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,124 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.util;
-
-import net.dpml.lang.PID;
-
-import java.util.logging.Formatter;
-import java.util.logging.LogRecord;
-
-/**
- * Logging message formatter that includes the category in the logging
statement.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class StandardFormatter extends Formatter
-{
- private static final PID ID = new PID();
-
- private static final String SEPARATOR = System.getProperty(
"line.separator" );
-
- /**
- * Format a LogRecord using a style appropriate for console messages. The
- * the log record message will be checked for a process identifier that
is
- * prepended to the raw message using the convention "$[" + PID + "] ".
If
- * a process id is resolved the value is assigned to the process block
and
- * the raw message is trimmed. The resulting formatted message is
presented
- * in the form "[PID ] [LEVEL ] (log.category): the message".
- *
- * @param record the log record to be formatted.
- * @return a formatted log record
- */
- public synchronized String format( LogRecord record )
- {
- if( null == record )
- {
- return "";
- }
- String process = getProcessHeader( record );
- StringBuffer buffer = new StringBuffer( process );
- String header = getLogHeader( record );
- buffer.append( header );
- if( null != record.getLoggerName() )
- {
- buffer.append( "(" + record.getLoggerName() + "): " );
- }
- else
- {
- buffer.append( "() " );
- }
- String message = getFormattedMessage( record );
- buffer.append( message );
- buffer.append( SEPARATOR );
- if( record.getThrown() != null )
- {
- Throwable cause = record.getThrown();
- String error = ExceptionHelper.packException( cause, true );
- buffer.append( error );
- }
- return buffer.toString();
- }
-
- private String getFormattedMessage( LogRecord record )
- {
- String message = formatMessage( record );
- if( ( null != message ) && message.startsWith( "$[" ) )
- {
- int n = message.indexOf( "] " );
- return message.substring( n + 2 );
- }
- else
- {
- return message;
- }
- }
-
- private String getLogHeader( LogRecord record )
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append( "[" );
- buffer.append( record.getLevel().getLocalizedName() );
- buffer.append( " " );
- String tag = buffer.toString();
- return tag.substring( 0, LEVEL_HEADER_WIDTH ) + "] ";
- }
-
- private String getProcessHeader( LogRecord record )
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append( "[" );
- String message = record.getMessage();
- if( ( null != message ) && ( message.startsWith( "$[" ) ) )
- {
- int n = message.indexOf( "] " );
- String id = message.substring( 2, n );
- buffer.append( id );
- }
- else
- {
- buffer.append( ID.getValue() );
- }
- buffer.append( " " );
- String tag = buffer.toString();
- return tag.substring( 0, PROCESS_HEADER_WIDTH ) + "] ";
- }
-
- private static final int LEVEL_HEADER_WIDTH = 8;
- private static final int PROCESS_HEADER_WIDTH = 6;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/StreamUtils.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/StreamUtils.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/StreamUtils.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,175 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 2004 Niclas Hedhman
- * 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.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.net.URL;
-
-import net.dpml.transit.NullArgumentException;
-
-import net.dpml.transit.monitor.NetworkMonitor;
-
-/**
- * Utility class that provides support for stream copy operations.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class StreamUtils
-{
- /**
- * Disabled constructor.
- */
- private StreamUtils()
- {
- // utility class
- }
-
- /**
- * Buffer size.
- */
- private static final int BUFFER_SIZE = 102400;
-
- /**
- * Copy a stream.
- * @param src the source input stream
- * @param dest the destination output stream
- * @param closeStreams TRUE if the streams should be closed on completion
- * @exception IOException if an IO error occurs
- * @exception NullArgumentException if src or destination are null
- */
- public static void copyStream( InputStream src, OutputStream dest,
boolean closeStreams )
- throws IOException, NullArgumentException
- {
- copyStream( null, null, 0, src, dest, closeStreams );
- }
-
- /**
- * Copy a stream.
- * @param monitor optional network monitor to log updates
- * @param source the source url
- * @param expected the expected size in bytes
- * @param src the source input stream
- * @param dest the destination output stream
- * @param closeStreams TRUE if the streams should be closed on completion
- * @exception IOException if an IO error occurs
- * @exception NullArgumentException if src or destination are null
- */
- public static void copyStream( NetworkMonitor monitor, URL source, int
expected,
- InputStream src, OutputStream dest, boolean
closeStreams )
- throws IOException, NullArgumentException
- {
- if( src == null )
- {
- throw new NullArgumentException( "src" );
- }
-
- if( dest == null )
- {
- throw new NullArgumentException( "dest" );
- }
-
- int length;
- int count = 0; // cumulative total read
- byte[] buffer = new byte[BUFFER_SIZE];
- if( !( dest instanceof BufferedOutputStream ) )
- {
- dest = new BufferedOutputStream( dest );
- }
- if( !( src instanceof BufferedInputStream ) )
- {
- src = new BufferedInputStream( src );
- }
-
- try
- {
- if( null != monitor )
- {
- monitor.notifyUpdate( source, expected, 0 );
- }
- while( ( length = src.read( buffer ) ) >= 0 )
- {
- count = count + length;
- dest.write( buffer, 0, length );
- if( null != monitor )
- {
- monitor.notifyUpdate( source, expected, count );
- }
- }
- }
- finally
- {
- if( closeStreams )
- {
- try
- {
- src.close();
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
-
- try
- {
- dest.close();
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
- if( null != monitor )
- {
- monitor.notifyCompletion( source );
- }
- }
- }
-
- /**
- * Compare two streams.
- * @param in1 the first input stream
- * @param in2 the second input stream
- * @return the equality status
- * @exception IOException if an IO error occurs
- */
- public static boolean compareStreams( InputStream in1, InputStream in2 )
- throws IOException
- {
- boolean result = true;
- do
- {
- int v1 = in1.read();
- int v2 = in2.read();
- if( v1 != v2 )
- {
- return false;
- }
- if( v1 == -1 )
- {
- break;
- }
- } while( true );
- return result;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/util/UnicastEventSource.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/UnicastEventSource.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/UnicastEventSource.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -1,226 +0,0 @@
-/*
- * Copyright 2005-2006 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.util;
-
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.rmi.NoSuchObjectException;
-import java.util.EventObject;
-import java.util.EventListener;
-import java.util.WeakHashMap;
-
-/**
- * A abstract base class that established an event queue and handles event
dispatch
- * operations for listeners declared in a class extending this base class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public abstract class UnicastEventSource extends UnicastRemoteObject
implements EventHandler
-{
- /**
- * Internal synchronization lock.
- */
- private final Object m_lock = new Object();
-
- /**
- * The controller that provides the main event dispath thread.
- */
- private final EventQueue m_queue;
-
- private final WeakHashMap m_listeners = new WeakHashMap();
-
- private final Logger m_logger;
-
- /**
- * Creation of a new <tt>UnicastEventSource</tt>.
- * @param queue the event queue
- * @param logger the assigned logging channel
- * @exception RemoteException if a remote I/O exception occurs
- */
- protected UnicastEventSource( EventQueue queue, Logger logger ) throws
RemoteException
- {
- super();
- m_queue = queue;
- m_logger = logger;
- }
-
-
//--------------------------------------------------------------------------
- // internal
-
//--------------------------------------------------------------------------
-
- /**
- * Return the logging channel assigned to the event source.
- * @return the logging channel
- */
- protected Logger getLocalLogger()
- {
- return m_logger;
- }
-
- /**
- * Return the event queue.
- * @return the queue
- */
- protected EventQueue getEventQueue()
- {
- return m_queue;
- }
-
- /**
- * Abstract operation to be implemented by classes extending this base
class.
- * An implementation is reposible for the posting of the event to
associated
- * listeners. Event posting will be executed under a separate thread to
the
- * thread that initiated the event post.
- *
- * @param event the event to process
- */
- public abstract void processEvent( EventObject event );
-
- /**
- * Add a listener to the set of listeners handled by this producer.
- * @param listener the event listener
- */
- protected void addListener( EventListener listener )
- {
- if( null == listener )
- {
- throw new NullPointerException( "listener" );
- }
- synchronized( m_lock )
- {
- m_listeners.put( listener, null );
- }
- }
-
- /**
- * Remove a listener to the set of listeners handled by this producer.
- * @param listener the event listener
- */
- protected void removeListener( EventListener listener )
- {
- if( null == listener )
- {
- throw new NullPointerException( "listener" );
- }
- synchronized( m_lock )
- {
- m_listeners.remove( listener );
- }
- }
-
-
- /**
- * Return the array of registered event listeners.
- *
- * @return the event listeners
- */
- public EventListener[] getEventListeners()
- {
- synchronized( m_lock )
- {
- return (EventListener[]) m_listeners.keySet().toArray( new
EventListener[0] );
- }
- }
-
- /**
- * Enqueue an event for delivery to registered
- * listeners unless there are no registered
- * listeners.
- * @param event the event to enqueue
- */
- protected void enqueueEvent( EventObject event )
- {
- if( m_listeners.size() > 0 )
- {
- m_queue.enqueueEvent( event );
- }
- }
-
- /**
- * Return the internal synchronization lock.
- * @return the lock object
- */
- protected Object getLock()
- {
- return m_lock;
- }
-
- /**
- * Terminate the event source.
- */
- public void terminate()
- {
- synchronized( m_lock )
- {
- EventListener[] listeners = getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- removeListener( listener );
- }
- }
-
- Thread thread = new Terminator( this, m_logger );
- thread.start();
- }
-
- /**
- * Internal class that handles instance retraction for the RMI runtime.
- */
- private class Terminator extends Thread
- {
- private final UnicastEventSource m_source;
- private final Logger m_logger;
-
- /**
- * Internal class terminator that handles unexport of an event source
- * under a separate thread.
- * @param source the event source instance
- * @param logger the event source logger
- */
- Terminator( UnicastEventSource source, Logger logger )
- {
- m_source = source;
- m_logger = logger;
- }
-
- /**
- * Terminator execution.
- */
- public void run()
- {
- try
- {
- UnicastRemoteObject.unexportObject( m_source, true );
- m_logger.trace( "terminated " +
m_source.getClass().getName() );
- }
- catch( NoSuchObjectException e )
- {
- boolean ignoreThis = true; // object has not been exported
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected remote exception while retracting component
handler remote reference.";
- m_logger.warn( error, e );
- }
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/util/Util.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/Util.java 2007-02-08
23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/Util.java 2007-02-08
23:47:32 UTC (rev 1835)
@@ -1,182 +0,0 @@
-/*
- * Copyright 2004 Niclas Hedhman
- *
- * 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.util;
-
-import net.dpml.transit.Transit;
-
-import java.util.Properties;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.ArrayList;
-import java.net.URL;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.BufferedReader;
-
-/**
- * Utility class supporting operations related to property retrival.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class Util
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * Read a set of properties from a property file specificed by a url.
- * Property files may reference symbolic properties in the form ${name}.
- * @param propsUrl the url of the property file to read
- * @return the resolved properties
- * @exception IOException if an io error occurs
- */
- public static Properties readProps( URL propsUrl )
- throws IOException
- {
- return readProps( propsUrl, true );
- }
-
- /**
- * Read a set of properties from a property file specificed by a url.
- * Property files may reference symbolic properties in the form ${name}.
- * @param propsUrl the url of the property file to read
- * @param resolve if TRUE apply property symbol resolution
- * @return the resolved properties
- * @exception IOException if an io error occurs
- */
- public static Properties readProps( URL propsUrl, boolean resolve )
- throws IOException
- {
- InputStream stream = propsUrl.openStream();
- try
- {
- Properties p = new Properties();
- p.load( stream );
- if( resolve )
- {
- p.setProperty( Transit.HOME_KEY,
Transit.DPML_HOME.toString() );
- Iterator list = p.entrySet().iterator();
- while ( list.hasNext() )
- {
- Map.Entry entry = (Map.Entry) list.next();
- String value = (String) entry.getValue();
- value = resolveProperty( p, value );
- entry.setValue( value );
- }
- }
- return p;
- }
- finally
- {
- stream.close();
- }
- }
-
- /**
- * Resolve symbols in a supplied value against supplied known properties.
- * @param props a set of know properties
- * @param value the string to parse for tokens
- * @return the resolved string
- */
- public static String resolveProperty( Properties props, String value )
- {
- value = PropertyResolver.resolve( props, value );
- return value;
- }
-
- /**
- * Return the value of a property.
- * @param props the property file
- * @param key the property key to lookup
- * @param def the default value
- * @return the resolve value
- */
- public static String getProperty( Properties props, String key, String
def )
- {
- String value = props.getProperty( key, def );
- if( value == null )
- {
- return null;
- }
- if( "".equals( value ) )
- {
- return value;
- }
- value = PropertyResolver.resolve( props, value );
- return value;
- }
-
- /**
- * Read a file and return the list of lines in an array of strings.
- * @param listFile the url to read from
- * @return the lines
- * @exception IOException if a read error occurs
- */
- public static String[] readListFile( URL listFile )
- throws IOException
- {
- ArrayList list = new ArrayList();
- InputStream stream = openInputStream( listFile );
- try
- {
- InputStreamReader isr = new InputStreamReader( stream, "UTF-8" );
- BufferedReader reader = new BufferedReader( isr );
- String line = reader.readLine();
- while ( line != null )
- {
- list.add( line );
- line = reader.readLine();
- }
- String[] items = new String[ list.size() ];
- list.toArray( items );
- return items;
- }
- finally
- {
- stream.close();
- }
- }
-
- private static InputStream openInputStream( URL url ) throws IOException
- {
- try
- {
- return url.openStream();
- }
- catch( IOException e )
- {
- System.out.println( "#URL: " + url );
- System.out.println( e.toString() );
- throw e;
- }
- }
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Constructor.
- */
- private Util()
- {
- }
-}

Added: trunk/main/transit/core/src/main/net/dpml/util/package-info.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/package-info.java
2007-02-08 23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/package-info.java
2007-02-08 23:47:32 UTC (rev 1835)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2004-2007 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.
+ */
+
+/**
+ * Common utility interfaces.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+package net.dpml.util;

Deleted: trunk/main/transit/core/src/main/net/dpml/util/package.html
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/util/package.html 2007-02-08
23:46:20 UTC (rev 1834)
+++ trunk/main/transit/core/src/main/net/dpml/util/package.html 2007-02-08
23:47:32 UTC (rev 1835)
@@ -1,7 +0,0 @@
-
-<body>
-<p>
-Common transit utilities.
-</p>
-</body>
-




  • r1835 - trunk/main/transit/core/src/main/net/dpml/util, mcconnell at BerliOS, 02/08/2007

Archive powered by MHonArc 2.6.24.

Top of Page