Commit d0c45562 authored by seinturi's avatar seinturi

Add a field in ComponentDesc to reference the code element that is the source...

Add a field in ComponentDesc to reference the code element that is the source for this component definition.
parent 31ec8fae
...@@ -43,13 +43,14 @@ public class ComponentDescFactoryClassGenerator ...@@ -43,13 +43,14 @@ public class ComponentDescFactoryClassGenerator
extends org.objectweb.fractal.juliac.desc.ComponentDescFactoryClassGenerator { extends org.objectweb.fractal.juliac.desc.ComponentDescFactoryClassGenerator {
public ComponentDescFactoryClassGenerator( public ComponentDescFactoryClassGenerator(
Juliac jc, ComponentDesc cdesc, String targetname ) { Juliac jc, ComponentDesc<?> cdesc, String targetname ) {
super(jc,cdesc,targetname); super(jc,cdesc,targetname);
} }
@Override @Override
protected void generateAttributes( ComponentDesc cdesc, PrintWriter pw ) { protected void generateAttributes(
ComponentDesc<?> cdesc, PrintWriter pw ) {
String id = cdesc.getID(); String id = cdesc.getID();
Set<String> names = cdesc.getAttributeNames(); Set<String> names = cdesc.getAttributeNames();
......
...@@ -126,7 +126,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -126,7 +126,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
@Override @Override
protected SourceCodeGeneratorItf getComponentDescFactoryClassGenerator( protected SourceCodeGeneratorItf getComponentDescFactoryClassGenerator(
ComponentDesc cdesc, String targetname ) { ComponentDesc<?> cdesc, String targetname ) {
return new ComponentDescFactoryClassGenerator(jc,cdesc,targetname); return new ComponentDescFactoryClassGenerator(jc,cdesc,targetname);
} }
...@@ -200,7 +200,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -200,7 +200,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
/** /**
* Transform the specified {@link Composite} to {@link ComponentDesc}. * Transform the specified {@link Composite} to {@link ComponentDesc}.
*/ */
protected ComponentDesc toComponentDesc( Composite composite ) protected ComponentDesc<Composite> toComponentDesc( Composite composite )
throws IOException { throws IOException {
/* /*
...@@ -218,19 +218,20 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -218,19 +218,20 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String controllerDesc = String controllerDesc =
name.startsWith(MEMBRANE_PKG_NAME) ? "mComposite" : "scaComposite"; name.startsWith(MEMBRANE_PKG_NAME) ? "mComposite" : "scaComposite";
ComponentDesc cdesc = ComponentDesc<Composite> cdesc =
new ComponentDesc(id,name,name,ct,controllerDesc,null); new ComponentDesc<Composite>(
id,name,name,ct,controllerDesc,null,composite);
/* /*
* Subcomponents. * Subcomponents.
*/ */
EList<Component> subs = composite.getComponent(); EList<Component> subs = composite.getComponent();
Map<String,ComponentDesc> subcdescs = Map<String,ComponentDesc<?>> subcdescs =
new HashMap<String,ComponentDesc>(); new HashMap<String,ComponentDesc<?>>();
String subControllerDesc = String subControllerDesc =
name.startsWith(MEMBRANE_PKG_NAME) ? "mPrimitive" : "scaPrimitive"; name.startsWith(MEMBRANE_PKG_NAME) ? "mPrimitive" : "scaPrimitive";
for (Component sub : subs) { for (Component sub : subs) {
ComponentDesc subcdesc = ComponentDesc<?> subcdesc =
handleComponent(name,sub,subControllerDesc); handleComponent(name,sub,subControllerDesc);
handleProperties(sub,subcdesc); handleProperties(sub,subcdesc);
cdesc.addSubComponent(subcdesc); cdesc.addSubComponent(subcdesc);
...@@ -283,7 +284,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -283,7 +284,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
// Declared protected to enable extension in frascati-tinfi-osgi-scaadl // Declared protected to enable extension in frascati-tinfi-osgi-scaadl
protected ComponentDesc handleComponent( protected ComponentDesc<?> handleComponent(
String compositeName, Component sub, String controllerDesc ) String compositeName, Component sub, String controllerDesc )
throws IOException { throws IOException {
...@@ -293,7 +294,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -293,7 +294,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String name = sub.getName(); String name = sub.getName();
ComponentType subct = ecore2fractal(sub); ComponentType subct = ecore2fractal(sub);
Implementation implementation = sub.getImplementation(); Implementation implementation = sub.getImplementation();
ComponentDesc cdesc = null; ComponentDesc<?> cdesc = null;
if( implementation instanceof JavaImplementation ) { if( implementation instanceof JavaImplementation ) {
...@@ -305,8 +306,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -305,8 +306,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
String id = "C"+(compidx++); String id = "C"+(compidx++);
cdesc = cdesc =
new ComponentDesc( new ComponentDesc<JavaImplementation>(
id,name,name,subct,controllerDesc,contentDesc); id,name,name,subct,controllerDesc,contentDesc,jimpl);
} }
else if( implementation instanceof SCAImplementation ) { else if( implementation instanceof SCAImplementation ) {
...@@ -344,8 +345,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -344,8 +345,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
private void handleExport( private void handleExport(
ComponentDesc cdesc, String compositeName, ComponentDesc<?> cdesc, String compositeName,
Service service, Map<String,ComponentDesc> subcdescs ) Service service, Map<String,ComponentDesc<?>> subcdescs )
throws IOException { throws IOException {
String serviceName = service.getName(); String serviceName = service.getName();
...@@ -367,7 +368,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -367,7 +368,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
throw new IOException(msg); throw new IOException(msg);
} }
ComponentDesc target = subcdescs.get(promotes[0]); ComponentDesc<?> target = subcdescs.get(promotes[0]);
if( target == null ) { if( target == null ) {
final String msg = final String msg =
"No such target component "+promotes[0]+ "No such target component "+promotes[0]+
...@@ -379,8 +380,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -379,8 +380,8 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
private void handleImport( private void handleImport(
ComponentDesc cdesc, String compositeName, ComponentDesc<?> cdesc, String compositeName,
Reference reference, Map<String,ComponentDesc> subcdescs ) Reference reference, Map<String,ComponentDesc<?>> subcdescs )
throws IOException { throws IOException {
String referenceName = reference.getName(); String referenceName = reference.getName();
...@@ -395,7 +396,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -395,7 +396,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
throw new IOException(msg); throw new IOException(msg);
} }
ComponentDesc src = subcdescs.get(prs[0]); ComponentDesc<?> src = subcdescs.get(prs[0]);
if( src == null ) { if( src == null ) {
final String msg = final String msg =
"No such source component "+prs[0]+ "No such source component "+prs[0]+
...@@ -408,7 +409,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -408,7 +409,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
} }
private void handleWire( Wire wire, Map<String,ComponentDesc> subcdescs ) private void handleWire( Wire wire, Map<String,ComponentDesc<?>> subcdescs )
throws IOException { throws IOException {
// Wire source // Wire source
...@@ -418,7 +419,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -418,7 +419,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
final String msg = "Illegal source '"+source+"' in wire "+wire; final String msg = "Illegal source '"+source+"' in wire "+wire;
throw new IOException(msg); throw new IOException(msg);
} }
ComponentDesc clt = subcdescs.get(sources[0]); ComponentDesc<?> clt = subcdescs.get(sources[0]);
if( clt == null ) { if( clt == null ) {
final String msg = final String msg =
"No such source component '"+sources[0]+"' in wire "+wire; "No such source component '"+sources[0]+"' in wire "+wire;
...@@ -447,7 +448,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -447,7 +448,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
final String msg = "Illegal target '"+target+"' in wire "+wire; final String msg = "Illegal target '"+target+"' in wire "+wire;
throw new IOException(msg); throw new IOException(msg);
} }
ComponentDesc srv = subcdescs.get(targets[0]); ComponentDesc<?> srv = subcdescs.get(targets[0]);
if( srv == null ) { if( srv == null ) {
final String msg = final String msg =
"No such target component '"+targets[0]+"' in wire "+wire; "No such target component '"+targets[0]+"' in wire "+wire;
...@@ -488,11 +489,11 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -488,11 +489,11 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
private void handleInternal( private void handleInternal(
String compositeName, Component sub, String compositeName, Component sub,
Map<String,ComponentDesc> subcdescs ) Map<String,ComponentDesc<?>> subcdescs )
throws IOException { throws IOException {
String name = sub.getName(); String name = sub.getName();
ComponentDesc clt = subcdescs.get(name); ComponentDesc<?> clt = subcdescs.get(name);
EList<ComponentReference> references = sub.getReference(); EList<ComponentReference> references = sub.getReference();
for (ComponentReference reference : references) { for (ComponentReference reference : references) {
...@@ -524,7 +525,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -524,7 +525,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
compositeName; compositeName;
throw new IOException(msg); throw new IOException(msg);
} }
ComponentDesc srv = subcdescs.get(targs[0]); ComponentDesc<?> srv = subcdescs.get(targs[0]);
if( srv == null ) { if( srv == null ) {
final String msg = final String msg =
"No such target component "+targs[0]+ "No such target component "+targs[0]+
...@@ -543,15 +544,15 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -543,15 +544,15 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
private void createBinding( private void createBinding(
BindingType bindingType, ComponentDesc clt, String cltItfName, BindingType bindingType, ComponentDesc<?> clt, String cltItfName,
ComponentDesc srv, String srvItfName ) { ComponentDesc<?> srv, String srvItfName ) {
BindingDesc bdesc = BindingDesc bdesc =
new BindingDesc(bindingType,clt,cltItfName,srv,srvItfName); new BindingDesc(bindingType,clt,cltItfName,srv,srvItfName);
clt.putBinding(cltItfName,bdesc); clt.putBinding(cltItfName,bdesc);
} }
private void handleProperties( Component sub, ComponentDesc cdesc ) { private void handleProperties( Component sub, ComponentDesc<?> cdesc ) {
EList<PropertyValue> propvalues = sub.getProperty(); EList<PropertyValue> propvalues = sub.getProperty();
for (PropertyValue propvalue : propvalues) { for (PropertyValue propvalue : propvalues) {
handleProperty(cdesc,propvalue); handleProperty(cdesc,propvalue);
...@@ -559,7 +560,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> { ...@@ -559,7 +560,7 @@ public class EMFParserSupportImpl extends AbstractADLSupportImpl<Composite> {
} }
private void handleProperty( private void handleProperty(
ComponentDesc cdesc, PropertyValue propvalue ) ComponentDesc<?> cdesc, PropertyValue propvalue )
throws IllegalArgumentException { throws IllegalArgumentException {
String name = propvalue.getName(); String name = propvalue.getName();
......
...@@ -65,9 +65,9 @@ public class EMFParserSupportImplTestCase { ...@@ -65,9 +65,9 @@ public class EMFParserSupportImplTestCase {
@Test @Test
public void testPropertyClass() throws IOException { public void testPropertyClass() throws IOException {
ComponentDesc cdesc = emfps.parse("Property",null); ComponentDesc<?> cdesc = emfps.parse("Property",null);
List<ComponentDesc> subs = cdesc.getSubComponents(); List<ComponentDesc<?>> subs = cdesc.getSubComponents();
ComponentDesc sub = subs.get(0); ComponentDesc<?> sub = subs.get(0);
AttributeDesc adesc = sub.getAttribute("classprop"); AttributeDesc adesc = sub.getAttribute("classprop");
String type = adesc.getType(); String type = adesc.getType();
String value = adesc.getValue(); String value = adesc.getValue();
......
...@@ -135,7 +135,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf { ...@@ -135,7 +135,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
* @param context contextual information * @param context contextual information
* @return the model of the specified ADL * @return the model of the specified ADL
*/ */
public ComponentDesc parse( String adl, Map<Object,Object> context ) public ComponentDesc<?> parse( String adl, Map<Object,Object> context )
throws IOException { throws IOException {
// Not relevant for this ADL parser // Not relevant for this ADL parser
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
...@@ -373,7 +373,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf { ...@@ -373,7 +373,7 @@ public class TinfiParserSupportImpl implements ADLParserSupportItf {
* @param targetname the fully-qualified name of the factory class * @param targetname the fully-qualified name of the factory class
* @since 2.5 * @since 2.5
*/ */
public void generate( ComponentDesc cdesc, String targetname ) public void generate( ComponentDesc<?> cdesc, String targetname )
throws IOException { throws IOException {
// Not relevant for this ADL parser // Not relevant for this ADL parser
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
......
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