Commit 287e3a3d authored by Lionel Seinturier's avatar Lionel Seinturier
Browse files

Tagging Julia Scala Mixins 2.5.2.1

<?xml version="1.0"?>
<!--
* 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
-->
<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</groupId>
<artifactId>ow2</artifactId>
<version>1.3</version>
</parent>
<groupId>org.ow2.fractal.julia</groupId>
<artifactId>julia-mixins-scala</artifactId>
<version>2.5.2.1</version>
<name>Julia Mixins in Scala</name>
<packaging>jar</packaging>
<description>Julia mixins in Scala</description>
<build>
<plugins>
<!-- =============== -->
<!-- Scala compiling -->
<!-- =============== -->
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.14.1</version>
<executions>
<execution>
<id>scala-compile</id>
<phase>initialize</phase>
<goals><goal>compile</goal></goals>
</execution>
</executions>
</plugin>
<!-- =================================== -->
<!-- For OptimizedCompositeBindingHelper -->
<!-- =================================== -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>
${basedir}/src/main/resources/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
<!-- ================================== -->
<!-- Unpack the Julia conformance tests -->
<!-- ================================== -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>unpack-julia-bundled.cfg</id>
<phase>generate-test-resources</phase>
<goals><goal>unpack</goal></goals>
<configuration>
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>org.objectweb.fractal.julia.tests</groupId>
<artifactId>julia-tests-conf</artifactId>
<version>2.5.2</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- ========================== -->
<!-- Test plugin configuration -->
<!-- ========================== -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>fractal.provider</name>
<value>org.objectweb.fractal.julia.Julia</value>
</property>
<property>
<name>julia.loader.gen.dir</name>
<value>target/test-classes/generated</value>
</property>
<property>
<name>julia.config</name>
<value>julia-bundled.cfg</value>
</property>
</systemProperties>
</configuration>
</plugin>
<!-- ================= -->
<!-- Source packaging -->
<!-- ================= -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
<!-- ================== -->
<!-- Javadoc packaging -->
<!-- ================== -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>doc-jar</goal></goals>
</execution>
</executions>
<configuration>
<windowtitle>Julia Scala Mixins</windowtitle>
<doctitle>Julia Scala Mixins</doctitle>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.objectweb.fractal.julia</groupId>
<artifactId>julia-asm</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<developers>
<developer>
<id>seintur</id>
<name>Lionel Seinturier</name>
<email>Lionel Seinturier@univ-lille1.fr</email>
<organization>University Lille 1</organization>
<organizationUrl>http://www.univ-lille1.fr</organizationUrl>
<roles>
<role>Architect</role>
<role>Developer</role>
</roles>
</developer>
</developers>
</project>
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
import org.objectweb.fractal.api.Component
import org.objectweb.fractal.api.NoSuchInterfaceException
import org.objectweb.fractal.api.Type
import org.objectweb.fractal.api.factory.InstantiationException
/**
* Trait providing a basic implementation of the {@link Component} interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait BasicComponentTrait extends BasicControllerTrait with ComponentTrait {
/** The type of this component. */
private var fcType: Type = null
/**
* The interfaces of this component. This map associates each interface to
* its name.
*
* I'm using here java.util.Map instead of Scala Map since fcInterfaces is
* initialized in initFcController from InitializationContext.interfaces
* which is a java.util.Map (instantiated with a java.util.HashMap.) An
* alternative solution would be to convert from java.util.Map to Scala Map
* but this would lead to duplicated data.
*/
protected var fcInterfaces: java.util.Map[String,Object] = null
/**
* Initializes the fields of this mixin from the given context, and then
* calls the overriden method.
*
* @param ic information about the component to which this controller
* object belongs
* @throws InstantiationException if the initialization fails
*/
override def initFcController( ic: InitializationContext ) = {
this.fcType = ic.`type`
this.fcInterfaces = ic.interfaces.asInstanceOf[java.util.Map[String,Object]]
super.initFcController(ic)
}
override def getFcType : Type = { return fcType }
override def getFcInterfaces : Array[Object] = {
if( fcInterfaces == null ) {
return new Array[Object](0);
}
// returns the names of all the public interfaces in fcInterfaces
// interfaces whose name begins with '/' are private
var size = 0
val names = fcInterfaces.keySet.toArray(new Array[String](fcInterfaces.size))
for( name <- names ) {
if ( name.charAt(0) != '/' ) {
size += 1
}
}
var index = 0
val itfs = new Array[Object](size)
for( name <- names ) {
if ( name.charAt(0) != '/' ) {
itfs(index) = fcInterfaces.get(name)
index += 1
}
}
return itfs;
}
override def getFcInterface( interfaceName: String ) : Object = {
val itf = if(fcInterfaces==null) null else fcInterfaces.get(interfaceName)
if( itf == null ) {
throw new ChainedNoSuchInterfaceException(null,this,interfaceName)
}
return itf;
}
}
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
/**
* Base class for controllers.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait BasicControllerTrait extends Controller {
def initFcController( ic: InitializationContext ) = {}
}
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
import org.objectweb.fractal.julia.loader.Initializable
import org.objectweb.fractal.julia.loader.Tree
/**
* Trait providing an empty implementation of the {@link Initializable}
* interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait BasicInitializableTrait extends Initializable {
def initialize ( args: Tree ) = {}
}
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
/**
* Implementation of the {@link Component} control interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
class ComponentControllerImpl extends ComponentControllerTrait
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
import org.objectweb.fractal.api.Component
/**
* Trait implementing the {@link Component} control interface.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait ComponentControllerTrait extends BasicControllerTrait
with TypeComponentTrait // with BasicComponentTrait // already included by TypeComponentTrait
with Component
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
import org.objectweb.fractal.api.Component
import org.objectweb.fractal.api.Type
/**
* Abstract implementation of the {@link Component} interface to enable calling
* super.aMethod (e.g. getFcType) in traits which use this trait.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait ComponentTrait extends Component {
def getFcType : Type = return null
def getFcInterfaces : Array[Object] = return null
def getFcInterface( interfaceName: String ) : Object = return null
}
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* 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: Lionel.Seinturier@univ-lille1.fr
*
* Author: Lionel Seinturier
*/
package org.objectweb.fractal.julia
import org.objectweb.fractal.api.Component
import org.objectweb.fractal.api.NoSuchInterfaceException
import org.objectweb.fractal.api.Type
import org.objectweb.fractal.api.`type`.ComponentType
import org.objectweb.fractal.api.`type`.InterfaceType
/**
* Trait implementing a basic type system related checks to a {@link Component}.
*
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 2.5.2
*/
trait TypeComponentTrait extends BasicControllerTrait with BasicComponentTrait {
/**
* Checks the interface name against the component's type and then calls the
* overriden method. This method also creates the collection interfaces
* when needed, and puts them in the {@link #_this_fcInterfaces} map.
*
* @param interfaceName
* the name of the external interface that must be returned
* @return the external interface of the component to which this interface
* belongs, whose name is equal to the given name
* @throws NoSuchInterfaceException if there is no such interface
*/
override def getFcInterface( interfaceName: String ) : Object = {
if( interfaceName.indexOf('/') == 0 ) {
return super.getFcInterface(interfaceName)
}
val compType = getFcType.asInstanceOf[ComponentType]
var itfType = compType.getFcInterfaceType(interfaceName)
var result : Object = null
try {
result = super.getFcInterface(interfaceName)
}
catch {
case e: NoSuchInterfaceException => {
if ( itfType.isFcCollectionItf ) {
result = super.getFcInterface("/collection/" + itfType.getFcItfName)
/*
* result = result.asInstanceOf[ComponentInterface].clone
*
* generates the following error with Scala 2.8.1:
* method clone cannot be accessed in org.objectweb.fractal.julia.ComponentInterface
*
* A quick search in Google returns mixed opinions with
* issues existing with the clone() method, some being
* apparently fixed. To avoid the issue, 2 options seem to
* exist:
* (1) using dynamic call (such as below),
* (2) subclassing BasicComponentInterface with a myclone()
* method which calls super.clone(), and invoking this
* myclone() method here (yet, the condition is to use this
* new subclass for all interfaces - see the interface class
* generator.)
*/
val m = result.getClass.getMethod("clone")
result = m.invoke(result)
result.asInstanceOf[ComponentInterface].setFcItfName(interfaceName)
fcInterfaces.put(interfaceName,result)
}
else {
throw e
}
}
}
return result
}
}
/***
* Julia
* Copyright (C) 2011-2016 Inria, Universite Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public