Commit 82384e95 authored by Lionel Seinturier's avatar Lionel Seinturier

Fix for the management of collection interfaces with the binding controller.

parent 11857bf1
Tinfi 1.4.6
-----------
* bug fix for the implementation of the binding controller
* minor additional framework behavior when setting collection references
(requested by Philippe)
......
......@@ -33,9 +33,11 @@ import org.objectweb.fractal.julia.BasicComponentMixin;
import org.objectweb.fractal.julia.BasicControllerMixin;
import org.objectweb.fractal.julia.TypeComponentMixin;
import org.objectweb.fractal.julia.UseComponentMixin;
import org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin;
import org.objectweb.fractal.julia.control.binding.CheckBindingMixin;
import org.objectweb.fractal.julia.control.binding.ContentBindingMixin;
import org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
import org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin;
import org.objectweb.fractal.julia.control.content.SuperControllerNotifier;
......@@ -52,7 +54,8 @@ import org.objectweb.fractal.juliac.osgi.control.lifecycle.OSGiLifeCycleControll
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.ow2.frascati.tinfi.api.control.SCAIntentController;
import org.ow2.frascati.tinfi.api.control.SCAPropertyController;
import org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.CollectionInterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.InterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.component.ComponentContextMixin;
import org.ow2.frascati.tinfi.control.content.UseSCAContentControllerMixin;
import org.ow2.frascati.tinfi.control.intent.LifeCycleIntentMixin;
......@@ -121,9 +124,12 @@ public class SCAOSGiPrimitive {
impl="SCABindingControllerImpl",
mixins={
BasicControllerMixin.class,
BasicBindingControllerMixin.class,
TypeBasicBindingMixin.class,
CollectionInterfaceBindingControllerMixin.class,
InterfaceBindingControllerMixin.class,
UseSCAContentControllerMixin.class,
UseComponentMixin.class,
BasicBindingControllerMixin.class,
CheckBindingMixin.class,
TypeBindingMixin.class,
UseSuperControllerMixin.class,
......
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2013 Inria, Univ. Lille 1
*
* 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.binding;
import java.util.Map;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.api.type.InterfaceType;
/**
* This mixin layer removes collection interface instances from the map of
* bindings.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.4.6
*/
public abstract class CollectionInterfaceBindingControllerMixin
implements BindingController {
// -------------------------------------------------------------------------
// Implementation of the BindingController interface
// -------------------------------------------------------------------------
public void unbindFc( String clientItfName )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
Interface itf = (Interface) _this_weaveableC.getFcInterface(clientItfName);
InterfaceType it = (InterfaceType) itf.getFcItfType();
if( it.isFcCollectionItf() ) {
_this_fcBindings.remove(clientItfName);
}
else {
_super_unbindFc(clientItfName);
}
}
// -------------------------------------------------------------------------
// Fields and methods required by the mixin class in the base class
// -------------------------------------------------------------------------
private Component _this_weaveableC;
private Map<String,Object> _this_fcBindings;
abstract protected void _super_unbindFc( String clientItfName )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException;
}
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2013 Inria, Univ. Lille 1
*
* 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.binding;
import org.oasisopen.sca.ServiceReference;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
import org.objectweb.fractal.julia.ComponentInterface;
import org.objectweb.fractal.julia.Interceptor;
import org.ow2.frascati.tinfi.TinfiComponentOutInterface;
import org.ow2.frascati.tinfi.control.content.SCAExtendedContentController;
/**
* This mixin manages the references hold by client interfaces in relation with
* the methods of the {@link BindingController} interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.4.6
*/
public abstract class InterfaceBindingControllerMixin implements BindingController {
// -------------------------------------------------------------------------
// Implementation of the BindingController interface
// -------------------------------------------------------------------------
public void bindFc( final String clientItfName, final Object serverItf )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
// Propagate to super layers
_super_bindFc( clientItfName, serverItf );
ComponentInterface ci = (ComponentInterface)
_this_weaveableC.getFcInterface(clientItfName);
// Skip client interceptor
Interceptor interceptor = (Interceptor) ci.getFcItfImpl();
interceptor.setFcItfDelegate(serverItf);
// Inject reference into content instances
TinfiComponentOutInterface<?> tci =
(TinfiComponentOutInterface<?>) ci;
ServiceReference<?> sr = tci.getServiceReference();
_this_weaveableSCACC.setReferenceValue(clientItfName,sr);
}
public void unbindFc( final String clientItfName )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
// Propagate to super layers
_super_unbindFc( clientItfName );
ComponentInterface ci = (ComponentInterface)
_this_weaveableC.getFcInterface(clientItfName);
// Skip client interceptor
Interceptor interceptor = (Interceptor) ci.getFcItfImpl();
interceptor.setFcItfDelegate(null);
// Inject null into content instances
_this_weaveableSCACC.unsetReferenceValue(clientItfName);
}
// -------------------------------------------------------------------------
// Fields and methods required by the mixin class in the base class
// -------------------------------------------------------------------------
private Component _this_weaveableC;
private SCAExtendedContentController _this_weaveableSCACC;
abstract protected void _super_bindFc( String clientItfName, Object serverItf )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException;
abstract protected void _super_unbindFc( String clientItfName )
throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException;
}
......@@ -33,9 +33,11 @@ import org.objectweb.fractal.julia.BasicComponentMixin;
import org.objectweb.fractal.julia.BasicControllerMixin;
import org.objectweb.fractal.julia.TypeComponentMixin;
import org.objectweb.fractal.julia.UseComponentMixin;
import org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin;
import org.objectweb.fractal.julia.control.binding.CheckBindingMixin;
import org.objectweb.fractal.julia.control.binding.ContentBindingMixin;
import org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
import org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin;
import org.objectweb.fractal.julia.control.content.SuperControllerNotifier;
......@@ -50,7 +52,8 @@ import org.objectweb.fractal.julia.control.name.UseNameControllerMixin;
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.ow2.frascati.tinfi.api.control.SCAIntentController;
import org.ow2.frascati.tinfi.api.control.SCAPropertyController;
import org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.CollectionInterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.InterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.component.ComponentContextMixin;
import org.ow2.frascati.tinfi.control.content.LifeCycleSCAContentMixin;
import org.ow2.frascati.tinfi.control.content.RequestContextSCAContentMixin;
......@@ -103,9 +106,12 @@ public class SCAPrimitive {
impl="SCABindingControllerImpl",
mixins={
BasicControllerMixin.class,
BasicBindingControllerMixin.class,
TypeBasicBindingMixin.class,
CollectionInterfaceBindingControllerMixin.class,
InterfaceBindingControllerMixin.class,
UseSCAContentControllerMixin.class,
UseComponentMixin.class,
BasicBindingControllerMixin.class,
CheckBindingMixin.class,
TypeBindingMixin.class,
UseSuperControllerMixin.class,
......
......@@ -33,9 +33,11 @@ import org.objectweb.fractal.julia.BasicComponentMixin;
import org.objectweb.fractal.julia.BasicControllerMixin;
import org.objectweb.fractal.julia.TypeComponentMixin;
import org.objectweb.fractal.julia.UseComponentMixin;
import org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin;
import org.objectweb.fractal.julia.control.binding.CheckBindingMixin;
import org.objectweb.fractal.julia.control.binding.ContentBindingMixin;
import org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin;
import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
import org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin;
import org.objectweb.fractal.julia.control.content.SuperControllerNotifier;
......@@ -50,7 +52,8 @@ import org.objectweb.fractal.julia.control.name.BasicNameControllerMixin;
import org.objectweb.fractal.julia.control.name.UseNameControllerMixin;
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.ow2.frascati.tinfi.api.control.SCAPropertyController;
import org.ow2.frascati.tinfi.control.binding.BasicBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.CollectionInterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.binding.InterfaceBindingControllerMixin;
import org.ow2.frascati.tinfi.control.component.ComponentContextMixin;
import org.ow2.frascati.tinfi.control.content.LifeCycleSCAContentMixin;
import org.ow2.frascati.tinfi.control.content.RequestContextSCAContentMixin;
......@@ -99,9 +102,12 @@ public class SCALightPrimitive {
impl="SCABindingControllerImpl",
mixins={
BasicControllerMixin.class,
BasicBindingControllerMixin.class,
TypeBasicBindingMixin.class,
CollectionInterfaceBindingControllerMixin.class,
InterfaceBindingControllerMixin.class,
UseSCAContentControllerMixin.class,
UseComponentMixin.class,
BasicBindingControllerMixin.class,
CheckBindingMixin.class,
TypeBindingMixin.class,
UseSuperControllerMixin.class,
......
......@@ -192,7 +192,7 @@ public class SCAIntentControllerTestCase {
* invocations on interface methods.
*/
int count = countItf.getCount();
Assert.assertEquals(36,count);
Assert.assertEquals(30,count);
}
/**
......
......@@ -42,6 +42,14 @@ import org.objectweb.fractal.api.type.TypeFactory;
import org.objectweb.fractal.util.Fractal;
import org.ow2.frascati.tinfi.TinfiDomain;
/**
* This test originates from Julia but is reused here since the implemenation of
* the binding controller for Tinfi scaPrimitive components differs from the one
* of Julia primitive components.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.4.6
*/
public class BindingControllerTestCase
extends org.objectweb.fractal.julia.conform.components.Test {
......@@ -54,10 +62,6 @@ extends org.objectweb.fractal.julia.conform.components.Test {
protected boolean isTemplate;
protected final static String serverI = "server/"+PKG+".I/false,false,false";
protected final static String clientI = "client/"+PKG+".I/true,false,false";
protected final static String clients0I = "clients0/"+PKG+".I/true,false,true";
// -------------------------------------------------------------------------
// Constructor and setup
// -------------------------------------------------------------------------
......@@ -113,43 +117,16 @@ extends org.objectweb.fractal.julia.conform.components.Test {
Assert.assertEquals(null, bc.lookupFc("client"));
}
// @Test
@Test
public void testCollectionBindLookupUnbind () throws Exception {
/*
* TODO
*
* in tinfi-runtime-oo
* add a o.o.f.t.control.component.ComponentExt interface with a removeFc(Object) method
*
* in tinfi-mixins
* add a o.o.f.t.control.component.CollectionInterfaceComponentMixin layer
* implementing this method "in the vein of"
* org.objectweb.fractal.julia.TypeComponentMixin#getFcInterface(java.lang.String)
* but of course for removing collection interface instances
*
* in tinfi-opt-oo
* declare this extra layer in SCAPrimitive and in SCAComposite
*
* propage this change in tinfi-opt-comp-core and the tests in tinfi-tests-comp
*/
BindingController bc = Fractal.getBindingController(c);
bc.bindFc("clients0", d.getFcInterface("server"));
checkList(bc, new String[] { "client", "clients0" });
Assert.assertEquals(d.getFcInterface("server"), bc.lookupFc("clients0"));
bc.unbindFc("clients0");
/*
* From below, this differs from the original Julia test. The purpose is to
* illustrate the fact that although clients0 is unbound and is no longer
* returned with listFc, it is still present in the array returned by
* getFcInterfaces.
*/
Assert.assertEquals(null, bc.lookupFc("clients0"));
checkList(bc, new String[] { "client" });
checkComponent(c, new HashSet<String>(Arrays.asList(new String[] {
COMP, BC, LC, SC, NC, serverI, clientI, clients0I
})));
}
protected void checkList (BindingController bc, String[] expected) {
......
......@@ -221,11 +221,11 @@ public class SCAIntentControllerTestCase {
Fractal.getLifeCycleController(comp).startFc();
/*
* 36. That's the count. counter is incremented before and after
* 30. That's the count. counter is incremented before and after
* invocations on interface methods.
*/
int count = countItf.getCount();
Assert.assertEquals(36,count);
Assert.assertEquals(30,count);
}
/**
......
......@@ -192,7 +192,7 @@ public class SCAIntentControllerTestCase {
* invocations on interface methods.
*/
int count = countItf.getCount();
Assert.assertEquals(36,count);
Assert.assertEquals(30,count);
}
/**
......
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