mcconnell 2003/11/24 00:19:09
Modified: repository platform.xml
repository/impl/src/java/org/apache/avalon/repository/impl
DefaultFactory.java
repository/spi/src/java/org/apache/avalon/repository/criteria
Criteria.java Parameter.java
Log:
Housekeeping.
Revision Changes Path
1.3 +4 -4 avalon-sandbox/repository/platform.xml
Index: platform.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/repository/platform.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- platform.xml 24 Nov 2003 06:06:11 -0000 1.2
+++ platform.xml 24 Nov 2003 08:19:09 -0000 1.3
@@ -28,12 +28,12 @@
<packageGroups>
<packageGroup>
- <title>Application Programming Interface</title>
+ <title>API</title>
<packages>org.apache.avalon.repository</packages>
</packageGroup>
<packageGroup>
- <title>Service Provider Interface</title>
+ <title>SPI</title>
<packages>org.apache.avalon.repository.criteria,org.apache.avalon.repository.meta</packages>
</packageGroup>
@@ -43,12 +43,12 @@
</packageGroup>
<packageGroup>
- <title>Bootstrap Facilities</title>
+ <title>Bootstrap</title>
<packages>org.apache.avalon.repository.main</packages>
</packageGroup>
<packageGroup>
- <title>Common Utilities</title>
+ <title>Utilities</title>
<packages>org.apache.avalon.repository.util</packages>
</packageGroup>
1.7 +15 -85
avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultFactory.java 24 Nov 2003 06:06:11 -0000 1.6
+++ DefaultFactory.java 24 Nov 2003 08:19:09 -0000 1.7
@@ -70,6 +70,7 @@
import org.apache.avalon.repository.Repository ;
import org.apache.avalon.repository.RepositoryException ;
import org.apache.avalon.repository.RepositoryRuntimeException;
+import org.apache.avalon.repository.RepositoryCriteria ;
import org.apache.avalon.repository.criteria.Factory ;
import org.apache.avalon.repository.criteria.Criteria ;
import org.apache.avalon.repository.criteria.Parameter ;
@@ -94,83 +95,6 @@
private static Resources REZ =
ResourceManager.getPackageResources( DefaultFactory.class );
- /**
- * Repository cache directory parameter descriptor.
- */
- public static final Parameter REPOSITORY_CACHE_DIR =
- new Parameter(
- "avalon.repository.cache.dir",
- File.class.getName(),
- false,
- REZ.getString( "repository-cache-dir" ) );
-
- /**
- * Repository proxy host parameter descriptor.
- */
- public static final Parameter REPOSITORY_PROXY_HOST =
- new Parameter(
- "avalon.repository.proxy.host",
- String.class.getName(),
- false,
- REZ.getString( "repository-proxy-host" ) );
-
- /**
- * Repository proxy port parameter descriptor.
- */
- public static final Parameter REPOSITORY_PROXY_PORT =
- new Parameter(
- "avalon.repository.proxy.port",
- Integer.class.getName(),
- false,
- REZ.getString( "repository-proxy-port" ) );
-
- /**
- * Repository proxy username parameter descriptor.
- */
- public static final Parameter REPOSITORY_PROXY_USERNAME =
- new Parameter(
- "avalon.repository.proxy.username",
- String.class.getName(),
- false,
- REZ.getString( "repository-proxy-username" ) );
-
- /**
- * Repository proxy password parameter descriptor.
- */
- public static final Parameter REPOSITORY_PROXY_PASSWORD =
- new Parameter(
- "avalon.repository.proxy.password",
- String.class.getName(),
- false,
- REZ.getString( "repository-proxy-password" ) );
-
- /**
- * Repository proxy password parameter descriptor.
- */
- public static final Parameter REPOSITORY_REMOTE_HOSTS =
- new Parameter(
- "avalon.repository.remote.url",
- String[].class.getName(),
- false,
- true,
- REZ.getString( "repository-remote-hosts" ) );
-
- /**
- * The factory parameters template.
- */
- public static final Template TEMPLATE =
- new Template(
- REZ.getString( "template-description" ),
- new Parameter[]
- {
- REPOSITORY_CACHE_DIR,
- REPOSITORY_PROXY_HOST,
- REPOSITORY_PROXY_PORT,
- REPOSITORY_PROXY_USERNAME,
- REPOSITORY_PROXY_PASSWORD,
- REPOSITORY_REMOTE_HOSTS
- } );
-
//--------------------------------------------------------------------------
// Factory
//--------------------------------------------------------------------------
@@ -183,7 +107,7 @@
{
try
{
- return new DefaultCriteria( TEMPLATE );
+ return new DefaultRepositoryCriteria();
}
catch( Throwable e )
{
@@ -223,23 +147,27 @@
System.out.println( "CRITERIA: " + map );
final String proxyHostName =
- (String) map.get( REPOSITORY_PROXY_HOST.getKey() );
+ (String) map.get(
+ RepositoryCriteria.REPOSITORY_PROXY_HOST.getKey() );
ProxyContext proxy = null;
if( null != proxyHostName )
{
final String proxyUsername =
- (String) map.get( REPOSITORY_PROXY_USERNAME.getKey() );
+ (String) map.get(
+ RepositoryCriteria.REPOSITORY_PROXY_USERNAME.getKey() );
final String proxyPassword =
- (String) map.get( REPOSITORY_PROXY_PASSWORD.getKey() );
+ (String) map.get(
+ RepositoryCriteria.REPOSITORY_PROXY_PASSWORD.getKey() );
Authenticator authenticator =
new DefaultAuthenticator( proxyUsername, proxyPassword );
Integer proxyPort =
- (Integer) map.get( REPOSITORY_PROXY_PORT.getKey() );
+ (Integer) map.get(
+ RepositoryCriteria.REPOSITORY_PROXY_PORT.getKey() );
if( null == proxyPort ) proxyPort = new Integer( 0 );
proxy =
@@ -250,9 +178,11 @@
}
File cache =
- (File) map.get( REPOSITORY_CACHE_DIR.getKey() );
+ (File) map.get(
+ RepositoryCriteria.REPOSITORY_CACHE_DIR.getKey() );
String[] hosts =
- (String[]) map.get( REPOSITORY_REMOTE_HOSTS.getKey() );
+ (String[]) map.get(
+ RepositoryCriteria.REPOSITORY_REMOTE_HOSTS.getKey() );
URL[] repositories = convertToURLs( hosts );
if ( null == proxy && null == repositories )
1.2 +3 -3
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Criteria.java
Index: Criteria.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Criteria.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Criteria.java 23 Nov 2003 15:24:12 -0000 1.1
+++ Criteria.java 24 Nov 2003 08:19:09 -0000 1.2
@@ -62,10 +62,10 @@
public interface Criteria
{
/**
- * Return the template backing the criteria.
- * @return the template
+ * Return the parameter associated to the criteria.
+ * @return the parameters
*/
- public Template getTemplate();
+ public Parameter[] getParameters();
/**
* Set a named parameter of the criteria to a value.
1.3 +2 -82
avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java
Index: Parameter.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/repository/spi/src/java/org/apache/avalon/repository/criteria/Parameter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Parameter.java 24 Nov 2003 05:19:54 -0000 1.2
+++ Parameter.java 24 Nov 2003 08:19:09 -0000 1.3
@@ -60,8 +60,6 @@
private final String m_key;
private final String m_type;
private final boolean m_required;
- private final String m_description;
- private final boolean m_multivalue;
/**
* Creation of a new parameter constraint.
@@ -71,29 +69,11 @@
* @param description a human readable parameter description
*/
public Parameter(
- final String key, final String type, boolean required,
- String description )
- {
- this( key, type, required, false, description );
- }
-
- /**
- * Creation of a new parameter constraint.
- * @param key the parameter key
- * @param type the name of a class constraining assigned values
- * @boolean required TRUE if the parameter is required
- * @param description a human readable parameter description
- * @param initial an initial default value
- */
- public Parameter(
- final String key, final String type, boolean required,
- boolean multivalue, String description )
+ final String key, final String type, boolean required )
{
m_key = key;
m_type = type;
m_required = required;
- m_description = description;
- m_multivalue = multivalue ;
}
/**
@@ -131,64 +111,4 @@
{
return !isRequired();
}
-
- /**
- * Return the human readable description of the parameter.
- * @return the description
- */
- public String getDescription()
- {
- return m_description;
- }
-
- /**
- * Return TRUE if this parameter is multivalued.
- * @return the multivalue state
- */
- public boolean isMultivalue()
- {
- return m_multivalue;
- }
-
- /**
- * Verify a value relative to the parameter constraints.
- * @param value the value to verify
- * @exception ValidationException if the value is invalid
- */
- public void verify( Object value )
- throws ValidationException
- {
- Class c = getParameterClass();
- if( value == null ) return;
- if( !c.isInstance( value ) )
- {
- final String error =
- "Value of class: ["
- + value.getClass().getName()
- + "] supplied for key ["
- + getKey()
- + "] is not an instance of type: ["
- + getClassname()
- + "].";
- throw new ValidationException( error );
- }
- }
-
- private Class getParameterClass()
- throws ValidationException
- {
- try
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return loader.loadClass( getClassname() );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve parameter class: "
- + getClassname();
- throw new ValidationException( error, e );
- }
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]