Commit c1c75470 authored by Christophe Demarey's avatar Christophe Demarey

Add scaparent, scasibling, scaancestor axes.

parent a48c0540
FraSCAti Script 1.3
---------------------
* Add a transitive (scadescendant) and reflexive (scadescendant-or-self) axis for scachild
* Add the scaparent axis
* Add a transitive (scaancestor) and reflexive (scaancestor-or-self) axis for scaparent
* Add the scasibling axis
FraSCAti Script 1.2
---------------------
......
......@@ -29,6 +29,7 @@ import static org.objectweb.fractal.fscript.types.PrimitiveType.STRING;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.fscript.model.ComposedAxis;
import org.objectweb.fractal.fscript.model.Model;
import org.objectweb.fractal.fscript.model.Property;
import org.objectweb.fractal.fscript.model.ReflectiveAxis;
......@@ -93,7 +94,7 @@ public class FraSCAtiModel
super.createAxes();
// Base axes
addAxis(new ScaChildAxis(this));
// addAxis(new ParentAxis(this));
addAxis(new ScaParentAxis(this));
// addAxis(new ComponentAxis(this));
addAxis(new ScaServiceAxis(this));
addAxis(new ScaReferenceAxis(this));
......@@ -103,15 +104,15 @@ public class FraSCAtiModel
addAxis(new ScaIntentAxis(this));
// Transitive axes
addAxis(new TransitiveAxis(getAxis("scachild"), "scadescendant"));
// addAxis(new TransitiveAxis(getAxis("scaparent"), "scaancestor"));
addAxis(new TransitiveAxis(getAxis("scaparent"), "scaancestor"));
// Composed axes
// addAxis(new ComposedAxis("sibling", getAxis("scaparent"), getAxis("scachild")));
addAxis(new ComposedAxis("scasibling", getAxis("scaparent"), getAxis("scachild")));
// Reflective axes
addAxis(new ReflectiveAxis(getAxis("scachild")));
// addAxis(new ReflectiveAxis(getAxis("scaparent")));
addAxis(new ReflectiveAxis(getAxis("scaparent")));
addAxis(new ReflectiveAxis(getAxis("scadescendant")));
// addAxis(new ReflectiveAxis(getAxis("scaancestor")));
// addAxis(new ReflectiveAxis(getAxis("scasibling")));
addAxis(new ReflectiveAxis(getAxis("scaancestor")));
addAxis(new ReflectiveAxis(getAxis("scasibling")));
}
/**
......
/***
* OW2 FraSCAti fscript
* Copyright (C) 2010 INRIA, USTL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author: Christophe Demarey
*
* Contributor(s):
*
*/
package org.ow2.frascati.fscript.model;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.SuperController;
import org.objectweb.fractal.fscript.model.AbstractAxis;
import org.objectweb.fractal.fscript.model.Node;
import org.objectweb.fractal.fscript.model.fractal.ComponentNode;
import org.objectweb.fractal.util.Fractal;
/**
* Implements the <code>scaparent</code> axis in FPath. This axis connects SCA
* components to their direct parents (if any). This axis is not modifiable
* directly (although changes to the <code>child</code> axis will reflect on
* this one).
*
* @author Christophe Demarey.
*/
public class ScaParentAxis extends AbstractAxis {
/** The logger */
private static Logger logger = Logger.getLogger("org.ow2.frascati.fscript.model.ScaParentAxis");
/**
* Default constructor.
*
* @param model The model referencing this axis.
*/
public ScaParentAxis(FraSCAtiModel model) {
super(model, "scaparent", "scacomponent", "scacomponent");
}
public boolean isPrimitive() {
return true;
}
public boolean isModifiable() {
return false;
}
/**
* Get nodes for this axis from the specified source node.
*
* @param source The source node to introspect.
* @return A set of nodes.
*/
public Set<Node> selectFrom(Node source) {
Component comp = ((ComponentNode) source).getComponent();
String compName = null;
try {
compName = Fractal.getNameController(comp).getFcName();
} catch (NoSuchInterfaceException e1) {
logger.warning(comp + "should have a Name Controller!");
}
try {
SuperController cc = Fractal.getSuperController(comp);
Set<Node> result = new HashSet<Node>();
for (Component parent : cc.getFcSuperComponents()) {
try {
parent.getFcInterface(org.ow2.frascati.tinfi.control.component.ReconfigurableComponentContext.NAME);
ScaComponentNode node = ((NodeFactory) model).createScaComponentNode(parent);
// Check that parent is not an hidden frascati container
if (compName != null) {
String parentName = null;
try {
parentName = Fractal.getNameController(parent).getFcName();
} catch (NoSuchInterfaceException e1) {
logger.warning(parent + "should have a Name Controller!");
}
if ( (parentName != null) && (parentName.compareTo(compName+"-container") != 0))
result.add(node);
}
} catch (NoSuchInterfaceException e) {
/* The sca-component-controller cannot be found!
This component is not a SCA component => Nothing to do! */
}
}
return result; // Collections.unmodifiableSet(result);
} catch (NoSuchInterfaceException e) {
// Not a composite, no children.
return Collections.emptySet();
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment