donaldp 2003/04/06 04:34:06
Modified: src/java/org/apache/avalon/cornerstone/blocks/datasource
DefaultDataSourceSelector.java
src/java/org/apache/avalon/cornerstone/blocks/datasources
DefaultDataSourceSelector.java
src/java/org/apache/avalon/cornerstone/blocks/sockets
DefaultSocketManager.java
src/java/org/apache/avalon/cornerstone/blocks/threads
DefaultThreadManager.java
Log:
Update configuration schema type to specify full URI of relax where necessary.
Minor code cleanups
Revision Changes Path
1.32 +190 -190
avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasource/DefaultDataSourceSelector.java
Index: DefaultDataSourceSelector.java
===================================================================
RCS file:
/home/cvs/avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasource/DefaultDataSourceSelector.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- DefaultDataSourceSelector.java 22 Mar 2003 12:50:24 -0000 1.31
+++ DefaultDataSourceSelector.java 6 Apr 2003 11:34:06 -0000 1.32
@@ -3,34 +3,34 @@
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Jakarta", "Apache Avalon", "Avalon Cornerstone", "Avalon
Framework" and "Apache Software Foundation" must not be used to endorse
or promote products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,189 +41,189 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation. For more information on the
+ on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
-
+
*/
-
-package org.apache.avalon.cornerstone.blocks.datasource;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.avalon.cornerstone.services.datasource.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.LogEnabled;
-
-/**
- * The Default implementation for DataSourceSelector.
- * The Configuration is like this:
- *
- * <pre>
- * <myBlock>
- * <data-source name="<i>default</i>"
- * class="<i>org.apache.avalon.excalibur.datasource.JdbcDataSource</i>">
- * <!-- configuration for JdbcDataSource -->
- * <pool-controller min="<i>5</i>" max="<i>10</i>"
connection-class="<i>my.overrided.ConnectionClass</i>">
- * <keep-alive>select 1</keep-alive>
- * </pool-controller>
- * <driver><i>com.database.jdbc.JdbcDriver</i></driver>
- * <dburl><i>jdbc:driver://host/mydb</i></dburl>
- * <user><i>username</i></user>
- * <password><i>password</i></password>
- * </data-source>
- * </myBlock>
- * </pre>
- *
- * @phoenix:block
- * @phoenix:service
name="org.apache.avalon.cornerstone.services.datasource.DataSourceSelector"
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
+
+package org.apache.avalon.cornerstone.blocks.datasource;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.avalon.cornerstone.services.datasource.DataSourceSelector;
+import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.LogEnabled;
+
+/**
+ * The Default implementation for DataSourceSelector.
+ * The Configuration is like this:
+ *
+ * <pre>
+ * <myBlock>
+ * <data-source name="<i>default</i>"
+ * class="<i>org.apache.avalon.excalibur.datasource.JdbcDataSource</i>">
+ * <!-- configuration for JdbcDataSource -->
+ * <pool-controller min="<i>5</i>" max="<i>10</i>"
connection-class="<i>my.overrided.ConnectionClass</i>">
+ * <keep-alive>select 1</keep-alive>
+ * </pool-controller>
+ * <driver><i>com.database.jdbc.JdbcDriver</i></driver>
+ * <dburl><i>jdbc:driver://host/mydb</i></dburl>
+ * <user><i>username</i></user>
+ * <password><i>password</i></password>
+ * </data-source>
+ * </myBlock>
+ * </pre>
+ *
+ * @phoenix:block
+ * @phoenix:service
name="org.apache.avalon.cornerstone.services.datasource.DataSourceSelector"
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
* @deprecated Use [EMAIL PROTECTED]
org.apache.avalon.cornerstone.blocks.datasources.DefaultDataSourceSelector} instead.
- */
-public class DefaultDataSourceSelector
- extends AbstractLogEnabled
- implements DataSourceSelector, Contextualizable, Configurable, Initializable,
Disposable
-{
- private Configuration m_configuration;
- private Map m_dataSources;
- private String m_blockName;
-
- public void contextualize( final Context context )
- throws ContextException
- {
- m_blockName = (String) context.get("block.name");
- }
-
- /**
- * @phoenix:configuration-schema type="relax-ng"
- */
- public void configure( final Configuration configuration )
- {
- m_configuration = configuration;
- }
-
- public void initialize()
- throws Exception
- {
- m_dataSources = new HashMap();
-
- Configuration[] dataSourceConfs = getDataSourceConfig();
-
- for( int i = 0; i < dataSourceConfs.length; i++ )
- {
- final Configuration dataSourceConf = dataSourceConfs[ i ];
-
- final String name = dataSourceConf.getAttribute( "name" );
- final String clazz = dataSourceConf.getAttribute( "class" );
- final String driver = dataSourceConf.getChild( "driver", true
).getValue( "" );
-
- final ClassLoader classLoader =
- Thread.currentThread().getContextClassLoader();
-
- DataSourceComponent component = null;
- if( null == classLoader )
- {
- if( !"".equals( driver ) )
- {
- Class.forName( driver, true,
Thread.currentThread().getContextClassLoader() );
- }
-
- component = (DataSourceComponent)Class.forName( clazz
).newInstance();
- }
- else
- {
- if( !"".equals( driver ) )
- {
- classLoader.loadClass( driver );
- }
-
- component = (DataSourceComponent)classLoader.loadClass( clazz
).newInstance();
- }
-
- if( component instanceof LogEnabled )
- {
- setupLogger( component, name );
- }
- component.configure( dataSourceConf );
- m_dataSources.put( name, component );
-
- if( getLogger().isInfoEnabled() )
- {
- getLogger().info( "DataSource " + name + " ready" );
- }
- }
- }
-
- private Configuration[] getDataSourceConfig()
- {
- final Configuration head =
- m_configuration.getChild( "data-sources" );
- if( 0 != head.getChildren().length )
- {
-
- final String message =
- "WARNING: Child node <data-sources/> in " +
- "configuration of component named " + m_blockName +
- " has been deprecated. Please put <data-source/> elements" +
- " in root configuration element";
- getLogger().warn( message );
- System.out.println( message );
- return head.getChildren( "data-source" );
- }
- else
- {
- return m_configuration.getChildren( "data-source" );
- }
- }
-
- public void dispose()
- {
- final Iterator keys = m_dataSources.keySet().iterator();
- while( keys.hasNext() )
- {
- final DataSourceComponent dsc =
- (DataSourceComponent)m_dataSources.get( keys.next() );
- if( dsc instanceof Disposable )
- {
- ((Disposable)dsc).dispose();
- }
- }
- }
-
- public boolean hasComponent( final Object hint )
- {
- return m_dataSources.containsKey( hint );
- }
-
- public Component select( final Object hint )
- throws ComponentException
- {
- final Component component = (Component)m_dataSources.get( hint );
-
- if( null == component )
- {
- throw new ComponentException( "Unable to provide DataSourceComponent
for " + hint );
- }
-
- return component;
- }
-
- public void release( final Component component )
- {
- //do nothing
- }
-
-}
+ */
+public class DefaultDataSourceSelector
+ extends AbstractLogEnabled
+ implements DataSourceSelector, Contextualizable, Configurable, Initializable,
Disposable
+{
+ private Configuration m_configuration;
+ private Map m_dataSources;
+ private String m_blockName;
+
+ public void contextualize( final Context context )
+ throws ContextException
+ {
+ m_blockName = (String) context.get("block.name");
+ }
+
+ /**
+ * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0"
+ */
+ public void configure( final Configuration configuration )
+ {
+ m_configuration = configuration;
+ }
+
+ public void initialize()
+ throws Exception
+ {
+ m_dataSources = new HashMap();
+
+ Configuration[] dataSourceConfs = getDataSourceConfig();
+
+ for( int i = 0; i < dataSourceConfs.length; i++ )
+ {
+ final Configuration dataSourceConf = dataSourceConfs[ i ];
+
+ final String name = dataSourceConf.getAttribute( "name" );
+ final String clazz = dataSourceConf.getAttribute( "class" );
+ final String driver = dataSourceConf.getChild( "driver", true
).getValue( "" );
+
+ final ClassLoader classLoader =
+ Thread.currentThread().getContextClassLoader();
+
+ DataSourceComponent component = null;
+ if( null == classLoader )
+ {
+ if( !"".equals( driver ) )
+ {
+ Class.forName( driver, true,
Thread.currentThread().getContextClassLoader() );
+ }
+
+ component = (DataSourceComponent)Class.forName( clazz
).newInstance();
+ }
+ else
+ {
+ if( !"".equals( driver ) )
+ {
+ classLoader.loadClass( driver );
+ }
+
+ component = (DataSourceComponent)classLoader.loadClass( clazz
).newInstance();
+ }
+
+ if( component instanceof LogEnabled )
+ {
+ setupLogger( component, name );
+ }
+ component.configure( dataSourceConf );
+ m_dataSources.put( name, component );
+
+ if( getLogger().isInfoEnabled() )
+ {
+ getLogger().info( "DataSource " + name + " ready" );
+ }
+ }
+ }
+
+ private Configuration[] getDataSourceConfig()
+ {
+ final Configuration head =
+ m_configuration.getChild( "data-sources" );
+ if( 0 != head.getChildren().length )
+ {
+
+ final String message =
+ "WARNING: Child node <data-sources/> in " +
+ "configuration of component named " + m_blockName +
+ " has been deprecated. Please put <data-source/> elements" +
+ " in root configuration element";
+ getLogger().warn( message );
+ System.out.println( message );
+ return head.getChildren( "data-source" );
+ }
+ else
+ {
+ return m_configuration.getChildren( "data-source" );
+ }
+ }
+
+ public void dispose()
+ {
+ final Iterator keys = m_dataSources.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ final DataSourceComponent dsc =
+ (DataSourceComponent)m_dataSources.get( keys.next() );
+ if( dsc instanceof Disposable )
+ {
+ ((Disposable)dsc).dispose();
+ }
+ }
+ }
+
+ public boolean hasComponent( final Object hint )
+ {
+ return m_dataSources.containsKey( hint );
+ }
+
+ public Component select( final Object hint )
+ throws ComponentException
+ {
+ final Component component = (Component)m_dataSources.get( hint );
+
+ if( null == component )
+ {
+ throw new ComponentException( String.valueOf( hint ), "Unable to
provide DataSourceComponent for " + hint );
+ }
+
+ return component;
+ }
+
+ public void release( final Component component )
+ {
+ //do nothing
+ }
+
+}
1.6 +187 -187
avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasources/DefaultDataSourceSelector.java
Index: DefaultDataSourceSelector.java
===================================================================
RCS file:
/home/cvs/avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/datasources/DefaultDataSourceSelector.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultDataSourceSelector.java 22 Mar 2003 12:50:24 -0000 1.5
+++ DefaultDataSourceSelector.java 6 Apr 2003 11:34:06 -0000 1.6
@@ -3,34 +3,34 @@
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Jakarta", "Apache Avalon", "Avalon Cornerstone", "Avalon
Framework" and "Apache Software Foundation" must not be used to endorse
or promote products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,197 +41,197 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation. For more information on the
+ on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
-
+
*/
-
-package org.apache.avalon.cornerstone.blocks.datasources;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
-import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.LogEnabled;
-
-/**
- * A default implementation for DataSourceSelector.
- * The Configuration is like this:
- *
- * <pre>
- * <myBlock>
- * <data-source name="<i>default</i>"
- * class="<i>org.apache.avalon.excalibur.datasource.JdbcDataSource</i>">
- * <!-- configuration for JdbcDataSource -->
- * <pool-controller min="<i>5</i>" max="<i>10</i>"
connection-class="<i>my.overrided.ConnectionClass</i>">
- * <keep-alive>select 1</keep-alive>
- * </pool-controller>
- * <driver><i>com.database.jdbc.JdbcDriver</i></driver>
- * <dburl><i>jdbc:driver://host/mydb</i></dburl>
- * <user><i>username</i></user>
- * <password><i>password</i></password>
- * </data-source>
- * </myBlock>
- * </pre>
- *
- * @phoenix:block
- * @phoenix:service
name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
- *
+
+package org.apache.avalon.cornerstone.blocks.datasources;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
+import org.apache.avalon.excalibur.datasource.DataSourceComponent;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.LogEnabled;
+
+/**
+ * A default implementation for DataSourceSelector.
+ * The Configuration is like this:
+ *
+ * <pre>
+ * <myBlock>
+ * <data-source name="<i>default</i>"
+ * class="<i>org.apache.avalon.excalibur.datasource.JdbcDataSource</i>">
+ * <!-- configuration for JdbcDataSource -->
+ * <pool-controller min="<i>5</i>" max="<i>10</i>"
connection-class="<i>my.overrided.ConnectionClass</i>">
+ * <keep-alive>select 1</keep-alive>
+ * </pool-controller>
+ * <driver><i>com.database.jdbc.JdbcDriver</i></driver>
+ * <dburl><i>jdbc:driver://host/mydb</i></dburl>
+ * <user><i>username</i></user>
+ * <password><i>password</i></password>
+ * </data-source>
+ * </myBlock>
+ * </pre>
+ *
+ * @phoenix:block
+ * @phoenix:service
name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
- */
-public class DefaultDataSourceSelector
- extends AbstractLogEnabled
- implements DataSourceSelector, Contextualizable, Configurable, Initializable,
Disposable
-{
- private Configuration m_configuration;
- private Map m_dataSources;
- private String m_blockName;
-
- public void contextualize( final Context context )
- throws ContextException
+ */
+public class DefaultDataSourceSelector
+ extends AbstractLogEnabled
+ implements DataSourceSelector, Contextualizable, Configurable, Initializable,
Disposable
+{
+ private Configuration m_configuration;
+ private Map m_dataSources;
+ private String m_blockName;
+
+ public void contextualize( final Context context )
+ throws ContextException
{
try
- {
+ {
m_blockName = (String) context.get("block.name");
}
catch( Throwable e )
{
m_blockName = "DataSourceSelector/" + System.identityHashCode( this );
- }
- }
-
- /**
- * @phoenix:configuration-schema type="relax-ng"
- */
- public void configure( final Configuration configuration )
- {
- m_configuration = configuration;
- }
-
- public void initialize()
- throws Exception
- {
- m_dataSources = new HashMap();
-
- Configuration[] dataSourceConfs = getDataSourceConfig();
-
- for( int i = 0; i < dataSourceConfs.length; i++ )
- {
- final Configuration dataSourceConf = dataSourceConfs[ i ];
-
- final String name = dataSourceConf.getAttribute( "name" );
- final String clazz = dataSourceConf.getAttribute( "class" );
- final String driver = dataSourceConf.getChild( "driver", true
).getValue( "" );
-
- final ClassLoader classLoader =
- Thread.currentThread().getContextClassLoader();
-
- DataSourceComponent component = null;
- if( null == classLoader )
- {
- if( !"".equals( driver ) )
- {
- Class.forName( driver, true,
Thread.currentThread().getContextClassLoader() );
- }
-
- component = (DataSourceComponent)Class.forName( clazz
).newInstance();
- }
- else
- {
- if( !"".equals( driver ) )
- {
- classLoader.loadClass( driver );
- }
-
- component = (DataSourceComponent)classLoader.loadClass( clazz
).newInstance();
- }
-
- if( component instanceof LogEnabled )
- {
- setupLogger( component, name );
- }
- component.configure( dataSourceConf );
- m_dataSources.put( name, component );
-
- if( getLogger().isInfoEnabled() )
- {
- getLogger().info( "DataSource " + name + " ready" );
- }
- }
- }
-
- private Configuration[] getDataSourceConfig()
- {
- final Configuration head =
- m_configuration.getChild( "data-sources" );
- if( 0 != head.getChildren().length )
- {
-
- final String message =
- "WARNING: Child node <data-sources/> in " +
- "configuration of component named " + m_blockName +
- " has been deprecated. Please put <data-source/> elements" +
- " in root configuration element";
- getLogger().warn( message );
- System.out.println( message );
- return head.getChildren( "data-source" );
- }
- else
- {
- return m_configuration.getChildren( "data-source" );
- }
- }
-
- public void dispose()
- {
+ }
+ }
+
+ /**
+ * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0"
+ */
+ public void configure( final Configuration configuration )
+ {
+ m_configuration = configuration;
+ }
+
+ public void initialize()
+ throws Exception
+ {
+ m_dataSources = new HashMap();
+
+ Configuration[] dataSourceConfs = getDataSourceConfig();
+
+ for( int i = 0; i < dataSourceConfs.length; i++ )
+ {
+ final Configuration dataSourceConf = dataSourceConfs[ i ];
+
+ final String name = dataSourceConf.getAttribute( "name" );
+ final String clazz = dataSourceConf.getAttribute( "class" );
+ final String driver = dataSourceConf.getChild( "driver", true
).getValue( "" );
+
+ final ClassLoader classLoader =
+ Thread.currentThread().getContextClassLoader();
+
+ DataSourceComponent component = null;
+ if( null == classLoader )
+ {
+ if( !"".equals( driver ) )
+ {
+ Class.forName( driver, true,
Thread.currentThread().getContextClassLoader() );
+ }
+
+ component = (DataSourceComponent)Class.forName( clazz
).newInstance();
+ }
+ else
+ {
+ if( !"".equals( driver ) )
+ {
+ classLoader.loadClass( driver );
+ }
+
+ component = (DataSourceComponent)classLoader.loadClass( clazz
).newInstance();
+ }
+
+ if( component instanceof LogEnabled )
+ {
+ setupLogger( component, name );
+ }
+ component.configure( dataSourceConf );
+ m_dataSources.put( name, component );
+
+ if( getLogger().isInfoEnabled() )
+ {
+ getLogger().info( "DataSource " + name + " ready" );
+ }
+ }
+ }
+
+ private Configuration[] getDataSourceConfig()
+ {
+ final Configuration head =
+ m_configuration.getChild( "data-sources" );
+ if( 0 != head.getChildren().length )
+ {
+
+ final String message =
+ "WARNING: Child node <data-sources/> in " +
+ "configuration of component named " + m_blockName +
+ " has been deprecated. Please put <data-source/> elements" +
+ " in root configuration element";
+ getLogger().warn( message );
+ System.out.println( message );
+ return head.getChildren( "data-source" );
+ }
+ else
+ {
+ return m_configuration.getChildren( "data-source" );
+ }
+ }
+
+ public void dispose()
+ {
if( getLogger().isDebugEnabled() )
{
getLogger().debug( "disposal" );
}
- final Iterator keys = m_dataSources.keySet().iterator();
- while( keys.hasNext() )
- {
- final DataSourceComponent dsc =
- (DataSourceComponent)m_dataSources.get( keys.next() );
- if( dsc instanceof Disposable )
- {
- ((Disposable)dsc).dispose();
- }
- }
- }
-
- public boolean isSelectable( final Object hint )
- {
- return m_dataSources.containsKey( hint );
- }
-
- public Object select( final Object hint )
- throws ServiceException
- {
- final Object component = m_dataSources.get( hint );
-
- if( null == component )
- {
- throw new ServiceException( hint.toString(), "Unable to provide
DataSourceComponent for " + hint );
- }
-
- return component;
- }
-
- public void release( final Object component )
- {
- //do nothing
- }
-}
+ final Iterator keys = m_dataSources.keySet().iterator();
+ while( keys.hasNext() )
+ {
+ final DataSourceComponent dsc =
+ (DataSourceComponent)m_dataSources.get( keys.next() );
+ if( dsc instanceof Disposable )
+ {
+ ((Disposable)dsc).dispose();
+ }
+ }
+ }
+
+ public boolean isSelectable( final Object hint )
+ {
+ return m_dataSources.containsKey( hint );
+ }
+
+ public Object select( final Object hint )
+ throws ServiceException
+ {
+ final Object component = m_dataSources.get( hint );
+
+ if( null == component )
+ {
+ throw new ServiceException( hint.toString(), "Unable to provide
DataSourceComponent for " + hint );
+ }
+
+ return component;
+ }
+
+ public void release( final Object component )
+ {
+ //do nothing
+ }
+}
1.18 +13 -13
avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/sockets/DefaultSocketManager.java
Index: DefaultSocketManager.java
===================================================================
RCS file:
/home/cvs/avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/sockets/DefaultSocketManager.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultSocketManager.java 22 Mar 2003 12:50:26 -0000 1.17
+++ DefaultSocketManager.java 6 Apr 2003 11:34:06 -0000 1.18
@@ -3,34 +3,34 @@
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Jakarta", "Apache Avalon", "Avalon Cornerstone", "Avalon
Framework" and "Apache Software Foundation" must not be used to endorse
or promote products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,11 +41,11 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation. For more information on the
+ on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
-
+
*/
package org.apache.avalon.cornerstone.blocks.sockets;
@@ -93,7 +93,7 @@
*
* @param configuration the Configuration
* @exception ConfigurationException if an error occurs
- * @phoenix:configuration-schema type="relax-ng"
+ * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0"
*/
public void configure( final Configuration configuration )
throws ConfigurationException
@@ -175,7 +175,7 @@
try
{
final ClassLoader classLoader =
- (ClassLoader)Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().getContextClassLoader();
factory = classLoader.loadClass( className ).newInstance();
}
catch( final Exception e )
1.26 +13 -13
avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/threads/DefaultThreadManager.java
Index: DefaultThreadManager.java
===================================================================
RCS file:
/home/cvs/avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/threads/DefaultThreadManager.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DefaultThreadManager.java 22 Mar 2003 12:50:27 -0000 1.25
+++ DefaultThreadManager.java 6 Apr 2003 11:34:06 -0000 1.26
@@ -3,34 +3,34 @@
============================================================================
The Apache Software License, Version 1.1
============================================================================
-
+
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
-
+
4. The names "Jakarta", "Apache Avalon", "Avalon Cornerstone", "Avalon
Framework" and "Apache Software Foundation" must not be used to endorse
or promote products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
-
+
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -41,11 +41,11 @@
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+
This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation. For more information on the
+ on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
-
+
*/
package org.apache.avalon.cornerstone.blocks.threads;
@@ -81,7 +81,7 @@
*
* @param configuration the configuration data
* @exception ConfigurationException if an error occurs
- * @phoenix:configuration-schema type="relax-ng"
+ * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0"
*/
public void configure( final Configuration configuration )
throws ConfigurationException
@@ -110,7 +110,7 @@
final int minThreads = configuration.getChild( "min-threads"
).getValueAsInteger( 5 );
final int maxThreads = configuration.getChild( "max-threads"
).getValueAsInteger( 10 );
-
+
// NEVER USED!!
//final int minSpareThreads = configuration.getChild( "min-spare-threads" ).
// getValueAsInteger( maxThreads - minThreads );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]