You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/07/10 23:01:11 UTC
cvs commit: avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test DependencyDescriptorTestCase.java AbstractDescriptorTestCase.java ContextDescriptorTestCase.java
bloritsch 2003/07/10 14:01:10
Modified: meta/api/src/java/org/apache/avalon/meta/info
ContextDescriptor.java DependencyDescriptor.java
Descriptor.java EntryDescriptor.java
ExtensionDescriptor.java InfoDescriptor.java
LoggerDescriptor.java ReferenceDescriptor.java
Service.java ServiceDescriptor.java
StageDescriptor.java Type.java
meta/api/src/test/org/apache/avalon/meta/info/test
AbstractDescriptorTestCase.java
ContextDescriptorTestCase.java
Added: meta/api/src/test/org/apache/avalon/meta/info/test
DependencyDescriptorTestCase.java
Log:
Format and optimize imports. Add new testcase and fix the merge bug
Revision Changes Path
1.2 +27 -25 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java
Index: ContextDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContextDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ ContextDescriptor.java 10 Jul 2003 21:01:08 -0000 1.2
@@ -50,6 +50,7 @@
package org.apache.avalon.meta.info;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
@@ -73,8 +74,8 @@
*/
public class ContextDescriptor extends Descriptor
{
- public static final String STRATEGY_KEY =
- "urn:avalon:context.strategy";
+ public static final String STRATEGY_KEY =
+ "urn:avalon:context.strategy";
private final ReferenceDescriptor m_reference;
private final EntryDescriptor[] m_entries;
@@ -101,15 +102,15 @@
public ContextDescriptor( final ReferenceDescriptor reference,
final EntryDescriptor[] entries,
final Properties attributes )
- throws NullPointerException, IllegalArgumentException
+ throws NullPointerException, IllegalArgumentException
{
super( attributes );
- if( null == entries )
+ if ( null == entries )
{
throw new NullPointerException( "entries" );
}
- if( null == reference )
+ if ( null == reference )
{
throw new NullPointerException( "reference" );
}
@@ -152,19 +153,19 @@
*/
public EntryDescriptor getEntry( final String key )
{
- if( null == key )
+ if ( null == key )
{
throw new NullPointerException( "key" );
}
- for( int i = 0; i < m_entries.length; i++ )
+ for ( int i = 0; i < m_entries.length; i++ )
{
- final EntryDescriptor entry = m_entries[ i ];
- if( ( entry.getAlias() != null ) && entry.getAlias().equals( key ) )
+ final EntryDescriptor entry = m_entries[i];
+ if ( ( entry.getAlias() != null ) && entry.getAlias().equals( key ) )
{
return entry;
}
- if( entry.getKey().equals( key ) )
+ if ( entry.getKey().equals( key ) )
{
return entry;
}
@@ -173,28 +174,28 @@
return null;
}
- /**
- * Returns a set of entry descriptors resulting from a merge of the descriptors
- * container in this descriptor with the supplied descriptors.
- *
- * @param entries the entries to merge
- * @return the mergerged set of entries
- * @exception IllegalArgumentException if a entry conflict occurs
- */
+ /**
+ * Returns a set of entry descriptors resulting from a merge of the descriptors
+ * container in this descriptor with the supplied descriptors.
+ *
+ * @param entries the entries to merge
+ * @return the mergerged set of entries
+ * @exception IllegalArgumentException if a entry conflict occurs
+ */
public EntryDescriptor[] merge( EntryDescriptor[] entries )
- throws IllegalArgumentException
+ throws IllegalArgumentException
{
- for( int i=0; i<entries.length; i++ )
+ for ( int i = 0; i < entries.length; i++ )
{
EntryDescriptor entry = entries[i];
final String key = entry.getKey();
EntryDescriptor local = getEntry( entry.getKey() );
- if( local != null )
+ if ( local != null )
{
- if( !entry.getType().equals( local.getType() ) )
+ if ( !entry.getType().equals( local.getType() ) )
{
final String error =
- "Conflicting entry type for key: " + key;
+ "Conflicting entry type for key: " + key;
throw new IllegalArgumentException( error );
}
}
@@ -205,7 +206,8 @@
private EntryDescriptor[] join( EntryDescriptor[] primary, EntryDescriptor[] secondary )
{
- List list = Arrays.asList( primary );
+ List list = new ArrayList( primary.length + secondary.length );
+ list.addAll( Arrays.asList( primary ) );
list.addAll( Arrays.asList( secondary ) );
return (EntryDescriptor[]) list.toArray( new EntryDescriptor[0] );
}
1.2 +20 -14 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/DependencyDescriptor.java
Index: DependencyDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/DependencyDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DependencyDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ DependencyDescriptor.java 10 Jul 2003 21:01:08 -0000 1.2
@@ -145,12 +145,12 @@
{
super( attributes );
- if( null == role )
+ if ( null == role )
{
throw new NullPointerException( "role" );
}
- if( null == service )
+ if ( null == service )
{
throw new NullPointerException( "service" );
}
@@ -228,20 +228,26 @@
*/
public boolean equals( Object other )
{
- if( other instanceof DependencyDescriptor )
+ boolean isEqual = super.equals( other ) && other instanceof DependencyDescriptor;
+ if ( other instanceof DependencyDescriptor )
{
DependencyDescriptor dep = (DependencyDescriptor) other;
- if( dep.isOptional() != isOptional() )
- {
- return false;
- }
- if( !dep.getReference().equals( getReference() ) )
- {
- return false;
- }
- return super.equals( dep );
+
+ isEqual = isEqual && m_optional == dep.m_optional;
+ isEqual = isEqual && m_service.equals( dep.m_service );
}
- return false;
+
+ return isEqual;
+ }
+
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash >>>= 13;
+ hash ^= m_service.hashCode();
+ hash >>>= ( m_optional ) ? 1 : 0;
+
+ return hash;
}
}
1.2 +170 -170 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Descriptor.java
Index: Descriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Descriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Descriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ Descriptor.java 10 Jul 2003 21:01:08 -0000 1.2
@@ -1,170 +1,170 @@
-/*
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2002 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 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 apache@apache.org.
-
- 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
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- 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
- Apache Software Foundation, please see <http://www.apache.org/>.
-
-*/
-
-package org.apache.avalon.meta.info;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * This is the Abstract class for all feature feature descriptors.
- *
- * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
- * @version $Revision$ $Date$
- */
-public abstract class Descriptor
- implements Serializable
-{
- private static final String[] EMPTY_SET = new String[ 0 ];
-
- /**
- * The arbitrary set of attributes associated with Component.
- */
- private final Properties m_attributes;
-
- /**
- * Creation of an abstract descriptor.
- * @param attributes the set of attributes to assign to the descriptor
- */
- protected Descriptor( final Properties attributes )
- {
- m_attributes = attributes;
- }
-
- /**
- * Return the attribute for specified key.
- *
- * @param key the attribute key to resolve
- * @return the attribute for specified key.
- */
- public String getAttribute( final String key )
- {
- if( null == m_attributes )
- {
- return null;
- }
- else
- {
- return m_attributes.getProperty( key );
- }
- }
-
- /**
- * Return the attribute for specified key.
- *
- * @param key the attribute key to resolve
- * @param defaultValue the default value to use if the value is not defined
- * @return the attribute for specified key.
- */
- public String getAttribute( final String key,
- final String defaultValue )
- {
- if( null == m_attributes )
- {
- return defaultValue;
- }
- else
- {
- return m_attributes.getProperty( key, defaultValue );
- }
- }
-
- /**
- * Returns the set of attribute names available under this descriptor.
- *
- * @return an array of the properties names held by the descriptor.
- */
- public String[] getAttributeNames()
- {
- if( null == m_attributes )
- {
- return EMPTY_SET;
- }
- else
- {
- return (String[])m_attributes.keySet().toArray( EMPTY_SET );
- }
- }
-
- /**
- * Compare this object with another for equality.
- * @param other the object to compare this object with
- * @return TRUE if the supplied object equivalent
- */
- public boolean equals( Object other )
- {
- if( other instanceof Descriptor )
- {
- Descriptor descriptor = (Descriptor)other;
- if (null == m_attributes) return null == descriptor.m_attributes;
-
- return m_attributes.equals(descriptor.m_attributes);
- }
- return false;
- }
-
- /**
- * Return the hashcode for this object.
- */
- public int hashCode()
- {
- return m_attributes.hashCode();
- }
-
- /**
- * Returns the property set.
- *
- * @return the dproperty set.
- */
- protected Properties getProperties()
- {
- return m_attributes;
- }
-}
+/*
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 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 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 apache@apache.org.
+
+ 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
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ 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
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+
+package org.apache.avalon.meta.info;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * This is the Abstract class for all feature feature descriptors.
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version $Revision$ $Date$
+ */
+public abstract class Descriptor
+ implements Serializable
+{
+ private static final String[] EMPTY_SET = new String[0];
+
+ /**
+ * The arbitrary set of attributes associated with Component.
+ */
+ private final Properties m_attributes;
+
+ /**
+ * Creation of an abstract descriptor.
+ * @param attributes the set of attributes to assign to the descriptor
+ */
+ protected Descriptor( final Properties attributes )
+ {
+ m_attributes = attributes;
+ }
+
+ /**
+ * Return the attribute for specified key.
+ *
+ * @param key the attribute key to resolve
+ * @return the attribute for specified key.
+ */
+ public String getAttribute( final String key )
+ {
+ if ( null == m_attributes )
+ {
+ return null;
+ }
+ else
+ {
+ return m_attributes.getProperty( key );
+ }
+ }
+
+ /**
+ * Return the attribute for specified key.
+ *
+ * @param key the attribute key to resolve
+ * @param defaultValue the default value to use if the value is not defined
+ * @return the attribute for specified key.
+ */
+ public String getAttribute( final String key,
+ final String defaultValue )
+ {
+ if ( null == m_attributes )
+ {
+ return defaultValue;
+ }
+ else
+ {
+ return m_attributes.getProperty( key, defaultValue );
+ }
+ }
+
+ /**
+ * Returns the set of attribute names available under this descriptor.
+ *
+ * @return an array of the properties names held by the descriptor.
+ */
+ public String[] getAttributeNames()
+ {
+ if ( null == m_attributes )
+ {
+ return EMPTY_SET;
+ }
+ else
+ {
+ return (String[]) m_attributes.keySet().toArray( EMPTY_SET );
+ }
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the object to compare this object with
+ * @return TRUE if the supplied object equivalent
+ */
+ public boolean equals( Object other )
+ {
+ if ( other instanceof Descriptor )
+ {
+ Descriptor descriptor = (Descriptor) other;
+ if ( null == m_attributes ) return null == descriptor.m_attributes;
+
+ return m_attributes.equals( descriptor.m_attributes );
+ }
+ return false;
+ }
+
+ /**
+ * Return the hashcode for this object.
+ */
+ public int hashCode()
+ {
+ return m_attributes.hashCode();
+ }
+
+ /**
+ * Returns the property set.
+ *
+ * @return the dproperty set.
+ */
+ protected Properties getProperties()
+ {
+ return m_attributes;
+ }
+}
1.3 +17 -11 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/EntryDescriptor.java
Index: EntryDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/EntryDescriptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EntryDescriptor.java 10 Jul 2003 20:30:51 -0000 1.2
+++ EntryDescriptor.java 10 Jul 2003 21:01:09 -0000 1.3
@@ -65,7 +65,7 @@
* @version $Revision$ $Date$
*/
public final class EntryDescriptor
- implements Serializable
+ implements Serializable
{
/**
* The name the component uses to lookup entry.
@@ -126,12 +126,12 @@
final String type,
final boolean optional ) throws NullPointerException
{
- if( null == key )
+ if ( null == key )
{
throw new NullPointerException( "key" );
}
- if( null == type )
+ if ( null == type )
{
throw new NullPointerException( "type" );
}
@@ -192,20 +192,26 @@
return !isOptional();
}
- public boolean equals(Object other)
+ public boolean equals( Object other )
{
boolean isEqual = other instanceof EntryDescriptor;
- if (isEqual)
+ if ( isEqual )
{
- EntryDescriptor entry = (EntryDescriptor)other;
+ EntryDescriptor entry = (EntryDescriptor) other;
isEqual = isEqual && m_key.equals( entry.m_key );
isEqual = isEqual && m_type.equals( entry.m_type );
isEqual = isEqual && m_optional == entry.m_optional;
- isEqual = isEqual && (m_alias == null) ?
- entry.m_alias == null : m_alias.equals( entry.m_alias );
+ if ( null == m_alias )
+ {
+ isEqual = isEqual && null == entry.m_alias;
+ }
+ else
+ {
+ isEqual = isEqual && m_alias.equals( entry.m_alias );
+ }
}
return isEqual;
@@ -215,10 +221,10 @@
{
int hash = m_key.hashCode();
hash >>>= 13;
- hash ^= (null != m_alias) ? m_alias.hashCode() : 0;
+ hash ^= ( null != m_alias ) ? m_alias.hashCode() : 0;
hash >>>= 13;
hash ^= m_type.hashCode();
- hash >>>= (m_optional) ? 1 : 3;
+ hash >>>= ( m_optional ) ? 1 : 3;
return hash;
}
1.2 +5 -5 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ExtensionDescriptor.java
Index: ExtensionDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ExtensionDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExtensionDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ ExtensionDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -71,7 +71,7 @@
* @exception NullPointerException if the classname is null
*/
public ExtensionDescriptor( final String classname )
- throws NullPointerException
+ throws NullPointerException
{
this( new ReferenceDescriptor( classname ), null );
}
@@ -82,7 +82,7 @@
* @exception NullPointerException if the reference is null
*/
public ExtensionDescriptor( final ReferenceDescriptor reference )
- throws NullPointerException
+ throws NullPointerException
{
this( reference, null );
}
@@ -95,11 +95,11 @@
*/
public ExtensionDescriptor( final ReferenceDescriptor reference,
final Properties attributes )
- throws NullPointerException
+ throws NullPointerException
{
super( attributes );
- if( null == reference )
+ if ( null == reference )
{
throw new NullPointerException( "reference" );
}
1.2 +21 -21 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/InfoDescriptor.java
Index: InfoDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/InfoDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InfoDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ InfoDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -76,13 +76,13 @@
*/
public final class InfoDescriptor extends Descriptor
{
- public static final String TRANSIENT = "transient";
+ public static final String TRANSIENT = "transient";
- public static final String SINGLETON = "singleton";
+ public static final String SINGLETON = "singleton";
- public static final String THREAD = "thread";
+ public static final String THREAD = "thread";
- public static final String POOLED = "pooled";
+ public static final String POOLED = "pooled";
/**
@@ -118,7 +118,7 @@
* @exception IllegalArgumentException if the implementation key is not a classname
*/
public InfoDescriptor( final String classname )
- throws IllegalArgumentException
+ throws IllegalArgumentException
{
this( null, classname, null, null, null );
}
@@ -134,15 +134,15 @@
* @exception IllegalArgumentException if the implementation key is not a classname
*/
public InfoDescriptor( final String name,
- final String classname,
- final Version version,
- final String lifestyle,
- final Properties attributes )
- throws IllegalArgumentException
+ final String classname,
+ final Version version,
+ final String lifestyle,
+ final Properties attributes )
+ throws IllegalArgumentException
{
super( attributes );
- if( classname.indexOf( "/" ) > -1 )
+ if ( classname.indexOf( "/" ) > -1 )
{
throw new IllegalArgumentException( "classname: " + classname );
}
@@ -150,7 +150,7 @@
m_classname = classname;
m_version = version;
- if( lifestyle == null )
+ if ( lifestyle == null )
{
m_lifestyle = TRANSIENT;
}
@@ -160,7 +160,7 @@
m_lifestyle = lifestyle;
}
- if( name != null )
+ if ( name != null )
{
m_name = name;
}
@@ -172,10 +172,10 @@
private void validateLifestyle( String lifestyle ) throws IllegalArgumentException
{
- if( lifestyle.equals( TRANSIENT )
- || lifestyle.equals( SINGLETON )
- || lifestyle.equals( THREAD )
- || lifestyle.equals( POOLED ) )
+ if ( lifestyle.equals( TRANSIENT )
+ || lifestyle.equals( SINGLETON )
+ || lifestyle.equals( THREAD )
+ || lifestyle.equals( POOLED ) )
{
return;
}
@@ -185,14 +185,14 @@
private String getClassName( String classname )
{
- int i = classname.lastIndexOf(".");
- if( i == -1 )
+ int i = classname.lastIndexOf( "." );
+ if ( i == -1 )
{
return classname.toLowerCase();
}
else
{
- return classname.substring( i+1, classname.length() ).toLowerCase();
+ return classname.substring( i + 1, classname.length() ).toLowerCase();
}
}
1.2 +4 -4 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/LoggerDescriptor.java
Index: LoggerDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/LoggerDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LoggerDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ LoggerDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -66,7 +66,7 @@
* @version $Revision$ $Date$
*/
public class LoggerDescriptor
- extends Descriptor
+ extends Descriptor
{
private final String m_name;
@@ -80,10 +80,10 @@
*/
public LoggerDescriptor( final String name,
final Properties attributes )
- throws NullPointerException
+ throws NullPointerException
{
super( attributes );
- if( null == name )
+ if ( null == name )
{
throw new NullPointerException( "name" );
}
1.2 +24 -24 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ReferenceDescriptor.java
Index: ReferenceDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ReferenceDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReferenceDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ ReferenceDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -65,7 +65,7 @@
* @version $Revision$ $Date$
*/
public final class ReferenceDescriptor
- implements Serializable
+ implements Serializable
{
/**
* The name of service class.
@@ -85,8 +85,8 @@
*/
public ReferenceDescriptor( final String type ) throws NullPointerException
{
- int index = type.indexOf(":");
- if( index > -1 )
+ int index = type.indexOf( ":" );
+ if ( index > -1 )
{
m_classname = type.substring( 0, index );
m_version = Version.getVersion( type.substring( index + 1 ) );
@@ -108,14 +108,14 @@
public ReferenceDescriptor( final String classname,
final Version version ) throws NullPointerException
{
- if( null == classname )
+ if ( null == classname )
{
throw new NullPointerException( "classname" );
}
m_classname = classname;
- if( null == version )
+ if ( null == version )
{
m_version = Version.getVersion( "1.0" );
}
@@ -155,7 +155,7 @@
public boolean matches( final ReferenceDescriptor other )
{
return other.getClassname().equals( getClassname() )
- && other.getVersion().complies( getVersion() );
+ && other.getVersion().complies( getVersion() );
}
/**
@@ -187,37 +187,37 @@
{
boolean match = false;
- if( other instanceof ReferenceDescriptor )
+ if ( other instanceof ReferenceDescriptor )
{
- match = ( (ReferenceDescriptor)other ).matches( this );
+ match = ( (ReferenceDescriptor) other ).matches( this );
}
- else if( other instanceof Service )
+ else if ( other instanceof Service )
{
- match = ( (Service)other ).matches( this );
+ match = ( (Service) other ).matches( this );
}
- else if( other instanceof ServiceDescriptor )
+ else if ( other instanceof ServiceDescriptor )
{
- match = ( (Service)other ).matches( this );
+ match = ( (Service) other ).matches( this );
}
return match;
}
- /**
- * Creation of a new reference descriptor form a supplied string.
- * The implementation looks for the classname/version delimiter
- * of ":". If no version information is found, the default 1.0.0
- * version is assigned.
- *
- * @param path the structured path in for form <classname>:<version>
- * @return the new reference descriptor
- */
+ /**
+ * Creation of a new reference descriptor form a supplied string.
+ * The implementation looks for the classname/version delimiter
+ * of ":". If no version information is found, the default 1.0.0
+ * version is assigned.
+ *
+ * @param path the structured path in for form <classname>:<version>
+ * @return the new reference descriptor
+ */
public static ReferenceDescriptor newInstance( String path )
{
final String type;
final Version version;
- int index = path.indexOf(":");
- if( index > -1 )
+ int index = path.indexOf( ":" );
+ if ( index > -1 )
{
type = path.substring( 0, index );
version = Version.getVersion( path.substring( index + 1 ) );
1.2 +15 -15 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Service.java
Index: Service.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Service.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Service.java 10 Jul 2003 16:00:05 -0000 1.1
+++ Service.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -100,8 +100,8 @@
* @param attributes the set of attributes to assign to the descriptor
*/
public Service(
- final ReferenceDescriptor reference,
- final EntryDescriptor[] entries )
+ final ReferenceDescriptor reference,
+ final EntryDescriptor[] entries )
{
this( reference, entries, null );
}
@@ -114,8 +114,8 @@
* @param attributes the set of attributes to assign to the descriptor
*/
public Service(
- final ReferenceDescriptor reference,
- final Properties attributes )
+ final ReferenceDescriptor reference,
+ final Properties attributes )
{
this( reference, null, attributes );
}
@@ -129,17 +129,17 @@
* @param attributes the set of attributes to assign to the descriptor
*/
public Service(
- final ReferenceDescriptor reference,
- final EntryDescriptor[] entries,
- final Properties attributes )
+ final ReferenceDescriptor reference,
+ final EntryDescriptor[] entries,
+ final Properties attributes )
{
super( attributes );
- if( reference == null )
+ if ( reference == null )
{
throw new NullPointerException( "reference" );
}
m_reference = reference;
- if( entries == null )
+ if ( entries == null )
{
m_entries = new EntryDescriptor[0];
}
@@ -221,15 +221,15 @@
{
boolean match = false;
- if( other instanceof ReferenceDescriptor )
+ if ( other instanceof ReferenceDescriptor )
{
- match = matches( (ReferenceDescriptor)other );
+ match = matches( (ReferenceDescriptor) other );
}
- else if( other instanceof Service )
+ else if ( other instanceof Service )
{
- Service ref = (Service)other;
+ Service ref = (Service) other;
match = ref.getClassname().equals( getClassname() )
- && ref.getVersion().complies( getVersion() );
+ && ref.getVersion().complies( getVersion() );
}
return match;
1.2 +6 -6 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ServiceDescriptor.java
Index: ServiceDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ServiceDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ ServiceDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -74,7 +74,7 @@
* @version $Revision$ $Date$
*/
public class ServiceDescriptor
- extends Descriptor
+ extends Descriptor
{
/**
* The service reference that descriptor is describing.
@@ -88,7 +88,7 @@
* @exception NullPointerException if the descriptor argument is null
*/
public ServiceDescriptor( final ServiceDescriptor descriptor )
- throws NullPointerException
+ throws NullPointerException
{
super( descriptor.getProperties() );
m_designator = descriptor.getReference();
@@ -102,7 +102,7 @@
* @exception NullPointerException if the designator argument is null
*/
public ServiceDescriptor( final ReferenceDescriptor designator )
- throws NullPointerException
+ throws NullPointerException
{
this( designator, null );
}
@@ -116,11 +116,11 @@
*/
public ServiceDescriptor( final ReferenceDescriptor designator,
final Properties attributes )
- throws NullPointerException
+ throws NullPointerException
{
super( attributes );
- if( null == designator )
+ if ( null == designator )
{
throw new NullPointerException( "designator" );
}
1.2 +5 -5 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/StageDescriptor.java
Index: StageDescriptor.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/StageDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StageDescriptor.java 10 Jul 2003 16:00:05 -0000 1.1
+++ StageDescriptor.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -72,7 +72,7 @@
* @exception NullPointerException if the classname argument is null
*/
public StageDescriptor( final String classname )
- throws NullPointerException
+ throws NullPointerException
{
this( new ReferenceDescriptor( classname ), null );
}
@@ -83,7 +83,7 @@
* @exception NullPointerException if the reference argument is null
*/
public StageDescriptor( final ReferenceDescriptor reference )
- throws NullPointerException
+ throws NullPointerException
{
this( reference, null );
}
@@ -96,11 +96,11 @@
*/
public StageDescriptor( final ReferenceDescriptor reference,
final Properties attributes )
- throws NullPointerException
+ throws NullPointerException
{
super( attributes );
- if( null == reference )
+ if ( null == reference )
{
throw new NullPointerException( "reference" );
}
1.2 +26 -25 avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java
Index: Type.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/Type.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Type.java 10 Jul 2003 16:00:05 -0000 1.1
+++ Type.java 10 Jul 2003 21:01:09 -0000 1.2
@@ -85,6 +85,7 @@
private final ExtensionDescriptor[] m_extensions;
private transient Configuration m_configuration;
+
/**
* Creation of a new Type instance using a supplied component descriptor,
* logging, cotext, services, depedencies, stages and extension descriptors.
@@ -113,7 +114,7 @@
final DependencyDescriptor[] dependencies,
final StageDescriptor[] stages,
final ExtensionDescriptor[] extensions )
- throws NullPointerException
+ throws NullPointerException
{
this( descriptor, loggers, context, services, dependencies, stages, extensions, null );
}
@@ -147,33 +148,33 @@
final StageDescriptor[] stages,
final ExtensionDescriptor[] extensions,
final Configuration defaults )
- throws NullPointerException
+ throws NullPointerException
{
- if( null == descriptor )
+ if ( null == descriptor )
{
throw new NullPointerException( "descriptor" );
}
- if( null == loggers )
+ if ( null == loggers )
{
throw new NullPointerException( "loggers" );
}
- if( null == context )
+ if ( null == context )
{
throw new NullPointerException( "context" );
}
- if( null == services )
+ if ( null == services )
{
throw new NullPointerException( "services" );
}
- if( null == dependencies )
+ if ( null == dependencies )
{
throw new NullPointerException( "dependencies" );
}
- if( null == stages )
+ if ( null == stages )
{
throw new NullPointerException( "stages" );
}
- if( null == extensions )
+ if ( null == extensions )
{
throw new NullPointerException( "extensions" );
}
@@ -217,10 +218,10 @@
public boolean isaLogger( String name )
{
LoggerDescriptor[] loggers = getLoggers();
- for( int i = 0; i < loggers.length; i++ )
+ for ( int i = 0; i < loggers.length; i++ )
{
- LoggerDescriptor logger = loggers[ i ];
- if( logger.getName().equals( name ) )
+ LoggerDescriptor logger = loggers[i];
+ if ( logger.getName().equals( name ) )
{
return true;
}
@@ -257,10 +258,10 @@
*/
public ServiceDescriptor getService( final ReferenceDescriptor reference )
{
- for( int i = 0; i < m_services.length; i++ )
+ for ( int i = 0; i < m_services.length; i++ )
{
- final ServiceDescriptor service = m_services[ i ];
- if( service.getReference().matches( reference ) )
+ final ServiceDescriptor service = m_services[i];
+ if ( service.getReference().matches( reference ) )
{
return service;
}
@@ -276,10 +277,10 @@
*/
public ServiceDescriptor getService( final String classname )
{
- for( int i = 0; i < m_services.length; i++ )
+ for ( int i = 0; i < m_services.length; i++ )
{
- final ServiceDescriptor service = m_services[ i ];
- if( service.getReference().getClassname().equals( classname ) )
+ final ServiceDescriptor service = m_services[i];
+ if ( service.getReference().getClassname().equals( classname ) )
{
return service;
}
@@ -305,11 +306,11 @@
*/
public DependencyDescriptor getDependency( final String key )
{
- for( int i = 0; i < m_dependencies.length; i++ )
+ for ( int i = 0; i < m_dependencies.length; i++ )
{
- if( m_dependencies[ i ].getKey().equals( key ) )
+ if ( m_dependencies[i].getKey().equals( key ) )
{
- return m_dependencies[ i ];
+ return m_dependencies[i];
}
}
return null;
@@ -358,11 +359,11 @@
{
ReferenceDescriptor reference = stage.getReference();
ExtensionDescriptor[] extensions = getExtensions();
- for( int i = 0; i < extensions.length; i++ )
+ for ( int i = 0; i < extensions.length; i++ )
{
- ExtensionDescriptor extension = extensions[ i ];
+ ExtensionDescriptor extension = extensions[i];
ReferenceDescriptor ref = extension.getReference();
- if( reference.matches( ref ) )
+ if ( reference.matches( ref ) )
{
return extension;
}
1.4 +0 -0 avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/AbstractDescriptorTestCase.java
Index: AbstractDescriptorTestCase.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/AbstractDescriptorTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
1.3 +5 -4 avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/ContextDescriptorTestCase.java
Index: ContextDescriptorTestCase.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/ContextDescriptorTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContextDescriptorTestCase.java 10 Jul 2003 20:31:37 -0000 1.2
+++ ContextDescriptorTestCase.java 10 Jul 2003 21:01:10 -0000 1.3
@@ -105,12 +105,13 @@
};
checkDescriptor( desc );
- desc.merge( good );
+ EntryDescriptor[] merged = desc.merge( good );
checkDescriptor( desc );
- assertEquals( m_entries[0], desc.getEntry( m_entries[0].getKey() ) );
- assertEquals( good[0], desc.getEntry( good[0].getKey() ) );
- assertEquals( good[1], desc.getEntry( good[1].getKey() ) );
+ // The items to merge in are first. Shouldn't this be a set?
+ assertEquals( good[0], merged[0] );
+ assertEquals( good[1], merged[1] );
+ assertEquals( m_entries[0], merged[2] );
try
{
1.1 avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/DependencyDescriptorTestCase.java
Index: DependencyDescriptorTestCase.java
===================================================================
/*
============================================================================
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", "Avalon", "Excalibur" 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
apache@apache.org.
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
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
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
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.avalon.meta.info.test;
import junit.framework.TestCase;
import org.apache.avalon.meta.info.Descriptor;
import org.apache.avalon.meta.info.DependencyDescriptor;
import org.apache.avalon.meta.info.ReferenceDescriptor;
import org.apache.avalon.framework.Version;
/**
* DependencyDescriptorTestCase does XYZ
*
* @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
* @version CVS $ Revision: 1.1 $
*/
public class DependencyDescriptorTestCase extends AbstractDescriptorTestCase
{
private String m_role;
private ReferenceDescriptor m_reference;
private boolean m_optional = true;
public DependencyDescriptorTestCase( String name )
{
super( name );
}
protected Descriptor getDescriptor()
{
return new DependencyDescriptor( m_role, m_reference, m_optional, getProperties() );
}
protected void checkDescriptor( Descriptor desc )
{
super.checkDescriptor( desc );
DependencyDescriptor dep = (DependencyDescriptor) desc;
assertEquals( m_role, dep.getKey() );
assertEquals( m_reference, dep.getReference() );
assertEquals( m_optional, dep.isOptional() );
assertEquals( !m_optional, dep.isRequired() );
}
public void setUp()
{
m_role = "Test";
m_reference = new ReferenceDescriptor( DependencyDescriptorTestCase.class.getName(), Version.getVersion( "1.2.1" ) );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org