crafterm 2002/10/23 04:32:25
Modified: xfc/src/java/org/apache/excalibur/xfc/model/instance
MultiRoleInstance.java
xfc/src/java/org/apache/excalibur/xfc/modules/ecm
ECMGenerator.java ECMSerializer.java
xfc/src/java/org/apache/excalibur/xfc/modules/fortress
FortressSerializer.java
Added: xfc/src/java/org/apache/excalibur/xfc/model/instance
SelectorHintInstance.java
Log:
Added new instance class for holding details about component selector hints,
which fixes a defect when generating xconf entries of such type.
Updated ECM and Fortress serialization modules to use this new class.
Revision Changes Path
1.2 +4 -4
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/MultiRoleInstance.java
Index: MultiRoleInstance.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/MultiRoleInstance.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultiRoleInstance.java 17 Oct 2002 14:38:17 -0000 1.1
+++ MultiRoleInstance.java 23 Oct 2002 11:32:25 -0000 1.2
@@ -60,7 +60,7 @@
{
// instance configuration
private final String m_shorthand;
- private final SingleRoleInstance[] m_subinstances;
+ private final SelectorHintInstance[] m_subinstances;
/**
* Constructor
@@ -70,7 +70,7 @@
*/
public MultiRoleInstance(
final String shorthand,
- final SingleRoleInstance[] subinstances
+ final SelectorHintInstance[] subinstances
)
{
super( null, null, null );
@@ -94,7 +94,7 @@
*
* @return an {@link SingleRoleInstance} value
*/
- public SingleRoleInstance[] getSubInstances()
+ public SelectorHintInstance[] getSubInstances()
{
return m_subinstances;
}
1.1
jakarta-avalon-excalibur/xfc/src/java/org/apache/excalibur/xfc/model/instance/SelectorHintInstance.java
Index: SelectorHintInstance.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 component selector definition.
*
* @author <a href="mailto:crafterm@;apache.org">Marcus Crafter</a>
* @version CVS $Id: SelectorHintInstance.java,v 1.1 2002/10/23 11:32:25 crafterm
Exp $
*/
public class SelectorHintInstance extends Instance
{
// instance configuration
private final String m_shorthand;
private final String m_hint;
/**
* Constructor
*
* @param shorthand shorthand name
* @param hint selector hint
* @param clazz override class, if any
* @param config instance <code>Configuration</code> as an array, if any
* @param handler handler name
*/
public SelectorHintInstance(
final String shorthand,
final String hint,
final String clazz,
final Configuration[] config,
final String handler
)
{
super( clazz, config, handler );
m_shorthand = shorthand;
m_hint = hint;
}
/**
* Obtain shorthand name
*
* @return shorthand name
*/
public String getShorthand()
{
return m_shorthand;
}
/**
* Obtain hint name
*
* @return hint name
*/
public String getHint()
{
return m_hint;
}
}
1.3 +11 -4
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ECMGenerator.java 17 Oct 2002 14:38:18 -0000 1.2
+++ ECMGenerator.java 23 Oct 2002 11:32:25 -0000 1.3
@@ -63,6 +63,7 @@
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.SelectorHintInstance;
import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
import org.apache.excalibur.xfc.model.role.RoleRef;
@@ -448,16 +449,22 @@
* @return an {@link Instance} instance
*/
private Instance buildRoleComponentSelectorInstance( final Configuration i )
+ throws Exception
{
// get the subinstances
Configuration[] kids = i.getChildren();
- SingleRoleInstance[] subinstances = new SingleRoleInstance[ kids.length ];
+ SelectorHintInstance[] subinstances = new SelectorHintInstance[ kids.length
];
for ( int j = 0; j < kids.length; ++j )
{
- // REVISIT; invent a new node type ?
subinstances[j] =
- new SingleRoleInstance( kids[j].getName(), null,
kids[j].getChildren(), null );
+ new SelectorHintInstance(
+ kids[j].getName(),
+ kids[j].getAttribute( NAME ),
+ kids[j].getAttribute( CLASS, null ),
+ kids[j].getChildren(),
+ null // REVISIT(MC) ?
+ );
}
// create the root instance
1.3 +4 -5
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ECMSerializer.java 17 Oct 2002 14:38:18 -0000 1.2
+++ ECMSerializer.java 23 Oct 2002 11:32:25 -0000 1.3
@@ -62,6 +62,7 @@
import org.apache.excalibur.xfc.model.Definition;
import org.apache.excalibur.xfc.model.instance.Instance;
import org.apache.excalibur.xfc.model.instance.InstanceVisitor;
+import org.apache.excalibur.xfc.model.instance.SelectorHintInstance;
import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
import org.apache.excalibur.xfc.model.instance.MultiRoleInstance;
@@ -199,7 +200,6 @@
DefaultConfiguration role = new DefaultConfiguration( ROLE, "" );
Definition def = ref.getProvider();
- // there is only 1 provider, use index 0 directly
role.setAttribute( NAME, ref.getRole() );
role.setAttribute( SHORTHAND, ref.getShorthand() );
role.setAttribute( DEFAULT, def.getDefaultClass() );
@@ -358,14 +358,13 @@
{
DefaultConfiguration conf = new DefaultConfiguration( i.getShorthand(), ""
);
- SingleRoleInstance[] subs = i.getSubInstances();
+ SelectorHintInstance[] 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() );
+ child.setAttribute( NAME, subs[j].getHint() );
if ( subs[j].getConfiguration() != null )
{
1.3 +19 -4
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FortressSerializer.java 17 Oct 2002 14:38:18 -0000 1.2
+++ FortressSerializer.java 23 Oct 2002 11:32:25 -0000 1.3
@@ -58,6 +58,7 @@
import org.apache.excalibur.xfc.model.Definition;
import org.apache.excalibur.xfc.model.instance.Instance;
import org.apache.excalibur.xfc.model.instance.InstanceVisitor;
+import org.apache.excalibur.xfc.model.instance.SelectorHintInstance;
import org.apache.excalibur.xfc.model.instance.SingleRoleInstance;
import org.apache.excalibur.xfc.model.instance.SingleNonRoleInstance;
import org.apache.excalibur.xfc.model.instance.MultiRoleInstance;
@@ -170,11 +171,25 @@
public void visit( final MultiRoleInstance i )
throws Exception
{
- Instance[] subinstances = i.getSubInstances();
+ SelectorHintInstance[] subs = i.getSubInstances();
- for ( int j = 0; j < subinstances.length; ++j )
+ for ( int j = 0; j < subs.length; ++j )
{
- subinstances[j].accept( this );
+ DefaultConfiguration child =
+ new DefaultConfiguration( subs[j].getShorthand(), "" );
+ child.setAttribute( ID, subs[j].getHint() );
+
+ if ( subs[j].getConfiguration() != null )
+ {
+ Configuration[] kids = subs[j].getConfiguration();
+
+ for ( int k = 0; k < kids.length; ++k )
+ {
+ child.addChild( kids[k] );
+ }
+ }
+
+ m_xconf.addChild( child );
}
}
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>