Commit 1e427f39 authored by seinturier's avatar seinturier

Extends the SCAPropertyController API to allow property promotion.

Fixing bug for the completion API.
Setting version number to 0.4.3-SNAPSHOT
parent d361bd4e
......@@ -21,8 +21,8 @@ Contact: Lionel.Seinturier@univ-lille1.fr
Author: Lionel Seinturier
============================================================================
Tinfi 0.5
---------
Tinfi 0.4.3
-----------
Tinfi is a runtime kernel for the SCA component model. Tinfi provides an
infrastructure for running Java applications which comply with version 1.0 of
......@@ -128,7 +128,7 @@ follows:
16 <configuration>
17 <opt>org.scorware.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
18 <srcs>src/main/java</srcs>
19 <mixins>org.scorware.tinfi:mixins:0.5:sources
19 <mixins>org.scorware.tinfi:mixins:0.4.3:sources
org.objectweb.fractal.julia:julia-mixins:2.5.2:sources</mixins>
20 <types>example.hw.HelloWorld</types>
21 </configuration>
......@@ -186,4 +186,4 @@ To run the conformance tests, type:
For any question, please contact: Lionel.Seinturier@univ-lille1.fr
Date of creation of this file: June 24, 2007.
Last modified: October 17, 2008.
Last modified: October 24, 2008.
Tinfi 0.4.3
-----------
* manage property promotions
* for the completion API, let the dynamically set metadata override annotations
* move to Juliac 2.1.3
Tinfi 0.4.2
-----------
* move to Juliac 2.1.2
* remove the Tinfi Fractal provider class and rely on the Juliac one
Released on October 11, 2008
Tinfi 0.4.1
-----------
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......
......@@ -21,8 +21,8 @@ Contact: Lionel.Seinturier@univ-lille1.fr
Author: Lionel Seinturier
============================================================================
Tinfi 0.5
---------
Tinfi 0.4.3
-----------
Tinfi is a runtime kernel for the SCA component model. Tinfi provides an
infrastructure for running Java applications which comply with version 1.0 of
......@@ -101,4 +101,4 @@ for that.
For any question, please contact: Lionel.Seinturier@univ-lille1.fr
Date of creation of this file: June 29, 2008.
Last modified: October 17, 2008.
Last modified: October 24, 2008.
......@@ -53,7 +53,7 @@
<arg value="--opt" />
<arg value="org.scorware.tinfi.juliac.FCOOCtrlSourceCodeGenerator" />
<arg value="--mixins" />
<arg value="${lib}/julia-mixins-2.5.2-sources.jar;${lib}/frascati-tinfi-mixins-0.5-sources.jar" />
<arg value="${lib}/julia-mixins-2.5.2-sources.jar;${lib}/frascati-tinfi-mixins-0.4.3-sources.jar" />
<arg value="example.hw.HelloWorld" />
</java>
</target>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......@@ -25,11 +25,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>juliac-core</artifactId>
<version>${juliac.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-helloworld-bin</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-helloworld-bin</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi.examples</groupId>
<artifactId>frascati-tinfi-basic</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi.examples</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......@@ -19,11 +19,6 @@
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>juliac-core</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
<build>
......
......@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Map;
import org.objectweb.fractal.api.control.ContentController;
import org.objectweb.fractal.api.control.NameController;
/**
* Mixin layer for implementing the {@link ContentController} interface.
......@@ -46,7 +47,9 @@ implements SCAPropertyController {
// Implementation of the SCAPropertyController interface
// -------------------------------------------------------------------------
private Map<String,Object> properties = new HashMap<String, Object>();
private Map<String,Object> properties = new HashMap<String,Object>();
private Map<String,SCAPropertyController> promoters =
new HashMap<String,SCAPropertyController>();
/**
* Set the value for the specified property name. If the property has
......@@ -56,7 +59,13 @@ implements SCAPropertyController {
* @param value the property value
*/
public void set( String name, Object value ) {
properties.put(name, value);
SCAPropertyController promoter = promoters.get(name);
if( promoter == null ) {
properties.put(name, value);
}
else {
promoter.set(name,value);
}
}
/**
......@@ -67,7 +76,13 @@ implements SCAPropertyController {
* @return the property value
*/
public Object get( String name ) {
return properties.get(name);
SCAPropertyController promoter = promoters.get(name);
if( promoter == null ) {
return properties.get(name);
}
else {
return promoter.get(name);
}
}
/**
......@@ -77,7 +92,13 @@ implements SCAPropertyController {
* @return true if the property has been set, false otherwise
*/
public boolean containsKey( String name ) {
return properties.containsKey(name);
SCAPropertyController promoter = promoters.get(name);
if( promoter == null ) {
return properties.containsKey(name);
}
else {
return promoter.containsKey(name);
}
}
/**
......@@ -86,6 +107,67 @@ implements SCAPropertyController {
* @return a map of all the properties which have been set so far
*/
public Map<String,Object> getAll() {
return properties;
Map<String,Object> result = new HashMap<String,Object>();
for (Map.Entry<String,Object> entry : properties.entrySet()) {
String name = entry.getKey();
Object value = null;
SCAPropertyController promoter = promoters.get(name);
if( promoter == null ) {
value = entry.getValue();
}
else {
value = promoter.get(name);
}
result.put(name,value);
}
return result;
}
/**
* Set the reference of the property controller which promotes the specified
* property to the current property controller.
*
* @param name the promoter 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
* @since 0.4.3
*/
public void setPromoter( String name, SCAPropertyController promoter )
throws IllegalPromoterException {
promoters.put(name,promoter);
if( promoter != null ) {
SCAPropertyController peer = promoter.getPromoter(name);
if( peer == this ) {
String compname = _this_weaveableOptNC.getFcName();
throw new IllegalPromoterException(compname);
}
}
}
/**
* Return the reference of the property controller which promotes the
* specified property. Return <code>null</code> if the property is managed
* locally by the current property controller.
*
* @param name the promoter property name
* @return the promoter component or <code>null</code>
* @since 0.4.3
*/
public SCAPropertyController getPromoter( String name ) {
return promoters.get(name);
}
// -------------------------------------------------------------------------
// Fields and methods required by the mixin class in the base class
// -------------------------------------------------------------------------
/**
* The {@link NameController} interface of the component to which this
* controller object belongs.
*/
public NameController _this_weaveableOptNC;
}
......@@ -131,6 +131,7 @@
((org.objectweb.fractal.julia.asm.MixinClassGenerator
SCAPropertyControllerImpl
org.objectweb.fractal.julia.BasicControllerMixin
org.objectweb.fractal.julia.control.name.UseNameControllerMixin
org.scorware.tinfi.control.property.SCAPropertyControllerMixin
))
)
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-opt-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......
......@@ -6,7 +6,7 @@
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<packaging>pom</packaging>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
<name>Tinfi Parent</name>
<url>http://www.scorware.org</url>
......@@ -14,7 +14,7 @@
<properties>
<julia.version>2.5.2</julia.version>
<juliac.version>2.2-SNAPSHOT</juliac.version>
<juliac.version>2.1.3</juliac.version>
</properties>
<modules>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime-parent</artifactId>
<version>0.5-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime-oo-dyn</artifactId>
<packaging>jar</packaging>
<name>Tinfi Runtime OO dynamic</name>
<dependencies>
<dependency>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>juliac-core</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime-parent</artifactId>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime-oo-dyn</artifactId>
<packaging>jar</packaging>
<name>Tinfi Runtime OO dynamic</name>
<dependencies>
<dependency>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>juliac-compiler</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
</project>
......@@ -43,10 +43,13 @@ import org.objectweb.fractal.julia.loader.Initializable;
import org.objectweb.fractal.julia.loader.Tree;
import org.objectweb.fractal.julia.type.BasicComponentType;
import org.objectweb.fractal.julia.type.BasicInterfaceType;
import org.objectweb.fractal.juliac.ClassGenerator;
import org.objectweb.fractal.juliac.JuliacLoader;
import org.objectweb.fractal.juliac.Utils;
import org.objectweb.fractal.juliac.desc.ControllerDesc;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException;
import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator;
import org.objectweb.fractal.juliac.runtime.JuliacBootstrapComponentImpl;
import org.objectweb.fractal.juliac.visit.MethodSourceCodeVisitor;
......@@ -57,7 +60,7 @@ import org.objectweb.fractal.juliac.visit.MethodSourceCodeVisitor;
* classloader interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 0.5
* @since 0.4.3
*/
public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
......@@ -187,7 +190,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
}
MembraneDesc membraneDesc =
new MembraneDesc(null,ctrlDesc,membraneits,ctrlDescs);
membraneDesc.setInterceptorClassGenerator(icg);
membraneDesc.setInterceptorClassGenerator(icg); // TODO fix me
// Check the content
contentChecks(ct,content);
......@@ -243,7 +246,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
intercept = compctrl;
// Component controller
Class<?> compFcItfCl = loadFcItfClass(Component.class.getName());
Class<?> compFcItfCl = loadFcItfClass(compctrlit);
Interface proxy =
instanciateFcItfClass(
compFcItfCl,compctrl,"component",compctrlit,false,intercept);
......@@ -289,8 +292,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
// Interceptors (no interceptor for controllers)
intercept = ctrl;
String ctrlFcItfSig = membraneits[i].getFcItfSignature();
Class<?> ctrlFcItfCl = loadFcItfClass(ctrlFcItfSig);
Class<?> ctrlFcItfCl = loadFcItfClass(membraneits[i]);
proxy =
instanciateFcItfClass(
ctrlFcItfCl, proxyForCompCtrl, itname, membraneits[i],
......@@ -302,8 +304,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
if( itname.equals("factory") ) {
InterfaceType intit =
Utils.newSymetricInterfaceType(membraneits[i]);
String ctrlFcItfSig = intit.getFcItfSignature();
Class<?> ctrlFcItfCl = loadFcItfClass(ctrlFcItfSig);
Class<?> ctrlFcItfCl = loadFcItfClass(intit);
proxy =
instanciateFcItfClass(
ctrlFcItfCl, proxyForCompCtrl, itname, intit, true,
......@@ -341,8 +342,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
}
// External interface
String fcItfSig = its[i].getFcItfSignature();
Class<?> fcItfCl = loadFcItfClass(fcItfSig);
Class<?> fcItfCl = loadFcItfClass(its[i]);
proxy =
instanciateFcItfClass(
fcItfCl, proxyForCompCtrl, itname, its[i], false,
......@@ -351,8 +351,7 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
// Internal interface
if( ! itname.equals("attribute-controller") ) {
InterfaceType intit = Utils.newSymetricInterfaceType(its[i]);
fcItfSig = intit.getFcItfSignature();
fcItfCl = loadFcItfClass(fcItfSig);
fcItfCl = loadFcItfClass(intit);
proxy =
instanciateFcItfClass(
fcItfCl, proxyForCompCtrl, itname, intit, true,
......@@ -451,21 +450,15 @@ public class TinfiBootstrapComponentImpl extends JuliacBootstrapComponentImpl {
/**
* Load the class implementing the Fractal interface corresponding to the
* given Java interface fully-qualified name. If the class can not be loaded
* directly from the classpath, this method uses ASM to generate its
* bytecode and to dynamically load it.
* given interface type. If the class can not be loaded from the classpath,
* this method uses ASM to generate its bytecode and to dynamically load it.
*/
protected Class<?> loadFcItfClass( String name )
protected Class<?> loadFcItfClass( InterfaceType it )
throws InstantiationException {
/*
* Assume the suffix for interface implementation class names will
* always be FcItf. Otherwise, one would have to depend on the interface
* source code generator class to retrieve this information. Given that
* this generator is defined in tinfi-compiler, this saves some
* dependencies.
*/
name += "FcItf";
ClassGenerator iicg =
new InterfaceImplementationClassGenerator(it,null,false,null);
String name = iicg.getTargetClassName();
try {
Class<?> cl = loadClass(name);
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.scorware.tinfi</groupId>
<artifactId>frascati-tinfi-runtime-parent</artifactId>
<version>0.5-SNAPSHOT</version>
<version>0.4.3-SNAPSHOT</version>
</parent>
<groupId>org.scorware.tinfi</groupId>
......
......@@ -42,8 +42,8 @@ import java.util.Map;
* </p>
*
* <ul>
* <li>either Java 5 annotations which can be introspected at runtime,</li>
* <li>or raw data which can be set and get by the API provided by this class.</li>
* <li>either raw data which can be set and get by the API provided by this class,</li>
* <li>or Java 5 annotations which can be introspected at runtime.</li>
* </ul>
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
......@@ -95,14 +95,7 @@ public class ClassMetaData {
*/
public <A extends Annotation> A getAnnotation( Class<A> annotcl ) {
// First, search in Java 5 annotations
A annot = cl.getAnnotation(annotcl);
if( annot != null ) {
// TODO what about cases where the annotation is both declared in the class and metadata
return annot;
}
// Second, search in dynamically set metadata
// First, search in dynamically set metadata
List<Object> mds = getMetaData();
for (Object md : mds) {
if( annotcl.isAssignableFrom(md.getClass()) ) {
......@@ -112,6 +105,12 @@ public class ClassMetaData {
}
}
// Second, search in Java 5 annotations
A annot = cl.getAnnotation(annotcl);
if( annot != null ) {
return annot;
}
// No match
return null;
}
......@@ -122,11 +121,35 @@ public class ClassMetaData {
* @since 0.4
*/
public Object[] getAnnotations() {
Annotation[] annots = cl.getAnnotations();
List<Object> mds = getMetaData();
Object[] all = new Object[ annots.length + mds.size() ];
System.arraycopy(annots,0,all,0,annots.length);
System.arraycopy(mds.toArray(),0,all,annots.length,mds.size());
mds = new ArrayList<Object>(mds); // Work on a copy
Annotation[] annots = cl.getAnnotations();
for (Annotation annot : annots) {
Class<?> annotcl = annot.getClass();
/*
* Iterate on dynamically set metadata to check whether a
* corresponding annotation exists.
*/
boolean exists = false;
for (Object md : mds) {
Class<?> cl = md.getClass();
if( cl.equals(annotcl) ) {
exists = true;
}
}
if(!exists) {
/*
* Only consider the annotation if it has not been set in the
* metadata. The priority given to metadata is higher than that
* of annotations.
*/
mds.add(annot);
}
}
Object[] all = mds.toArray();
return all;
}
......@@ -464,7 +487,8 @@ public class ClassMetaData {
* Check that the specified class member is declared by the class for which
* metadata is managed by this instance.
*/
private void checkOwnership( Member member ) throws IllegalArgumentException {
private void checkOwnership( Member member )
throws IllegalArgumentException {
Class<?> declaringClass = member.getDeclaringClass();
......
......@@ -79,7 +79,7 @@ public class ContentClassMetaData extends ClassMetaData {
}
catch( NoSuchInterfaceException nsie ) {
/*
* Shouldn't occur since Tinfi provides a classloader interface.
* Shouldn't occur since Juliac provides a classloader interface.
*/
throw new RuntimeException(nsie);
}
......
/***
* Tinfi
* Copyright (C) 2008 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