crafterm 2002/10/17 07:38:18
Modified: xfc/src/java/org/apache/excalibur/xfc/model Model.java
xfc/src/java/org/apache/excalibur/xfc/modules/ecm
ECMGenerator.java ECMSerializer.java
xfc/src/java/org/apache/excalibur/xfc/modules/fortress
Fortress.java FortressGenerator.java
FortressSerializer.java
xfc/src/test/org/apache/excalibur/xfc/test fortress.xconf
xfcTestCase.java
xfc/src/test/org/apache/excalibur/xfc/test/util
ECMTestRig.java FortressTestRig.java
Added: xfc/src/java/org/apache/excalibur/xfc/model/instance
Instance.java InstanceVisitor.java
MultiNonRoleInstance.java MultiRoleInstance.java
SingleNonRoleInstance.java SingleRoleInstance.java
package.html
xfc/src/java/org/apache/excalibur/xfc/model/role
MultiRoleRef.java RoleRef.java RoleRefVisitor.java
SingleRoleRef.java package.html
Removed: xfc/src/java/org/apache/excalibur/xfc/model Instance.java
RoleRef.java
Log:
Further xfc cleanups:
* Created specialized classes for each possible type of role and instance
definition
* Created Visitor interfaces for performing operations on these groups
of classes.
* Updated ECM and Fortress modules to utilize these newer classes.
* General documentation fixes.
* Updated testrig to work with new role and instance classes.
Revision Changes Path
1.4 +4 -1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Model.java
Index: Model.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/Model.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Model.java 14 Oct 2002 16:17:50 -0000 1.3
+++ Model.java 17 Oct 2002 14:38:17 -0000 1.4
@@ -52,6 +52,9 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.excalibur.xfc.model.role.RoleRef;
+import org.apache.excalibur.xfc.model.instance.Instance;
+
/**
* Class for maintaining the Roles and their providing Components
* a particular Container configuration.
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/Instance.java
Index: Instance.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
import org.apache.avalon.framework.configuration.Configuration;
/**
* Abstract base class for representing an instance of a particular component
* in a configuraiton file.
*
* <p>
* Subclasses specify concrete types of instance definitions, eg:
* those based on role manager, component selector, etc.
* </p>
*
* <p>
* [EMAIL PROTECTED] InstanceVisitor} defines an interface for traversing
groups of
* Instance classes.
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: Instance.java,v 1.1 2002/10/17 14:38:17 crafterm Exp $
*/
public abstract class Instance
{
// common instance configuration
private final Configuration[] m_configuration;
private final String m_class;
private final String m_handler;
/**
* Creates a new [EMAIL PROTECTED] Instance} instance. This constructor
creates
* an instance definition of a particular role, indexed by shorthand name.
*
* @param clazz override class, if any
* @param config instance <code>Configuration</code> as an array, if any
* @param handler a <code>String</code> value
*/
public Instance(
final String clazz,
final Configuration[] config,
final String handler
)
{
m_class = clazz;
m_configuration = config;
m_handler = handler;
}
/**
* Obtain this Instance's configuration
*
* @return a <code>Configuration[]</code> value
*/
public Configuration[] getConfiguration()
{
return m_configuration;
}
/**
* Obtain this Instance's implementing class, or override class name
*
* @return implementing class
*/
public String getClassImpl()
{
return m_class;
}
/**
* Obtain this Instance's normalized handler
*
* @return normalized handler name
*/
public String getHandler()
{
return m_handler;
}
/**
* Method for accepting an [EMAIL PROTECTED] InstanceVisitor} class.
*
* @param visitor an [EMAIL PROTECTED] InstanceVisitor} value
* @exception Exception if an error occurs
*/
public void accept( final InstanceVisitor visitor )
throws Exception
{
throw new UnsupportedOperationException( "This method shouldn't be
invoked" );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/InstanceVisitor.java
Index: InstanceVisitor.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
/**
* Visitor class for performing operations on concrete [EMAIL PROTECTED]
Instance}
* classes.
*
* <p>
* This class is based on the Visitor pattern <i>(Design Patterns, p331)</i>.
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: InstanceVisitor.java,v 1.1 2002/10/17 14:38:17 crafterm
Exp $
*/
public interface InstanceVisitor
{
/**
* Operate on a [EMAIL PROTECTED] SingleRoleInstance} class.
*
* @param instance a [EMAIL PROTECTED] SingleRoleInstance} value
* @exception Exception if an error occurs
*/
void visit( SingleRoleInstance instance )
throws Exception;
/**
* Operate on a [EMAIL PROTECTED] SingleNonRoleInstance} class.
*
* @param instance a [EMAIL PROTECTED] SingleNonRoleInstance} value
* @exception Exception if an error occurs
*/
void visit( SingleNonRoleInstance instance )
throws Exception;
/**
* Operate on a [EMAIL PROTECTED] MultiRoleInstance} class.
*
* @param instance a [EMAIL PROTECTED] MultiRoleInstance} value
* @exception Exception if an error occurs
*/
void visit( MultiRoleInstance instance )
throws Exception;
/**
* Operate on a [EMAIL PROTECTED] MultiNonRoleInstance} class.
*
* @param instance a [EMAIL PROTECTED] MultiNonRoleInstance} value
* @exception Exception if an error occurs
*/
void visit( MultiNonRoleInstance instance )
throws Exception;
/**
* Operate on a [EMAIL PROTECTED] Instance} class.
*
* @param instance an [EMAIL PROTECTED] Instance} value
* @exception Exception if an error occurs
*/
void visit( Instance instance )
throws Exception;
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/MultiNonRoleInstance.java
Index: MultiNonRoleInstance.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
/**
* Class which represents an instance of a particular component, that does not
* use RoleManager, but has multiple providers of the same role.
* (eg. ComponentSelector)
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: MultiNonRoleInstance.java,v 1.1 2002/10/17 14:38:17
crafterm Exp $
*/
public class MultiNonRoleInstance extends Instance
{
// instance roles/override class/and subinstance definitions, if any
private final String m_role;
private final SingleRoleInstance[] m_subinstances;
/**
* Constructor
*
* @param role role name
* @param subinstances an [EMAIL PROTECTED] SingleRoleInstance}[] array
*/
public MultiNonRoleInstance(
final String role,
final SingleRoleInstance[] subinstances
)
{
super( null, null, null );
m_role = role;
m_subinstances = subinstances;
}
/**
* Obtain this Instance's role name
*
* @return role name
*/
public String getRole()
{
return m_role;
}
/**
* Obtain this Instance's list of sub instances.
*
* @return an [EMAIL PROTECTED] SingleRoleInstance}[] value
*/
public SingleRoleInstance[] getSubInstances()
{
return m_subinstances;
}
/**
* Accept an [EMAIL PROTECTED] InstanceVisitor} on this class.
*
* @param visitor an [EMAIL PROTECTED] InstanceVisitor} value
* @exception Exception if an error occurs
*/
public void accept( final InstanceVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/MultiRoleInstance.java
Index: MultiRoleInstance.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
/**
* Class which represents an instance of a particular component in an xconf
file,
* that uses role manager and has more than one provider of the role it
defines.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: MultiRoleInstance.java,v 1.1 2002/10/17 14:38:17
crafterm Exp $
*/
public class MultiRoleInstance extends Instance
{
// instance configuration
private final String m_shorthand;
private final SingleRoleInstance[] m_subinstances;
/**
* Constructor
*
* @param shorthand a <code>String</code> value
* @param subinstances an <code>Instance[]</code> value
*/
public MultiRoleInstance(
final String shorthand,
final SingleRoleInstance[] subinstances
)
{
super( null, null, null );
m_shorthand = shorthand;
m_subinstances = subinstances;
}
/**
* Obtain shorthand name
*
* @return shorthand name
*/
public String getShorthand()
{
return m_shorthand;
}
/**
* Obtain this Instance's list of sub instances.
*
* @return an [EMAIL PROTECTED] SingleRoleInstance} value
*/
public SingleRoleInstance[] getSubInstances()
{
return m_subinstances;
}
/**
* Accept an [EMAIL PROTECTED] InstanceVisitor} on this class.
*
* @param visitor an [EMAIL PROTECTED] InstanceVisitor} value
* @exception Exception if an error occurs
*/
public void accept( final InstanceVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/SingleNonRoleInstance.java
Index: SingleNonRoleInstance.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
import org.apache.avalon.framework.configuration.Configuration;
/**
* Class which represents an instance of a particular component in an xconf
file,
* that does not use role manager and defines a component with a single
* implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: SingleNonRoleInstance.java,v 1.1 2002/10/17 14:38:17
crafterm Exp $
*/
public class SingleNonRoleInstance extends Instance
{
// instance configuration
private final String m_role;
/**
* Constructor
*
* @param role role name
* @param clazz component implementation class name
* @param config instance <code>Configuration</code> as an array, if any
* @param handler component handler name
*/
public SingleNonRoleInstance(
final String role,
final String clazz,
final Configuration[] config,
final String handler
)
{
super( clazz, config, handler );
m_role = role;
}
/**
* Obtain role name
*
* @return role name
*/
public String getRole()
{
return m_role;
}
/**
* Accept an [EMAIL PROTECTED] InstanceVisitor} on this class.
*
* @param visitor an [EMAIL PROTECTED] InstanceVisitor} value
* @exception Exception if an error occurs
*/
public void accept( final InstanceVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/SingleRoleInstance.java
Index: SingleRoleInstance.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.instance;
import org.apache.avalon.framework.configuration.Configuration;
/**
* Class which represents an instance of a particular component in an xconf
file,
* that represents a role managed component with a single implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: SingleRoleInstance.java,v 1.1 2002/10/17 14:38:17
crafterm Exp $
*/
public class SingleRoleInstance extends Instance
{
// instance configuration
private final String m_shorthand;
/**
* Constructor
*
* @param shorthand shorthand name
* @param clazz override class, if any
* @param config instance <code>Configuration</code> as an array, if any
* @param handler handler name
*/
public SingleRoleInstance(
final String shorthand,
final String clazz,
final Configuration[] config,
final String handler
)
{
super( clazz, config, handler );
m_shorthand = shorthand;
}
/**
* Obtain shorthand name
*
* @return shorthand name
*/
public String getShorthand()
{
return m_shorthand;
}
/**
* Accept an [EMAIL PROTECTED] InstanceVisitor} on this class.
*
* @param visitor an [EMAIL PROTECTED] InstanceVisitor} value
* @exception Exception if an error occurs
*/
public void accept( final InstanceVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<body>
<p>
<b>Instance</b> - Set of classes used for defining instances of components
</p>
<p>
This package provides a set of classes that define the different types of
component instance definitions possible, and a <i>Visitor</i> class for
performing operations on them.
</p>
<!--
<h2>Package Specification</h2>
##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
<ul>
<li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
</ul>
<h2>Related Documentation</h2>
For overviews, tutorials, examples, guides, and tool documentation, please
see:
<ul>
<li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/role/MultiRoleRef.java
Index: MultiRoleRef.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.role;
import org.apache.excalibur.xfc.model.Definition;
/**
* Class which represents an entry in a roles file, that contains multiple
* definitions for the one role.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: MultiRoleRef.java,v 1.1 2002/10/17 14:38:17 crafterm Exp
$
*/
public class MultiRoleRef extends RoleRef
{
// internals
private Definition[] m_definitions;
/**
* Constructor
*
* @param role role name
* @param shorthand shorthand name
* @param definitions a [EMAIL PROTECTED] Definition}[] array
*/
public MultiRoleRef(
final String role, final String shorthand, final Definition[]
definitions
)
{
super( role, shorthand );
m_definitions = definitions;
}
/**
* Obtain a list of all Definition objects that provide the role
* this represents.
*
* @return a [EMAIL PROTECTED] Definition}[] array
*/
public Definition[] getProviders()
{
return m_definitions;
}
/**
* Accept a [EMAIL PROTECTED] RoleRefVisitor} on this class.
*
* @param visitor a [EMAIL PROTECTED] RoleRefVisitor} value
* @exception Exception if an error occurs
*/
public void accept( RoleRefVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/role/RoleRef.java
Index: RoleRef.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.role;
/**
* Abstract base class for concrete classes that represent role definitions
* in roles files.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: RoleRef.java,v 1.1 2002/10/17 14:38:17 crafterm Exp $
*/
public abstract class RoleRef
{
// internals
private final String m_role;
private final String m_shorthand;
/**
* Creates a new <code>RoleRef</code> instance.
*
* @param role role name
* @param shorthand shorthand name
*/
public RoleRef( final String role, final String shorthand )
{
m_role = role;
m_shorthand = shorthand;
}
/**
* Obtain the role this ref object manages
*
* @return role name
*/
public String getRole()
{
return m_role;
}
/**
* Obtain the shorthand name of this role
*
* @return shorthand name
*/
public String getShorthand()
{
return m_shorthand;
}
/**
* Accept a [EMAIL PROTECTED] RoleRefVisitor} on this class.
*
* @param visitor a [EMAIL PROTECTED] RoleRefVisitor} value
* @exception Exception if an error occurs
*/
public void accept( RoleRefVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/role/RoleRefVisitor.java
Index: RoleRefVisitor.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.role;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: RoleRefVisitor.java,v 1.1 2002/10/17 14:38:17 crafterm
Exp $
*/
public interface RoleRefVisitor
{
void visit( SingleRoleRef ref )
throws Exception;
void visit( MultiRoleRef ref )
throws Exception;
void visit( RoleRef ref )
throws Exception;
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/role/SingleRoleRef.java
Index: SingleRoleRef.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ 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
[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.excalibur.xfc.model.role;
import org.apache.excalibur.xfc.model.Definition;
/**
* Class which represents a single entry in a roles file, that
* defines a role with a single implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: SingleRoleRef.java,v 1.1 2002/10/17 14:38:17 crafterm
Exp $
*/
public class SingleRoleRef extends RoleRef
{
// internals
private Definition m_definition;
/**
* Constructor
*
* @param role role name
* @param shorthand shorthand name
* @param definition a [EMAIL PROTECTED] Definition} instance
*/
public SingleRoleRef( final String role, final String shorthand, final
Definition definition )
{
super( role, shorthand );
m_definition = definition;
}
/**
* Obtain the [EMAIL PROTECTED] Definition} object that describes the
implementation
* of this role.
*
* @return a [EMAIL PROTECTED] Definition} instance
*/
public Definition getProvider()
{
return m_definition;
}
/**
* Accept a [EMAIL PROTECTED] RoleRefVisitor} object on this class.
*
* @param visitor a [EMAIL PROTECTED] RoleRefVisitor} value
* @exception Exception if an error occurs
*/
public void accept( RoleRefVisitor visitor )
throws Exception
{
visitor.visit( this );
}
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/role/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<body>
<p>
<b>Role</b> - Simple set of classes used defining component roles
</p>
<p>
This package provides a set of classes that define the different types of
component roles that can be made, and a <i>Visitor</i> class for performing
operations on them.
</p>
<!--
<h2>Package Specification</h2>
##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
<ul>
<li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
</ul>
<h2>Related Documentation</h2>
For overviews, tutorials, examples, guides, and tool documentation, please
see:
<ul>
<li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>
1.2 +82 -58
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ecm/ECMGenerator.java
Index: ECMGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ecm/ECMGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ECMGenerator.java 16 Oct 2002 16:20:38 -0000 1.1
+++ ECMGenerator.java 17 Oct 2002 14:38:18 -0000 1.2
@@ -60,8 +60,14 @@
import org.apache.excalibur.xfc.model.Model;
import org.apache.excalibur.xfc.model.Definition;
-import org.apache.excalibur.xfc.model.Instance;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.instance.Instance;
+import org.apache.excalibur.xfc.model.instance.MultiNonRoleInstance;
+import org.apache.excalibur.xfc.model.instance.MultiRoleInstance;
+import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
+import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
+import org.apache.excalibur.xfc.model.role.RoleRef;
+import org.apache.excalibur.xfc.model.role.SingleRoleRef;
+import org.apache.excalibur.xfc.model.role.MultiRoleRef;
import org.apache.excalibur.xfc.modules.Constants;
@@ -97,6 +103,28 @@
{
Model model = new Model();
+ addRoles( model, context);
+ addInstances( model, context);
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "Model built" );
+ }
+
+ return model;
+ }
+
+ /**
+ * Helper method for adding all role definitions to the
+ * given model.
+ *
+ * @param model a [EMAIL PROTECTED] Model} instance
+ * @param context input context
+ * @exception Exception if an error occurs
+ */
+ private void addRoles( final Model model, final String context )
+ throws Exception
+ {
// locate all roles
Configuration[] roles = getRoles( getRoleFile( context ) );
@@ -110,7 +138,19 @@
{
model.addRoleRef( buildRoleRef( roles[i] ) );
}
+ }
+ /**
+ * Helper method for adding all component instance definitions
+ * to the given model.
+ *
+ * @param model a [EMAIL PROTECTED] Model} instance
+ * @param context input context
+ * @exception Exception if an error occurs
+ */
+ private void addInstances( final Model model, final String context )
+ throws Exception
+ {
// locate all component instances
Configuration[] instances = getInstanceList( getConfigurationFile(
context ) );
@@ -125,14 +165,6 @@
{
model.addInstance( buildInstance( instances[i], model ) );
}
-
- // finished
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Model built" );
- }
-
- return model;
}
/**
@@ -171,7 +203,7 @@
throws Exception
{
Configuration config = m_builder.buildFromFile( input );
- return config.getChildren( "role" );
+ return config.getChildren( ROLE );
}
/**
@@ -202,7 +234,7 @@
protected RoleRef buildRoleRef( final Configuration role )
throws Exception
{
- if ( isComponentSelectorRole( role ) ) // component selector
definition
+ if ( isComponentSelectorRole( role ) )
{
return buildMultipleComponentRoleRef( role );
}
@@ -216,7 +248,7 @@
* a ComponentSelector style definition or not.
*
* @param role a <code>Configuration</code> value
- * @return a <code>boolean</code> value
+ * @return true if the given role refers to a ECS definition, false
otherwise
*/
protected boolean isComponentSelectorRole( final Configuration role )
{
@@ -242,7 +274,9 @@
HandlerAnalyzer.getHandler( role.getAttribute( DEFAULT ) )
);
- return new RoleRef( role.getAttribute( NAME ), role.getAttribute(
SHORTHAND ), def );
+ return new SingleRoleRef(
+ role.getAttribute( NAME ), role.getAttribute( SHORTHAND ), def
+ );
}
/**
@@ -269,13 +303,22 @@
);
}
- return new RoleRef(
+ return new MultiRoleRef(
role.getAttribute( NAME ), role.getAttribute( SHORTHAND ),
definitions
);
}
// INSTANCE GENERATION METHODS
+ /**
+ * Builds an [EMAIL PROTECTED] Instance} object from a given component
configuration
+ * definition.
+ *
+ * @param i a <code>Configuration</code> definition
+ * @param model a [EMAIL PROTECTED] Model} instance
+ * @return an [EMAIL PROTECTED] Instance} instance
+ * @exception Exception if an error occurs
+ */
protected Instance buildInstance( final Configuration i, final Model
model )
throws Exception
{
@@ -320,13 +363,7 @@
{
// check if shorthand corresponds to ECM
RoleRef ref = model.findByShorthand( shorthand );
-
- if ( ref != null && ref.getProviders().length > 1 )
- {
- return true;
- }
-
- return false;
+ return ( ref != null && ref instanceof MultiRoleRef );
}
/**
@@ -344,16 +381,22 @@
throws Exception
{
final Configuration[] kids = i.getChildren( COMPONENT_INSTANCE );
- final Instance[] subinstances = new Instance[ kids.length ];
+ final SingleRoleInstance[] subs = new SingleRoleInstance[
kids.length ];
for ( int j = 0; j < kids.length; ++j )
{
- subinstances[j] = buildSubInstance( kids[j] );
+ String clazz = kids[j].getAttribute( CLASS );
+
+ subs[j] =
+ new SingleRoleInstance(
+ kids[j].getAttribute( NAME ),
+ clazz,
+ kids[j].getChildren(),
+ clazz == null ? null : HandlerAnalyzer.getHandler( clazz
)
+ );
}
- return new Instance(
- ECS, i.getAttribute( ROLE ), subinstances, SINGLETON
- );
+ return new MultiNonRoleInstance( i.getAttribute( ROLE ), subs );
}
/**
@@ -368,10 +411,10 @@
private Instance buildNonRoleComponentInstance( final Configuration i )
throws Exception
{
- return new Instance(
- i.getChildren(),
- i.getAttribute( CLASS, null ),
+ return new SingleNonRoleInstance(
i.getAttribute( ROLE ),
+ i.getAttribute( CLASS, null ),
+ i.getChildren(),
HandlerAnalyzer.getHandler( i.getAttribute( CLASS, null ) )
);
}
@@ -387,12 +430,13 @@
private Instance buildRoleComponentInstance( final Configuration i )
throws Exception
{
- String cl = i.getAttribute( CLASS, null );
+ String clazz = i.getAttribute( CLASS, null );
- return new Instance(
+ return new SingleRoleInstance(
i.getName(),
+ clazz,
i.getChildren(),
- cl, cl == null ? null : HandlerAnalyzer.getHandler( cl )
+ clazz == null ? null : HandlerAnalyzer.getHandler( clazz )
);
}
@@ -407,36 +451,16 @@
{
// get the subinstances
Configuration[] kids = i.getChildren();
- Instance[] subinstances = new Instance[ kids.length ];
+ SingleRoleInstance[] subinstances = new SingleRoleInstance[
kids.length ];
for ( int j = 0; j < kids.length; ++j )
{
+ // REVISIT; invent a new node type ?
subinstances[j] =
- new Instance( kids[j].getName(), kids[j].getChildren(),
null, null );
+ new SingleRoleInstance( kids[j].getName(), null,
kids[j].getChildren(), null );
}
// create the root instance
- return new Instance( i.getName(), subinstances );
- }
-
- /**
- * Helper method for buiding an [EMAIL PROTECTED] Instance} object from
a
- * configuration snippet that refers to the component definitions
- * inside a component selector definitino that isn't using rolemanager.
- *
- * @param i a <code>Configuration</code> instance
- * @return an [EMAIL PROTECTED] Instance} instance
- * @exception Exception if an error occurs
- */
- private Instance buildSubInstance( final Configuration i )
- throws Exception
- {
- String cl = i.getAttribute( CLASS );
-
- return new Instance(
- i.getAttribute( NAME ),
- i.getChildren(),
- cl, cl == null ? null : HandlerAnalyzer.getHandler( cl )
- );
+ return new MultiRoleInstance( i.getName(), subinstances );
}
}
1.2 +125 -99
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ecm/ECMSerializer.java
Index: ECMSerializer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/ecm/ECMSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ECMSerializer.java 16 Oct 2002 16:20:38 -0000 1.1
+++ ECMSerializer.java 17 Oct 2002 14:38:18 -0000 1.2
@@ -60,21 +60,33 @@
import org.apache.excalibur.xfc.model.Model;
import org.apache.excalibur.xfc.model.Definition;
-import org.apache.excalibur.xfc.model.Instance;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.instance.Instance;
+import org.apache.excalibur.xfc.model.instance.InstanceVisitor;
+import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
+import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
+import org.apache.excalibur.xfc.model.instance.MultiRoleInstance;
+import org.apache.excalibur.xfc.model.instance.MultiNonRoleInstance;
+import org.apache.excalibur.xfc.model.role.RoleRef;
+import org.apache.excalibur.xfc.model.role.RoleRefVisitor;
+import org.apache.excalibur.xfc.model.role.SingleRoleRef;
+import org.apache.excalibur.xfc.model.role.MultiRoleRef;
import org.apache.excalibur.xfc.modules.Constants;
/**
* ECM module serialization class. This class contains the implementation
* of the <code>serialize</code> method defined in [EMAIL PROTECTED] ECM}.
-
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id$
*/
public class ECMSerializer extends AbstractLogEnabled
- implements Constants
+ implements RoleRefVisitor, InstanceVisitor, Constants
{
+ // internals
+ protected DefaultConfiguration m_roles = new DefaultConfiguration(
ROLELIST, "" );
+ protected DefaultConfiguration m_xconf = new DefaultConfiguration(
"xconf", "" );
+
protected final DefaultConfigurationSerializer m_serializer;
/**
@@ -82,6 +94,7 @@
*/
public ECMSerializer()
{
+ // create our serializer and enable indentation
m_serializer = new DefaultConfigurationSerializer();
m_serializer.setIndent( true );
}
@@ -97,29 +110,54 @@
public void serialize( final Model model, final String context )
throws Exception
{
+ buildRoles( model, context );
+ buildXConf( model, context );
+ }
+
+ /**
+ * Helper method to build the output roles file from the given
+ * [EMAIL PROTECTED] Model} object.
+ *
+ * @param model a [EMAIL PROTECTED] Model} instance
+ * @param context output context
+ * @exception Exception if an error occurs
+ */
+ protected void buildRoles( final Model model, final String context )
+ throws Exception
+ {
// create the role file
RoleRef[] rolerefs = model.getDefinitions();
- DefaultConfiguration roles = new DefaultConfiguration( ROLELIST, ""
);
// for each type object generate a roles file entry
for ( int i = 0; i < rolerefs.length; ++i )
{
- roles.addChild( buildRole( rolerefs[i] ) );
+ rolerefs[i].accept( this );
}
- m_serializer.serializeToFile( getRoleFile( context ), roles );
+ m_serializer.serializeToFile( getRoleFile( context ), m_roles );
+ }
+ /**
+ * Helper method to build the output xconf file from the given
+ * [EMAIL PROTECTED] Model} object.
+ *
+ * @param model a [EMAIL PROTECTED] Model} instance
+ * @param context output context
+ * @exception Exception if an error occurs
+ */
+ protected void buildXConf( final Model model, final String context )
+ throws Exception
+ {
// create the xconf file
Instance[] instances = model.getInstances();
- DefaultConfiguration xconf = new DefaultConfiguration( "xconf", "" );
// for each instance object generate an xconf file entry
- for ( int j = 0; j < instances.length; ++j )
+ for ( int i = 0; i < instances.length; ++i )
{
- xconf.addChild( buildXConf( instances[j] ) );
+ instances[i].accept( this );
}
- m_serializer.serializeToFile( getConfigurationFile( context ), xconf
);
+ m_serializer.serializeToFile( getConfigurationFile( context ),
m_xconf );
}
/**
@@ -128,7 +166,7 @@
* @param context a <code>String</code> value
* @return a <code>File</code> value
*/
- protected File getRoleFile( final String context )
+ private File getRoleFile( final String context )
{
int i = context.indexOf( CONTEXT_SEPARATOR );
return new File( context.substring( 0, i ) );
@@ -149,40 +187,34 @@
// ROLE GENERATION METHODS
/**
- * Method to build a Role definition from a [EMAIL PROTECTED] RoleRef}
- * object.
+ * Builds a single component Role definition from a [EMAIL PROTECTED]
RoleRef}
+ * definition.
*
- * @param roleref a [EMAIL PROTECTED] RoleRef} instance
- * @return role definition as a <code>Configuration</code> instance
+ * @param ref a [EMAIL PROTECTED] SingleRoleRef} instance
* @exception Exception if an error occurs
*/
- protected Configuration buildRole( final RoleRef roleref )
+ public void visit( final SingleRoleRef ref )
throws Exception
{
- Definition[] defs = roleref.getProviders();
-
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Building role for model: " +
roleref.getRole() );
- }
+ DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
+ Definition def = ref.getProvider();
- if ( roleref.getProviders().length > 1 )
- {
- return buildMultipleComponentRole( roleref );
- }
+ // there is only 1 provider, use index 0 directly
+ role.setAttribute( NAME, ref.getRole() );
+ role.setAttribute( SHORTHAND, ref.getShorthand() );
+ role.setAttribute( DEFAULT, def.getDefaultClass() );
- return buildSingleComponentRole( roleref );
+ m_roles.addChild( role );
}
/**
* Builds a multiple component Role definition (ie ComponentSelector
based)
* from a [EMAIL PROTECTED] RoleRef} definition.
*
- * @param ref a [EMAIL PROTECTED] RoleRef} instance
- * @return a <code>Configuration</code> instance
+ * @param ref a [EMAIL PROTECTED] MultiRoleRef} instance
* @exception Exception if an error occurs
*/
- protected Configuration buildMultipleComponentRole( final RoleRef ref )
+ public void visit( final MultiRoleRef ref )
throws Exception
{
DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
@@ -200,70 +232,31 @@
role.setAttribute( SHORTHAND, ref.getShorthand() );
role.setAttribute( DEFAULT, ECS );
- return role;
+ m_roles.addChild( role );
}
/**
- * Builds a single component Role definition from a [EMAIL PROTECTED]
RoleRef}
- * definition.
+ * Builds a multiple component role definition from a
+ * [EMAIL PROTECTED] RoleRef} definition. (Note, this method is unused).
*
* @param ref a [EMAIL PROTECTED] RoleRef} instance
- * @return a <code>Configuration</code> instance
* @exception Exception if an error occurs
*/
- protected Configuration buildSingleComponentRole( final RoleRef ref )
+ public void visit( final RoleRef ref )
throws Exception
{
- DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
- Definition[] defs = ref.getProviders();
-
- // there is only 1 provider, use index 0 directly
- role.setAttribute( NAME, ref.getRole() );
- role.setAttribute( SHORTHAND, ref.getShorthand() );
- role.setAttribute( DEFAULT, defs[0].getDefaultClass() );
-
- return role;
+ throw new UnsupportedOperationException( "This method shouldn't be
invoked" );
}
// XCONF GENERATION METHODS
/**
- * Builds a Configuration object from an instance declaration
- *
- * @param i an [EMAIL PROTECTED] Instance} instance
- * @return a <code>Configuration</code> instance
- * @exception Exception if an error occurs
- */
- private Configuration buildXConf( final Instance i )
- throws Exception
- {
- // has shorthand
- if ( i.getShorthand() != null )
- {
- return buildSingleRoleXConf( i );
- }
-
- if ( i.getSubInstances() == null )
- {
- // has no shorthand, no subinstances
- return buildNonRoleSingleXConf( i );
- }
-
- // has no shorthand, has subinstances
- return buildNonRoleMultiXConf( i );
-
- // return buildMultiRoleXConf();
- }
-
- /**
- * Builds a Configuration object from an Instance declaration,
- * referring to a single role based component.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
SingleRoleInstance} declaration,
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i a [EMAIL PROTECTED] SingleRoleInstance} instance
* @exception Exception if an error occurs
*/
- private Configuration buildSingleRoleXConf( final Instance i )
+ public void visit( final SingleRoleInstance i )
throws Exception
{
DefaultConfiguration conf = new DefaultConfiguration(
i.getShorthand(), "" );
@@ -283,18 +276,17 @@
conf.setAttribute( CLASS, i.getClassImpl() );
}
- return conf;
+ m_xconf.addChild( conf );
}
/**
- * Builds a Configuration object from an Instance declaration,
- * referring to a single non role based component.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
SingleNonRoleInstance}
+ * declaration
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i an [EMAIL PROTECTED] SingleNonRoleInstance} instance
* @exception Exception if an error occurs
*/
- private Configuration buildNonRoleSingleXConf( final Instance i )
+ public void visit( final SingleNonRoleInstance i )
throws Exception
{
DefaultConfiguration conf = new DefaultConfiguration( COMPONENT, ""
);
@@ -312,18 +304,17 @@
}
}
- return conf;
+ m_xconf.addChild( conf );
}
/**
- * Builds a Configuration object from an Instance declaration,
- * referring to a non role based component selector component.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
MultiNonRoleInstance}
+ * declaration
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i a [EMAIL PROTECTED] MultiNonRoleInstance} instance
* @exception Exception if an error occurs
*/
- private Configuration buildNonRoleMultiXConf( final Instance i )
+ public void visit( final MultiNonRoleInstance i )
throws Exception
{
DefaultConfiguration conf = new DefaultConfiguration( COMPONENT, ""
);
@@ -331,7 +322,7 @@
conf.setAttribute( ROLE, i.getRole() );
conf.setAttribute( CLASS, ECS );
- Instance[] subs = i.getSubInstances();
+ SingleRoleInstance[] subs = i.getSubInstances();
for ( int j = 0; j < subs.length; ++j )
{
@@ -353,20 +344,55 @@
conf.addChild( child );
}
- return conf;
+ m_xconf.addChild( conf );
}
/**
- * Describe <code>buildRoleMultiXConf</code> method here.
+ * Builds an xconf entry based on a [EMAIL PROTECTED] MultiRoleInstance}
declaration.
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i a [EMAIL PROTECTED] MultiRoleInstance} instancex
+ * @exception Exception if an error occurs
+ */
+ public void visit( final MultiRoleInstance i )
+ throws Exception
+ {
+ DefaultConfiguration conf = new DefaultConfiguration(
i.getShorthand(), "" );
+
+ SingleRoleInstance[] subs = i.getSubInstances();
+
+ for ( int j = 0; j < subs.length; ++j )
+ {
+ DefaultConfiguration child =
+ new DefaultConfiguration( subs[j].getShorthand(), "" );
+ // child.setAttribute( CLASS, subs[j].getClassImpl() );
+ child.setAttribute( NAME, subs[j].getShorthand() );
+
+ if ( subs[j].getConfiguration() != null )
+ {
+ Configuration[] kids = subs[j].getConfiguration();
+
+ for ( int k = 0; k < kids.length; ++k )
+ {
+ child.addChild( kids[k] );
+ }
+ }
+
+ conf.addChild( child );
+ }
+
+ m_xconf.addChild( conf );
+ }
+
+ /**
+ * Builds an xconf entry baesd on an [EMAIL PROTECTED] Instance}
declaration.
+ * (method not actually used).
+ *
+ * @param i an [EMAIL PROTECTED] Instance} instance
* @exception Exception if an error occurs
*/
- private Configuration buildRoleMultiXConf( final Instance i )
+ public void visit( final Instance i )
throws Exception
{
- // REVISIT
- throw new UnsupportedOperationException( "Not yet implemented" );
+ throw new UnsupportedOperationException( "This method shouldn't be
invoked" );
}
}
1.2 +9 -2
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/Fortress.java
Index: Fortress.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/Fortress.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Fortress.java 16 Oct 2002 16:20:38 -0000 1.1
+++ Fortress.java 17 Oct 2002 14:38:18 -0000 1.2
@@ -60,7 +60,6 @@
* <code>Fortress</code> module implementation.
*
* <p>
- * Fortress style role files are an extension to the ECM model.
* This implementation supports Fortress style role files. ie:
*
* <pre>
@@ -69,6 +68,14 @@
* <component shorthand="..." class="..." handler="..."/>
* </role>
* </role-list>
+ * </pre>
+ *
+ * and Fortress style configuration files. ie:
+ *
+ * <pre>
+ * <shorthand id="..">
+ * <config-data/>
+ * </shorthand>
* </pre>
* </p>
*
1.2 +18 -11
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/FortressGenerator.java
Index: FortressGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/FortressGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FortressGenerator.java 16 Oct 2002 16:20:38 -0000 1.1
+++ FortressGenerator.java 17 Oct 2002 14:38:18 -0000 1.2
@@ -56,13 +56,20 @@
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.excalibur.xfc.model.Definition;
-import org.apache.excalibur.xfc.model.Instance;
+
import org.apache.excalibur.xfc.model.Model;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.instance.Instance;
+import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
+import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
+import org.apache.excalibur.xfc.model.role.RoleRef;
+import org.apache.excalibur.xfc.model.role.SingleRoleRef;
+import org.apache.excalibur.xfc.model.role.MultiRoleRef;
import org.apache.excalibur.xfc.modules.ecm.ECMGenerator;
/**
+ * Implementation of the <code>generate</code> method on the [EMAIL
PROTECTED] Fortress}
+ * module.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id$
@@ -103,7 +110,7 @@
HandlerMapper.getHandler( config.getAttribute( HANDLER ) )
);
- return new RoleRef(
+ return new SingleRoleRef(
role.getAttribute( NAME ), config.getAttribute( SHORTHAND ),
definition
);
}
@@ -132,7 +139,7 @@
);
}
- return new RoleRef( role.getAttribute( NAME ), "UNKNOWN",
definitions );
+ return new MultiRoleRef( role.getAttribute( NAME ), "UNKNOWN",
definitions );
}
// INSTANCE GENERATION METHODS
@@ -168,11 +175,11 @@
private Instance buildNonRoleComponentInstance( final Configuration i )
throws Exception
{
- return new Instance(
- i.getChildren(),
- i.getAttribute( CLASS ),
+ return new SingleNonRoleInstance(
i.getAttribute( ROLE ),
- null
+ i.getAttribute( CLASS ),
+ i.getChildren(),
+ i.getAttribute( HANDLER )
);
}
@@ -187,10 +194,10 @@
private Instance buildRoleComponentInstance( final Configuration i )
throws Exception
{
- return new Instance(
+ return new SingleRoleInstance(
i.getName(),
+ i.getAttribute( CLASS, null ),
i.getChildren(),
- null,
null
);
}
1.2 +49 -114
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/FortressSerializer.java
Index: FortressSerializer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/modules/fortress/FortressSerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FortressSerializer.java 16 Oct 2002 16:20:38 -0000 1.1
+++ FortressSerializer.java 17 Oct 2002 14:38:18 -0000 1.2
@@ -56,86 +56,61 @@
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.excalibur.xfc.model.Definition;
-import org.apache.excalibur.xfc.model.Instance;
+import org.apache.excalibur.xfc.model.instance.Instance;
+import org.apache.excalibur.xfc.model.instance.InstanceVisitor;
+import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
+import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
+import org.apache.excalibur.xfc.model.instance.MultiRoleInstance;
+import org.apache.excalibur.xfc.model.instance.MultiNonRoleInstance;
import org.apache.excalibur.xfc.model.Model;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.role.SingleRoleRef;
+import org.apache.excalibur.xfc.model.role.MultiRoleRef;
import org.apache.excalibur.xfc.modules.ecm.ECMSerializer;
/**
+ * Implementation of the <code>serialize</code> method on the [EMAIL
PROTECTED] Fortress}
+ * module.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id$
*/
public class FortressSerializer extends ECMSerializer
{
- /**
- * Serializes a [EMAIL PROTECTED] Model} definition, ECM style, to an
- * output context.
- *
- * @param model a [EMAIL PROTECTED] Model} instance
- * @param context ECM output Context
- * @exception Exception if an error occurs
- */
- public void serialize( final Model model, final String context )
- throws Exception
- {
- // create the role file
- RoleRef[] rolerefs = model.getDefinitions();
- DefaultConfiguration roles = new DefaultConfiguration( "role-list",
"" );
-
- // for each type object generate a roles file entry
- for ( int i = 0; i < rolerefs.length; ++i )
- {
- roles.addChild( buildRole( rolerefs[i] ) );
- }
-
- m_serializer.serializeToFile( getRoleFile( context ), roles );
-
- // create the xconf file
- Instance[] instances = model.getInstances();
- DefaultConfiguration xconf = new DefaultConfiguration( "xconf", "" );
-
- // for each instance object generate an xconf file entry
- for ( int j = 0; j < instances.length; ++j )
- {
- Configuration[] xconfs = buildXConf( instances[j] );
-
- for ( int k = 0; k < xconfs.length; ++k )
- {
- xconf.addChild( xconfs[k] );
- }
- }
-
- m_serializer.serializeToFile( getConfigurationFile( context ), xconf
);
- }
-
// ROLE GENERATION METHODS
/**
- * Builds a single component Role definition from a [EMAIL PROTECTED]
RoleRef}
+ * Builds a single component Role definition from a [EMAIL PROTECTED]
SingleRoleRef}
* definition.
*
- * @param ref a [EMAIL PROTECTED] RoleRef} instance
- * @return a <code>Configuration</code> instance
- * @exception Exception if an error occurs
+ * @param ref a [EMAIL PROTECTED] SingleRoleRef} instance
+ * @exception Exception if an error occurs
*/
- protected Configuration buildSingleComponentRole( final RoleRef ref )
+ public void visit( final SingleRoleRef ref )
throws Exception
{
- // single role definitions are the same as multiple definitions
- return buildMultipleComponentRole( ref );
+ DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
+ Definition def = ref.getProvider();
+
+ DefaultConfiguration hint = new DefaultConfiguration( COMPONENT, ""
);
+ hint.setAttribute( SHORTHAND, def.getShorthand() );
+ hint.setAttribute( CLASS, def.getDefaultClass() );
+ hint.setAttribute( HANDLER, HandlerMapper.getHandler(
def.getHandler() ) );
+
+ role.addChild( hint );
+ role.setAttribute( NAME, ref.getRole() );
+
+ m_roles.addChild( role );
}
/**
* Builds a multiple component Role definition (ie ComponentSelector
based)
- * from a [EMAIL PROTECTED] RoleRef} definition.
+ * from a [EMAIL PROTECTED] MultiRoleRef} definition.
*
- * @param ref a [EMAIL PROTECTED] RoleRef} instance
- * @return a <code>Configuration</code> instance
+ * @param ref a [EMAIL PROTECTED] MultiRoleRef} instance
* @exception Exception if an error occurs
*/
- protected Configuration buildMultipleComponentRole( final RoleRef ref )
+ public void visit( final MultiRoleRef ref )
throws Exception
{
DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
@@ -155,52 +130,18 @@
role.setAttribute( NAME, ref.getRole() );
- return role;
+ m_roles.addChild( role );
}
// XCONF GENERATION METHODS
/**
- * Describe <code>buildXConf</code> method here.
- *
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration[]</code> value
- * @exception Exception if an error occurs
- */
- private Configuration[] buildXConf( final Instance i )
- throws Exception
- {
- if ( i.getShorthand() != null )
- {
-
- if ( i.getSubInstances() == null )
- {
- // has shorthand, single component
- return new Configuration[] { buildSingleRoleXConf( i ) };
- }
-
- // has shorthand, multi component
- return buildMultiRoleXConf( i );
- }
-
- if ( i.getSubInstances() == null )
- {
- // has no shorthand, no subinstances
- return new Configuration[] { buildNonRoleSingleXConf( i ) };
- }
-
- // has no shorthand, has subinstances
- return buildNonRoleMultiXConf( i );
- }
-
- /**
- * Describe <code>buildSingleRoleXConf</code> method here.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
SingleRoleInstance} object.
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i an [EMAIL PROTECTED] SingleRoleInstance} instance
* @exception Exception if an error occurs
*/
- private Configuration buildSingleRoleXConf( final Instance i )
+ public void visit( final SingleRoleInstance i )
throws Exception
{
DefaultConfiguration conf = new DefaultConfiguration(
i.getShorthand(), "" );
@@ -217,38 +158,33 @@
conf.setAttribute( ID, i.getShorthand() );
- return conf;
+ m_xconf.addChild( conf );
}
/**
- * Describe <code>buildMultiRoleXConf</code> method here.
+ * Builds an xconf entry based on a [EMAIL PROTECTED] MultiRoleInstance}
object.
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration[]</code> value
+ * @param i a [EMAIL PROTECTED] MultiRoleInstance} instance
* @exception Exception if an error occurs
*/
- private Configuration[] buildMultiRoleXConf( final Instance i )
+ public void visit( final MultiRoleInstance i )
throws Exception
{
Instance[] subinstances = i.getSubInstances();
- Configuration[] xconf = new Configuration[ subinstances.length ];
for ( int j = 0; j < subinstances.length; ++j )
{
- xconf[j] = buildSingleRoleXConf( subinstances[j] );
+ subinstances[j].accept( this );
}
-
- return xconf;
}
/**
- * Describe <code>buildNonRoleSingleXConf</code> method here.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
SingleNonRoleInstance} object.
*
- * @param i an <code>Instance</code> value
- * @return a <code>Configuration</code> value
+ * @param i a [EMAIL PROTECTED] SingleNonRoleInstance} instance.
* @exception Exception if an error occurs
*/
- private Configuration buildNonRoleSingleXConf( final Instance i )
+ public void visit( final SingleNonRoleInstance i )
throws Exception
{
DefaultConfiguration conf = new DefaultConfiguration( COMPONENT, ""
);
@@ -268,18 +204,19 @@
}
}
- return conf;
+ m_xconf.addChild( conf );
}
/**
- * Describe <code>buildNonRoleMultiXConf</code> method here.
+ * Builds an xconf entry based on a [EMAIL PROTECTED]
MultiNonRoleInstance} object.
*
- * @param i an <code>Instance</code> value
+ * @param i a [EMAIL PROTECTED] MultiNonRoleInstance} instance
* @return a <code>Configuration[]</code> value
*/
- private Configuration[] buildNonRoleMultiXConf( final Instance i )
+ public void visit( final MultiNonRoleInstance i )
+ throws Exception
{
- Instance[] subs = i.getSubInstances();
+ SingleRoleInstance[] subs = i.getSubInstances();
Configuration[] xconfs = new Configuration[ subs.length ];
for ( int j = 0; j < subs.length; ++j )
@@ -301,9 +238,7 @@
}
}
- xconfs[j] = conf;
+ m_xconf.addChild( conf );
}
-
- return xconfs;
}
}
1.2 +1 -1
jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/fortress.xconf
Index: fortress.xconf
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/fortress.xconf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fortress.xconf 14 Oct 2002 16:17:50 -0000 1.1
+++ fortress.xconf 17 Oct 2002 14:38:18 -0000 1.2
@@ -29,7 +29,7 @@
id="default-connection"
class="org.apache.avalon.excalibur.datasource.JdbcDataSourceComponent"
handler="org.apache.excalibur.fortress.handler.ThreadSafeComponentHandler">
- <omponent-specific-configuration/>
+ <component-specific-configuration/>
</component>
</fortress-xconf>
1.8 +2 -2
jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java
Index: xfcTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/xfcTestCase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- xfcTestCase.java 16 Oct 2002 16:21:06 -0000 1.7
+++ xfcTestCase.java 17 Oct 2002 14:38:18 -0000 1.8
@@ -60,7 +60,7 @@
import org.apache.excalibur.xfc.modules.ecm.ECM;
import org.apache.excalibur.xfc.model.Definition;
import org.apache.excalibur.xfc.model.Model;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.role.RoleRef;
import org.apache.excalibur.xfc.Main;
import org.apache.excalibur.xfc.Module;
1.5 +6 -3
jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/util/ECMTestRig.java
Index: ECMTestRig.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/util/ECMTestRig.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ECMTestRig.java 16 Oct 2002 16:21:06 -0000 1.4
+++ ECMTestRig.java 17 Oct 2002 14:38:18 -0000 1.5
@@ -50,12 +50,13 @@
package org.apache.excalibur.xfc.test.util;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.logger.Logger;
import org.apache.excalibur.xfc.modules.ecm.ECM;
import org.apache.excalibur.xfc.modules.ecm.ECMSerializer;
import org.apache.excalibur.xfc.modules.ecm.HandlerAnalyzer;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.role.RoleRef;
/**
* ECM Module Test Rig. This class extends ECM and provides several accessor
methods to
@@ -91,7 +92,9 @@
public Configuration buildRole( final RoleRef roleref )
throws Exception
{
- return super.buildRole( roleref );
+ m_roles = new DefaultConfiguration( "", "" );
+ roleref.accept( this );
+ return m_roles.getChildren()[0];
}
}
}
1.3 +6 -3
jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/util/FortressTestRig.java
Index: FortressTestRig.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/test/org/apache/excalibur/xfc/test/util/FortressTestRig.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FortressTestRig.java 16 Oct 2002 16:21:06 -0000 1.2
+++ FortressTestRig.java 17 Oct 2002 14:38:18 -0000 1.3
@@ -50,9 +50,10 @@
package org.apache.excalibur.xfc.test.util;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.excalibur.xfc.model.RoleRef;
+import org.apache.excalibur.xfc.model.role.RoleRef;
import org.apache.excalibur.xfc.modules.fortress.Fortress;
import org.apache.excalibur.xfc.modules.fortress.FortressSerializer;
@@ -86,7 +87,9 @@
public Configuration buildRole( final RoleRef roleref )
throws Exception
{
- return super.buildRole( roleref );
+ m_roles = new DefaultConfiguration( "", "" );
+ roleref.accept( this );
+ return m_roles.getChildren()[0];
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>