Commit 80b3d23a authored by Lionel Seinturier's avatar Lionel Seinturier

Support property promotion with different names in the promoter and promotee.

Refactor the implementation of the property controller.
parent f013bce9
Tinfi 1.3.2
-----------
* support property promotion with different names in the promoter and promotee
* support @EndsConversation methods in non @Conversational annotated interfaces
* fix proxy generation for generic methods to enable compilation with javac
......
......@@ -95,7 +95,6 @@
<adl>org.ow2.frascati.tinfi.PolicySetsHandler</adl>
<adl>org.ow2.frascati.tinfi.PolicySets</adl>
<adl>org.ow2.frascati.tinfi.Property</adl>
<adl>org.ow2.frascati.tinfi.PropertyComposite</adl>
<adl>org.ow2.frascati.tinfi.PropertyReInject</adl>
<adl>org.ow2.frascati.tinfi.ReconfigurableComponentContext</adl>
<adl>org.ow2.frascati.tinfi.ReferenceMultiple</adl>
......@@ -194,7 +193,6 @@
<!-- adl>org.ow2.frascati.tinfi.PolicySetsHandler</adl>
<adl>org.ow2.frascati.tinfi.PolicySets</adl -->
<adl>org.ow2.frascati.tinfi.Property</adl>
<adl>org.ow2.frascati.tinfi.PropertyComposite</adl>
<adl>org.ow2.frascati.tinfi.PropertyReInject</adl>
<adl>org.ow2.frascati.tinfi.ReconfigurableComponentContext</adl>
<adl>org.ow2.frascati.tinfi.ReferenceMultiple</adl>
......
......@@ -4,7 +4,15 @@
<definition name="org.ow2.frascati.tinfi.Property" >
<interface name="r" role="server" signature="org.ow2.frascati.tinfi.PropertyItf" />
<content class="org.ow2.frascati.tinfi.PropertyImpl"/>
<controller desc="scaPrimitive" />
<component name="inner" >
<interface name="r" role="server" signature="org.ow2.frascati.tinfi.PropertyItf" />
<content class="org.ow2.frascati.tinfi.PropertyImpl"/>
<controller desc="scaPrimitive" />
</component>
<binding client="this.r" server="inner.r" />
<controller desc="scaComposite" />
</definition>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<definition name="org.ow2.frascati.tinfi.PropertyComposite" >
<interface name="r" role="server" signature="org.ow2.frascati.tinfi.PropertyItf" />
<component name="inner" >
<interface name="r" role="server" signature="org.ow2.frascati.tinfi.PropertyItf" />
<content class="org.ow2.frascati.tinfi.PropertyImpl"/>
<controller desc="scaPrimitive" />
</component>
<binding client="this.r" server="inner.r" />
<controller desc="scaComposite" />
</definition>
......@@ -23,31 +23,38 @@
package org.ow2.frascati.tinfi;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.control.ContentController;
import org.objectweb.fractal.util.Fractal;
import org.ow2.frascati.tinfi.control.property.IllegalPromoterException;
import org.ow2.frascati.tinfi.control.property.SCAPropertyController;
/**
* Class for testing the use of properties on scaComposite components.
* Class for testing properties on scaComposite components.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.1.2
*/
public class PropertyCompositeTestCase extends PropertyTestCase {
private SCAPropertyController innerscapc;
@Before
@Override
public void setUp() throws Exception {
String adl = getClass().getPackage().getName()+".PropertyComposite";
String adl = getClass().getPackage().getName()+".Property";
String service = "r";
Component comp = TinfiDomain.getComponent(adl);
ContentController cc = Fractal.getContentController(comp);
Component[] subs = cc.getFcSubComponents();
Component inner = subs[0];
innerscapc = (SCAPropertyController)
inner.getFcInterface(SCAPropertyController.NAME);
itf = TinfiDomain.getService(comp,PropertyItf.class,service);
scapc = (SCAPropertyController)
......@@ -57,12 +64,25 @@ public class PropertyCompositeTestCase extends PropertyTestCase {
* Promote the properties from the primitive subcomponent to the
* composite.
*/
SCAPropertyController innerscapc = (SCAPropertyController)
inner.getFcInterface(SCAPropertyController.NAME);
scapc.setPromoter("mandatoryProp",innerscapc);
scapc.setPromoter("propWithDefault",innerscapc);
scapc.setPromoter("fieldPropWithDefault",innerscapc);
scapc.setPromoter("unannotatedFieldProp",innerscapc);
scapc.setPromoter("unannotatedProp",innerscapc);
}
@Test
public void testSetPromoterWithDifferentName()
throws IllegalPromoterException {
String expected = "foo";
scapc.setPromoter("top",innerscapc,"mandatoryProp");
scapc.setValue("top",expected);
Object actual = scapc.getValue("top");
Assert.assertEquals(expected,actual);
actual = innerscapc.getValue("mandatoryProp");
Assert.assertEquals(expected,actual);
}
}
......@@ -49,7 +49,7 @@ import org.ow2.frascati.tinfi.control.property.SCAPropertyController;
import org.ow2.frascati.tinfi.reflect.InjectionPoint;
/**
* Class for testing the use of properties.
* Class for testing component properties.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
*/
......@@ -113,13 +113,18 @@ public class PropertyTestCase {
}
@Before
public void setUp() throws Exception {
public void setUp() throws Exception {
String adl = getClass().getPackage().getName()+".Property";
String service = "r";
Component comp = TinfiDomain.getComponent(adl);
itf = TinfiDomain.getService(comp,PropertyItf.class,service);
ContentController cc = Fractal.getContentController(comp);
Component[] subs = cc.getFcSubComponents();
Component inner = subs[0];
itf = TinfiDomain.getService(inner,PropertyItf.class,service);
scapc = (SCAPropertyController)
comp.getFcInterface(SCAPropertyController.NAME);
inner.getFcInterface(SCAPropertyController.NAME);
}
public static class PropertyAnnotationImpl implements Property {
......
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2007-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: Lionel Seinturier
*/
package org.ow2.frascati.tinfi.control.property;
import org.objectweb.fractal.api.factory.InstantiationException;
import org.objectweb.fractal.julia.Controller;
import org.objectweb.fractal.julia.InitializationContext;
import org.ow2.frascati.tinfi.control.content.SCAContentController;
/**
* Implementing the {@link SCAContentController} control interface for
* scaPrimitive components.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.3.2
*/
public abstract class SCAPrimitivePropertyControllerMixin
implements Controller, SCAPropertyController {
// -------------------------------------------------------------------------
// Implementation of the Controller interface
// -------------------------------------------------------------------------
public void initFcController( InitializationContext ic )
throws InstantiationException {
_super_initFcController(ic);
}
// -------------------------------------------------------------------------
// Implementation of the SCAPropertyController interface
// -------------------------------------------------------------------------
public void setValue( String name, Object value )
throws IllegalArgumentException {
// Re-inject the value on current content instances
_this_weaveableSCACC.setPropertyValue(name,value);
}
public boolean containsDeclaredPropertyName( String name ) {
boolean b = _this_weaveableSCACC.containsPropertyName(name);
return b;
}
public String[] getDeclaredPropertyNames() {
String[] names = _this_weaveableSCACC.getPropertyNames();
return names;
}
public Class<?> getDeclaredPropertyType( String name ) {
Class<?> type = _this_weaveableSCACC.getPropertyType(name);
return type;
}
// -------------------------------------------------------------------------
// Fields and methods required by the mixin class in the base class
// -------------------------------------------------------------------------
protected abstract void _super_initFcController( InitializationContext ic )
throws InstantiationException;
private SCAContentController _this_weaveableSCACC;
}
......@@ -135,6 +135,7 @@
org.objectweb.fractal.julia.BasicControllerMixin
org.ow2.frascati.tinfi.control.content.UseSCAContentControllerMixin
org.objectweb.fractal.julia.control.name.UseNameControllerMixin
org.ow2.frascati.tinfi.control.property.SCAPrimitivePropertyControllerMixin
org.ow2.frascati.tinfi.control.property.SCAPropertyControllerMixin
))
)
......@@ -147,6 +148,7 @@
org.ow2.frascati.tinfi.control.content.UseSCAContentControllerMixin
org.objectweb.fractal.julia.control.name.UseNameControllerMixin
org.ow2.frascati.tinfi.control.property.SCACompositePropertyControllerMixin
org.ow2.frascati.tinfi.control.property.SCAPropertyControllerMixin
))
)
......
......@@ -141,11 +141,11 @@ public interface SCAPropertyController {
* Set the reference of the property controller which promotes the specified
* property to the current property controller.
*
* @param name the promoter property name
* @param name the property name
* @param promoter the promoter component or
* <code>null</code> to unregister the promoter
* @throws IllegalPromoterException
* thrown when attempting to set a cycle between property promoters
* when attempting to set a cycle between property promoters
* @since 0.4.3
*/
public void setPromoter( String name, SCAPropertyController promoter )
......@@ -156,9 +156,40 @@ public interface SCAPropertyController {
* specified property. Return <code>null</code> if the property is managed
* locally by the current property controller.
*
* @param name the promoter property name
* @param name the property name
* @return the promoter component or <code>null</code>
* @since 0.4.3
*/
public SCAPropertyController getPromoter( String name );
/**
* Set the reference of the property controller which promotes the specified
* property name to the current property controller and the associated
* property name at the level of the promoter.
*
* @param name the property name
* @param promoter the promoter component or
* <code>null</code> to unregister the promoter
* @param promoterPropertyName
* the property name at the level of the promoter
* @throws IllegalPromoterException
* when attempting to set a cycle between property promoters
* @since 1.3.2
*/
public void setPromoter(
String name, SCAPropertyController promoter,
String promoterPropertyName )
throws IllegalPromoterException;
/**
* Return the name of the property defined at the level of the component
* which promotes the specified property. Return <code>null</code> if the
* property is managed locally by the current property controller.
*
* @param name the property name
* @return the property name at the level of the promoter or
* <code>null</code>
* @since 1.3.2
*/
public String getPromoterPropertyName( String name );
}
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