Commit fb5a9b38 authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Move the configuration of scaPrimitive and scaComposite interception policies...

Move the configuration of scaPrimitive and scaComposite interception policies from tinfi-bundled.cfg to the Tinfi optimization level source code generators (intent and no intent.)
The configuration was previously scattered around these two places and was not so easy to figure out. Since some configuration steps need to be programmed and can not be simply declared, all configuration steps are now handled by Tinfi optimization level source code generators.
parent 17ba773f
......@@ -25,6 +25,7 @@ package org.ow2.frascati.tinfi.osgi;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.juliac.InitializerClassGenerator;
......@@ -32,6 +33,8 @@ 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.ow2.frascati.tinfi.TinfiDomain;
/**
* Source code generator for <code>scaOsgiPrimitive</code> components.
......@@ -123,10 +126,6 @@ extends org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator {
}
// ------------------------------------------------------------------
// Implementation specific
// ------------------------------------------------------------------
/**
* Return the source code generator for the initializer class associated
* with this component source code generator.
......@@ -135,4 +134,18 @@ extends org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator {
public InitializerOOCtrlClassGenerator getInitializerClassGenerator() {
return new InitializerOOCtrlClassGenerator();
}
/**
* Return the interceptor class generator associated with the specified
* controller descriptor. Return <code>null</code> if there is no such
* generator.
*/
@Override
protected ProxyClassGenerator getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
// No sense but temporary hack to prevent compilation failure
ctrldesc = TinfiDomain.SCA_PRIMITIVE;
return super.getInterceptorClassGenerator(ctrldesc,context);
}
}
......@@ -179,11 +179,12 @@
'sca-primitive-property-controller-impl
)
(
(org.objectweb.fractal.julia.asm.InterceptorClassGenerator
org.objectweb.fractal.julia.asm.LifeCycleCodeGenerator
org.ow2.frascati.tinfi.asm.SCAContentInterceptorCodeGenerator
org.ow2.frascati.tinfi.asm.SCAIntentInterceptorCodeGenerator
)
# see org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator
#
# org.ow2.frascati.tinfi.opt.oo.InterceptorClassGenerator
# org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator
# org.ow2.frascati.tinfi.opt.oo.SCAContentInterceptorSourceCodeGenerator
# org.ow2.frascati.tinfi.opt.oo.SCAIntentInterceptorSourceCodeGenerator
)
org.objectweb.fractal.julia.asm.MergeClassGenerator
'optimizationLevel
......@@ -216,9 +217,10 @@
'sca-composite-property-controller-impl
)
(
(org.objectweb.fractal.julia.asm.InterceptorClassGenerator
org.ow2.frascati.tinfi.asm.SCAIntentInterceptorCodeGenerator
)
# see org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator
#
# org.ow2.frascati.tinfi.opt.oo.InterceptorClassGenerator
# org.ow2.frascati.tinfi.opt.oo.SCAIntentInterceptorSourceCodeGenerator
)
org.objectweb.fractal.julia.asm.MergeClassGenerator
'optimizationLevel
......
......@@ -23,9 +23,13 @@
package org.ow2.frascati.tinfi.opt.oo;
import org.objectweb.fractal.juliac.ITBasedClassGenerator;
import org.objectweb.fractal.juliac.conf.JuliacConfig;
import java.util.Map;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.LifeCycleSourceCodeGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGenerator;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.tinfi.TinfiRuntimeException;
/**
* Source code generator for scaPrimitive and scaComposite membranes with no
......@@ -37,21 +41,73 @@ import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
public class FCOOCtrlNoIntentSourceCodeGenerator
extends FCOOCtrlSourceCodeGenerator {
public FCOOCtrlNoIntentSourceCodeGenerator() {
super();
}
/**
* Return the interceptor class generator associated with the specified
* controller descriptor. Return <code>null</code> if there is no such
* generator.
*
* @since 1.3
*/
@Override
protected void registerIntentInterceptorSourceCodeGenerator(
JuliacConfig jconf ) {
jconf.putInterceptorSourceCodeGenerator(
"org.ow2.frascati.tinfi.asm.SCAIntentInterceptorCodeGenerator",
new SCANoIntentInterceptorSourceCodeGenerator() );
}
protected ProxyClassGenerator getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
InterceptorSourceCodeGenerator[] iscgs =
getInterceptorSourceCodeGenerators(ctrldesc);
if( iscgs == null ) {
return null;
}
ProxyClassGenerator icg =
new InterceptorNoIntentClassGenerator(iscgs,jc);
return icg;
}
/**
* Return the class generator for interceptors.
* Return the interceptor source code generators associated with the
* specified controller descriptor. Return <code>null</code> if there is no
* such generator.
*
* @since 1.3
*/
@Override
protected ITBasedClassGenerator getInterceptorClassGenerator(
InterceptorSourceCodeGenerator[] iscgs ) {
return new InterceptorNoIntentClassGenerator(iscgs,jc);
}
@Override
protected InterceptorSourceCodeGenerator[]
getInterceptorSourceCodeGenerators( String ctrldesc ) {
InterceptorSourceCodeGenerator[] iscgs = null;
boolean mergeable = false;
InterceptorSourceCodeGenerator iscg =
new SCANoIntentInterceptorSourceCodeGenerator();
iscg.setMergeable(mergeable);
iscg.setJuliac(jc);
if( ctrldesc.equals(TinfiDomain.SCA_PRIMITIVE) ) {
InterceptorSourceCodeGenerator lcscg =
new LifeCycleSourceCodeGenerator();
lcscg.setMergeable(mergeable);
lcscg.setJuliac(jc);
InterceptorSourceCodeGenerator cscg =
new SCAContentInterceptorSourceCodeGenerator();
cscg.setMergeable(mergeable);
cscg.setJuliac(jc);
iscgs = new InterceptorSourceCodeGenerator[]{lcscg,cscg,iscg};
}
else if( ctrldesc.equals(TinfiDomain.SCA_COMPOSITE) ) {
iscgs = new InterceptorSourceCodeGenerator[]{iscg};
}
else {
String msg = "Unsupported controller descriptor: "+ctrldesc;
throw new TinfiRuntimeException(msg);
}
return iscgs;
}
}
......@@ -24,21 +24,22 @@
package org.ow2.frascati.tinfi.opt.oo;
import java.io.IOException;
import java.util.Map;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.julia.type.BasicInterfaceType;
import org.objectweb.fractal.juliac.ClassGeneratorItf;
import org.objectweb.fractal.juliac.ITBasedClassGenerator;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.JuliacLoader;
import org.objectweb.fractal.juliac.conf.JuliacConfig;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGenerator;
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.ucf.UnifiedClass;
import org.osoa.sca.annotations.Callback;
import org.ow2.frascati.tinfi.TinfiDomain;
import org.ow2.frascati.tinfi.TinfiRuntimeException;
/**
* This class generates the source code associated to Fractal components.
......@@ -79,33 +80,8 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
loader.loadConfigFile(DEFAULT_CONFIGURATION);
super.init(jc);
/*
* Register component interceptor code generators.
*/
JuliacConfig jconf = jc.getJuliacConfig();
jconf.putInterceptorSourceCodeGenerator(
"org.ow2.frascati.tinfi.asm.SCAContentInterceptorCodeGenerator",
new SCAContentInterceptorSourceCodeGenerator() );
registerIntentInterceptorSourceCodeGenerator(jconf);
}
/**
* Register the intent interceptor source code generators associated with
* this optimization level source code generator. This method is kept
* separated from {@link #init(Juliac)} in order to allow overriding in
* {@link FCOOCtrlNoIntentSourceCodeGenerator}.
*
* @since 1.1.1
*/
protected void registerIntentInterceptorSourceCodeGenerator(
JuliacConfig jconf ) {
jconf.putInterceptorSourceCodeGenerator(
"org.ow2.frascati.tinfi.asm.SCAIntentInterceptorCodeGenerator",
new SCAIntentInterceptorSourceCodeGenerator() );
}
/**
* Return <code>true</code> if the current source code generator handles the
* specified controller descriptor.
......@@ -239,11 +215,66 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator {
}
/**
* Return the class generator for interceptors.
* Return the interceptor class generator associated with the specified
* controller descriptor. Return <code>null</code> if there is no such
* generator.
*
* @since 1.3
*/
@Override
protected ITBasedClassGenerator getInterceptorClassGenerator(
InterceptorSourceCodeGenerator[] iscgs ) {
return new InterceptorClassGenerator(iscgs,jc);
}
protected ProxyClassGenerator getInterceptorClassGenerator(
String ctrldesc, Map<?,?> context ) {
InterceptorSourceCodeGenerator[] iscgs =
getInterceptorSourceCodeGenerators(ctrldesc);
if( iscgs == null ) {
return null;
}
ProxyClassGenerator icg = new InterceptorClassGenerator(iscgs,jc);
return icg;
}
/**
* Return the interceptor source code generators associated with the
* specified controller descriptor. Return <code>null</code> if there is no
* such generator.
*
* @since 1.3
*/
protected InterceptorSourceCodeGenerator[]
getInterceptorSourceCodeGenerators( String ctrldesc ) {
InterceptorSourceCodeGenerator[] iscgs = null;
boolean mergeable = false;
InterceptorSourceCodeGenerator iscg =
new SCAIntentInterceptorSourceCodeGenerator();
iscg.setMergeable(mergeable);
iscg.setJuliac(jc);
if( ctrldesc.equals(TinfiDomain.SCA_PRIMITIVE) ) {
InterceptorSourceCodeGenerator lcscg =
new LifeCycleSourceCodeGenerator();
lcscg.setMergeable(mergeable);
lcscg.setJuliac(jc);
InterceptorSourceCodeGenerator cscg =
new SCAContentInterceptorSourceCodeGenerator();
cscg.setMergeable(mergeable);
cscg.setJuliac(jc);
iscgs = new InterceptorSourceCodeGenerator[]{lcscg,cscg,iscg};
}
else if( ctrldesc.equals(TinfiDomain.SCA_COMPOSITE) ) {
iscgs = new InterceptorSourceCodeGenerator[]{iscg};
}
else {
String msg = "Unsupported controller descriptor: "+ctrldesc;
throw new TinfiRuntimeException(msg);
}
return iscgs;
}
}
......@@ -24,13 +24,11 @@
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.ucf.UnifiedClass;
import org.objectweb.fractal.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.juliac.visit.MethodSourceCodeVisitor;
import org.ow2.frascati.tinfi.TinfiComponentInterceptor;
/**
* This class generates interceptor classes. This generator differs from {@link
......@@ -49,32 +47,6 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
super(iscgs,jc);
}
/**
* @since 1.1.1
*/
@Override
public String getSuperClassName() throws IllegalArgumentException {
StringBuffer sb = new StringBuffer();
sb.append(TinfiComponentInterceptor.class.getName());
sb.append('<');
String signature = it.getFcItfSignature();
sb.append(signature);
/*
* Add type parameters if any.
*/
UnifiedClass proxycl = jc.create(signature);
String[] tpnames = proxycl.getTypeParameterNames();
if( tpnames.length != 0 ) {
String s = Utils.getTypeParameterNamesSignature(tpnames);
sb.append(s);
}
sb.append('>');
return sb.toString();
}
@Override
public void generateProxyMethodBodyDelegatingCode(
MethodSourceCodeVisitor mv, UnifiedClass proxycl, UnifiedMethod proxym ) {
......
......@@ -49,6 +49,7 @@ extends org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator {
@Override
public String getSuperClassName() throws IllegalArgumentException {
StringBuffer sb = new StringBuffer();
sb.append(TinfiComponentInterceptor.class.getName());
sb.append('<');
......
......@@ -29,6 +29,7 @@ import java.lang.reflect.Modifier;
import org.objectweb.fractal.api.Interface;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.juliac.Juliac;
import org.objectweb.fractal.juliac.Utils;
import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.proxy.AbstractInterceptorSourceCodeGenerator;
import org.objectweb.fractal.juliac.ucf.UnifiedClass;
......@@ -36,6 +37,7 @@ import org.objectweb.fractal.juliac.ucf.UnifiedMethod;
import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor;
import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor;
import org.objectweb.fractal.juliac.visit.MethodSourceCodeVisitor;
import org.ow2.frascati.tinfi.TinfiComponentInterceptor;
import org.ow2.frascati.tinfi.TinfiRuntimeException;
import org.ow2.frascati.tinfi.control.component.ReconfigurableComponentContext;
import org.ow2.frascati.tinfi.control.intent.IntentHandler;
......@@ -88,6 +90,33 @@ extends AbstractInterceptorSourceCodeGenerator {
}
}
/**
* @since 1.3
*/
@Override
public String getSuperClassName() {
StringBuffer sb = new StringBuffer();
sb.append(TinfiComponentInterceptor.class.getName());
sb.append('<');
String signature = it.getFcItfSignature();
sb.append(signature);
/*
* Add type parameters if any.
*/
UnifiedClass proxycl = jc.create(signature);
String[] tpnames = proxycl.getTypeParameterNames();
if( tpnames.length != 0 ) {
String s = Utils.getTypeParameterNamesSignature(tpnames);
sb.append(s);
}
sb.append('>');
return sb.toString();
}
@Override
public void generateStaticParts( ClassSourceCodeVisitor cv, UnifiedClass proxycl ) {
......
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