mcconnell 2003/12/07 00:33:39
Modified: repository/spi/src/java/org/apache/avalon/repository/meta
ArtifactDescriptor.java FactoryDescriptor.java
Log:
Reshuffle artifact and factory metadata.
Revision Changes Path
1.2 +47 -1
avalon/repository/spi/src/java/org/apache/avalon/repository/meta/ArtifactDescriptor.java
Index: ArtifactDescriptor.java
===================================================================
RCS file:
/home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/meta/ArtifactDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArtifactDescriptor.java 4 Dec 2003 19:34:55 -0000 1.1
+++ ArtifactDescriptor.java 7 Dec 2003 08:33:39 -0000 1.2
@@ -56,6 +56,8 @@
import javax.naming.directory.Attribute;
import javax.naming.NamingException;
+import org.apache.avalon.repository.Artifact;
+
/**
* An abstract descriptor holds attributes about an artifact.
*
@@ -71,6 +73,8 @@
public static final String DOMAIN_KEY = "meta.domain";
public static final String VERSION_KEY = "meta.version";
+ public static final String BUILD_KEY =
+ "avalon.artifact.signature";
//-----------------------------------------------------------
// immutable state
@@ -79,6 +83,12 @@
private final String c_domain;
private final String c_version;
+ private final String m_group;
+ private final String m_name;
+ private final String m_version;
+ private final String m_build;
+
+
//-----------------------------------------------------------
// constructor
//-----------------------------------------------------------
@@ -114,6 +124,12 @@
"Missing attribute: " + VERSION_KEY;
throw new MetaException( error );
}
+
+ m_group = getAttribute( attributes, Artifact.GROUP_KEY, "" );
+ m_name = getAttribute( attributes, Artifact.NAME_KEY, "" );
+ m_version = getAttribute( attributes, Artifact.VERSION_KEY, "" );
+ m_build = getAttribute( attributes, BUILD_KEY, "" );
+
}
catch( NamingException e )
{
@@ -152,6 +168,15 @@
}
/**
+ * Return the build identifier
+ * @return the identifier
+ */
+ public String getBuild()
+ {
+ return m_build;
+ }
+
+ /**
* Test is the supplied object is equal to this object.
* @param other the obhject to compare this object with
* @return true if the objects are equivalent
@@ -164,6 +189,9 @@
ArtifactDescriptor meta = (ArtifactDescriptor) other;
isEqual = isEqual && c_domain.equals( meta.c_domain );
isEqual = isEqual && c_version.equals( meta.c_version );
+ isEqual = isEqual && m_group.equals( meta.m_version );
+ isEqual = isEqual && m_name.equals( meta.m_name );
+ isEqual = isEqual && m_version.equals( meta.m_version );
}
return isEqual;
}
@@ -180,6 +208,12 @@
hash >>>= 13;
hash ^= c_version.hashCode();
hash >>>= 13;
+ hash ^= m_group.hashCode();
+ hash >>>= 13;
+ hash ^= m_version.hashCode();
+ hash >>>= 13;
+ hash ^= m_build.hashCode();
+ hash >>>= 13;
return hash;
}
@@ -196,6 +230,18 @@
//-----------------------------------------------------------
// utilities
//-----------------------------------------------------------
+
+ private String getAttribute( Attributes attributes, String key, String def )
+ {
+ try
+ {
+ return getValue( attributes, key );
+ }
+ catch( Throwable e )
+ {
+ return def;
+ }
+ }
protected String getValue( Attributes attributes, String key )
throws NamingException, NoSuchElementException
1.2 +2 -40
avalon/repository/spi/src/java/org/apache/avalon/repository/meta/FactoryDescriptor.java
Index: FactoryDescriptor.java
===================================================================
RCS file:
/home/cvs/avalon/repository/spi/src/java/org/apache/avalon/repository/meta/FactoryDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FactoryDescriptor.java 4 Dec 2003 19:34:56 -0000 1.1
+++ FactoryDescriptor.java 7 Dec 2003 08:33:39 -0000 1.2
@@ -85,19 +85,11 @@
public static final String FACTORY_KEY =
"avalon.artifact.factory";
- public static final String BUILD_KEY =
- "avalon.artifact.signature";
-
//-----------------------------------------------------------
// immutable state
//-----------------------------------------------------------
- private final String m_group;
- private final String m_name;
- private final String m_version;
- private final String m_build;
-
private final Artifact[] c_api;
private final Artifact[] c_spi;
@@ -120,11 +112,6 @@
{
super( attributes );
- m_group = getAttribute( attributes, Artifact.GROUP_KEY, "" );
- m_name = getAttribute( attributes, Artifact.NAME_KEY, "" );
- m_version = getAttribute( attributes, Artifact.VERSION_KEY, "" );
- m_build = getAttribute( attributes, BUILD_KEY, "" );
-
c_api = buildDependents( attributes, API_KEY );
c_spi = buildDependents( attributes, SPI_KEY );
c_imp = buildDependents( attributes, IMP_KEY );
@@ -136,14 +123,6 @@
// public
//-----------------------------------------------------------
- /**
- * Return the build identifier
- * @return the identifier
- */
- public String getBuild()
- {
- return m_build;
- }
/**
* Return the factory classname.
@@ -205,13 +184,7 @@
public String toString()
{
- return "[meta:"
- + " group:" + m_group
- + " name:" + m_name
- + " version:" + m_version
- + " build:" + m_build
- + " factory:" + m_factory
- + "]";
+ return "[factory:" + m_factory + "]";
}
//-----------------------------------------------------------
@@ -255,15 +228,4 @@
}
}
- private String getAttribute( Attributes attributes, String key, String def )
- {
- try
- {
- return getValue( attributes, key );
- }
- catch( Throwable e )
- {
- return def;
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]