mcconnell 2003/07/16 17:03:55
Modified: merlin/meta-spi/src/java/org/apache/avalon/meta/data
DeploymentProfile.java
merlin/meta-spi/src/test/org/apache/avalon/meta/data/test
DeploymentProfileTestCase.java
Added: merlin/meta-spi/src/java/org/apache/avalon/meta/data
DependencyDirective.java SelectionDirective.java
Log:
Add selection directive.
Revision Changes Path
1.3 +26 -2
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/DeploymentProfile.java
Index: DeploymentProfile.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/DeploymentProfile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeploymentProfile.java 7 Jul 2003 08:31:20 -0000 1.2
+++ DeploymentProfile.java 17 Jul 2003 00:03:54 -0000 1.3
@@ -165,6 +165,11 @@
private ContextDirective m_context;
/**
+ * The dependency directives.
+ */
+ private DependencyDirective[] m_dependencies;
+
+ /**
* The creation mode.
*/
private Mode m_mode;
@@ -177,7 +182,7 @@
final String name,
final String classname )
{
- this( name, false, classname, null, null, null, null, Mode.IMPLICIT );
+ this( name, false, classname, null, null, null, null, null, Mode.IMPLICIT );
}
public DeploymentProfile(
@@ -186,6 +191,7 @@
final String classname,
final CategoriesDirective categories,
final ContextDirective context,
+ final DependencyDirective[] dependencies,
final Parameters parameters,
final Configuration config,
final Mode mode )
@@ -195,6 +201,14 @@
m_classname = classname;
m_categories = categories;
m_context = context;
+ if( dependencies == null )
+ {
+ m_dependencies = new DependencyDirective[0];
+ }
+ else
+ {
+ m_dependencies = dependencies;
+ }
m_parameters = parameters;
m_configuration = config;
}
@@ -231,6 +245,16 @@
public ContextDirective getContext()
{
return m_context;
+ }
+
+ /**
+ * Return the dependency directives.
+ *
+ * @return the set of DependencyDirective statements for the profile.
+ */
+ public DependencyDirective[] getDependencyDirectives()
+ {
+ return m_dependencies;
}
/**
1.1
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/DependencyDirective.java
Index: DependencyDirective.java
===================================================================
/*
============================================================================
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 [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
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.data;
import java.io.Serializable;
/**
* A DependencyDirective contains information describing how a
* dependency should be resolved.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/07/17 00:03:54 $
*/
public final class DependencyDirective implements Serializable
{
/**
* The dependency key that the directive refers to.
*/
private final String m_key;
/**
* The dependency source (possibly null)
*/
private final String m_source;
/**
* The set of features used during selection.
*/
private final SelectionDirective[] m_features;
/**
* Creation of a new dependency directive.
*
* @param key the dependency key
* @param source path to the source provider component
*/
public DependencyDirective( String key, String source )
{
m_key = key;
m_source = source;
m_features = new SelectionDirective[0];
}
/**
* Creation of a new dependency directive.
*
* @param key the dependency key
* @param features the set of selection directives
*/
public DependencyDirective( String key, SelectionDirective[] features )
{
m_key = key;
m_features = features;
m_source = null;
}
/**
* Return the dependency key.
* @return the key
*/
public String getKey()
{
return m_key;
}
/**
* Return the dependency source path.
* @return the path
*/
public String getSource()
{
return m_source;
}
/**
* Return the set of selection directive constraints.
* @return the selection directive set
*/
public SelectionDirective[] getSelectionDirectives()
{
return m_features;
}
}
1.1
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/SelectionDirective.java
Index: SelectionDirective.java
===================================================================
/*
============================================================================
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 [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
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.data;
import java.io.Serializable;
/**
* A DependencyDirective contains information describing how a
* depedency should be resolved.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/07/17 00:03:54 $
*/
public final class SelectionDirective implements Serializable
{
public static final String EXISTS = "exists";
public static final String EQUALS = "equals";
public static final String INCLUDES = "includes";
/**
* The feature name.
*/
private final String m_feature;
/**
* The value attributed to the feature selection criteria.
*/
private final String m_value;
/**
* The criteria to be applied with respect to the feature criteria.
*/
private final String m_criteria;
/**
* The optional status of the selection directive.
*/
private final boolean m_optional;
/**
* Creation of a new dependency directive.
*
* @param key the selection feature
* @param value the value to asses
* @param criteria the selection criteria
* @param optional the optional status
*/
public SelectionDirective( String feature, String value, String criteria,
boolean optional )
{
m_feature = feature;
m_value = value;
m_criteria = criteria;
m_optional = optional;
}
/**
* Return the feature name.
* @return the name
*/
public String getFeature()
{
return m_feature;
}
/**
* Return the feature value.
* @return the name
*/
public String getValue()
{
return m_value;
}
/**
* Return the feature selection criteria.
* @return the criteria
*/
public String getCriteria()
{
return m_criteria;
}
/**
* Return the required status of this directive.
* @return the required status
*/
public boolean isRequired()
{
return !m_optional;
}
/**
* Return the optional status of this directive. This
* is equivalent to !isRequired()
* @return the optional status
*/
public boolean isOptional()
{
return m_optional;
}
}
1.2 +3 -1
avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/DeploymentProfileTestCase.java
Index: DeploymentProfileTestCase.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/data/test/DeploymentProfileTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeploymentProfileTestCase.java 10 Jul 2003 23:01:59 -0000 1.1
+++ DeploymentProfileTestCase.java 17 Jul 2003 00:03:55 -0000 1.2
@@ -77,6 +77,7 @@
private Parameters m_parameters;
private Configuration m_configuration;
private ContextDirective m_context;
+ private DependencyDirective[] m_dependencies;
private String m_name;
private String m_classname;
@@ -92,6 +93,7 @@
m_context =
new ContextDirective( getClass().getName(), new ImportDirective[0] );
m_configuration = new DefaultConfiguration("test");
+ m_dependencies = new DependencyDirective[0];
m_parameters = Parameters.fromProperties(System.getProperties());
m_activation = true;
m_mode = Mode.IMPLICIT;
@@ -102,7 +104,7 @@
{
DeploymentProfile profile = new DeploymentProfile(
m_name, m_activation, m_classname, m_categories,
- m_context, m_parameters, m_configuration, m_mode );
+ m_context, m_dependencies, m_parameters, m_configuration, m_mode );
assertEquals( "name", m_name, profile.getName() );
assertEquals( "classname", m_classname, profile.getClassname() );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]