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

SCA Assembly Language parser refactored to move the part specific to the...

SCA Assembly Language parser refactored to move the part specific to the support of the OSGi implementation type in the extension/osgi module.
parent 7b2dff95
Tinfi 1.3.1
-----------
* SCA Assembly Language parser refactored to move the part specific to the
support of the OSGi implementation type in the extension/osgi module
Tinfi 1.3
---------
* move to Juliac 2.2.4
......
......@@ -83,7 +83,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<adlParser>org.ow2.frascati.tinfi.osgi.EMFParserSupportImpl</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.objectweb.fractal.juliac.osgi.FCOOCtrlSourceCodeGenerator</opt>
......@@ -97,7 +97,7 @@
<adls><adl>${tinfi.run.component}</adl></adls>
<modules>
<module>org.ow2.frascati.tinfi:frascati-tinfi-oo:${project.version}</module>
<module>org.ow2.frascati.tinfi:frascati-tinfi-emf:${project.version}</module>
<module>org.ow2.frascati.tinfi.osgi:frascati-tinfi-osgi-scaadl:${project.version}</module>
<module>org.objectweb.fractal.juliac.osgi:juliac-osgi-opt-oo:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-jdt:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-spoon:${juliac.version}</module>
......
......@@ -83,7 +83,7 @@
</executions>
<configuration>
<srcs><src>src/main/java</src></srcs>
<adlParser>org.ow2.frascati.tinfi.emf.EMFParserSourceCodeGenerator</adlParser>
<adlParser>org.ow2.frascati.tinfi.osgi.EMFParserSupportImpl</adlParser>
<opts>
<opt>org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator</opt>
<opt>org.objectweb.fractal.juliac.osgi.FCOOCtrlSourceCodeGenerator</opt>
......@@ -97,7 +97,7 @@
<adls><adl>${tinfi.run.component}</adl></adls>
<modules>
<module>org.ow2.frascati.tinfi:frascati-tinfi-oo:${project.version}</module>
<module>org.ow2.frascati.tinfi:frascati-tinfi-emf:${project.version}</module>
<module>org.ow2.frascati.tinfi.osgi:frascati-tinfi-osgi-scaadl:${project.version}</module>
<module>org.objectweb.fractal.juliac.osgi:juliac-osgi-opt-oo:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-jdt:${juliac.version}</module>
<module>org.objectweb.fractal.juliac:juliac-spoon:${juliac.version}</module>
......
<?xml version="1.0" encoding="UTF-8"?><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.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-plugin-parent</artifactId>
<version>1.3.1-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-adlparser-parent</artifactId>
<name>Tinfi OSGi ADL Parsers</name>
<packaging>pom</packaging>
<modules>
<module>scaadl</module>
</modules>
</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.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-adlparser-parent</artifactId>
<version>1.3.1-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-scaadl</artifactId>
<packaging>jar</packaging>
<name>Tinfi Plugin SCA Assembly Language</name>
<dependencies>
<dependency>
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-emf</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ow2.frascati.model.osgi;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Document Root</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.ow2.frascati.model.osgi.DocumentRoot#getImplementationOsgi <em>Implementation Osgi</em>}</li>
* </ul>
* </p>
*
* @see org.ow2.frascati.model.osgi.OsgiPackage#getDocumentRoot()
* @model extendedMetaData="name='' kind='mixed'"
* @generated
*/
public interface DocumentRoot extends org.eclipse.stp.sca.DocumentRoot {
/**
* Returns the value of the '<em><b>Implementation Osgi</b></em>' containment reference.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Implementation Osgi</em>' reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Implementation Osgi</em>' containment reference.
* @see #setImplementationOsgi(OsgiImplementation)
* @see org.ow2.frascati.model.osgi.OsgiPackage#getDocumentRoot_ImplementationOsgi()
* @model containment="true" upper="-2" transient="true" volatile="true" derived="true"
* extendedMetaData="kind='element' name='implementation.osgi' namespace='##targetNamespace' affiliation='http://www.osoa.org/xmlns/sca/1.0#implementation'"
* @generated
*/
OsgiImplementation getImplementationOsgi();
/**
* Sets the value of the '{@link org.ow2.frascati.model.osgi.DocumentRoot#getImplementationOsgi <em>Implementation Osgi</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Implementation Osgi</em>' containment reference.
* @see #getImplementationOsgi()
* @generated
*/
void setImplementationOsgi(OsgiImplementation value);
} // DocumentRoot
/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ow2.frascati.model.osgi;
import org.eclipse.emf.ecore.EFactory;
/**
* <!-- begin-user-doc -->
* The <b>Factory</b> for the model.
* It provides a create method for each non-abstract class of the model.
* <!-- end-user-doc -->
* @see org.ow2.frascati.model.osgi.OsgiPackage
* @generated
*/
public interface OsgiFactory extends EFactory {
/**
* The singleton instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
OsgiFactory eINSTANCE = org.ow2.frascati.model.osgi.impl.OsgiFactoryImpl.init();
/**
* Returns a new object of class '<em>Document Root</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return a new object of class '<em>Document Root</em>'.
* @generated
*/
DocumentRoot createDocumentRoot();
/**
* Returns a new object of class '<em>Implementation</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return a new object of class '<em>Implementation</em>'.
* @generated
*/
OsgiImplementation createOsgiImplementation();
/**
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the package supported by this factory.
* @generated
*/
OsgiPackage getOsgiPackage();
} //OsgiFactory
/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ow2.frascati.model.osgi;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.stp.sca.Implementation;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Implementation</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.ow2.frascati.model.osgi.OsgiImplementation#getBundle <em>Bundle</em>}</li>
* <li>{@link org.ow2.frascati.model.osgi.OsgiImplementation#getAnyAttribute <em>Any Attribute</em>}</li>
* <li>{@link org.ow2.frascati.model.osgi.OsgiImplementation#getGroup <em>Group</em>}</li>
* </ul>
* </p>
*
* @see org.ow2.frascati.model.osgi.OsgiPackage#getOsgiImplementation()
* @model extendedMetaData="name='OsgiImplementation' kind='elementOnly'"
* @generated
*/
public interface OsgiImplementation extends Implementation {
/**
* Returns the value of the '<em><b>Bundle</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Bundle</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Bundle</em>' attribute.
* @see #setBundle(String)
* @see org.ow2.frascati.model.osgi.OsgiPackage#getOsgiImplementation_Bundle()
* @model dataType="org.eclipse.emf.ecore.xml.type.String" required="true"
* @generated
*/
String getBundle();
/**
* Sets the value of the '{@link org.ow2.frascati.model.osgi.OsgiImplementation#getBundle <em>Bundle</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Bundle</em>' attribute.
* @see #getBundle()
* @generated
*/
void setBundle(String value);
/**
* Returns the value of the '<em><b>Any Attribute</b></em>' attribute list.
* The list contents are of type {@link org.eclipse.emf.ecore.util.FeatureMap.Entry}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Any Attribute</em>' attribute list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Any Attribute</em>' attribute list.
* @see org.ow2.frascati.model.osgi.OsgiPackage#getOsgiImplementation_AnyAttribute()
* @model dataType="org.eclipse.emf.ecore.EFeatureMapEntry" many="true"
* extendedMetaData="kind='attributeWildcard' wildcards='##any' name=':3' processing='lax'"
* @generated
*/
FeatureMap getAnyAttribute();
/**
* Returns the value of the '<em><b>Group</b></em>' attribute list.
* The list contents are of type {@link org.eclipse.emf.ecore.util.FeatureMap.Entry}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Group</em>' attribute list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Group</em>' attribute list.
* @see org.ow2.frascati.model.osgi.OsgiPackage#getOsgiImplementation_Group()
* @model dataType="org.eclipse.emf.ecore.EFeatureMapEntry" many="true"
* extendedMetaData="kind='group' name='group:sca:osgiimplementation'"
* @generated
*/
FeatureMap getGroup();
} // OsgiImplementation
/***
* OW2 FraSCAti Tinfi
* Copyright (C) 2010 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
*
* Contact: frascati@ow2.org
*
* Author: Lionel Seinturier
*/
package org.ow2.frascati.tinfi.osgi;
import java.io.IOException;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.stp.sca.Component;
import org.eclipse.stp.sca.Implementation;
import org.objectweb.fractal.api.type.ComponentType;
import org.ow2.frascati.model.osgi.OsgiImplementation;
import org.ow2.frascati.model.osgi.OsgiPackage;
import org.ow2.frascati.tinfi.emf.ComponentDesc;
/**
* EMF parser for SCA Assembly Language descriptors with support for the OSGi
* component implementation type.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.3.1
*/
public class EMFParserSupportImpl
extends org.ow2.frascati.tinfi.emf.EMFParserSupportImpl {
// ----------------------------------------------------------------------
// Methods for transforming Composite to ComponentDesc
// ----------------------------------------------------------------------
@Override
protected ComponentDesc handleComponent( String compositeName, Component sub )
throws IOException {
/*
* Component name and type.
*/
String name = sub.getName();
ComponentType subct = ecore2fractal(sub);
Implementation implementation = sub.getImplementation();
ComponentDesc cdesc = null;
if( implementation instanceof OsgiImplementation ) {
/*
* OSGi bundle implementation.
*/
OsgiImplementation osgiimpl = (OsgiImplementation) implementation;
String controllerDesc = "osgiPrimitive";
String contentDesc = osgiimpl.getBundle();
String id = "C"+(compidx++);
cdesc =
new ComponentDesc(
id,name,name,jc,subct,controllerDesc,contentDesc);
}
else {
cdesc = super.handleComponent(compositeName,sub);
}
return cdesc;
}
// -------------------------------------------------------------------
// Implementation specific
// -------------------------------------------------------------------
@Override
protected void register( ResourceSet resourceSet ) {
super.register(resourceSet);
org.eclipse.emf.ecore.EPackage.Registry reg =
resourceSet.getPackageRegistry();
reg.put( OsgiPackage.eNS_URI, OsgiPackage.eINSTANCE );
}
}
<?xml version="1.0" encoding="UTF-8"?><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.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-parent</artifactId>
<version>1.3.1-SNAPSHOT</version>
</parent>
<groupId>org.ow2.frascati.tinfi.osgi</groupId>
<artifactId>frascati-tinfi-osgi-plugin-parent</artifactId>
<name>Tinfi OSGi Plugins</name>
<packaging>pom</packaging>
<modules>
<module>adlparser</module>
</modules>
</project>
......@@ -16,6 +16,7 @@
<modules>
<module>mixins</module>
<module>opt</module>
<module>plugin</module>
<module>mixed</module>
</modules>
......
......@@ -19,8 +19,15 @@
<name>Tinfi Plugin SCA Assembly Language</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>org.objectweb.fractal.juliac</groupId>
<artifactId>juliac-core</artifactId>
<version>${juliac.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.frascati.tinfi</groupId>
<artifactId>frascati-tinfi-oo</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -79,8 +79,6 @@ import org.objectweb.fractal.juliac.desc.BindingDesc;
import org.objectweb.fractal.juliac.desc.BindingType;
import org.objectweb.fractal.juliac.desc.ComponentDescFactoryClassGenerator;
import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf;
import org.ow2.frascati.model.osgi.OsgiImplementation;
import org.ow2.frascati.model.osgi.OsgiPackage;
import org.ow2.frascati.tinfi.TinfiDomain;
/**
......@@ -102,7 +100,7 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
this.jc = jc;
}
protected Juliac jc;
private int compidx = 0;
protected int compidx = 0;
/**
......@@ -111,7 +109,6 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
* @param adl the fully-qualified name of the ADL descriptor
* @return <code>true</code> if this ADL parser accepts the specified
* ADL descriptor
* @since 1.3.1
*/
public boolean acceptADLDesc( String adl ) {
/*
......@@ -167,10 +164,7 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
/*
* Register the EMF packages.
*/
org.eclipse.emf.ecore.EPackage.Registry reg =
resourceSet.getPackageRegistry();
reg.put( ScaPackage.eNS_URI, ScaPackage.eINSTANCE );
reg.put( OsgiPackage.eNS_URI, OsgiPackage.eINSTANCE );
register(resourceSet);
/*
* Parse the composite file.
......@@ -254,6 +248,7 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
new HashMap<String,ComponentDesc>();
for (Component sub : subs) {
ComponentDesc subcdesc = handleComponent(name,sub);
handleProperties(sub,subcdesc);
cdesc.addSubComponent(subcdesc);
subcdesc.addSuperComponent(cdesc);
String subname = sub.getName();
......@@ -303,7 +298,7 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
return cdesc;
}
private ComponentDesc handleComponent( String compositeName, Component sub )
protected ComponentDesc handleComponent( String compositeName, Component sub )
throws IOException {
/*
......@@ -351,20 +346,6 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
cdesc = toComponentDesc(adl);
}
else if( implementation instanceof OsgiImplementation ) {
/*
* OSGi bundle implementation.
*/
OsgiImplementation osgiimpl = (OsgiImplementation) implementation;
String controllerDesc = "osgiPrimitive";
String contentDesc = osgiimpl.getBundle();
String id = "C"+(compidx++);
cdesc =
new ComponentDesc(
id,name,name,jc,subct,controllerDesc,contentDesc);
}
else {
String msg =
"Unsupported implementation type "+
......@@ -373,14 +354,6 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
throw new IOException(msg);
}
/*
* Component properties.
*/
EList<PropertyValue> propvalues = sub.getProperty();
for (PropertyValue propvalue : propvalues) {
handleProperty(cdesc,propvalue);
}
return cdesc;
}
......@@ -495,10 +468,12 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
// throw new IOException(msg);
}
// When the wire source is a collection client interface, add the name
// of the target component at the end of the source interface name.
// This allows to generate an unique source interface name (as component
// names are unique.)
/*
* When the wire source is a collection client interface, add the name
* of the target component at the end of the source interface name. This
* allows to generate an unique source interface name (as component
* names are unique.)
*/
if(cltItf.isFcCollectionItf() && cltItf.getFcItfName().equals(sources[1])) {
sources[1] = sources[1] + '-' + targets[0];
}
......@@ -572,6 +547,13 @@ public class EMFParserSupportImpl implements ADLParserSupportItf {
clt.putBinding(cltItfName,bdesc);
}
private void handleProperties( Component sub, ComponentDesc cdesc ) {
EList<PropertyValue> propvalues = sub.getProperty();
for (PropertyValue propvalue : propvalues) {
handleProperty(cdesc,propvalue);