Commit 841e99bc authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Switch to Juliac 2.2.5-SNAPSHOT.

parent ae5530fe
......@@ -131,31 +131,34 @@ follows:
14 </execution>
15 </executions>
16 <configuration>
17 <opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator:OO</opt>
18 <srcs><src>src/main/java</src></srcs>
19 <mixins>
20 <mixin>org.ow2.frascati.tinfi:mixins:1.3.1:sources</mixin>
21 <mixin>org.objectweb.fractal.julia:julia-mixins:2.5.2:sources</mixin>
22 </mixins>
23 <adls><adl>HelloWorld</adl></adls>
24 <modules>
25 <module>org.ow2.frascati.tinfi:frascati-tinfi-oo:${project.version}</module>
26 <module>org.ow2.frascati.tinfi:frascati-tinfi-emf:${project.version}</module>
27 <module>org.objectweb.fractal.juliac:juliac-jdt:${juliac.version}</module>
28 <module>org.objectweb.fractal.juliac:juliac-spoon:${juliac.version}</module>
29 </modules>
30 </configuration>
31 </plugin>
32 </plugins>
33 </build>
Lines 17 to 23 in the <configuration> section particularily matter. The
17 <srcs><src>src/main/java</src></srcs>
18 <adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
19 <opts>
20 <opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
21 <opt>OO</opt>
22 </opts>
23 <mixins>
24 <mixin>org.ow2.frascati.tinfi:mixins:1.3.1:sources</mixin>
25 <mixin>org.objectweb.fractal.julia:julia-mixins:2.5.2:sources</mixin>
26 </mixins>
27 <adls><adl>HelloWorld</adl></adls>
28 <modules>
29 <module>org.ow2.frascati.tinfi:frascati-tinfi-oo:${project.version}</module>
30 <module>org.ow2.frascati.tinfi:frascati-tinfi-emf:${project.version}</module>
31 <module>org.objectweb.fractal.juliac:juliac-jdt:${juliac.version}</module>
32 <module>org.objectweb.fractal.juliac:juliac-spoon:${juliac.version}</module>
33 </modules>
34 </configuration>
35 </plugin>
36 </plugins>
37 </build>
Lines 17 to 27 in the <configuration> section particularily matter. The
following tags are supported:
- <opt>: defines the optimization level. The FCOOCtrlSourceCodeGenerator class
defines an optimization level where control membranes are implemented as
objects.
- <srcs>: defines the list of directories containing the source code of the
application.
- <adlParser>: defines the ADL parser to be used.
- <opts>: defines the membrane source code generators.
- <mixins>: defines the list of source code artifacts which contain the
implementations of controllers.
- <adls>: defines the list of SCA composite files to be compiled.
......
......@@ -56,8 +56,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
</opts>
......
......@@ -60,8 +60,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlNoIntentSourceCodeGenerator</opt>
<opt>OO</opt>
</opts>
......
......@@ -49,8 +49,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
</opts>
......
......@@ -83,8 +83,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.objectweb.fractal.juliac.osgi.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
......
......@@ -83,8 +83,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.objectweb.fractal.juliac.osgi.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
......
......@@ -50,7 +50,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<opts><opt>org.ow2.frascati.tinfi.opt.ultramerge.FCUltraMergeSourceCodeGenerator</opt></opts>
<adlParser>org.ow2.frascati.tinfi.opt.ultramerge.FCUltraMergeSourceCodeGenerator</adlParser>
<adls><adl>HelloWorld</adl></adls>
<modules>
<module>org.ow2.frascati.tinfi:frascati-tinfi-ultra-merge:${project.version}</module>
......
......@@ -53,8 +53,8 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</opt>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>OO</opt>
</opts>
......
......@@ -33,7 +33,7 @@ import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.JuliacException;
import org.objectweb.fractal.juliac.JuliacLoader;
import org.objectweb.fractal.juliac.desc.ControllerDesc;
import org.objectweb.fractal.juliac.proxy.ProxyClassGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf;
import org.ow2.frascati.tinfi.TinfiDomain;
/**
......@@ -141,7 +141,7 @@ extends org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator {
* generator.
*/
@Override
protected ProxyClassGenerator getInterceptorClassGenerator(
protected ProxyClassGeneratorItf getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
// No sense but temporary hack to prevent compilation failure
......
......@@ -25,9 +25,9 @@ package org.ow2.frascati.tinfi.opt.oo;
import java.util.Map;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf;
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.tinfi.TinfiRuntimeException;
......@@ -53,16 +53,16 @@ extends FCOOCtrlSourceCodeGenerator {
* @since 1.3
*/
@Override
protected ProxyClassGenerator getInterceptorClassGenerator(
protected ProxyClassGeneratorItf getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
InterceptorSourceCodeGenerator[] iscgs =
InterceptorSourceCodeGeneratorItf[] iscgs =
getInterceptorSourceCodeGenerators(ctrldesc);
if( iscgs == null ) {
return null;
}
ProxyClassGenerator icg =
ProxyClassGeneratorItf icg =
new InterceptorNoIntentClassGenerator(iscgs,jc);
return icg;
}
......@@ -75,33 +75,33 @@ extends FCOOCtrlSourceCodeGenerator {
* @since 1.3
*/
@Override
protected InterceptorSourceCodeGenerator[]
protected InterceptorSourceCodeGeneratorItf[]
getInterceptorSourceCodeGenerators( String ctrldesc ) {
InterceptorSourceCodeGenerator[] iscgs = null;
InterceptorSourceCodeGeneratorItf[] iscgs = null;
boolean mergeable = false;
InterceptorSourceCodeGenerator iscg =
InterceptorSourceCodeGeneratorItf iscg =
new SCANoIntentInterceptorSourceCodeGenerator();
iscg.setMergeable(mergeable);
iscg.setJuliac(jc);
if( ctrldesc.equals(TinfiDomain.SCA_PRIMITIVE) ) {
InterceptorSourceCodeGenerator lcscg =
InterceptorSourceCodeGeneratorItf lcscg =
new LifeCycleSourceCodeGenerator();
lcscg.setMergeable(mergeable);
lcscg.setJuliac(jc);
InterceptorSourceCodeGenerator cscg =
InterceptorSourceCodeGeneratorItf cscg =
new SCAContentInterceptorSourceCodeGenerator();
cscg.setMergeable(mergeable);
cscg.setJuliac(jc);
iscgs = new InterceptorSourceCodeGenerator[]{lcscg,cscg,iscg};
iscgs = new InterceptorSourceCodeGeneratorItf[]{lcscg,cscg,iscg};
}
else if( ctrldesc.equals(TinfiDomain.SCA_COMPOSITE) ) {
iscgs = new InterceptorSourceCodeGenerator[]{iscg};
iscgs = new InterceptorSourceCodeGeneratorItf[]{iscg};
}
else {
String msg = "Unsupported controller descriptor: "+ctrldesc;
......
......@@ -32,10 +32,10 @@ import org.objectweb.fractal.juliac.ClassGeneratorItf;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.JuliacLoader;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf;
import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator;
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf;
import org.objectweb.fractal.juliac.ucf.UnifiedClass;
import org.osoa.sca.annotations.Callback;
import org.ow2.frascati.tinfi.TinfiDomain;
......@@ -111,10 +111,10 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
* Return the source code generator for component interfaces.
*/
@Override
public ProxyClassGenerator getInterfaceClassGenerator(
public ProxyClassGeneratorItf getInterfaceClassGenerator(
InterfaceType it, MembraneDesc<?> membraneDesc ) {
ProxyClassGenerator pcg = null;
ProxyClassGeneratorItf pcg = null;
String itname = it.getFcItfName();
/*
......@@ -222,16 +222,16 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
* @since 1.3
*/
@Override
protected ProxyClassGenerator getInterceptorClassGenerator(
protected ProxyClassGeneratorItf getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
InterceptorSourceCodeGenerator[] iscgs =
InterceptorSourceCodeGeneratorItf[] iscgs =
getInterceptorSourceCodeGenerators(ctrldesc);
if( iscgs == null ) {
return null;
}
ProxyClassGenerator icg = new InterceptorClassGenerator(iscgs,jc);
ProxyClassGeneratorItf icg = new InterceptorClassGenerator(iscgs,jc);
return icg;
}
......@@ -242,33 +242,33 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
*
* @since 1.3
*/
protected InterceptorSourceCodeGenerator[]
protected InterceptorSourceCodeGeneratorItf[]
getInterceptorSourceCodeGenerators( String ctrldesc ) {
InterceptorSourceCodeGenerator[] iscgs = null;
InterceptorSourceCodeGeneratorItf[] iscgs = null;
boolean mergeable = false;
InterceptorSourceCodeGenerator iscg =
InterceptorSourceCodeGeneratorItf iscg =
new SCAIntentInterceptorSourceCodeGenerator();
iscg.setMergeable(mergeable);
iscg.setJuliac(jc);
if( ctrldesc.equals(TinfiDomain.SCA_PRIMITIVE) ) {
InterceptorSourceCodeGenerator lcscg =
InterceptorSourceCodeGeneratorItf lcscg =
new LifeCycleSourceCodeGenerator();
lcscg.setMergeable(mergeable);
lcscg.setJuliac(jc);
InterceptorSourceCodeGenerator cscg =
InterceptorSourceCodeGeneratorItf cscg =
new SCAContentInterceptorSourceCodeGenerator();
cscg.setMergeable(mergeable);
cscg.setJuliac(jc);
iscgs = new InterceptorSourceCodeGenerator[]{lcscg,cscg,iscg};
iscgs = new InterceptorSourceCodeGeneratorItf[]{lcscg,cscg,iscg};
}
else if( ctrldesc.equals(TinfiDomain.SCA_COMPOSITE) ) {
iscgs = new InterceptorSourceCodeGenerator[]{iscg};
iscgs = new InterceptorSourceCodeGeneratorItf[]{iscg};
}
else {
String msg = "Unsupported controller descriptor: "+ctrldesc;
......
......@@ -24,7 +24,7 @@
package org.ow2.frascati.tinfi.opt.oo;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf;
import org.objectweb.fractal.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor;
......@@ -43,7 +43,7 @@ public class InterceptorClassGenerator
extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
public InterceptorClassGenerator(
InterceptorSourceCodeGenerator[] iscgs, Juliac jc ) {
InterceptorSourceCodeGeneratorItf[] iscgs, Juliac jc ) {
super(iscgs,jc);
}
......
......@@ -25,7 +25,7 @@ package org.ow2.frascati.tinfi.opt.oo;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.Utils;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf;
import org.objectweb.fractal.juliac.ucf.UnifiedClass;
import org.objectweb.fractal.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor;
......@@ -43,7 +43,7 @@ public class InterceptorNoIntentClassGenerator
extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
public InterceptorNoIntentClassGenerator(
InterceptorSourceCodeGenerator[] iscgs, Juliac jc ) {
InterceptorSourceCodeGeneratorItf[] iscgs, Juliac jc ) {
super(iscgs,jc);
}
......
......@@ -23,46 +23,12 @@
package org.ow2.frascati.tinfi.opt.ultramerge;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.objectweb.fractal.juliac.JuliacRuntimeException;
import org.objectweb.fractal.juliac.conf.JuliacConfig;
import org.objectweb.fractal.juliac.desc.AttributeDesc;
import org.objectweb.fractal.juliac.desc.ComponentDesc;
import org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeAbstractSourceCodeGenerator;
import org.objectweb.fractal.juliac.opt.ultramerge.IllegalComponentCodeException;
import org.objectweb.fractal.juliac.opt.ultramerge.UMClass;
import org.objectweb.fractal.juliac.opt.ultramerge.UMField;
import org.objectweb.fractal.juliac.opt.ultramerge.UMMethod;
import org.objectweb.fractal.juliac.spoon.SpoonHelper;
import org.objectweb.fractal.juliac.ucf.UnifiedClass;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Scope;
import org.ow2.frascati.tinfi.TinfiRuntimeException;
import org.objectweb.fractal.juliac.opt.ultramerge.AbstractUltraMerge;
import org.ow2.frascati.tinfi.emf.EMFParserSupportImpl;
import spoon.reflect.code.CtAssignment;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtFieldAccess;
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.AnnotationFactory;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.reference.CtTypeReference;
/**
* Optimization level source code generator which merges all component business
* code in a single class. This source code generator handles component business
......@@ -71,461 +37,23 @@ import spoon.reflect.reference.CtTypeReference;
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.1
*/
public class FCUltraMergeSourceCodeGenerator
extends FCUltraMergeAbstractSourceCodeGenerator {
public class FCUltraMergeSourceCodeGenerator extends EMFParserSupportImpl {
// ----------------------------------------------------------------------
// Implementation of the FCSourceCodeGeneratorItf interface
// ----------------------------------------------------------------------
/**
* Return <code>true</code> if the current source code generator handles the
* specified ADL descriptor.
*
* @param adl the ADL descriptor to be checked
* @return if the ADL descriptor should be accepted
*/
public boolean acceptADLDesc( String adl ) {
String adlFileName = adl.replace('.',File.separatorChar)+".composite";
JuliacConfig jconf = jc.getJuliacConfig();
ClassLoader loader = jconf.getClassLoader();
InputStream is = loader.getResourceAsStream(adlFileName);
boolean exist = (is != null);
return exist;
}
// -----------------------------------------------------------------------
// Implementation of the FractalADLSupportItf interface
// -----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Abstract methods
// ----------------------------------------------------------------------
/**
* Parse the specified ADL descriptor and return a model of it.
* Generate the source code of a factory class for the specified ADL.
*
* @param adl the fully-qualified name of the ADL descriptor
* @return the model of the specified ADL
*/
protected ComponentDesc parse( String adl ) throws IOException {
EMFParserSupportImpl emf = new EMFParserSupportImpl();
emf.init(jc);
ComponentDesc cdesc = emf.toComponentDesc(adl);
return cdesc;
}
protected String getRequiredAnnotatedUMFieldName( UMField<?> umfield ) {
CtField<?> ctfield = umfield.getCtField();
Reference r = ctfield.getAnnotation(Reference.class);
if( r == null ) {
/*
* Not a @Reference annotated field.
* Assume there is a @Reference annotated setter method.
* Retrieve the corresponding reference name.
*/
String refName = refNames.get(umfield);
if( refName == null ) {
// Defensive programming. Shouldn't occur.
String msg =
"Unexpected case. No reference name for field: "+
SpoonHelper.toEclipseClickableString(ctfield);
throw new TinfiRuntimeException(msg);
}
return refName;
}
String name = r.name();
if( name.length() == 0 ) {
/*
* No name parameter for the @Requires annotation.
* Return the field name.
*/
name = umfield.getSimpleName();
}
return name;
}
protected boolean isRequiredAnnotatedUMField( UMField<?> umfield ) {
CtField<?> ctfield = umfield.getCtField();
Reference r = ctfield.getAnnotation(Reference.class);
if( r != null ) {
// @Reference annotated field
return true;
}
// @Reference annotated setter method
boolean b = refNames.containsKey(umfield);
return b;
}
protected boolean
isRequiredAnnotatedUMFieldCardinalitySingleton( UMField<?> umfield ) {
CtField<?> ctfield = umfield.getCtField();
CtTypeReference<?> tref = ctfield.getType();
String qname = tref.getQualifiedName();
UnifiedClass umclass = jc.create(qname);
UnifiedClass umlist = jc.create(List.class.getName());
/*
* Fields of type List hold references for collection references.
*/
boolean b = !( umlist.isAssignableFrom(umclass) );
return b;
}
protected boolean
isRequiredAnnotatedUMFieldCardinalityCollection( UMField<?> umfield ) {
CtField<?> ctfield = umfield.getCtField();
CtTypeReference<?> tref = ctfield.getType();
String qname = tref.getQualifiedName();
UnifiedClass umclass = jc.create(qname);
UnifiedClass umlist = jc.create(List.class.getName());
/*
* Fields of type List hold references for collection references.
*/
boolean b = umlist.isAssignableFrom(umclass);
return b;
}
protected void annotateRequiredCtField(
AnnotationFactory af, CtField<?> field, String cltItfName ) {
af.annotate(field,Reference.class,"name",cltItfName);
}
protected boolean isRequiredAnnotation( Annotation a ) {
boolean b = a instanceof Reference;
return b;
}
/**
* Return the setter method for the specified attribute name.
* @param adl the fully-qualified name of the ADL descriptor
* @param targetname the fully-qualified name of the factory class
*/
protected UMMethod<?> getAttributeSetterUMMethod(
UMClass<?> umclass, AttributeDesc adesc ) {
String aname = adesc.getName();
List<UMMethod<?>> ummethods = umclass.getUMMethods();
for (UMMethod<?> ummethod : ummethods) {
CtMethod<?> ctmethod = ummethod.getCtMethod();
Property p = ctmethod.getAnnotation(Property.class);
if( p != null ) {
String name = p.name();
if( aname.equals(name) ) {
return ummethod;
}
}
}
return null;
}
protected boolean isAttributeAnnotatedCtField( CtField<?> ctfield ) {
Property p = ctfield.getAnnotation(Property.class);
boolean b = p != null;
return b;
}
protected String getAttributeAnnotatedCtFieldName( CtField<?> ctfield ) {
Property p = ctfield.getAnnotation(Property.class);
String name = p.name();
return name;
}
protected CtTypeReference<?> getCollectionFieldType( UMField<?> umfield ) {