donaldp 01/04/03 16:18:04
Modified: proposal/4.0/src/java/org/apache/avalon/camelot
AbstractContainer.java AbstractDeployer.java
DefaultFactory.java DefaultLoader.java
DeployerUtil.java
proposal/4.0/src/java/org/apache/avalon/datasource
JdbcConnection.java JdbcConnectionPool.java
JdbcDataSource.java
proposal/4.0/src/java/org/apache/avalon/thread
DefaultThreadPool.java WorkerThread.java
proposal/4.0/src/java/org/apache/framework/component
ComponentException.java
proposal/4.0/src/java/org/apache/framework/configuration
ConfigurationException.java
proposal/4.0/src/java/org/apache/log/format
AvalonLogFormatter.java
Added: proposal/4.0/src/java/org/apache/avalon/camelot
Container.java ContainerException.java
Deployer.java DeploymentException.java Entry.java
Factory.java FactoryException.java Loader.java
Locator.java MetaInfo.java Registry.java
RegistryException.java State.java
proposal/4.0/src/java/org/apache/avalon/thread
ThreadContext.java ThreadManager.java
ThreadPool.java
proposal/4.0/src/java/org/apache/framework
CascadingError.java CascadingException.java
CascadingRuntimeException.java
CascadingThrowable.java ExceptionUtil.java
proposal/4.0/src/java/org/apache/framework/component
DefaultComponentManager.java
DefaultComponentSelector.java
proposal/4.0/src/java/org/apache/framework/configuration
AbstractConfiguration.java
DefaultConfiguration.java
DefaultConfigurationBuilder.java
SAXConfigurationHandler.java
proposal/4.0/src/java/org/apache/framework/context
DefaultContext.java
proposal/4.0/src/java/org/apache/framework/logger
AbstractLoggable.java
Removed: proposal/4.0/src/java/org/apache/aut CascadingError.java
CascadingException.java
CascadingRuntimeException.java
CascadingThrowable.java ExceptionUtil.java
proposal/4.0/src/java/org/apache/avalon/component
DefaultComponentManager.java
DefaultComponentSelector.java
proposal/4.0/src/java/org/apache/avalon/configuration
AbstractConfiguration.java
DefaultConfiguration.java
DefaultConfigurationBuilder.java
SAXConfigurationHandler.java
proposal/4.0/src/java/org/apache/avalon/context
DefaultContext.java
proposal/4.0/src/java/org/apache/avalon/logger
AbstractLoggable.java
proposal/4.0/src/java/org/apache/framework/container
Container.java ContainerException.java
Deployer.java DeploymentException.java Entry.java
Factory.java FactoryException.java Loader.java
Locator.java MetaInfo.java Registry.java
RegistryException.java State.java
proposal/4.0/src/java/org/apache/framework/thread
ThreadContext.java ThreadManager.java
ThreadPool.java
Log:
Moved implementations to live with their interfaces in framework.
Moved container interfaces to camelot as they are not stable enough.
Revision Changes Path
1.5 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractContainer.java
Index: AbstractContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractContainer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractContainer.java 2001/03/15 04:34:44 1.4
+++ AbstractContainer.java 2001/04/03 23:17:59 1.5
@@ -13,7 +13,7 @@
import org.apache.framework.container.Container;
import org.apache.framework.container.ContainerException;
import org.apache.framework.container.Entry;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.framework.logger.AbstractLoggable;
/**
* This contains it during execution and may provide certain
1.5 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractDeployer.java
Index: AbstractDeployer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractDeployer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractDeployer.java 2001/03/15 04:34:44 1.4
+++ AbstractDeployer.java 2001/04/03 23:17:59 1.5
@@ -14,7 +14,7 @@
import java.io.OutputStream;
import java.net.URL;
import java.util.HashMap;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.framework.logger.AbstractLoggable;
import org.apache.framework.component.Component;
import org.apache.aut.io.FileUtil;
import org.apache.log.Logger;
1.5 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultFactory.java 2001/03/15 04:34:45 1.4
+++ DefaultFactory.java 2001/04/03 23:17:59 1.5
@@ -9,7 +9,7 @@
import java.net.URL;
import java.util.HashMap;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.framework.logger.AbstractLoggable;
import org.apache.framework.component.Component;
import org.apache.framework.container.Factory;
import org.apache.framework.container.FactoryException;
1.5 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLoader.java
Index: DefaultLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLoader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultLoader.java 2001/04/03 04:41:41 1.4
+++ DefaultLoader.java 2001/04/03 23:17:59 1.5
@@ -9,7 +9,7 @@
import java.net.URL;
import java.net.URLClassLoader;
-import org.apache.aut.ExceptionUtil;
+import org.apache.framework.ExceptionUtil;
import org.apache.framework.component.Component;
import org.apache.framework.container.FactoryException;
import org.apache.framework.container.Loader;
1.4 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeployerUtil.java
Index: DeployerUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeployerUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DeployerUtil.java 2001/03/15 04:34:45 1.3
+++ DeployerUtil.java 2001/04/03 23:17:59 1.4
@@ -18,7 +18,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.apache.avalon.configuration.DefaultConfigurationBuilder;
+import org.apache.framework.configuration.DefaultConfigurationBuilder;
import org.apache.framework.component.ComponentManager;
import org.apache.framework.component.Composer;
import org.apache.framework.configuration.Configuration;
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Container.java
Index: Container.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import java.util.Iterator;
import org.apache.framework.component.Component;
/**
* This contains it during execution and may provide certain
* facilities (like a thread per EJB etc).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Container
extends Component
{
/**
* Add a component instance to container.
*
* @param entry the component entry
*/
void add( String name, Entry entry )
throws ContainerException;
/**
* Remove a component instance from container.
*
* @param name the name of component
*/
void remove( String name )
throws ContainerException;
/**
* Retrieve Entry from container
*
* @param name the name of entry
* @return the entry
*/
Entry getEntry( String name )
throws ContainerException;
/**
* List all names of entries in container.
*
* @return the list of all entries
*/
Iterator list();
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/ContainerException.java
Index: ContainerException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.CascadingException;
/**
* Exception to indicate error manipulating container.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public final class ContainerException
extends CascadingException
{
/**
* Construct a new <code>ContainerException</code> instance.
*
* @param message The detail message for this exception.
*/
public ContainerException( final String message )
{
this( message, null );
}
/**
* Construct a new <code>ContainerException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public ContainerException( final String message, final Throwable
throwable )
{
super( message, throwable );
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Deployer.java
Index: Deployer.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import java.net.URL;
import org.apache.framework.component.Component;
/**
* A Deployer is responsible for taking a URL (ie a jar/war/ear) and deploying
* it to a particular "location". "location" means different things for
* different containers. For a servlet container it may mean the place to
* mount servlet (ie /myapp --> /myapp/Cocoon.xml is mapping cocoon servlet to
* /myapp context).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Deployer
extends Component
{
/**
* Deploy a resource indicate by url to location.
*
* @param location the location to deploy to
* @param url the url of deployment
* @exception DeploymentException if an error occurs
*/
void deploy( String location, URL url )
throws DeploymentException;
/**
* undeploy a resource from a location.
*
* @param location the location
* @exception DeploymentException if an error occurs
*/
void undeploy( String location )
throws DeploymentException;
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeploymentException.java
Index: DeploymentException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.CascadingException;
/**
* Exception to indicate error deploying.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public final class DeploymentException
extends CascadingException
{
/**
* Construct a new <code>DeploymentException</code> instance.
*
* @param message The detail message for this exception.
*/
public DeploymentException( final String message )
{
this( message, null );
}
/**
* Construct a new <code>DeploymentException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public DeploymentException( final String message, final Throwable
throwable )
{
super( message, throwable );
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Entry.java
Index: Entry.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.component.Component;
/**
* Contains information about a particular instance of contained component.
* This would contain name, configuration data, parameters, log entries etc.
* Basically instance data.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class Entry
implements Component
{
protected MetaInfo m_info;
protected Object m_instance;
protected State m_state;
public Entry()
{
}
public Entry( final MetaInfo info, final Object instance, final State
state )
{
m_info = info;
m_instance = instance;
m_state = state;
}
/**
* Retrieve MetaInfo describing instance.
*
* @return the info
*/
public MetaInfo getInfo()
{
return m_info;
}
/**
* Mutator for info property.
*
* @param info the MetaInfo
*/
public void setInfo( final MetaInfo info )
{
m_info = info;
}
/**
* Retrieve instance of component.
*
* @return the component instance
*/
public Object getInstance()
{
return m_instance;
}
/**
* Set instance of component.
*
* @return the component instance
*/
public void setInstance( final Object instance )
{
m_instance = instance;
}
/**
* Retrieve state of a component.
*
* @return the components state
*/
public State getState()
{
return m_state;
}
/**
* set state of a component.
*
* @param state the components state
*/
public void setState( final State state )
{
m_state = state;
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Factory.java
Index: Factory.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.component.Component;
/**
* This is the component that creates the components.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Factory
extends Component
{
/**
* Create a component whos position is indicated by locator.
*
* @param locator the locator indicating the component location
* @return the component
* @exception FactoryException if an error occurs
*/
Object create( Locator locator )
throws FactoryException;
/**
* Create a component whos position is indicated by locator.
* Make sure it is of the correct type.
*
* @param locator the locator indicating the component location
* @param clazz the expected type of component
* @return the component
* @exception FactoryException if an error occurs
*/
Object create( Locator locator, Class clazz )
throws FactoryException;
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/FactoryException.java
Index: FactoryException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.CascadingException;
/**
* Exception to indicate error creating entries in factory.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public final class FactoryException
extends CascadingException
{
/**
* Construct a new <code>FactoryException</code> instance.
*
* @param message The detail message for this exception.
*/
public FactoryException( final String message )
{
this( message, null );
}
/**
* Construct a new <code>FactoryException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public FactoryException( final String message, final Throwable throwable
)
{
super( message, throwable );
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Loader.java
Index: Loader.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.component.Component;
/**
* Class used to load resources from a source.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Loader
extends Component
{
/**
* Retrieve classloader associated with source.
*
* @return the ClassLoader
*/
ClassLoader getClassLoader();
/**
* Load an object from source.
*
* @param component the name of object
* @return the Object
* @exception Exception if an error occurs
*/
Object load( String component )
throws FactoryException;
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Locator.java
Index: Locator.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import java.net.URL;
import org.apache.framework.component.Component;
/**
* This contains information required to locate a component.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Locator
extends MetaInfo
{
/**
* Retrieve "name" of component type.
* The "name" usually indicates the classname.
*
* @return the name
*/
String getName();
/**
* Retrieve location of component.
* Usually references the archive (zip/jar/war/ear)
* which contains the name (ie classname)
*
* @return the URL of location
*/
URL getLocation();
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/MetaInfo.java
Index: MetaInfo.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
/**
* This contains information about the component.
* (ie would be a BlockInfo, an EJBDescriptor, a MailetInfo etc)
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface MetaInfo
{
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Registry.java
Index: Registry.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import java.util.Iterator;
import org.apache.framework.component.Component;
/**
* Represents a database of Infos.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface Registry
extends Component
{
/**
* register an info under a particular name.
*
* @param name the name
* @param info the info
* @exception RegistryException if info is invalid or name already
contains info under name
*/
void register( String name, MetaInfo info ) throws RegistryException;
/**
* unregister an info.
*
* @param name the name of info
* @exception RegistryException if no such info exists
*/
void unregister( String name ) throws RegistryException;
/**
* Retrieve an MetaInfo by name.
*
* @param name the name
* @return the MetaInfo
* @exception RegistryException if an error occurs
*/
MetaInfo getInfo( String name ) throws RegistryException;
/**
* Return an iterator of all names of infos registered.
*
* @return the info names
*/
Iterator getInfoNames();
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/RegistryException.java
Index: RegistryException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.framework.CascadingException;
/**
* Exception to indicate registry error.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public final class RegistryException
extends CascadingException
{
/**
* Construct a new <code>RegistryException</code> instance.
*
* @param message The detail message for this exception.
*/
public RegistryException( final String message )
{
this( message, null );
}
/**
* Construct a new <code>RegistryException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public RegistryException( final String message, final Throwable throwable
)
{
super( message, throwable );
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/State.java
Index: State.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.container;
import org.apache.aut.ValuedEnum;
/**
* Defines possible states for contained components.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public abstract class State
extends ValuedEnum
{
public State( final String name, final int value )
{
super( name, value );
}
}
1.6 +2 -2
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnection.java
Index: JdbcConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JdbcConnection.java 2001/04/03 04:41:42 1.5
+++ JdbcConnection.java 2001/04/03 23:18:01 1.6
@@ -15,7 +15,7 @@
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Map;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.framework.logger.AbstractLoggable;
import org.apache.avalon.pool.Recyclable;
import org.apache.avalon.pool.Pool;
import org.apache.avalon.pool.Poolable;
@@ -29,7 +29,7 @@
* total number of Connection objects that are created.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/04/03 04:41:42 $
+ * @version CVS $Revision: 1.6 $ $Date: 2001/04/03 23:18:01 $
*/
public class JdbcConnection
extends AbstractLoggable
1.7 +4 -4
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnectionPool.java
Index: JdbcConnectionPool.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnectionPool.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JdbcConnectionPool.java 2001/04/03 04:41:42 1.6
+++ JdbcConnectionPool.java 2001/04/03 23:18:01 1.7
@@ -12,19 +12,19 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.avalon.pool.Pool;
+import org.apache.avalon.pool.Poolable;
import org.apache.avalon.pool.Recyclable;
import org.apache.framework.lifecycle.Disposable;
import org.apache.framework.lifecycle.Initializable;
-import org.apache.avalon.pool.Pool;
-import org.apache.avalon.pool.Poolable;
+import org.apache.framework.logger.AbstractLoggable;
/**
* The Pool implementation for JdbcConnections. It uses a background
* thread to manage the number of SQL Connections.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/04/03 04:41:42 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/04/03 23:18:01 $
*/
public class JdbcConnectionPool
extends AbstractLoggable
1.5 +2 -2
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcDataSource.java
Index: JdbcDataSource.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcDataSource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JdbcDataSource.java 2001/03/15 04:34:50 1.4
+++ JdbcDataSource.java 2001/04/03 23:18:01 1.5
@@ -12,7 +12,7 @@
import org.apache.framework.configuration.Configuration;
import org.apache.framework.configuration.ConfigurationException;
import org.apache.framework.lifecycle.Disposable;
-import org.apache.avalon.logger.AbstractLoggable;
+import org.apache.framework.logger.AbstractLoggable;
/**
* The Default implementation for DataSources in Avalon. This uses the
@@ -20,7 +20,7 @@
* <code>java.sql.DriverManager</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/03/15 04:34:50 $
+ * @version CVS $Revision: 1.5 $ $Date: 2001/04/03 23:18:01 $
*/
public class JdbcDataSource
extends AbstractLoggable
1.4 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/DefaultThreadPool.java
Index: DefaultThreadPool.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/DefaultThreadPool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultThreadPool.java 2001/04/03 04:41:44 1.3
+++ DefaultThreadPool.java 2001/04/03 23:18:01 1.4
@@ -11,7 +11,7 @@
import org.apache.avalon.pool.ObjectFactory;
import org.apache.avalon.pool.Poolable;
import org.apache.avalon.pool.ThreadSafePool;
-import org.apache.framework.thread.ThreadPool;
+import org.apache.avalon.thread.ThreadPool;
import org.apache.log.Logger;
/**
1.7 +2 -2
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/WorkerThread.java
Index: WorkerThread.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/WorkerThread.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WorkerThread.java 2001/04/03 04:41:45 1.6
+++ WorkerThread.java 2001/04/03 23:18:01 1.7
@@ -10,8 +10,8 @@
import org.apache.avalon.pool.Poolable;
import org.apache.avalon.pool.ThreadSafePool;
import org.apache.framework.logger.Loggable;
-import org.apache.framework.thread.ThreadContext;
-import org.apache.framework.thread.ThreadPool;
+import org.apache.avalon.thread.ThreadContext;
+import org.apache.avalon.thread.ThreadPool;
import org.apache.log.Logger;
/**
1.4 +0 -4
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/ThreadContext.java
1.4 +0 -0
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/ThreadManager.java
1.6 +0 -0
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/thread/ThreadPool.java
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/CascadingError.java
Index: CascadingError.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework;
/**
* Class from which all exceptions should inherit.
* Allows recording of nested exceptions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public abstract class CascadingError
extends Error
implements CascadingThrowable
{
private final Throwable m_throwable;
/**
* Construct a new <code>CascadingError</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public CascadingError( final String message, final Throwable throwable )
{
super( message );
m_throwable = throwable;
}
/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/CascadingException.java
Index: CascadingException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework;
/**
* Class from which all exceptions should inherit.
* Allows recording of nested exceptions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class CascadingException
extends Exception
implements CascadingThrowable
{
private final Throwable m_throwable;
/**
* Construct a new <code>CascadingException</code> instance.
*
* @param message The detail message for this exception.
*/
public CascadingException( final String message )
{
this( message, null );
}
/**
* Construct a new <code>CascadingException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public CascadingException( final String message, final Throwable
throwable )
{
super( message );
m_throwable = throwable;
}
/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/CascadingRuntimeException.java
Index: CascadingRuntimeException.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework;
/**
* Class from which all exceptions should inherit.
* Allows recording of nested exceptions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public abstract class CascadingRuntimeException
extends RuntimeException
implements CascadingThrowable
{
private final Throwable m_throwable;
/**
* Construct a new <code>CascadingRuntimeException</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public CascadingRuntimeException( final String message, final Throwable
throwable )
{
super( message );
m_throwable = throwable;
}
/**
* Retrieve root cause of the exception.
*
* @return the root cause
*/
public final Throwable getCause()
{
return m_throwable;
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/CascadingThrowable.java
Index: CascadingThrowable.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework;
/**
* Interface which all cascadign throwables should implement.
* Allows recording of nested exceptions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public interface CascadingThrowable
{
Throwable getCause();
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/ExceptionUtil.java
Index: ExceptionUtil.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* This class provides basic facilities for manipulating exceptions.
*
* Some exception handling stuff thieved from Turbine...
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Rafal Krzewski</a>
*/
public final class ExceptionUtil
{
/**
* Private constructor to prevent instantiation.
*/
private ExceptionUtil()
{
}
public static String printStackTrace( final Throwable throwable )
{
return printStackTrace( throwable, 0, true );
}
public static String printStackTrace( final Throwable throwable,
final boolean printCascading )
{
return printStackTrace( throwable, 0, printCascading );
}
public static String printStackTrace( final Throwable throwable, int
depth )
{
final String[] lines = captureStackTrace( throwable );
if( 0 == depth || depth > lines.length ) depth = lines.length;
final StringBuffer sb = new StringBuffer();
for( int i = 0; i < depth; i++ )
{
sb.append( lines[ i ] );
sb.append( '\n' );
}
return sb.toString();
}
public static String printStackTrace( Throwable throwable,
final int depth,
final boolean printCascading )
{
final String result = printStackTrace( throwable, depth );
if( !printCascading || !(throwable instanceof CascadingThrowable) )
{
return result;
}
else
{
final StringBuffer sb = new StringBuffer();
sb.append( result );
throwable = ((CascadingThrowable)throwable).getCause();
while( null != throwable )
{
sb.append( "rethrown from\n" );
sb.append( printStackTrace( throwable, depth ) );
if( throwable instanceof CascadingThrowable )
{
throwable = ((CascadingThrowable)throwable).getCause();
}
else
{
throwable = null;
}
}
return sb.toString();
}
}
/**
* Captures the stack trace associated with this exception.
*
* @return an array of Strings describing stack frames.
*/
public static String[] captureStackTrace( final Throwable throwable )
{
final StringWriter sw = new StringWriter();
throwable.printStackTrace( new PrintWriter( sw, true ) );
return splitString( sw.toString(), "\n" );
}
/**
* Splits the string on every token into an array of stack frames.
*
* @param string the string
* @param onToken the token
* @return the resultant array
*/
public static String[] splitString( final String string, final String
onToken )
{
final StringTokenizer tokenizer = new StringTokenizer( string,
onToken );
final ArrayList lines = new ArrayList();
while( tokenizer.hasMoreTokens() )
{
lines.add( tokenizer.nextToken() );
}
return (String[])lines.toArray( new String[ 0 ] );
}
}
1.2 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/component/ComponentException.java
Index: ComponentException.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/framework/component/ComponentException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentException.java 2001/03/15 04:35:01 1.1
+++ ComponentException.java 2001/04/03 23:18:02 1.2
@@ -7,7 +7,7 @@
*/
package org.apache.framework.component;
-import org.apache.aut.CascadingException;
+import org.apache.framework.CascadingException;
/**
* This base class of exceptions thrown by ComponentManager.
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/component/DefaultComponentManager.java
Index: DefaultComponentManager.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.component;
import java.util.HashMap;
import java.util.Iterator;
/**
* This class is a static implementation of a ComponentManager. Allow
ineritance
* and extention so you can generate a tree of ComponentManager each defining
* Component scope.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class DefaultComponentManager
implements ComponentManager
{
protected final HashMap m_components = new HashMap();
protected final ComponentManager m_parent;
public DefaultComponentManager()
{
this( null );
}
public DefaultComponentManager( final ComponentManager parent )
{
m_parent = parent;
}
public Component lookup( final String role )
throws ComponentException
{
final Component component = (Component)m_components.get( role );
if( null != component )
{
return component;
}
else if( null != m_parent )
{
return m_parent.lookup( role );
}
else
{
throw new ComponentException("Unable to provide implementation
for " + role);
}
}
public void put( final String name, final Component component )
{
m_components.put( name, component );
}
public void release( final Component component )
{
// if the ComponentManager handled pooling, it would be
// returned to the pool here.
}
public String toString()
{
final StringBuffer buffer = new StringBuffer();
final Iterator components = m_components.keySet().iterator();
buffer.append( "Components:" );
while( components.hasNext() )
{
buffer.append( "[" );
buffer.append( components.next() );
buffer.append( "]" );
}
return buffer.toString();
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/component/DefaultComponentSelector.java
Index: DefaultComponentSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.component;
import java.util.HashMap;
/**
* This is the default implementation of the ComponentSelector
*/
public class DefaultComponentSelector implements ComponentSelector {
protected final HashMap components = new HashMap();
public DefaultComponentSelector() {
// do nothing
}
/**
* Select the desired component. It does not cascade, neither
* should it.
*/
public Component select(Object hint)
throws ComponentException {
final Component component = (Component) components.get(hint);
if ( component != null ) {
return component;
} else {
throw new ComponentException( "Unable to provide implementation
for " +
hint.toString() );
}
}
public void release( final Component component )
{
// if the ComponentManager handled pooling, it would be
// returned to the pool here.
}
/**
* Populate the ComponentSelector.
*/
public void put(final Object hint, final Component component) {
this.components.put(hint, component);
}
}
1.2 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/ConfigurationException.java
Index: ConfigurationException.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/ConfigurationException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConfigurationException.java 2001/03/15 04:35:02 1.1
+++ ConfigurationException.java 2001/04/03 23:18:02 1.2
@@ -7,7 +7,7 @@
*/
package org.apache.framework.configuration;
-import org.apache.aut.CascadingException;
+import org.apache.framework.CascadingException;
/**
* Thrown when a <code>Configurable</code> component cannot be configured
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/AbstractConfiguration.java
Index: AbstractConfiguration.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.configuration;
import java.util.Iterator;
/**
* This is an abstract <code>Configuration</code> implementation that deals
* with methods that can be abstracted away from underlying implementations.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/04/03 23:18:02 $
* @deprecated This has been deprecated in favour of configuration interface
in org.apache.avalon.configuration interface
*/
public abstract class AbstractConfiguration
implements Configuration
{
private static int PREFIX = 2;
/**
* Returns the value of the configuration element as an <code>int</code>.
*/
public int getValueAsInt()
throws ConfigurationException
{
final String value = getValue();
try
{
if( value.startsWith("0x") )
{
return Integer.parseInt(
value.substring(AbstractConfiguration.PREFIX), 16 );
}
else if( value.startsWith("0o") )
{
return Integer.parseInt(
value.substring(AbstractConfiguration.PREFIX), 8 );
}
else if( value.startsWith("0b") )
{
return Integer.parseInt(
value.substring(AbstractConfiguration.PREFIX), 2 );
}
else
{
return Integer.parseInt( value );
}
}
catch( final Exception nfe )
{
throw
new ConfigurationException( "Cannot parse the value of the
configuration " +
"element \"" + getName() + "\" as
an integer" );
}
}
/**
* Returns the value of the configuration element as an <code>int</code>.
*/
public int getValueAsInt( final int defaultValue )
{
try
{
return getValueAsInt();
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the configuration element as a <code>long</code>.
*/
public long getValueAsLong()
throws ConfigurationException
{
final String value = getValue();
try
{
if( value.startsWith("0x") )
{
return Long.parseLong( value.substring(2), 16 );
}
else if( value.startsWith("0o") )
{
return Long.parseLong( value.substring(2), 8);
}
else if( value.startsWith("0b") )
{
return Long.parseLong(value.substring(2),2);
}
else return Integer.parseInt(value);
}
catch( final Exception nfe )
{
throw new ConfigurationException( "Cannot parse the value of the
" +
"configuration element \"" +
getName() +
"\" as a long" );
}
}
/**
* Returns the value of the configuration element as a <code>long</code>.
*/
public long getValueAsLong( final long defaultValue )
{
try
{
return getValueAsLong();
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the configuration element as a <code>float</code>.
*/
public float getValueAsFloat()
throws ConfigurationException
{
final String value = getValue();
try
{
return Float.parseFloat( value );
}
catch( final Exception nfe )
{
throw new ConfigurationException( "Cannot parse the value of the
" +
"configuration element \"" +
getName() +
"\" as a float" );
}
}
/**
* Returns the value of the configuration element as a <code>float</code>.
*/
public float getValueAsFloat( final float defaultValue )
{
try
{
return getValueAsFloat();
}
catch( final ConfigurationException ce )
{
return(defaultValue);
}
}
/**
* Returns the value of the configuration element as a
<code>boolean</code>.
*/
public boolean getValueAsBoolean()
throws ConfigurationException
{
final String value = getValue();
if( value.equals("true") ) return true;
else if( value.equals("false") ) return false;
else
{
throw new ConfigurationException( "Cannot parse the value of the
" +
"configuration element \"" +
getName() + "\" as a boolean" );
}
}
/**
* Returns the value of the configuration element as a
<code>boolean</code>.
*/
public boolean getValueAsBoolean( final boolean defaultValue )
{
try
{
return getValueAsBoolean();
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the configuration element as a
<code>String</code>.
*/
public String getValue( final String defaultValue )
{
try
{
return getValue();
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the attribute specified by its name as an
* <code>int</code>.
*/
public int getAttributeAsInt( final String name )
throws ConfigurationException
{
final String value = getAttribute( name );
try
{
if( value.startsWith("0x") )
{
return Integer.parseInt( value.substring(2), 16 );
}
else if( value.startsWith("0o") )
{
return Integer.parseInt( value.substring(2), 8);
}
else if( value.startsWith("0b") )
{
return Integer.parseInt(value.substring(2),2);
}
else
{
return Integer.parseInt(value);
}
}
catch( final Exception nfe )
{
throw new ConfigurationException( "Cannot parse the value of the
attribute \"" +
name + "\" of the configuration
element \"" +
getName() + "\" as an integer"
);
}
}
/**
* Returns the value of the attribute specified by its name as an
* <code>int</code>.
*/
public int getAttributeAsInt( final String name, final int defaultValue )
{
try
{
return getAttributeAsInt( name );
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>long</code>.
*/
public long getAttributeAsLong( final String name )
throws ConfigurationException
{
final String value = getAttribute( name );
try
{
if( value.startsWith("0x") )
{
return Long.parseLong( value.substring(2), 16 );
}
else if( value.startsWith("0o") )
{
return Long.parseLong( value.substring(2), 8 );
}
else if( value.startsWith("0b") )
{
return Long.parseLong( value.substring(2), 2);
}
else
{
return Integer.parseInt( value );
}
}
catch( final Exception nfe )
{
throw new ConfigurationException( "Cannot parse the value of the
attribute \"" +
name + "\" of the configuration
element \"" +
getName() + "\" as a long" );
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>long</code>.
*/
public long getAttributeAsLong( final String name, final long
defaultValue )
{
try
{
return getAttributeAsLong( name );
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>float</code>.
*/
public float getAttributeAsFloat( final String name )
throws ConfigurationException
{
final String value = getAttribute( name );
try
{
return Float.parseFloat( value );
}
catch( final Exception e )
{
throw new ConfigurationException( "Cannot parse the value of the
attribute \"" +
name + "\" of the configuration
element \"" +
getName() + "\" as a float" );
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>float</code>.
*/
public float getAttributeAsFloat( final String name, final float
defaultValue )
{
try
{
return getAttributeAsFloat( name );
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>boolean</code>.
*/
public boolean getAttributeAsBoolean( final String name )
throws ConfigurationException
{
final String value = getAttribute( name );
if( value.equals("true") ) return true;
else if( value.equals("false") ) return false;
else
{
throw new ConfigurationException( "Cannot parse the value of the
attribute \"" +
name + "\" of the configuration
element \"" +
getName() + "\" as a boolean" );
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>boolean</code>.
*/
public boolean getAttributeAsBoolean( final String name, final boolean
defaultValue )
{
try
{
return getAttributeAsBoolean( name );
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>String</code>.
*/
public String getAttribute( final String name, final String defaultValue )
{
try
{
return getAttribute( name );
}
catch( final ConfigurationException ce )
{
return defaultValue;
}
}
/**
* Return the first <code>Configuration</code> object child of this
* associated with the given name.
*/
public Configuration getChild( final String name )
{
final Iterator iterator = getChildren( name );
if( iterator.hasNext() )
{
return (Configuration)iterator.next();
}
else
{
return new DefaultConfiguration( name, "-" );
}
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/DefaultConfiguration.java
Index: DefaultConfiguration.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.configuration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
/**
* This is the default <code>Configuration</code> implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @deprecated This has been deprecated in favour of configuration interface
in org.apache.avalon.configuration interface
*/
public class DefaultConfiguration
extends AbstractConfiguration
{
protected final static Iterator EMPTY_ITERATOR = (new
ArrayList(1)).iterator();
protected final String m_name;
protected final String m_location;
protected HashMap m_attributes;
protected ArrayList m_children;
protected String m_value;
/**
* Create a new <code>DefaultConfiguration</code> instance.
*/
public DefaultConfiguration( final String name, final String location )
{
m_name = name;
m_location = location;
}
/**
* Returns the name of this configuration element.
*/
public String getName()
{
return m_name;
}
/**
* Returns a description of location of element.
*/
public String getLocation()
{
return m_location;
}
/**
* Returns the value of the configuration element as a
<code>String</code>.
*
* @exception ConfigurationException If the value is not present.
*/
public String getValue() throws ConfigurationException
{
if( null != m_value ) return m_value;
else
{
throw new ConfigurationException( "No value is associated with
the "+
"configuration element \"" +
getName() + "\"" );
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>String</code>.
*
* @exception ConfigurationException If the attribute is not present.
*/
public String getAttribute( final String name )
throws ConfigurationException
{
final String value =
(null != m_attributes) ? (String)m_attributes.get( name ) : null;
if( null != value ) return value;
else
{
throw new ConfigurationException( "No attribute named \"" + name
+ "\" is " +
"associated with the
configuration element \"" +
getName() + "\"" );
}
}
/**
* Return the first <code>Configuration</code> object child of this
* associated with the given name. If none exists a new one of that name
is created.
*
* @param name The name of the required child <code>Configuration</code>.
*/
public Configuration getChild( final String name )
{
if( null == m_children )
{
return new DefaultConfiguration( name, "-" );
}
else
{
final int size = m_children.size();
for( int i = 0; i < size; i++ )
{
final Configuration configuration =
(Configuration)m_children.get( i );
if( name.equals( configuration.getName() ) )
{
return configuration;
}
}
return new DefaultConfiguration( name, "-" );
}
}
/**
* Return an <code>Enumeration</code> of <code>Configuration</code>
objects
* children of this associated with the given name.
* <br>
* The returned <code>Enumeration</code> may be empty.
*
* @param name The name of the required children
<code>Configuration</code>.
*/
public Iterator getChildren( final String name )
{
if( null == m_children ) return EMPTY_ITERATOR;
else
{
final ArrayList children = new ArrayList();
final int size = m_children.size();
for( int i = 0; i < size; i++ )
{
final Configuration configuration =
(Configuration)m_children.get( i );
if( name.equals( configuration.getName() ) )
{
children.add( configuration );
}
}
return children.iterator();
}
}
public Configuration[] getChildrenAsArray( final String name )
{
if( null == m_children ) return new Configuration[0];
else
{
final ArrayList children = new ArrayList();
final int size = m_children.size();
for( int i = 0; i < size; i++ )
{
final Configuration configuration =
(Configuration)m_children.get( i );
if( name.equals( configuration.getName() ) )
{
children.add( configuration );
}
}
Configuration[] response = new Configuration[children.size()];
for (int i = 0; i < children.size(); i++) {
response[i] = (Configuration) children.get(i);
}
return response;
}
}
/**
* Append data to the value of this configuration element.
*/
public void appendValueData( final String value )
{
if( null == m_value )
{
m_value = value;
}
else
{
m_value = m_value + value;
}
}
/**
* Add an attribute to this configuration element, returning its old
* value or <b>null</b>.
*/
public String addAttribute( final String name, String value )
{
if( null == m_attributes ) m_attributes = new HashMap();
return (String) m_attributes.put( name, value );
}
/**
* Add a child <code>Configuration</code> to this configuration element.
*/
public void addChild( final Configuration configuration )
{
if( null == m_children )
{
m_children = new ArrayList();
}
m_children.add( configuration );
}
/**
* Return count of children.
*/
public int getChildCount()
{
if( null == m_children )
{
return 0;
}
return m_children.size();
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/DefaultConfigurationBuilder.java
Index: DefaultConfigurationBuilder.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.configuration;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
/**
* A SAXConfigurationBuilder builds configurations via SAX2 compliant parser.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class DefaultConfigurationBuilder
implements ConfigurationBuilder
{
protected final static String DEFAULT_PARSER =
"org.apache.xerces.parsers.SAXParser";
protected final static String PARSER =
System.getProperty("org.xml.sax.parser", DEFAULT_PARSER );
protected SAXConfigurationHandler m_handler;
protected XMLReader m_parser;
public DefaultConfigurationBuilder()
{
this( PARSER );
}
public DefaultConfigurationBuilder( final String parserClass )
{
//yaya the bugs with some compilers and final variables ..
m_handler = getHandler();
try
{
m_parser = XMLReaderFactory.createXMLReader( parserClass );
//m_parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
m_parser.setContentHandler( m_handler );
m_parser.setErrorHandler( m_handler );
}
catch( final SAXException se )
{
throw new Error( "Unable to setup SAX parser" + se );
}
}
protected SAXConfigurationHandler getHandler()
{
return new SAXConfigurationHandler();
}
public Configuration build( final String resource )
throws SAXException, IOException, ConfigurationException
{
final InputStream input = new FileInputStream( resource );
try { return build( input ); }
finally
{
try { input.close(); }
catch( final IOException ioe ) {}
}
}
public Configuration build( final InputStream inputStream )
throws SAXException, IOException, ConfigurationException
{
final InputSource inputSource = new InputSource( inputStream );
return build( inputSource );
}
public Configuration build( final InputSource input )
throws SAXException, IOException, ConfigurationException
{
m_handler.clear();
m_parser.parse( input );
return m_handler.getConfiguration();
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/SAXConfigurationHandler.java
Index: SAXConfigurationHandler.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.configuration;
import java.io.IOException;
import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
/**
* A SAXConfigurationHandler helps build Configurations out of sax events.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class SAXConfigurationHandler
extends DefaultHandler
implements ErrorHandler
{
protected final ArrayList m_elements = new
ArrayList();
protected Configuration m_configuration;
protected Locator m_locator;
public Configuration getConfiguration()
{
return m_configuration;
}
public void clear()
{
m_elements.clear();
m_locator = null;
}
public void setDocumentLocator( final Locator locator )
{
m_locator = locator;
}
public void characters( final char[] ch, int start, int end )
throws SAXException
{
final String value = (new String( ch, start, end )).trim();
if( value.equals( "" ) ) return;
final DefaultConfiguration configuration =
(DefaultConfiguration)m_elements.get( m_elements.size() - 1 );
if( 0 != configuration.getChildCount() )
{
throw new SAXException( "Not allowed to define mixed content in
the " +
"element " + configuration.getName() + "
at " +
configuration.getLocation() );
}
configuration.appendValueData( value );
}
public void endElement( final String namespaceURI,
final String localName,
final String rawName )
{
final int location = m_elements.size() - 1;
final Object object = m_elements.remove( location );
if( 0 == location )
{
m_configuration = (Configuration)object;
}
}
protected DefaultConfiguration createConfiguration( final String
localName,
final String location
)
{
return new DefaultConfiguration( localName, location );
}
public void startElement( final String namespaceURI,
final String localName,
final String rawName,
final Attributes attributes )
throws SAXException
{
final DefaultConfiguration configuration =
createConfiguration( localName, getLocationString() );
final int size = m_elements.size() - 1;
if( size > -1 )
{
final DefaultConfiguration parent =
(DefaultConfiguration)m_elements.get( size );
if( null != parent.getValue( null ) )
{
throw new SAXException( "Not allowed to define mixed content
in the " +
"element " + parent.getName() + " at
" +
parent.getLocation() );
}
parent.addChild( configuration );
}
m_elements.add( configuration );
final int attributesSize = attributes.getLength();
for( int i = 0; i < attributesSize; i++ )
{
final String name = attributes.getQName( i );
final String value = attributes.getValue( i );
configuration.addAttribute( name, value );
}
}
/**
* This just throws an exception on a parse error.
*/
public void error( final SAXParseException exception )
throws SAXException
{
throw exception;
}
/**
* This just throws an exception on a parse error.
*/
public void warning( final SAXParseException exception )
throws SAXException
{
throw exception;
}
/**
* This just throws an exception on a parse error.
*/
public void fatalError( final SAXParseException exception )
throws SAXException
{
throw exception;
}
protected String getLocationString()
{
if( null == m_locator ) return "Unknown";
else
{
return
m_locator.getSystemId() + ":" +
m_locator.getLineNumber() + ":" +
m_locator.getColumnNumber();
}
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/context/DefaultContext.java
Index: DefaultContext.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.context;
import java.util.Hashtable;
import java.util.Map;
import org.apache.framework.context.Context;
/**
* Default implementation of Context.
* This implementation is a static hierarchial store.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Federico Barbieri</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public class DefaultContext
implements Context
{
protected final Map m_contextData;
protected final Context m_parent;
public DefaultContext( final Map contextData, final Context parent )
{
m_parent = parent;
m_contextData = contextData;
}
public DefaultContext( final Map contextData )
{
this( contextData, null );
}
public DefaultContext( final Context parent )
{
this( new Hashtable(), parent );
}
public DefaultContext()
{
this( (Context)null );
}
public Object get( final Object key )
{
final Object data = m_contextData.get( key );
if( null == m_parent || null != data )
{
return data;
}
return m_parent.get( key );
}
public void put( final Object key, final Object value )
{
m_contextData.put( key, value );
}
}
1.1
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/logger/AbstractLoggable.java
Index: AbstractLoggable.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.framework.logger;
import org.apache.framework.component.Component;
import org.apache.framework.logger.Loggable;
import org.apache.log.Logger;
/**
* Helper class to inherit from.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
*/
public abstract class AbstractLoggable
implements Component, Loggable
{
protected Logger m_logger;
public void setLogger( final Logger logger )
{
m_logger = logger;
}
protected final Logger getLogger()
{
return m_logger;
}
protected void setupLogger( final Object component )
{
setupLogger( component, (String)null );
}
protected void setupLogger( final Object component, final String
subCategory )
{
if( component instanceof Loggable )
{
Logger logger = m_logger;
if( null != subCategory )
{
logger = m_logger.getChildLogger( subCategory );
}
((Loggable)component).setLogger( logger );
}
}
protected void setupLogger( final Object component, final Logger logger )
{
if( component instanceof Loggable )
{
((Loggable)component).setLogger( logger );
}
}
}
1.2 +1 -1
jakarta-avalon/proposal/4.0/src/java/org/apache/log/format/AvalonLogFormatter.java
Index: AvalonLogFormatter.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/log/format/AvalonLogFormatter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AvalonLogFormatter.java 2001/02/26 07:32:32 1.1
+++ AvalonLogFormatter.java 2001/04/03 23:18:04 1.2
@@ -8,7 +8,7 @@
package org.apache.log.format;
import java.util.Date;
-import org.apache.aut.ExceptionUtil;
+import org.apache.framework.ExceptionUtil;
import org.apache.log.format.PatternFormatter;
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]