Commit 2ded899c authored by Christophe Demarey's avatar Christophe Demarey
Browse files

Add a wrapper for the FraSCAti Domain (now an SCA composite) that can be used...

Add a wrapper for the FraSCAti Domain (now an SCA composite) that can be used in fractal architectures.
Refactor explorer to better isolate explorer components from the FraSCAti Domain.
Refactor FrascatiScript and its explorer plugin to better isolate fscript components from the FraSCAti Domain.
Load the fscript std lib by default.
parent 2a2741da
......@@ -34,15 +34,6 @@
<version>1.2-SNAPSHOT</version>
</parent>
<!-- ============= -->
<!-- Properties -->
<!-- ============= -->
<properties>
<spoon.maven-plugin.version>0.7.1</spoon.maven-plugin.version>
<spoon.core.version>1.4.2</spoon.core.version>
</properties>
<!-- ============= -->
<!-- Dependencies -->
<!-- ============= -->
......@@ -76,12 +67,6 @@
<artifactId>xercesImpl</artifactId>
</dependency>
<!-- Fraclet annotations -->
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fraclet-annotations</artifactId>
</dependency>
<!-- FraSCAti -->
<dependency>
<groupId>org.ow2.frascati.factory</groupId>
......@@ -96,49 +81,4 @@
</dependencies>
<!-- ====== -->
<!-- Build -->
<!-- ====== -->
<build>
<plugins>
<!-- Compile with java 1.5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- Process Fraclet annotations with Spoon. -->
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<version>${spoon.maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>${spoon.core.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractal-spoonlet</artifactId>
<version>${fraclet.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractaladl-spoonlet</artifactId>
<version>${fraclet.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>recompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -23,7 +23,7 @@
* Contributor(s):
*/
package org.ow2.frascati.explorer;
package org.ow2.frascati;
import java.io.File;
import java.io.IOException;
......@@ -52,7 +52,7 @@ import org.ow2.frascati.factory.runtime.domain.api.DomainConfig;
* @author Lionel Seinturier <Lionel.Seinturier@univ-lille1.fr>
* @since 1.2
*/
public class FrascatiDomainImpl
public class FrascatiDomainWrapper
implements Domain, DomainConfig, BindingController, LifeCycleController {
// ----------------------------------------------------------------------
......
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!--
* ====================================================================
*
* OW2 FraSCAti explorer
* Copyright (C) 2008-2009 INRIA
*
* 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
*
* Authors: Lionel Seinturier,
* Christophe Demarey
*
* Contributor(s):
* ====================================================================
-->
<!-- A Wrapper that can be used by fractal components
to bind to the FraSCAti Domain.
clt-* interfaces are bound at runtime (a new FrascatiDomain is instanciated). -->
<definition name="org.ow2.frascati.FrascatiDomainWrapper">
<interface name="domain" role="server"
signature="org.ow2.frascati.factory.runtime.domain.api.Domain" />
<interface name="domain-config" role="server"
signature="org.ow2.frascati.factory.runtime.domain.api.DomainConfig" />
<interface name="clt-domain" role="client" contingency="optional"
signature="org.ow2.frascati.factory.runtime.domain.api.Domain" />
<interface name="clt-domain-config" role="client" contingency="optional"
signature="org.ow2.frascati.factory.runtime.domain.api.DomainConfig" />
<content class="org.ow2.frascati.FrascatiDomainWrapper" />
</definition>
......@@ -40,41 +40,18 @@
<interface name="domain" contingency="mandatory" role="server" cardinality="singleton"
signature="org.ow2.frascati.factory.runtime.domain.api.Domain"/>
<!-- The FraSCAti Explorer GUI -->
<component name="ExplorerGUI"
definition="org.ow2.frascati.explorer.ExplorerGUI(frameTitle=>${title},explorerConfigurationFiles=>frascati-explorer.xml,initialRole=>SCA Explorer)"/>
<!-- The Explorer Engine component. -->
<component name="explorer-engine"
definition="org.objectweb.util.explorer.swing.SwingFractalExplorer" />
<!-- The Explorer SCA Domain Manager -->
<component name="domainManager"
definition="org.ow2.frascati.explorer.DomainManagerImpl" />
<!-- The FraSCAti Explorer Core -->
<component name="frascati-explorer-core"
definition="org.ow2.frascati.explorer.FrascatiExplorerCore(${title})"/>
<!-- The FraSCAti domain / runtime -->
<!-- component name="frascati-domain"
definition="org.ow2.frascati.factory.FrascatiDomain" / -->
<component name="frascati-domain">
<interface name="domain" role="server" signature="org.ow2.frascati.factory.runtime.domain.api.Domain" />
<interface name="domain-config" role="server" signature="org.ow2.frascati.factory.runtime.domain.api.DomainConfig" />
<interface name="clt-domain" role="client" contingency="optional" signature="org.ow2.frascati.factory.runtime.domain.api.Domain" />
<interface name="clt-domain-config" role="client" contingency="optional" signature="org.ow2.frascati.factory.runtime.domain.api.DomainConfig" />
<content class="org.ow2.frascati.explorer.FrascatiDomainImpl" />
</component>
<component name="frascati-domain"
definition="org.ow2.frascati.FrascatiDomainWrapper" />
<binding client="this.r" server="ExplorerGUI.r"/>
<binding client="this.domain" server="frascati-domain.domain"/>
<binding client="domainManager.domains" server="frascati-domain.domain"/>
<binding client="domainManager.configs" server="frascati-domain.domain-config"/>
<binding client="ExplorerGUI.scadomain-manager" server="domainManager.scadomain-manager"/>
<binding client="this.r" server="frascati-explorer-core.r"/>
<binding client="this.domain" server="frascati-domain.domain"/>
<binding client="ExplorerGUI.explorer" server="explorer-engine.explorer"/>
<binding client="ExplorerGUI.parser-configuration" server="explorer-engine.parser-configuration"/>
<binding client="ExplorerGUI.tree" server="explorer-engine.tree"/>
<binding client="ExplorerGUI.view-panel" server="explorer-engine.view-panel"/>
<binding client="ExplorerGUI.status-bar" server="explorer-engine.status-bar"/>
<binding client="frascati-explorer-core.domain" server="frascati-domain.domain"/>
<binding client="frascati-explorer-core.domain-config" server="frascati-domain.domain-config"/>
</definition>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!--
* ====================================================================
*
* OW2 FraSCAti explorer
* Copyright (C) 2008-2009 INRIA
*
* 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: Christophe Demarey
*
* Contributor(s):
* ====================================================================
-->
<!-- Architecture of the FraSCAti Explorer Core. -->
<!-- The explorer has to be bound to a FraSCAti domain / runtime. -->
<definition name="org.ow2.frascati.explorer.FrascatiExplorerCore"
arguments="title">
<interface name="r" contingency="mandatory" role="server" cardinality="singleton"
signature="java.lang.Runnable"/>
<interface name="domain" role="client"
signature="org.ow2.frascati.factory.runtime.domain.api.Domain" />
<interface name="domain-config" role="client"
signature="org.ow2.frascati.factory.runtime.domain.api.DomainConfig" />
<!-- The FraSCAti Explorer GUI -->
<component name="ExplorerGUI"
definition="org.ow2.frascati.explorer.ExplorerGUI(frameTitle=>${title},explorerConfigurationFiles=>frascati-explorer.xml,initialRole=>SCA Explorer)"/>
<!-- The Explorer Engine component. -->
<component name="explorer-engine"
definition="org.objectweb.util.explorer.swing.SwingFractalExplorer" />
<!-- The Explorer SCA Domain Manager -->
<component name="domainManager"
definition="org.ow2.frascati.explorer.DomainManagerImpl" />
<binding client="this.r" server="ExplorerGUI.r"/>
<binding client="domainManager.domains" server="this.domain"/>
<binding client="domainManager.configs" server="this.domain-config"/>
<binding client="ExplorerGUI.scadomain-manager" server="domainManager.scadomain-manager"/>
<binding client="ExplorerGUI.explorer" server="explorer-engine.explorer"/>
<binding client="ExplorerGUI.parser-configuration" server="explorer-engine.parser-configuration"/>
<binding client="ExplorerGUI.tree" server="explorer-engine.tree"/>
<binding client="ExplorerGUI.view-panel" server="explorer-engine.view-panel"/>
<binding client="ExplorerGUI.status-bar" server="explorer-engine.status-bar"/>
</definition>
......@@ -69,21 +69,6 @@
</dependencies>
<!-- ====== -->
<!-- Build -->
<!-- ====== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
<!-- ========= -->
<!-- Profiles -->
<!-- ========= -->
......
<?xml version="1.0" encoding="UTF-8"?>
<spoon>
<spoonlet groupId="org.objectweb.fractal.fraclet.java"
artifactId="fractal-spoonlet" version="3.2.1" />
<spoonlet groupId="org.objectweb.fractal.fraclet.java"
artifactId="fractaladl-spoonlet" version="3.2.1" />
</spoon>
/***
* OW2 FraSCAti Explorer
* Copyright (C) 2009 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: Christophe Demarey
*
* Contributor(s):
*/
package org.ow2.frascati.explorer.fscript;
import org.objectweb.fractal.fraclet.annotations.Requires;
import org.objectweb.fractal.fscript.FScriptEngine;
/**
* The main FraSCAti Framework Explorer GUI.
*
* @author Christophe Demarey
*/
@org.objectweb.fractal.fraclet.annotations.Component
public class ExplorerGUI
extends org.ow2.frascati.explorer.ExplorerGUI {
// --------------------------------------------------------------------------
// Internal state
// --------------------------------------------------------------------------
/**
* To store the ExplorerGUI singleton used by some static methods.
*/
protected static ExplorerGUI singleton;
/**
* The configuration parser.
*/
@Requires(name="fscript-engine")
protected FScriptEngine fscriptEngine ;
// --------------------------------------------------------------------------
// Public methods.
// --------------------------------------------------------------------------
/**
* Get the ExplorerGUI singleton.
*/
public static ExplorerGUI getSingleton() {
return singleton;
}
/**
* Get the FraSCAti Script engine.
*/
public FScriptEngine getFscriptEngine() {
return fscriptEngine;
}
}
......@@ -24,8 +24,10 @@
*/
package org.ow2.frascati.explorer.fscript;
import java.util.Map;
import java.util.logging.Logger;
import org.objectweb.fractal.adl.ContextMap;
import org.ow2.frascati.explorer.FrascatiExplorerLauncher;
import org.ow2.frascati.fscript.FraSCAtiScript;
......@@ -53,9 +55,11 @@ public class FrascatiScriptExplorerLauncher
*/
public FrascatiScriptExplorerLauncher() {
String adlFile = System.getProperty("frascati.explorer.adl");
Map<Object, Object> context = new ContextMap();
if (adlFile == null) adlFile = DEFAULT_EXPLORER_ADL;
FraSCAtiScript.createSingleton(adlFile);
context.put("title", "FraSCAti Explorer");
FraSCAtiScript.createSingleton(adlFile, context);
this.explorer = FraSCAtiScript.getSingleton().getRootComponent();
}
......
......@@ -34,4 +34,11 @@
<definition name="org.ow2.frascati.explorer.fscript.FrascatiScriptExplorer"
extends="org.ow2.frascati.explorer.FrascatiExplorer(${title}), org.ow2.frascati.fscript.FraSCAtiScript"
arguments="title">
<!-- The FraSCAtiScript Explorer Core -->
<component name="frascati-explorer-core"
definition="org.ow2.frascati.explorer.fscript.FrascatiScriptExplorerCore(${title})"/>
<!-- Bind explorer and fscript -->
<binding client="frascati-explorer-core.fscript-engine"
server="frascati-script-core.engine"/>
</definition>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" "classpath://org/objectweb/fractal/adl/xml/standard.dtd">
<!--
* ====================================================================
*
* OW2 FraSCAti explorer
* Copyright (C) 2008-2009 INRIA
*
* 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: Christophe Demarey
*
* Contributor(s):
* ====================================================================
-->
<!-- Architecture of the FraSCAti Explorer Core. -->
<definition name="org.ow2.frascati.explorer.fscript.FrascatiScriptExplorerCore"
extends="org.ow2.frascati.explorer.FrascatiExplorerCore(${title})"
arguments="title">
<!-- Need to use FraSCAtiScript interfaces -->
<interface name="fscript-engine" role="client"
signature="org.objectweb.fractal.fscript.FScriptEngine" />
<!-- The FraSCAtiScript Explorer GUI -->
<component name="ExplorerGUI"
definition="org.ow2.frascati.explorer.fscript.ExplorerGUI(frameTitle=>${title},explorerConfigurationFiles=>frascati-explorer.xml,initialRole=>SCA Explorer)"/>
<!-- Bindings -->
<binding client="ExplorerGUI.fscript-engine" server="this.fscript-engine"/>
</definition>
......@@ -43,6 +43,10 @@
<xerces.version>2.9.1</xerces.version>
<beanshell.version>2.0b4</beanshell.version>
<truezip.version>6.6</truezip.version>
<spoon.maven-plugin.version>0.7.1</spoon.maven-plugin.version>
<spoon.core.version>1.4.2</spoon.core.version>
<frascati-explorer.adl.file>org.ow2.frascati.explorer.FrascatiExplorer</frascati-explorer.adl.file>
<frascati-explorer.archi.adl.file>org.ow2.frascati.explorer.FrascatiExplorerFractalView</frascati-explorer.archi.adl.file>
</properties>
......@@ -145,6 +149,59 @@
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Fraclet annotations -->
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fraclet-annotations</artifactId>
</dependency>
</dependencies>
<!-- ====== -->
<!-- Build -->
<!-- ====== -->
<build>
<plugins>
<!-- Compile with java 1.5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- Process Fraclet annotations with Spoon. -->
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>spoon-maven-plugin</artifactId>
<version>${spoon.maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>${spoon.core.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractal-spoonlet</artifactId>
<version>${fraclet.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.fraclet.java</groupId>
<artifactId>fractaladl-spoonlet</artifactId>
<version>${fraclet.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>recompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- ========= -->
<!-- Profiles -->
<!-- ========= -->
......
......@@ -25,8 +25,11 @@
package org.ow2.frascati.fscript;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import java.util.logging.Level;
import java.util.Set;
import java.util.logging.Logger;
import org.objectweb.fractal.adl.ContextMap;
......@@ -34,8 +37,11 @@ import org.objectweb.fractal.adl.Factory;
import org.objectweb.fractal.adl.FactoryFactory;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.fscript.FScript;
import org.objectweb.fractal.fscript.FScriptEngine;
import org.objectweb.fractal.fscript.FScriptException;
import org.objectweb.fractal.fscript.InvalidScriptException;
import org.objectweb.fractal.fscript.ScriptLoader;
import org.objectweb.fractal.fscript.model.Node;
import org.objectweb.fractal.util.Fractal;
import org.ow2.frascati.fscript.model.NodeFactory;
......@@ -62,9 +68,10 @@ public class FraSCAtiScript {
* Create a FraSCAtiScript singleton with the specified implementation.
*
* @param adl - The name of the fractal ADL definition to use to instantiate FraSCAtiScript.
* @param context the context used to pass variable/value couple to the factory.
*/
public static void createSingleton(final String adl) {
if (singleton == null) singleton = new FraSCAtiScript(adl);
public static void createSingleton(final String adl, final Map<Object, Object> context) {
if (singleton == null) singleton = new FraSCAtiScript(adl, context);
}
/**
......@@ -80,18 +87,26 @@ public class FraSCAtiScript {
* Instanciates a FraSCAtiScript assembly from the given ADL definition.
*
* @param adl The architecture to instantiate.
* @param context the context used to pass variable/value couple to the factory.
*/
private FraSCAtiScript(final String adl) {
Map<Object, Object> context = new ContextMap();
context.put("title", "FraSCAti Explorer");
private FraSCAtiScript(final String adl, final Map<Object, Object> context) {
this.fscript = loadArchitecture(adl, context);
try {
FScript.loadStandardLibrary(fscript);
} catch (InvalidScriptException e) {
log.warning("Cannot load the standard library! Check the script syntax!\n"
+ e.getCause());
} catch (NoSuchInterfaceException e) {
log.warning("Cannot find the 'loader' interface! Cannot load the standard library!\n"
+ e.getCause());