Commit 211f7d74 authored by Lionel Seinturier's avatar Lionel Seinturier

Handle only scaPrimitive and scaComposite controller descriptors.

Additional check when instantiating a component.
Cosmetic changes.
parent 41425cd3
......@@ -120,7 +120,7 @@ follows:
14 </execution>
15 </executions>
16 <configuration>
17 <opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
17 <opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
18 <srcs><src>src/main/java</src></srcs>
19 <mixins>
20 <mixin>org.ow2.frascati.tinfi:mixins:0.4.4:sources</mixin>
......@@ -179,4 +179,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: January 25, 2009.
Last modified: January 24, 2009.
Tinfi 0.4.4
-----------
* move to org.ow2.frascati for artifacts and Java packages
* support SCA annotations on private fields (feature suggested by Nicolas P.)
* support SCA annotations on private fields (suggested by Nicolas P.)
* support unannotated POJO component implementations
* bug fix for intent handlers on component with client interfaces
(bug reported by Nicolas D.)
(reported by Nicolas D.)
* move to Juliac 2.1.5
......@@ -14,7 +14,7 @@ Tinfi 0.4.3
* for the completion API, let the dynamically set metadata override annotations
* move to Juliac 2.1.4
* new metadata module
* bug fix for callback interfaces (bug reported by Guillaume)
* bug fix for callback interfaces (reported by Guillaume)
Released on November 20, 2008
......@@ -51,8 +51,8 @@ http://mail.ow2.org/wws/arc/rntl-sco-2006/2008-09/msg00092.html
Tinfi 0.3.2
-----------
* move to Juliac 2.0.2
* bug fix in artifact version number for default optimization levels (report
by Damien)
* bug fix in artifact version number for default optimization levels
(reported by Damien)
Released on July 5, 2008
......@@ -60,7 +60,7 @@ Released on July 5, 2008
Tinfi 0.3.1
-----------
* move to Juliac 2.0.1
* bug fix in code generation with inner types (report by Fy)
* bug fix in code generation with inner types (reported by Fy)
* adding a tinfi-all artifact
Released on July 4, 2008
......@@ -79,7 +79,7 @@ http://mail.ow2.org/wws/arc/rntl-sco-2006/2008-06/msg00345.html
Tinfi 0.2.1
-----------
* org.scorware.tinfi.Tinfi is a full-fledged Fractal provider class
* bug fix (bug reported by Damien):
* bug fix (reported by Damien):
when a custom classloader is specified when invoking Tinfi, use this
classloader in the SCAContentController for loading component classes
......
......@@ -51,7 +51,7 @@
<arg value="--srcs" />
<arg value="src/main/java" />
<arg value="--opt" />
<arg value="org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator" />
<arg value="org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO" />
<arg value="--mixins" />
<arg value="${lib}/julia-mixins-2.5.2-sources.jar;${lib}/frascati-tinfi-mixins-0.4.4-sources.jar" />
<arg value="example.hw.HelloWorld" />
......
......@@ -26,9 +26,8 @@ package org.ow2.frascati.tinfi.juliac;
import java.io.IOException;
import java.util.Map;
import org.objectweb.fractal.api.control.AttributeController;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.julia.control.attribute.CloneableAttributeController;
import org.objectweb.fractal.julia.type.BasicInterfaceType;
import org.objectweb.fractal.juliac.ClassGenerator;
import org.objectweb.fractal.juliac.InitializerClassGenerator;
......@@ -37,7 +36,6 @@ import org.objectweb.fractal.juliac.JuliacConfig;
import org.objectweb.fractal.juliac.JuliacLoader;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException;
import org.objectweb.fractal.juliac.proxy.AttributeControllerClassGenerator;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGenerator;
......@@ -91,48 +89,39 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
SCAIntentInterceptorSourceCodeGenerator.class.getName() );
}
// TODO when upgrading to Juliac 2.1.5
/*
* Reason: 2.1.5 provides the ability to specify multiple source code
* generators, e.g. org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO
* We can then rely on OO for generating the code related to components
* other than scaPrimitive and scaComposite. Before 2.1.5, this generator
* was supposed to be also able to generate code for primitive, composite,
* etc.
/**
* Perform consistency checks on the parameter transmitted to
* {@link #generate(Type, Object, Object)}.
*
* @param type the component type
* @param controllerDesc the component controller descriptor
* @param contentDesc the component content descriptor
* @throws IllegalArgumentException in case of inconsistency
*/
// /**
// * Perform consistency checks on the parameter transmitted to
// * {@link #generate(Type, Object, Object)}.
// *
// * @param type the component type
// * @param controllerDesc the component controller descriptor
// * @param contentDesc the component content descriptor
// * @throws IllegalArgumentException in case of inconsistency
// */
// @Override
// protected void check( Type type, Object controllerDesc, Object contentDesc )
// throws IllegalArgumentException {
//
// super.check(type,controllerDesc,contentDesc);
//
// /*
// * Even though we extend the default OO optimization level source code
// * generator {@link
// * org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator} for
// * conveniently inheriting from already written code, the current
// * optimization level source code generator must only treat
// * scaPrimitive and scaComposite components. If we don't perform this
// * check, primitive, composite, etc. components are treated but the
// * generated code is not consistant.
// */
// String ctrlDesc = (String) controllerDesc;
// if( !ctrlDesc.equals("scaPrimitive") && !ctrlDesc.equals("scaComposite") ) {
// String msg =
// "Only scaPrimitive and scaComposite controller descriptors "+
// "are supported by optimization level "+getClass().getName();
// throw new IllegalArgumentException(msg);
// }
// }
@Override
protected void check( Type type, Object controllerDesc, Object contentDesc )
throws IllegalArgumentException {
super.check(type,controllerDesc,contentDesc);
/*
* Even though we extend the default OO optimization level source code
* generator {@link
* org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator} for
* conveniently inheriting from already written code, the current
* optimization level source code generator must only treat
* scaPrimitive and scaComposite components. If we don't perform this
* check, primitive, composite, etc. components are treated but the
* generated code is not consistant.
*/
String ctrlDesc = (String) controllerDesc;
if( !ctrlDesc.equals("scaPrimitive") && !ctrlDesc.equals("scaComposite") ) {
String msg =
"Only scaPrimitive and scaComposite controller descriptors "+
"are supported by optimization level "+getClass().getName();
throw new IllegalArgumentException(msg);
}
}
/**
* Return the source code generators for the initializer classes associated
......@@ -165,42 +154,13 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
protected void generateInterfaceImpl( InterfaceType it, String ctrlDesc )
throws IOException {
String signature = it.getFcItfSignature();
UnifiedClass cl = jc.create(signature);
UnifiedClass ac = jc.create(AttributeController.class.getName());
UnifiedClass cac = jc.create(CloneableAttributeController.class.getName());
// TODO remove when upgrading to Juliac 2.1.5
/*
* Reason: 2.1.5 provides the ability to specify multiple source code
* generators, e.g. org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO
* We can then rely on OO for generating the code related to components
* other than scaPrimitive and scaComposite. Before 2.1.5, this generator
* was supposed to be also able to generate code for primitive, composite,
* etc. Attribute controller implementations are not needed for
* scaPrimitive, nor for scaComposite.
*/
/*
* If the interface is a business attribute controller interface,
* generate an implementation which provides a cloneFcAttributes
* method.
*
* The second expression in the && skips cloneable attribute control
* interfaces which are provided by parametric membranes.
*/
if( ac.isAssignableFrom(cl) && ! cac.isAssignableFrom(cl) ) {
ClassGenerator cg =
new AttributeControllerClassGenerator(it,null,false,jc);
jc.generateSourceCode(cg);
}
InterfaceSourceCodeGeneratorFactory iscgf =
new InterfaceSourceCodeGeneratorFactory(it,ctrlDesc,null,jc);
if( iscgf.isSCACompBusinessInterface() ) {
/*
* Generate SCA specific code interface implementations.
* Generate SCA specific interface implementations.
*/
// Server (input) interfaces
......@@ -212,6 +172,8 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
jc.generateSourceCode(cg);
// CallableReference and input interface implementations for callbacks
String signature = it.getFcItfSignature();
UnifiedClass cl = jc.create(signature);
Callback annot = cl.getAnnotation(Callback.class);
if( annot != null ) {
Class<?> cbcl = annot.value();
......
......@@ -65,7 +65,7 @@
</execution>
</executions>
<configuration>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
<adls><adl>example.hw.HelloWorld</adl></adls>
<modules>
<module>org.ow2.frascati.tinfi:frascati-tinfi-compiler:${project.version}</module>
......
......@@ -59,7 +59,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
<mixins>
<mixin>org.ow2.frascati.tinfi:frascati-tinfi-mixins:${project.version}:sources</mixin>
<mixin>org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixin>
......
......@@ -51,7 +51,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
<mixins>
<mixin>org.ow2.frascati.tinfi:frascati-tinfi-mixins:${project.version}:sources</mixin>
<mixin>org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixin>
......
......@@ -52,7 +52,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
<mixins>
<mixin>org.ow2.frascati.tinfi:frascati-tinfi-mixins:${project.version}:sources</mixin>
<mixin>org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixin>
......
......@@ -29,7 +29,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -48,6 +47,7 @@ import org.osoa.sca.CallableReference;
import org.osoa.sca.ComponentContext;
import org.osoa.sca.RequestContext;
import org.osoa.sca.ServiceReference;
import org.osoa.sca.annotations.Constructor;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.ow2.frascati.tinfi.CallbackManager;
......@@ -95,9 +95,11 @@ public class AbstractScopeManager {
protected Object createAndInitializeFcInstance()
throws InstantiationException {
List<String> initnames = new ArrayList<String>();
try {
Object content = createFcInstance();
initializeFcInstance(content);
Object content = createFcInstance(initnames);
initializeFcInstance(content,initnames);
return content;
}
catch( Exception e ) {
......@@ -113,8 +115,13 @@ public class AbstractScopeManager {
/**
* Create a new content instance.
*
* @param initnames
* this list is empty when the method is called and populated with the
* reference and property names initialized while creating the content
* instance with an @{@link Constructor} annotated constructor
*/
private Object createFcInstance()
private Object createFcInstance( List<String> initnames )
throws
java.lang.InstantiationException, IllegalAccessException,
InstantiationException, InvocationTargetException {
......@@ -138,10 +145,11 @@ public class AbstractScopeManager {
* Potential issue: if the value is really [""]?
*/
String[] annotvalue = annot.value();
List<String> names =
annotvalue.length==1 && annotvalue[0].length()==0 ?
new ArrayList<String>() :
Arrays.asList(annot.value());
if( annotvalue.length>1 || annotvalue[0].length()>0 ) {
for (String av : annotvalue) {
initnames.add(av);
}
}
/*
* Extra property names may be specified by annotating the
......@@ -154,14 +162,14 @@ public class AbstractScopeManager {
if( pannot instanceof Property ) {
Property propannot = (Property) pannot;
String name = propannot.name();
names.add(name);
initnames.add(name);
}
}
}
Object[] values = new Object[names.size()];
for (int i = 0 ; i < names.size() ; i++) {
String name = names.get(i);
Object[] values = new Object[initnames.size()];
for (int i = 0 ; i < initnames.size() ; i++) {
String name = initnames.get(i);
try {
InterfaceType it = ct.getFcInterfaceType(name);
Object sr = getServiceReference(it);
......@@ -185,6 +193,11 @@ public class AbstractScopeManager {
values[i] = scapc.get(name);
}
}
/*
* Construct the content instance by invoking the constructor with
* initialization values.
*/
content = ccmd.constructorAnnotatedElement.newInstance(values);
}
......@@ -195,8 +208,11 @@ public class AbstractScopeManager {
* Initialize newly created content instances.
*
* @param content the content instance
* @param initnames
* the reference and property names which has been already initialized
* on the specified content instance
*/
private void initializeFcInstance( Object content )
private void initializeFcInstance( Object content, List<String> initnames )
throws
InstantiationException, AnnotatedElementNotFoundException,
IllegalAccessException, InvocationTargetException,
......@@ -269,7 +285,12 @@ public class AbstractScopeManager {
* have been injected via an @Constructor annotation. See
* {@link #createFcInstance()}.
*/
// TODO we should be checking that all references have been injected either as a constructor, or as a annonated element or as a POJO
if( ! initnames.contains(name) ) {
String msg =
"Reference or property "+name+
" can not be injected on "+ccmd.fcContentClass;
throw new InstantiationException(msg);
}
}
}
}
......
......@@ -66,7 +66,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.juliac.FCOOCtrlSourceCodeGenerator:OO</opt>
<mixins>
<mixin>org.ow2.frascati.tinfi:frascati-tinfi-mixins:${project.version}:sources</mixin>
<mixin>org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources</mixin>
......
call mvn clean
call mvn test
call mvn clean test
pause
cd ..\examples
call mvn clean
......
......@@ -11,7 +11,7 @@
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-membranes-oo</artifactId>
<packaging>jar</packaging>
<name>Pre-mixed Tinfi Control Membranes - OO Opt Level</name>
<name>Tinfi Pre-mixed Control Membranes - OO Opt Level</name>
<!-- ============================= -->
<!-- Dependency for generated code -->
......
......@@ -10,7 +10,7 @@
<groupId>org.ow2.frascati.tinfi.tinfi-mixed</groupId>
<artifactId>frascati-tinfi-parent</artifactId>
<name>Pre-mixed Tinfi Control Membranes</name>
<name>Tinfi Pre-mixed Control Membranes</name>
<packaging>pom</packaging>
<modules>
......
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