mcconnell 2002/12/07 01:48:58 Modified: meta/src/java/org/apache/avalon/meta/info DependencyDescriptor.java Descriptor.java Type.java meta/src/java/org/apache/avalon/meta/model/verifier ProfileVerifier.java Log: Small refinements arrising from assembly related work. Revision Changes Path 1.4 +47 -1 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/DependencyDescriptor.java Index: DependencyDescriptor.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/DependencyDescriptor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DependencyDescriptor.java 30 Nov 2002 14:46:24 -0000 1.3 +++ DependencyDescriptor.java 7 Dec 2002 09:48:57 -0000 1.4 @@ -80,6 +80,10 @@ */ public final class DependencyDescriptor extends Descriptor { + + private static final Version DEFAULT_VERSION = Version.getVersion( "1.0" ); + + /** * The name the component uses to lookup dependency. */ @@ -96,6 +100,16 @@ private final boolean m_optional; /** + * Creation of a new dependency descriptor using the default 1.0 version + * @param role the role name that will be used by the type when looking up a service + * @param service the interface service + */ + public DependencyDescriptor( final String role, String service ) + { + this( role, service, DEFAULT_VERSION ); + } + + /** * Creation of a new dependency descriptor. * @param role the role name that will be used by the type when looking up a service * @param service the version insterface service reference @@ -204,4 +218,36 @@ { return "[dependency: '" + getReference() + " key: '" + getRole() + "']"; } + + /** + * Compare this object with another for equality. + * @param other the object to compare this object with + * @return TRUE if the supplied object is a reference, service, or service + * descriptor that matches this objct in terms of classname and version + */ + public boolean equals( Object other ) + { + boolean match = false; + + if( other instanceof DependencyDescriptor ) + { + DependencyDescriptor dep = (DependencyDescriptor) other; + if( dep.isOptional() != isOptional() ) + { + return false; + } + if( !dep.getReference().equals( getReference() ) ) + { + return false; + } + if( !dep.getReference().equals( getReference() ) ) + { + return false; + } + + return super.equals( dep ); + } + return false; + } + } 1.2 +42 -1 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/Descriptor.java Index: Descriptor.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/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 24 Nov 2002 12:58:26 -0000 1.1 +++ Descriptor.java 7 Dec 2002 09:48:57 -0000 1.2 @@ -132,4 +132,45 @@ 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; + return compare( this, descriptor ); + } + return false; + } + + private boolean compare( Descriptor primary, Descriptor secondary ) + { + if( primary.getAttributeNames().length != secondary.getAttributeNames().length ) + { + return false; + } + String[] names = primary.getAttributeNames(); + for( int i=0; i<names.length; i++ ) + { + String v1 = primary.getAttribute( names[i] ); + String v2 = secondary.getAttribute( names[i] ); + if( v1 == null ) + { + if( v2 != null ) + { + return false; + } + } + if( !v1.equals( v2 ) ) + { + return false; + } + } + return true; + } } 1.4 +4 -4 avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/Type.java Index: Type.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/info/Type.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Type.java 26 Nov 2002 18:04:22 -0000 1.3 +++ Type.java 7 Dec 2002 09:48:57 -0000 1.4 @@ -99,11 +99,11 @@ * required by the type * @param context a component context descriptor that declares the context type * and context entry key and value classnames - * @param services a set of service descriprors that detail the service that + * @param services a set of service descriptors that detail the service that * this component type is capable of supplying - * @param dependencies a set of depedency descriprors that detail the service + * @param dependencies a set of depedency descriptors that detail the service * that this component type is depedent on - * @param stages a set of stage descriprors that detail the extensiuon stage + * @param stages a set of stage descriprors that detail the extension stage * interfaces that this component requires a handler for * @param extensions a set of lifecycle extension capabilities that this * componet can provide to its container during the process of stage 1.2 +12 -3 avalon-sandbox/meta/src/java/org/apache/avalon/meta/model/verifier/ProfileVerifier.java Index: ProfileVerifier.java =================================================================== RCS file: /home/cvs/avalon-sandbox/meta/src/java/org/apache/avalon/meta/model/verifier/ProfileVerifier.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProfileVerifier.java 24 Nov 2002 12:58:29 -0000 1.1 +++ ProfileVerifier.java 7 Dec 2002 09:48:58 -0000 1.2 @@ -154,7 +154,7 @@ m_verifier.verifyType( name, clazz, interfaces, phases ); - verifyContextPresence( profile, clazz ); + //verifyContextPresence( profile, clazz ); } /** @@ -169,6 +169,15 @@ final Class clazz ) throws VerifyException { + if( profile == null ) + { + throw new NullPointerException( "profile" ); + } + if( clazz == null ) + { + throw new NullPointerException( "clazz" ); + } + final Type info = profile.getType(); final ContextDescriptor context = info.getContext(); final int count = context.getEntrys().length; @@ -180,7 +189,7 @@ final String message = REZ.getString( "metadata.declare-uneeded-entrys.error", profile.getName(), - getClassname( profile ) ); + clazz.getName() ); throw new VerifyException( message ); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>