From 9f4cb27733827815a41740161967956728494e35 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Wed, 16 Feb 2011 20:51:32 +0000 Subject: [PATCH 01/24] Documenting TODO. --- juliac/TODO.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/juliac/TODO.txt b/juliac/TODO.txt index acca26b51e..ef7066306c 100644 --- a/juliac/TODO.txt +++ b/juliac/TODO.txt @@ -1,4 +1,14 @@ core/ +* add an interface method and refactor the code to enable generating code for a + given interface and controller descriptor. The issue was raised by Remi + Melisson who was bundling FraSCAti and who encountered interfaces in one + module with implementation classes in different modules. The subsequent + duplication of generated code in all implementation modules caused problem + when bundling. Hence the need for obtaining generated code for some given + controller descriptors (e.g. in the case of Remi scaPrimitive and + scaComposite) with the module containing the interface and not the ones + containing the implementation. We need to extend both the command line + arguments and the mojo to support this new feature. * dump generated files to disk only when one is sure that the generation process is over and everything went right. The purpose is to prevent generating incomplete code that can not be compiled. The issue arised with the -- GitLab From 212f66b76a8f347d23b38157716fb1e25c09725d Mon Sep 17 00:00:00 2001 From: Philippe Merle Date: Sun, 20 Feb 2011 15:10:38 +0000 Subject: [PATCH 02/24] Added a new key to use in the map of hints passed as arguments to the export/bind methods to not start stub/skeleton components created by the Fractal Binding Factory. These components will be started later by the calling application, e.g., OW2 FraSCAti. --- .../fractal/bf/BindingFactoryImpl.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/fractal-bf/core/src/main/java/org/objectweb/fractal/bf/BindingFactoryImpl.java b/fractal-bf/core/src/main/java/org/objectweb/fractal/bf/BindingFactoryImpl.java index 29fded3a6f..3fd0c1f3ad 100644 --- a/fractal-bf/core/src/main/java/org/objectweb/fractal/bf/BindingFactoryImpl.java +++ b/fractal-bf/core/src/main/java/org/objectweb/fractal/bf/BindingFactoryImpl.java @@ -1,6 +1,6 @@ /** * Fractal Binding Factory. - * Copyright (C) 2007-2009 INRIA, SARDES + * Copyright (C) 2007-2011 INRIA, SARDES * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -61,6 +61,15 @@ public class BindingFactoryImpl implements BindingFactory, BindingController { */ public static final String CLASS_LOADER = "classloader"; + /** + * The key to use in the map of hints passed as arguments to the export/bind + * methods, to not start stub/skeleton components created by the Fractal Binding Factory. + * These components will be started later by the calling application, e.g., OW2 FraSCAti. + * + * @since 0.9 + */ + public static final String DONT_START_COMPONENT = "don't start component"; + /** * The logger. */ @@ -220,9 +229,11 @@ public class BindingFactoryImpl implements BindingFactory, BindingController { } - // start the skeleton - Fractal.getLifeCycleController(skel).startFc(); - log.info("Skeleton component started"); + // start the skeleton only if hints does not contain the DONT_START_COMPONENT key. + if(!hints.containsKey(DONT_START_COMPONENT)) { + Fractal.getLifeCycleController(skel).startFc(); + log.info("Skeleton component started"); + } } catch (NoSuchInterfaceException e) { throw new BindingFactoryException( @@ -385,9 +396,11 @@ public class BindingFactoryImpl implements BindingFactory, BindingController { try { log.finest("State of stub component: " + Fractal.getLifeCycleController(stub).getFcState()); - // start the stub - Fractal.getLifeCycleController(stub).startFc(); - log.info("Stub component started"); + // start the stub only if hints does not contain the DONT_START_COMPONENT key. + if(!hints.containsKey(DONT_START_COMPONENT)) { + Fractal.getLifeCycleController(stub).startFc(); + log.info("Stub component started"); + } } catch (NoSuchInterfaceException e) { throw new BindingFactoryException("Cannot start stub component", e); } catch (IllegalLifeCycleException e) { -- GitLab From 3ccaa4c213200e2e83f99713321fedc2807ae33c Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 22 Feb 2011 20:35:29 +0000 Subject: [PATCH 03/24] Check for nullness. Typos. --- .../fractal/juliac/AbstractJuliacMojo.java | 4 ++-- .../objectweb/fractal/juliac/Component.java | 23 ++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java index 9f510fd1a2..9706e90124 100644 --- a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java @@ -601,7 +601,7 @@ implements JuliacMojoItf { } /* - * Interceptor class generatoirs . + * Interceptor class generators . */ JuliacGeneratorMap iclgs = jconf.getInterceptorClassGenerators(); @@ -616,7 +616,7 @@ implements JuliacMojoItf { } /* - * Interceptor source code generatoirs . + * Interceptor source code generators . */ JuliacGeneratorMap iscgs = jconf.getInterceptorSourceCodeGenerators(); diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Component.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Component.java index 52e72903df..05a0a7daf4 100644 --- a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Component.java +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Component.java @@ -77,10 +77,16 @@ public class Component { * Return the Fractal component type corresponding to the data stored in the * current instance. */ - public ComponentType toFractalComponentType() throws InstantiationException { + public ComponentType toFractalComponentType() + throws InstantiationException { + if( interfaceTypes == null ) { + return null; + } + org.objectweb.fractal.api.type.InterfaceType[] its = - new org.objectweb.fractal.api.type.InterfaceType[ interfaceTypes.size() ]; + new org.objectweb.fractal.api.type.InterfaceType[ + interfaceTypes.size() ]; int i = 0; for (InterfaceType interfaceType : interfaceTypes) { its[i] = interfaceType.toFractalInterfaceType(); @@ -96,10 +102,15 @@ public class Component { StringBuffer sb = new StringBuffer(); sb.append('['); - boolean first = true; - for (InterfaceType it : interfaceTypes) { - if(first) {first=false;} else {sb.append(',');} - sb.append(it.toString()); + if( interfaceTypes == null ) { + sb.append("null"); + } + else { + boolean first = true; + for (InterfaceType it : interfaceTypes) { + if(first) {first=false;} else {sb.append(',');} + sb.append(it.toString()); + } } sb.append("]:"); sb.append(controllerDesc); -- GitLab From 76ab643864194e4ea7b2ea17c1d844b71134a86f Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 22 Feb 2011 20:36:02 +0000 Subject: [PATCH 04/24] New service for generating proxy code. --- .../juliac/opt/FCSourceCodeGenerator.java | 47 +++++++++++++++++++ .../juliac/opt/FCSourceCodeGeneratorItf.java | 14 ++++++ 2 files changed, 61 insertions(+) diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java index 2f650bd310..69cdaaa799 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java @@ -27,9 +27,12 @@ import java.io.IOException; import org.objectweb.fractal.api.Type; import org.objectweb.fractal.api.control.AttributeController; +import org.objectweb.fractal.api.factory.InstantiationException; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.control.attribute.CloneableAttributeController; +import org.objectweb.fractal.julia.type.BasicComponentType; +import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; @@ -255,6 +258,50 @@ implements FCSourceCodeGeneratorItf { return scg; } + /** + * Generate the source code of the interfaces and interceptors (hence + * proxies) associated to the specified interface signature. Since + * interceptors may depend of controller implementations (e.g. lifecycle + * interceptors use lifecycle controllers), controllers need also to be + * generated. + * + * @param signature the interface signature + * @param controllerDesc the component controller descriptor + * @since 2.3.1 + */ + public void generateProxiesImpl( String signature, Object controllerDesc ) + throws IOException { + + /* + * Check parameter consistence. It's safe to perform the casts after + * having performed the checks. + */ + if( !(controllerDesc instanceof String) ) { + String msg = "controllerDesc should be a String"; + throw new IllegalArgumentException(msg); + } + String ctrlDesc = (String) controllerDesc; + + InterfaceType[] its = + new InterfaceType[]{ + new BasicInterfaceType("none",signature,false,false,false) + }; + ComponentType ct = null; + try { + ct = new BasicComponentType(its); + } + catch (InstantiationException e) { + IOException ioe = new IOException(); + ioe.initCause(e); + throw ioe; + } + + /* + * Generate the membrane implementation. + */ + generateMembraneImpl(ct,ctrlDesc,null); + } + /** * Return the class generator for component interfaces. */ diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java index be5847c652..a8b5d851fc 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java @@ -107,6 +107,20 @@ public interface FCSourceCodeGeneratorItf { Type type, Object controllerDesc, Object contentDesc ) throws IOException; + /** + * Generate the source code of the interfaces and interceptors (hence + * proxies) associated to the specified interface signature. Since + * interceptors may depend of controller implementations (e.g. lifecycle + * interceptors use lifecycle controllers), controllers need also to be + * generated. + * + * @param signature the interface signature + * @param controllerDesc the component controller descriptor + * @since 2.3.1 + */ + public void generateProxiesImpl( String signature, Object controllerDesc ) + throws IOException; + /** * Generate the implementation of the membrane associated to a Fractal * component. -- GitLab From 68527c7c63be357ecb06fb4485fdca05f7110117 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Thu, 24 Feb 2011 20:33:41 +0000 Subject: [PATCH 05/24] New service for generating proxy (interface and interceptor) implementations (requested by Remi M and Philippe.) Usage example. --- juliac/RELEASE_NOTES.txt | 2 + juliac/TODO.txt | 13 +--- .../org/objectweb/fractal/juliac/Juliac.java | 24 ++++++- .../foobar-cases/generate-proxies/README.txt | 3 + .../foobar-cases/generate-proxies/pom.xml | 60 ++++++++++++++++ .../src/main/java/example/hw/Service.java | 5 ++ juliac/examples/advanced/foobar-cases/pom.xml | 1 + .../fractal/juliac/AbstractJuliacMojo.java | 20 ++++++ .../org/objectweb/fractal/juliac/Proxy.java | 68 +++++++++++++++++++ 9 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 juliac/examples/advanced/foobar-cases/generate-proxies/README.txt create mode 100644 juliac/examples/advanced/foobar-cases/generate-proxies/pom.xml create mode 100644 juliac/examples/advanced/foobar-cases/generate-proxies/src/main/java/example/hw/Service.java create mode 100644 juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Proxy.java diff --git a/juliac/RELEASE_NOTES.txt b/juliac/RELEASE_NOTES.txt index 9f7ffef5ca..06f7ecf14a 100755 --- a/juliac/RELEASE_NOTES.txt +++ b/juliac/RELEASE_NOTES.txt @@ -3,6 +3,8 @@ Juliac 2.3.1 * bug fix when generating the membrane factory: support membrane types where the first type is not necessarily the component control interface * Juliet annotation definitions moved to Fraclet +* new service for generating proxy (interface and interceptor) implementations + (requested by Remi M and Philippe) Juliac 2.3 diff --git a/juliac/TODO.txt b/juliac/TODO.txt index ef7066306c..cd5241e734 100644 --- a/juliac/TODO.txt +++ b/juliac/TODO.txt @@ -1,14 +1,4 @@ core/ -* add an interface method and refactor the code to enable generating code for a - given interface and controller descriptor. The issue was raised by Remi - Melisson who was bundling FraSCAti and who encountered interfaces in one - module with implementation classes in different modules. The subsequent - duplication of generated code in all implementation modules caused problem - when bundling. Hence the need for obtaining generated code for some given - controller descriptors (e.g. in the case of Remi scaPrimitive and - scaComposite) with the module containing the interface and not the ones - containing the implementation. We need to extend both the command line - arguments and the mojo to support this new feature. * dump generated files to disk only when one is sure that the generation process is over and everything went right. The purpose is to prevent generating incomplete code that can not be compiled. The issue arised with the @@ -36,6 +26,9 @@ core/ BindingFactoryPlugin) from the Binding Factory. In this case, the extended class is ServiceReference and the identifier B clashes with the one from BindingFactoryPlugin. +* provide a command line option for generating proxy (interface and interceptor) + implementations similar to the parameters + available for the MOJO. examples/advanced/ * add an example which uses the julia-fraclet module developed by Marc diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java index f0e1cc9a2b..6fc64fb35e 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java @@ -508,8 +508,7 @@ public class Juliac { * Generate the source code for the specified membrane descriptor. * * @param controllerDesc the membrane descriptor - * @return the source code generator which has been used to generate the - * membrane implementation + * @return the source code generator * @throws IllegalArgumentException if no source code generator is suitable */ public FCSourceCodeGeneratorItf generate( Object controllerDesc ) @@ -523,13 +522,32 @@ public class Juliac { return fcscg; } + /** + * Generate the source code for the specified proxy interface and membrane + * descriptor. + * + * @param signature the interface signature + * @param controllerDesc the membrane descriptor + * @return the source code generator + * @throws IllegalArgumentException if no source code generator is suitable + */ + public FCSourceCodeGeneratorItf generateProxiesImpl( + String signature, Object controllerDesc ) + throws IOException, IllegalArgumentException { + + String ctrlDesc = (String) controllerDesc; + FCSourceCodeGeneratorItf fcscg = getFCSourceCodeGenerator(ctrlDesc); + fcscg.generateProxiesImpl(signature,controllerDesc); + return fcscg; + } + /** * Generate the source code for the specified component. * * @param type the component type * @param controllerDesc the controller descriptor * @param contentDesc the content descriptor - * @return the initializer class generator for this component + * @return the initializer class generator * @since 2.2.4 * @throws IllegalArgumentException if no source code generator is suitable */ diff --git a/juliac/examples/advanced/foobar-cases/generate-proxies/README.txt b/juliac/examples/advanced/foobar-cases/generate-proxies/README.txt new file mode 100644 index 0000000000..c51991bd31 --- /dev/null +++ b/juliac/examples/advanced/foobar-cases/generate-proxies/README.txt @@ -0,0 +1,3 @@ +Test code generation for a specified interface signature and controller +descriptor. +Feature introduced in Juliac 2.3.1. diff --git a/juliac/examples/advanced/foobar-cases/generate-proxies/pom.xml b/juliac/examples/advanced/foobar-cases/generate-proxies/pom.xml new file mode 100644 index 0000000000..0038926d05 --- /dev/null +++ b/juliac/examples/advanced/foobar-cases/generate-proxies/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + + + org.objectweb.fractal.juliac + juliac-parent + 2.3.1-SNAPSHOT + + + org.objectweb.fractal.juliac.examples + generate-proxies + jar + Juliac Example Generate Proxies + + + + + + + org.objectweb.fractal.juliac + juliac-runtime + ${project.version} + + + + + + + + + + org.objectweb.fractal.juliac + maven-juliac-plugin + ${project.version} + + + juliac-compile + generate-sources + compile + + + + OO + src/main/java + org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources + + + example.hw.Service + primitive + + + false + + + + + + + diff --git a/juliac/examples/advanced/foobar-cases/generate-proxies/src/main/java/example/hw/Service.java b/juliac/examples/advanced/foobar-cases/generate-proxies/src/main/java/example/hw/Service.java new file mode 100644 index 0000000000..7af7888cea --- /dev/null +++ b/juliac/examples/advanced/foobar-cases/generate-proxies/src/main/java/example/hw/Service.java @@ -0,0 +1,5 @@ +package example.hw; + +public interface Service { + void print(String msg); +} \ No newline at end of file diff --git a/juliac/examples/advanced/foobar-cases/pom.xml b/juliac/examples/advanced/foobar-cases/pom.xml index 2ad5714c6b..dd0bf490cf 100644 --- a/juliac/examples/advanced/foobar-cases/pom.xml +++ b/juliac/examples/advanced/foobar-cases/pom.xml @@ -20,6 +20,7 @@ generate-in-jar + generate-proxies graceful-exit helloworld-generate-test-sources helloworld-src-in-jar diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java index 9706e90124..a2e5a3db9e 100644 --- a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java @@ -178,6 +178,14 @@ implements JuliacMojoItf { */ private List components; + /** + * The proxies which are to be compiled with Juliac. + * + * @parameter + * @since 2.3.1 + */ + private List proxies; + /** *

* Juliac optional modules (plugins). Each module is represented by an @@ -778,6 +786,18 @@ implements JuliacMojoItf { } } + /* + * Code generation for proxies. + */ + if( proxies != null ) { + for (Proxy proxy : proxies) { + logger.info(proxy+"..."); + String signature = proxy.getSignature(); + Object controllerDesc = proxy.getControllerDesc(); + jc.generateProxiesImpl(signature,controllerDesc); + } + } + /* * Compile generated code if requested. */ diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Proxy.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Proxy.java new file mode 100644 index 0000000000..de7813fb93 --- /dev/null +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/Proxy.java @@ -0,0 +1,68 @@ +/*** + * Juliac + * Copyright (C) 2011 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: fractal@ow2.org + * + * Author: Lionel Seinturier + */ + +package org.objectweb.fractal.juliac; + + +/** + * This class implements the configuration parameters for the tag of the + * Juliac MOJO. The tag specifies the interface signature and the + * controller descriptor whose code is to be generated by Juliac. + * + * @author Lionel Seinturier + * @since 2.3.1 + */ +public class Proxy { + + /** + * The interface signature. + * + * @parameter + */ + private String signature; + + /** + * The controller descriptor. + * + * @parameter + */ + private String controllerDesc; + + + // --------------------------------------------------------------------- + // Getters + // --------------------------------------------------------------------- + + public String getSignature() { + return Utils.trimHeadingAndTrailingBlanks(signature); + } + + public String getControllerDesc() { + return Utils.trimHeadingAndTrailingBlanks(controllerDesc); + } + + @Override + public String toString() { + return signature+':'+controllerDesc; + } +} -- GitLab From c4778b5c4d66a23a2431468cc09e8c4a1a51c595 Mon Sep 17 00:00:00 2001 From: Christophe Demarey Date: Wed, 2 Mar 2011 17:09:38 +0000 Subject: [PATCH 06/24] Switch to CXF 3.3.3 --- fractal-bf/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal-bf/pom.xml b/fractal-bf/pom.xml index 0d51171acf..17444180d0 100644 --- a/fractal-bf/pom.xml +++ b/fractal-bf/pom.xml @@ -45,7 +45,7 @@ ${basedir}/src/site ${user.name} - 2.3.0 + 2.3.3 2.2.3 1.1.2 2.5.2 -- GitLab From c6d66a27ac2934afebaeb95f7fe9b27c70b39572 Mon Sep 17 00:00:00 2001 From: Philippe Merle Date: Wed, 2 Mar 2011 18:03:44 +0000 Subject: [PATCH 07/24] Updated to Apache CXF 2.3.3. --- fractal-bf/RELEASE_NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal-bf/RELEASE_NOTES.txt b/fractal-bf/RELEASE_NOTES.txt index 3f09ae2f8d..eb4292deb4 100644 --- a/fractal-bf/RELEASE_NOTES.txt +++ b/fractal-bf/RELEASE_NOTES.txt @@ -13,7 +13,7 @@ Planned for future versions of the Fractal-BF Fractal-BF 0.9 -------------- -* update dependencies: Apache CXF 2.3.0 +* update dependencies: Apache CXF 2.3.3 Fractal-BF 0.8 -------------- -- GitLab From 7a96f4b58e601ee18a55e633cfa8f5f5ccd971f1 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Sun, 6 Mar 2011 15:00:05 +0000 Subject: [PATCH 08/24] Documenting TODO. --- juliac/TODO.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/juliac/TODO.txt b/juliac/TODO.txt index cd5241e734..b506530bfa 100644 --- a/juliac/TODO.txt +++ b/juliac/TODO.txt @@ -1,4 +1,7 @@ core/ +* support multiple ADL parsers. The feature can be used for example with Tinfi + tests to generate code for components that are either defined in ADL files or + with Tinfilet. * dump generated files to disk only when one is sure that the generation process is over and everything went right. The purpose is to prevent generating incomplete code that can not be compiled. The issue arised with the -- GitLab From a378085b5b5ded86d3b90d95c3a11546e8aacf30 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 8 Mar 2011 07:14:19 +0000 Subject: [PATCH 09/24] Remove no longer needed method. --- .../juliac/opt/FCSourceCodeGenerator.java | 19 ------------------- .../juliac/opt/FCSourceCodeGeneratorItf.java | 7 ------- 2 files changed, 26 deletions(-) diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java index 69cdaaa799..d6b833e17d 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java @@ -171,25 +171,6 @@ implements FCSourceCodeGeneratorItf { return mloader; } - /** - * Add or register the specified membrane loader with this generator. - * - * @since 2.3 - */ - public void addMembraneLoader( MembraneLoaderItf loader ) { - - /* - * This method is not relevant in the general case since the management - * of the membrane loader is a matter of private affair for this - * generator. - * - * This method is implemented by the Tinfi optimization level source - * code generator. - */ - - throw new UnsupportedOperationException(); - } - /** * Return true if the current source code generator handles the * specified controller descriptor. diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java index a8b5d851fc..4d49345e4b 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java @@ -75,13 +75,6 @@ public interface FCSourceCodeGeneratorItf { */ public MembraneLoaderItf getMembraneLoader(); - /** - * Add or register the specified membrane loader with this generator. - * - * @since 2.3 - */ - public void addMembraneLoader( MembraneLoaderItf loader ); - /** * Test whether the current source code generator accepts the specified * controller descriptor. -- GitLab From 7b0b29d58df2ecc1b99bc71dd35ccd3047c32fc3 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 8 Mar 2011 07:14:33 +0000 Subject: [PATCH 10/24] Improve CoR pattern implementation. --- .../juliac/conf/MembraneLoaderCoR.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneLoaderCoR.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneLoaderCoR.java index 254f0fd301..c1bf4270b5 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneLoaderCoR.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneLoaderCoR.java @@ -39,21 +39,13 @@ import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException; * @author Lionel Seinturier * @since 2.3 */ -public class MembraneLoaderCoR implements MembraneLoaderItf { +public class MembraneLoaderCoR extends ArrayList +implements MembraneLoaderItf { - private List delegates = - new ArrayList(); - - public void add( MembraneLoaderItf delegate ) { - delegates.add(delegate); - } - - public void add( int index, MembraneLoaderItf delegate ) { - delegates.add(index,delegate); - } + private static final long serialVersionUID = -7762925777407239430L; public boolean containsKey( String ctrlDesc ) { - for (MembraneLoaderItf delegate : delegates) { + for (MembraneLoaderItf delegate : this) { if( delegate.containsKey(ctrlDesc) ) { return true; } @@ -64,9 +56,9 @@ public class MembraneLoaderCoR implements MembraneLoaderItf { public InterfaceType[] getMembraneType( ComponentType ct, String ctrlDesc ) throws NoSuchControllerDescriptorException { - String[] msgs = new String[delegates.size()]; - for (int i = 0; i < delegates.size(); i++) { - MembraneLoaderItf delegate = delegates.get(i); + String[] msgs = new String[size()]; + for (int i = 0; i < size(); i++) { + MembraneLoaderItf delegate = get(i); try { return delegate.getMembraneType(ct,ctrlDesc); } @@ -83,9 +75,9 @@ public class MembraneLoaderCoR implements MembraneLoaderItf { ComponentType ct, String ctrlDesc ) throws NoSuchControllerDescriptorException { - String[] msgs = new String[delegates.size()]; - for (int i = 0; i < delegates.size(); i++) { - MembraneLoaderItf delegate = delegates.get(i); + String[] msgs = new String[size()]; + for (int i = 0; i < size(); i++) { + MembraneLoaderItf delegate = get(i); try { return delegate.getCtrlImplLayers(ct,ctrlDesc); } @@ -102,9 +94,9 @@ public class MembraneLoaderCoR implements MembraneLoaderItf { ComponentType ct, String ctrlDesc ) throws NoSuchControllerDescriptorException { - String[] msgs = new String[delegates.size()]; - for (int i = 0; i < delegates.size(); i++) { - MembraneLoaderItf delegate = delegates.get(i); + String[] msgs = new String[size()]; + for (int i = 0; i < size(); i++) { + MembraneLoaderItf delegate = get(i); try { return delegate.getInterceptorClassGeneratorName(ct,ctrlDesc); } @@ -121,9 +113,9 @@ public class MembraneLoaderCoR implements MembraneLoaderItf { ComponentType ct, String ctrlDesc ) throws NoSuchControllerDescriptorException { - String[] msgs = new String[delegates.size()]; - for (int i = 0; i < delegates.size(); i++) { - MembraneLoaderItf delegate = delegates.get(i); + String[] msgs = new String[size()]; + for (int i = 0; i < size(); i++) { + MembraneLoaderItf delegate = get(i); try { return delegate.getInterceptorSourceCodeGeneratorNames(ct,ctrlDesc); } -- GitLab From 3b130a84945493a59c11709802b113910e6b5134 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Fri, 11 Mar 2011 14:46:57 +0000 Subject: [PATCH 11/24] New feature: several alternative ADL parsers can be specified with the and --adlParsers options when generating code. --- juliac/RELEASE_NOTES.txt | 1 + juliac/TODO.txt | 3 - .../org/objectweb/fractal/juliac/Juliac.java | 181 +++++++++++------- .../fractal/juliac/conf/ADLParser.java | 11 ++ .../fractal/juliac/conf/JuliacConfig.java | 84 ++++++-- .../advanced/mindadl/helloworld/pom.xml | 6 +- .../advanced/ultra-merge/comanche/pom.xml | 2 +- .../ultra-merge/cosmos-helloworld/pom.xml | 2 +- .../advanced/ultra-merge/helloworld/pom.xml | 2 +- .../src/main/java/test/ComancheTestCase.java | 5 +- .../src/main/java/test/CycleTestCase.java | 5 +- .../main/java/test/HelloWorldTestCase.java | 5 +- .../osgi/FCActivatorSourceCodeGenerator.java | 4 +- .../fractal/juliac/AbstractJuliacMojo.java | 33 ++-- .../comp/FCCompCtrlSourceCodeGenerator.java | 4 +- .../FCUltraCompSourceCodeGenerator.java | 6 +- 16 files changed, 243 insertions(+), 111 deletions(-) diff --git a/juliac/RELEASE_NOTES.txt b/juliac/RELEASE_NOTES.txt index 06f7ecf14a..fdcdb415e7 100755 --- a/juliac/RELEASE_NOTES.txt +++ b/juliac/RELEASE_NOTES.txt @@ -5,6 +5,7 @@ Juliac 2.3.1 * Juliet annotation definitions moved to Fraclet * new service for generating proxy (interface and interceptor) implementations (requested by Remi M and Philippe) +* several alternative ADL parsers can be specified when generating code Juliac 2.3 diff --git a/juliac/TODO.txt b/juliac/TODO.txt index b506530bfa..cd5241e734 100644 --- a/juliac/TODO.txt +++ b/juliac/TODO.txt @@ -1,7 +1,4 @@ core/ -* support multiple ADL parsers. The feature can be used for example with Tinfi - tests to generate code for components that are either defined in ADL files or - with Tinfilet. * dump generated files to disk only when one is sure that the generation process is over and everything went right. The purpose is to prevent generating incomplete code that can not be compiled. The issue arised with the diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java index 6fc64fb35e..0875eb883e 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java @@ -166,12 +166,18 @@ public class Juliac { jconf.setCompiler(compiler); } - String adlParser = cla.getOptionValue(CmdLineOptions.ADLPARSER); - if( adlParser != null ) { - jconf.setADLParser(adlParser); + String s = cla.getOptionValue(CmdLineOptions.ADLPARSER); + String[] adlParsers = s==null ? new String[0] : s.split(":"); + if( adlParsers.length == 0 ) { + ADLParser defaultParser = ADLParser.getDefaultADLParser(); + jconf.addADLParser(defaultParser); } + else { + jconf.addADLParserNames(adlParsers); + } + jconf.loadADLParsers(); - String s = cla.getOptionValue(CmdLineOptions.SRCS); + s = cla.getOptionValue(CmdLineOptions.SRCS); String[] srcs = s==null ? new String[0] : s.split(";"); jconf.addSrcs(srcs); @@ -267,10 +273,10 @@ public class Juliac { * file may be either an ADL descriptor, a membrane descriptor or a * list of component decriptors. */ - boolean b = jc.acceptADLDesc(file); - if(b) { + ADLParser ap = jc.acceptADLDesc(file); + if( ap != null ) { // file is an ADL descriptor - jc.generate(file,file); + jc.generate(ap,file,file); } else { FCSourceCodeGeneratorItf fcscg = jc.acceptCtrlDesc(file); @@ -326,7 +332,7 @@ public class Juliac { logger.info("Options:"); logger.info(""); - logger.info(" --adlparser : the ADL parser (default: FRACTAL_ADL)"); + logger.info(" --adlparser : the ADL parsers (default: FRACTAL_ADL)"); logger.info(" --compiler : Java compiler (default: JDT)"); logger.info(" --gensrc

: directory for generated source code (default: target/generated-sources/juliac)"); logger.info(" --genclass : directory for compiled code (default: target/classes)"); @@ -348,6 +354,7 @@ public class Juliac { logger.info("Details:"); logger.info(" is a semicolon-separated list of directories or jar files"); + logger.info(" is a colon-separated list of ADL parser class names"); logger.info(" is:"); logger.info(" - either one of the predefined values:"); @@ -432,41 +439,63 @@ public class Juliac { // ---------------------------------------------------------------------- /** - * Test whether the ADL parser accepts the specified ADL descriptor. + * Test whether one of the registered ADL parsers accepts the specified ADL + * descriptor. * * @param adl the fully-qualified name of the ADL descriptor - * @return true if the ADL parser accepts the specified ADL - * descriptor + * @return the ADL parser which accepts the specified ADL descriptor or + * null if none of the registered ADL parsers + * accept the specified ADL descriptor * @since 2.2.5 */ - public boolean acceptADLDesc( String adl ) { - try { - ADLParserSupportItf adlParser = getADLParser(); - boolean b = adlParser.acceptADLDesc(adl); - return b; - } - catch( JuliacRuntimeException jre ) { - /* - * In case a custom ADL parser has been specified, rethrow the - * exception if the specified ADL parser class can not be loaded. - * - * If one of the predefined ADL parsers (Fractal ADL or MIND ADL) - * can not be loaded, this means that the corresponding jar is not - * in the classpath. In this case, we assume this is a desired - * behavior (for example when generating code for membranes, there - * is no need to have the artefacts corresponding to predefined ADL - * parsers in the classpath.) - */ - Throwable cause = jre.getCause(); - if( cause instanceof ClassNotFoundException ) { - JuliacConfig jconf = getJuliacConfig(); - ADLParser ap = jconf.getADLParser(); - if( ap.equals(ADLParser.CUSTOM) ) { - throw jre; - } - } - return false; - } + public ADLParser acceptADLDesc( String adl ) { + + JuliacConfig jconf = getJuliacConfig(); + List adlParsers = jconf.getADLParsers(); + + for (ADLParser adlParser : adlParsers) { + ADLParserSupportItf supportItf = adlParser.getSupportItf(); + + if( supportItf == null ) { + /* + * supportItf can be null for the default ADL parser. See the + * comment in JuliacConfig#loadADLParsers() for the rationale. + */ + ADLParser defaultParser = ADLParser.getDefaultADLParser(); + if( ! adlParser.equals(defaultParser) ) { + String name = adlParser.getClassName(); + throw new JuliacRuntimeException( + new ClassNotFoundException(name)); + } + } + else { + boolean b = supportItf.acceptADLDesc(adl); + if(b) { + return adlParser; + } + } + } + + return null; + } + + /** + * Return the registered ADL parsers that accepts the specified ADL + * descriptor. + * + * @param adl the fully-qualified name of the ADL descriptor + * @return the ADL parser which accepts the specified ADL descriptor or + * @throws IOException if none of the registered ADL parsers accept the + * specified ADL descriptor + * @since 2.3.1 + */ + public ADLParser getADLDesc( String adl ) throws IOException { + ADLParser adlParser = acceptADLDesc(adl); + if( adlParser == null ) { + String msg = "No such ADL parser for: "+adl; + throw new IOException(msg); + } + return adlParser; } /** @@ -474,12 +503,41 @@ public class Juliac { * * @param adl the fully-qualified name of the ADL descriptor * @param targetname the fully-qualified name of the factory class + * @since 2.3.1 */ public void generate( String adl, String targetname ) throws IOException { - ADLParserSupportItf adlParser = getADLParser(); + + ADLParser adlParser = getADLDesc(adl); + ADLParserSupportItf supportItf = adlParser.getSupportItf(); + String rootedName = getRootedClassName(targetname); + + JuliacConfig jconf = getJuliacConfig(); + Logger logger = jconf.getLogger(); + logger.info("[ADLParser: "+supportItf.getClass().getName()+"]"); + + supportItf.generate(adl,rootedName,null); + } + + /** + * Generate the source code of a factory class for the specified ADL. + * + * @param adlParser the ADL parser for generating the factory class + * @param adl the fully-qualified name of the ADL descriptor + * @param targetname the fully-qualified name of the factory class + * @since 2.3.1 + */ + private void generate( ADLParser adlParser, String adl, String targetname ) + throws IOException { + + ADLParserSupportItf supportItf = adlParser.getSupportItf(); String rootedName = getRootedClassName(targetname); - adlParser.generate(adl,rootedName,null); + + JuliacConfig jconf = getJuliacConfig(); + Logger logger = jconf.getLogger(); + logger.info("[ADLParser: "+supportItf.getClass().getName()+"]"); + + supportItf.generate(adl,rootedName,null); } /** @@ -518,7 +576,12 @@ public class Juliac { ComponentType ct = new BasicComponentType(new BasicInterfaceType[0]); FCSourceCodeGeneratorItf fcscg = getFCSourceCodeGenerator(ctrlDesc); - fcscg.generateMembraneImpl(ct,ctrlDesc,null); + + JuliacConfig jconf = getJuliacConfig(); + Logger logger = jconf.getLogger(); + logger.info("[Generator: "+fcscg.getClass().getName()+"]"); + + fcscg.generateMembraneImpl(ct,ctrlDesc,null); return fcscg; } @@ -537,6 +600,11 @@ public class Juliac { String ctrlDesc = (String) controllerDesc; FCSourceCodeGeneratorItf fcscg = getFCSourceCodeGenerator(ctrlDesc); + + JuliacConfig jconf = getJuliacConfig(); + Logger logger = jconf.getLogger(); + logger.info("[Generator: "+fcscg.getClass().getName()+"]"); + fcscg.generateProxiesImpl(signature,controllerDesc); return fcscg; } @@ -554,8 +622,14 @@ public class Juliac { public InitializerClassGenerator generate( Type type, Object controllerDesc, Object contentDesc ) throws IOException, IllegalArgumentException { - FCSourceCodeGeneratorItf fcscg = + + FCSourceCodeGeneratorItf fcscg = getFCSourceCodeGenerator(controllerDesc); + + JuliacConfig jconf = getJuliacConfig(); + Logger logger = jconf.getLogger(); + logger.info("[Generator: "+fcscg.getClass().getName()+"]"); + InitializerClassGenerator icg = fcscg.generate(type,controllerDesc,contentDesc); return icg; @@ -1032,26 +1106,6 @@ public class Juliac { return compiler; } - /** - * Return the reference of the ADL parser service. - */ - public ADLParserSupportItf getADLParser() { - - if( adlParser == null ) { - - JuliacConfig jconf = getJuliacConfig(); - ADLParser adlParser = jconf.getADLParser(); - String adlParserClassName = adlParser.getClassName(); - - String cnfeMessage = - "ADL Parser support class can not be found: "+adlParser; - this.adlParser = loadAndInstantiate(adlParserClassName,cnfeMessage); - this.adlParser.init(this); - } - - return adlParser; - } - /** * Return the reference of the Spoon service. * @@ -1083,7 +1137,6 @@ public class Juliac { } private CompileSupportItf compiler; - private ADLParserSupportItf adlParser; private SpoonSupportItf spoon; /** diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java index 24a21d4373..6ea62ad2a4 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java @@ -23,6 +23,8 @@ package org.objectweb.fractal.juliac.conf; +import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; + /** * The default ADL parsers registered with Juliac. * @@ -78,6 +80,15 @@ public enum ADLParser { this.className = className; } + /** + * @since 2.3.1 + */ + public ADLParserSupportItf getSupportItf() { return support; } + public void setSupportItf( ADLParserSupportItf support ) { + this.support = support; + } + private ADLParserSupportItf support; + /** * Return the default ADL parser. */ diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java index 28b7595e57..78db03fe78 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java @@ -45,6 +45,7 @@ import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.SourceFile; import org.objectweb.fractal.juliac.Utils; import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; +import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; @@ -157,11 +158,11 @@ public class JuliacConfig { private Compiler compiler = Compiler.getDefaultCompiler(); /** - * The ADL parser. - * @since 2.2.4 + * The ADL parser class names. + * @since 2.3.1 */ - private ADLParser adlParser = ADLParser.getDefaultADLParser(); - + private List adlParsers = new ArrayList(); + /** * The controller descriptor prefixes for each optimization level name * stored in {@link #optLevelNames}. The value is null if no @@ -397,25 +398,84 @@ public class JuliacConfig { this.compiler = compiler; } - public ADLParser getADLParser() { return adlParser; } - public void setADLParser( String adlParser ) { - try { - this.adlParser = ADLParser.valueOf(adlParser); + + // ---------------------------------------------------------------------- + // Setter/getter methods for ADL parsers + // ---------------------------------------------------------------------- + + /** + * @since 2.3.1 + */ + public void addADLParserNames( String[] adlParserNames ) { + for (String adlParserName : adlParserNames) { + addADLParserName(adlParserName); + } + } + + /** + * @since 2.3.1 + */ + public void addADLParserName( String adlParserName ) { + ADLParser adlParser = null; + try { + adlParser = ADLParser.valueOf(adlParserName); } catch( IllegalArgumentException iae ) { /* * Assume this is the fully-qualified name of a class which * implements ADLParserSupportItf. */ - this.adlParser = ADLParser.CUSTOM; - this.adlParser.setClassName(adlParser); + adlParser = ADLParser.CUSTOM; + adlParser.setClassName(adlParserName); } + adlParsers.add(adlParser); } - public void setADLParser( ADLParser adlParser ) { - this.adlParser = adlParser; + + /** + * @since 2.3.1 + */ + public void addADLParser( ADLParser adlParser ) { + adlParsers.add(adlParser); } + /** + * @since 2.3.1 + */ + public void loadADLParsers() throws ClassNotFoundException { + for (ADLParser adlParser : adlParsers) { + String clname = adlParser.getClassName(); + Class cl = null; + try { + cl = load(clname); + ADLParserSupportItf parserItf = instantiate(cl); + parserItf.init(jc); + adlParser.setSupportItf(parserItf); + } + catch( ClassNotFoundException cnfe ){ + ADLParser defaultParser = ADLParser.getDefaultADLParser(); + if( ! adlParser.equals(defaultParser) ) { + /* + * It may happen that we don't need any ADL parser because, + * for example, we are generating the code for membranes + * only. In this case, the module containing the default ADL + * parser class is not required in the class path and cannot + * be loaded. Yet, this is not an error and we do not need + * to report a ClassNotFoundException. + */ + throw cnfe; + } + } + } + } + + /** + * @since 2.3.1 + */ + public List getADLParsers() { + return adlParsers; + } + // ---------------------------------------------------------------------- // Setter/getter methods for optimization level source code generators // ---------------------------------------------------------------------- diff --git a/juliac/examples/advanced/mindadl/helloworld/pom.xml b/juliac/examples/advanced/mindadl/helloworld/pom.xml index d61af259ea..46eff125dc 100644 --- a/juliac/examples/advanced/mindadl/helloworld/pom.xml +++ b/juliac/examples/advanced/mindadl/helloworld/pom.xml @@ -49,14 +49,12 @@ juliac-compile generate-sources - - compile - + compile src/main/java - MIND_ADL + MIND_ADL OO org.objectweb.fractal.julia:julia-mixins:${julia.version}:sources example.hw.HelloWorld diff --git a/juliac/examples/advanced/ultra-merge/comanche/pom.xml b/juliac/examples/advanced/ultra-merge/comanche/pom.xml index 7c221d7729..dcc7535812 100644 --- a/juliac/examples/advanced/ultra-merge/comanche/pom.xml +++ b/juliac/examples/advanced/ultra-merge/comanche/pom.xml @@ -31,7 +31,7 @@ - org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator + org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator src/main/java example.comanche.Comanche diff --git a/juliac/examples/advanced/ultra-merge/cosmos-helloworld/pom.xml b/juliac/examples/advanced/ultra-merge/cosmos-helloworld/pom.xml index fc0b929b5c..bd0f87fd27 100644 --- a/juliac/examples/advanced/ultra-merge/cosmos-helloworld/pom.xml +++ b/juliac/examples/advanced/ultra-merge/cosmos-helloworld/pom.xml @@ -98,7 +98,7 @@ - org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator + org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator src/main/java cosmos:cosmos-core:${cosmos.version}:sources diff --git a/juliac/examples/advanced/ultra-merge/helloworld/pom.xml b/juliac/examples/advanced/ultra-merge/helloworld/pom.xml index ff7677f453..cc5af519e4 100644 --- a/juliac/examples/advanced/ultra-merge/helloworld/pom.xml +++ b/juliac/examples/advanced/ultra-merge/helloworld/pom.xml @@ -39,7 +39,7 @@ - org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator + org.objectweb.fractal.juliac.opt.ultramerge.FCUltraMergeSourceCodeGenerator src/main/java example.hw.HelloWorld diff --git a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/ComancheTestCase.java b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/ComancheTestCase.java index 807d199e9d..e86d6fb88e 100644 --- a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/ComancheTestCase.java +++ b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/ComancheTestCase.java @@ -53,7 +53,7 @@ public class ComancheTestCase { private Juliac jc; @Before - public void setUp() throws IOException { + public void setUp() throws IOException, ClassNotFoundException { String prop = System.getProperty("basedir"); File baseDir = prop == null ? new File(".") : new File(prop); @@ -66,7 +66,8 @@ public class ComancheTestCase { ADLParser adlParser = ADLParser.CUSTOM; adlParser.setClassName(FCUltraMergeSourceCodeGenerator.class.getName()); - jconf.setADLParser(adlParser); + jconf.addADLParser(adlParser); + jconf.loadADLParsers(); } @After diff --git a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/CycleTestCase.java b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/CycleTestCase.java index 710eff85cf..bb81b4e3fb 100644 --- a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/CycleTestCase.java +++ b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/CycleTestCase.java @@ -48,7 +48,7 @@ public class CycleTestCase { private Juliac jc; @Before - public void setUp() throws IOException { + public void setUp() throws IOException, ClassNotFoundException { String prop = System.getProperty("basedir"); File baseDir = prop == null ? new File(".") : new File(prop); @@ -61,7 +61,8 @@ public class CycleTestCase { ADLParser adlParser = ADLParser.CUSTOM; adlParser.setClassName(FCUltraMergeSourceCodeGenerator.class.getName()); - jconf.setADLParser(adlParser); + jconf.addADLParser(adlParser); + jconf.loadADLParsers(); } @After diff --git a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/HelloWorldTestCase.java b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/HelloWorldTestCase.java index 7ac6c3e8f7..eb5fea25f6 100644 --- a/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/HelloWorldTestCase.java +++ b/juliac/examples/advanced/ultra-merge/tests/src/main/java/test/HelloWorldTestCase.java @@ -48,7 +48,7 @@ public class HelloWorldTestCase { private Juliac jc; @Before - public void setUp() throws IOException { + public void setUp() throws IOException, ClassNotFoundException { String prop = System.getProperty("basedir"); File baseDir = prop == null ? new File(".") : new File(prop); @@ -61,7 +61,8 @@ public class HelloWorldTestCase { ADLParser adlParser = ADLParser.CUSTOM; adlParser.setClassName(FCUltraMergeSourceCodeGenerator.class.getName()); - jconf.setADLParser(adlParser); + jconf.addADLParser(adlParser); + jconf.loadADLParsers(); } @After diff --git a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java index cc740114ad..46ae8dcbff 100644 --- a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java +++ b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java @@ -27,6 +27,7 @@ import java.io.IOException; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.juliac.adl.FractalADLSupportImpl; +import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.desc.ComponentDesc; import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; @@ -49,7 +50,8 @@ public class FCActivatorSourceCodeGenerator extends FractalADLSupportImpl { /* * Generate the activator class. */ - ADLParserSupportItf fractaladl = jc.getADLParser(); + ADLParser adlParser = jc.getADLDesc(adl); + ADLParserSupportItf fractaladl = adlParser.getSupportItf(); ComponentDesc cdesc = fractaladl.parse(adl,context); ComponentType ct = cdesc.getCT(); String activatorClassName = adl+"Activator"; diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java index a2e5a3db9e..440be44cc5 100644 --- a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java @@ -53,6 +53,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.objectweb.fractal.api.Type; import org.objectweb.fractal.api.factory.InstantiationException; +import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; @@ -229,14 +230,14 @@ implements JuliacMojoItf { private String compiler; /** - * The ADL parser. The legal values for this parameter are defined by + * The ADL parsers. The legal values for this parameter are defined by * {@link org.objectweb.fractal.juliac.conf.ADLParser}. The default value is * FRACTAL_ADL. * * @parameter * @since 2.2.4 */ - private String adlParser; + private List adlParsers; /** * false to prevent compilation of input code. @@ -521,18 +522,19 @@ implements JuliacMojoItf { } /* - * The ADL parser. + * The ADL parsers. */ - if( adlParser == null ) { - // Retrieve the default value - adlParser = jconf.getADLParser().getClassName(); + if( adlParsers == null || adlParsers.size() == 0 ) { + ADLParser defaultParser = ADLParser.getDefaultADLParser(); + jconf.addADLParser(defaultParser); } else { - String adlParser = - Utils.trimHeadingAndTrailingBlanks(this.adlParser); - if( adlParser.length() != 0 ) { - jconf.setADLParser(adlParser); - } + for (String adlParser : adlParsers) { + String s = Utils.trimHeadingAndTrailingBlanks(adlParser); + if( s.length() != 0 ) { + jconf.addADLParserName(adlParser); + } + } } /* @@ -746,14 +748,15 @@ implements JuliacMojoItf { } /* - * Load optimization level, interceptor class and source code - * generators. This needs to be done after the class loader has been set - * and the input code has been compiled as some generators may be - * included in the current project. + * Load optimization level generators, interceptor class generators, + * source code generators, and ADL parsers. This must be done after the + * class loader has been set and the input code has been compiled as + * some generators or parsers may be included in the current project. */ jconf.loadOptLevels(); iclgs.load(); iscgs.load(); + jconf.loadADLParsers(); /* * Code generation for membranes. diff --git a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java index ba14235a34..ff309071bd 100644 --- a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java +++ b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java @@ -36,6 +36,7 @@ import org.objectweb.fractal.julia.loader.BasicLoader; import org.objectweb.fractal.julia.loader.Tree; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.conf.JuliacInterceptorSourceCodeGeneratorMap; @@ -238,7 +239,8 @@ extends FCSourceCodeGenerator> { * Generate the factory for the membrane. */ String adl = getADLDesc(ctrlDesc); - ADLParserSupportItf fadl = jc.getADLParser(); + ADLParser adlParser = jc.getADLDesc(adl); + ADLParserSupportItf fadl = adlParser.getSupportItf(); fadl.generate(adl,classname,cclcontext); /* diff --git a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java index 4ae013066d..b5b5b36363 100644 --- a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java +++ b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java @@ -39,7 +39,7 @@ import org.objectweb.fractal.julia.type.BasicComponentType; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; -import org.objectweb.fractal.juliac.adl.FractalADLSupportImpl; +import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.conf.JuliacGeneratorMap; @@ -55,6 +55,7 @@ import org.objectweb.fractal.juliac.desc.SimpleMembraneDesc; import org.objectweb.fractal.juliac.opt.FCSourceCodeGenerator; import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; +import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; import org.objectweb.fractal.koch.control.interceptor.InterceptorController; @@ -397,8 +398,9 @@ extends FCSourceCodeGenerator { /* * Get and return the model of the membrane. */ - FractalADLSupportImpl fadl = (FractalADLSupportImpl) jc.getADLParser(); String adl = getADLDesc(ctrlDesc); + ADLParser adlParser = jc.getADLDesc(adl); + ADLParserSupportItf fadl = adlParser.getSupportItf(); ComponentDesc cdesc = fadl.parse(adl,context); return cdesc; } -- GitLab From 46170ea0ab780d7ee0902145873ea9840a21bb45 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Fri, 11 Mar 2011 20:33:46 +0000 Subject: [PATCH 12/24] Fix command line option name. --- .../java/org/objectweb/fractal/juliac/CmdLineOptions.java | 6 +++--- .../src/main/java/org/objectweb/fractal/juliac/Juliac.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/CmdLineOptions.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/CmdLineOptions.java index 7bb3e323ff..ba6628d3dd 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/CmdLineOptions.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/CmdLineOptions.java @@ -85,16 +85,16 @@ public enum CmdLineOptions { TARGET(JDKLevel.getVersions()), /** - * Java compiler to be used. + * Java compiler. * @since 2.2.3 */ COMPILER(null), /** - * ADL parser to be used. + * ADL parsers. * @since 2.2.4 */ - ADLPARSER(null), + ADLPARSERS(null), LOGLEVEL(null); diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java index 0875eb883e..d309ea9d92 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java @@ -166,7 +166,7 @@ public class Juliac { jconf.setCompiler(compiler); } - String s = cla.getOptionValue(CmdLineOptions.ADLPARSER); + String s = cla.getOptionValue(CmdLineOptions.ADLPARSERS); String[] adlParsers = s==null ? new String[0] : s.split(":"); if( adlParsers.length == 0 ) { ADLParser defaultParser = ADLParser.getDefaultADLParser(); @@ -332,7 +332,7 @@ public class Juliac { logger.info("Options:"); logger.info(""); - logger.info(" --adlparser : the ADL parsers (default: FRACTAL_ADL)"); + logger.info(" --adlparsers : the ADL parsers (default: FRACTAL_ADL)"); logger.info(" --compiler : Java compiler (default: JDT)"); logger.info(" --gensrc : directory for generated source code (default: target/generated-sources/juliac)"); logger.info(" --genclass : directory for compiled code (default: target/classes)"); -- GitLab From b391dfd02a6919054da41ce819cf81d274f626a0 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Sun, 20 Mar 2011 18:47:20 +0000 Subject: [PATCH 13/24] Move JulietLoader to juliac-core. --- juliac/core/pom.xml | 5 + .../fractal/juliac/conf/JuliacConfig.java | 13 +- .../fractal/juliac/conf/JulietLoader.java | 167 ++++++++++++ .../fractal/juliac/conf/MembraneHelper.java | 237 ++++++++++++++++++ .../juliac/opt/FCSourceCodeGenerator.java | 10 - .../juliac/opt/FCSourceCodeGeneratorItf.java | 9 - .../fractal/koch/factory/MPrimitiveImpl.java | 2 +- .../opt/ultramerge/FracletUltraMerge.java | 2 +- juliac/pom.xml | 2 +- 9 files changed, 424 insertions(+), 23 deletions(-) create mode 100644 juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JulietLoader.java create mode 100644 juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneHelper.java diff --git a/juliac/core/pom.xml b/juliac/core/pom.xml index e378b068e4..f68b42b7f6 100644 --- a/juliac/core/pom.xml +++ b/juliac/core/pom.xml @@ -24,6 +24,11 @@ julia-runtime ${julia.version} + + org.objectweb.fractal.fraclet.java + fraclet-annotations + ${fraclet.version} + org.objectweb.fractal.juliac diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java index 78db03fe78..975170b586 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java @@ -199,6 +199,7 @@ public class JuliacConfig { new JuliacInterceptorSourceCodeGeneratorMap(this); private ClassLoader classLoader; + private JulietLoader julietLoader; private CompilationRounds rounds; /** @@ -715,9 +716,19 @@ public class JuliacConfig { } // ---------------------------------------------------------------------- - // Setter/getter methods for loaders + // Setter/getter methods for loaders and compilation rounds // ---------------------------------------------------------------------- + /** + * @since 2.3.1 + */ + public JulietLoader getJulietLoader() { + if( julietLoader == null ) { + julietLoader = new JulietLoader(); + } + return julietLoader; + } + public CompilationRounds getCompilationRounds() { if( rounds == null ) { rounds = new CompilationRounds(this); diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JulietLoader.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JulietLoader.java new file mode 100644 index 0000000000..002559d12c --- /dev/null +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JulietLoader.java @@ -0,0 +1,167 @@ +/*** + * Juliac + * Copyright (C) 2011 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: fractal@ow2.org + * + * Author: Lionel Seinturier + */ + +package org.objectweb.fractal.juliac.conf; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.objectweb.fractal.api.type.ComponentType; +import org.objectweb.fractal.api.type.InterfaceType; +import org.objectweb.fractal.fraclet.extensions.Controller; +import org.objectweb.fractal.fraclet.types.Constants; +import org.objectweb.fractal.julia.type.BasicInterfaceType; +import org.objectweb.fractal.juliac.conf.MembraneLoaderItf; +import org.objectweb.fractal.juliac.desc.ControllerDesc; +import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException; + +/** + * A loader for membrane configuration data. Data is retrieved from {@link + * org.objectweb.fractal.fraclet.extensions.Membrane} annotated classes. + * + * This class implements the singleton pattern with the {@link #get()} method in + * order to enable to easily share it between {@link TinfiParserSupportImpl} and + * {@link org.ow2.frascati.tinfi.opt.oo.FCOOCtrlSourceCodeGenerator}. + * + * @author Lionel Seinturier + * @since 2.3.1 + */ +public class JulietLoader extends HashMap> +implements MembraneLoaderItf { + + private static final long serialVersionUID = 3490584715210564495L; + + /** + * Check that the specified value is a valid membrane definition before + * inserting it in the map. + * + * @throws IllegalArgumentException + * if the specified membrane definition is not valid + */ + @Override + public Class put( String ctrlDesc, Class cl ) + throws IllegalArgumentException { + MembraneHelper.check(cl); // may throw IllegalArgumentException + return super.put(ctrlDesc,cl); + } + + public boolean containsKey( String ctrlDesc ) { + return super.containsKey(ctrlDesc); + } + + public InterfaceType[] getMembraneType( ComponentType ct, String ctrlDesc ) + throws NoSuchControllerDescriptorException { + + if( ! containsKey(ctrlDesc) ) { + throw new NoSuchControllerDescriptorException(ctrlDesc); + } + + Class cl = get(ctrlDesc); + List fields = MembraneHelper.getControllerAnnotatedFields(cl); + + InterfaceType[] its = new InterfaceType[fields.size()]; + for (int i = 0; i < fields.size(); i++) { + Field field = fields.get(i); + Controller controller = field.getAnnotation(Controller.class); + String name = controller.name(); + String signature = field.getType().getName(); + its[i] = new BasicInterfaceType(name,signature,false,false,false); + } + + return its; + } + + public List getCtrlImplLayers( + ComponentType ct, String ctrlDesc ) + throws NoSuchControllerDescriptorException { + + if( ! containsKey(ctrlDesc) ) { + throw new NoSuchControllerDescriptorException(ctrlDesc); + } + + Class cl = get(ctrlDesc); + List fields = MembraneHelper.getControllerAnnotatedFields(cl); + List cdescs = new ArrayList(); + + for (Field field : fields) { + + Controller controller = field.getAnnotation(Controller.class); + String impl = controller.impl(); + if( impl.equals(Constants.EMPTY)) { + /* + * No impl() parameter specified in the @Controller annotation. + * Assume a default naming scheme based on the name of the type + * of the control interface extended with the membrane + * identifier, e.g. NameControllerMyPrimitive. + */ + Class rtype = field.getType(); + impl = rtype.getSimpleName()+ctrlDesc; + } + Class[] mixins = controller.mixins(); + List names = new ArrayList(); + for (Class mixin : mixins) { + String name = mixin.getName(); + names.add(name); + } + + ControllerDesc cdesc = new ControllerDesc(impl,names,null); + cdescs.add(cdesc); + } + + return cdescs; + } + + public String getInterceptorClassGeneratorName( + ComponentType ct, String ctrlDesc ) + throws NoSuchControllerDescriptorException { + + if( ! containsKey(ctrlDesc) ) { + throw new NoSuchControllerDescriptorException(ctrlDesc); + } + + Class cl = get(ctrlDesc); + Class generator = MembraneHelper.getGenerator(cl); + return generator.getName(); + } + + public String[] getInterceptorSourceCodeGeneratorNames( + ComponentType ct, String ctrlDesc ) + throws NoSuchControllerDescriptorException { + + if( ! containsKey(ctrlDesc) ) { + throw new NoSuchControllerDescriptorException(ctrlDesc); + } + + Class cl = get(ctrlDesc); + Class[] interceptors = MembraneHelper.getInterceptors(cl); + + String[] strs = new String[interceptors.length]; + for (int i = 0; i < interceptors.length; i++) { + strs[i] = interceptors[i].getName(); + } + + return strs; + } +} diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneHelper.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneHelper.java new file mode 100644 index 0000000000..c31cb053f9 --- /dev/null +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/MembraneHelper.java @@ -0,0 +1,237 @@ +/*** + * Juliac + * Copyright (C) 2011 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: fractal@ow2.org + * + * Author: Lionel Seinturier + */ + +package org.objectweb.fractal.juliac.conf; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.objectweb.fractal.fraclet.extensions.Controller; +import org.objectweb.fractal.fraclet.extensions.Membrane; +import org.objectweb.fractal.fraclet.types.Constants; + +/** + * Helper class for dealing with @{@link Membrane}-annotated classes. + * + * @author Lionel Seinturier + * @since 2.3.1 + */ +public class MembraneHelper { + + /** + * Check that the class associated with the specified + * @{@link Membrane}(controllerDesc=...) + * annotation references a membrane definition, i.e. a class that is + * annotated with + * @{@link Membrane}(desc="..."). + * + * @param jm the {@link Membrane} annotation + * @param name the name of the class annotated with {@link Membrane} + * @return the membrane definition + * @throws IllegalArgumentException + * if the referenced class is not a membrane definition + */ + public static Class getMembraneDef( Membrane jm, String name ) { + Class cl = jm.controllerDesc(); + Membrane mdef = cl.getAnnotation(Membrane.class); + if( mdef == null ) { + String msg = + "The "+cl.getName()+" membrane class specified in the "+ + "@Membrane(controllerDesc=...) annotation on the "+name+ + " class should be annotated with @Membrane(desc=\"...\")."; + throw new IllegalArgumentException(msg); + } + return cl; + } + + /** + * Check that the specified membrane definition is consistent. + */ + public static void check( Class cl ) throws IllegalArgumentException { + + // Check that the class is annotated with @Membrane + Membrane mdef = cl.getAnnotation(Membrane.class); + if( mdef == null ) { + String msg = "No @Membrane annotation on class "+cl.getName(); + throw new IllegalArgumentException(msg); + } + + /* + * Check that either the controller, template, controllerDesc, + * templateDesc parameters are set or the desc, generator, interceptors + * parameters are set. + */ + boolean isControllerSet = ! mdef.controller().equals(Constants.EMPTY); + boolean isTemplateSet = ! mdef.template().equals(Constants.EMPTY); + boolean isControllerDescSet = ! mdef.controllerDesc().equals(Constants.class); + boolean isTemplateDescSet = ! mdef.templateDesc().equals(Constants.class); + boolean isDescSet = ! mdef.desc().equals(Constants.EMPTY); + boolean isGeneratorSet = ! mdef.generator().equals(Constants.class); + boolean isInterceptorsSet = mdef.interceptors().length != 0; + + boolean first = + isControllerSet | isTemplateSet | isControllerDescSet | + isTemplateDescSet; + boolean second = isDescSet | isGeneratorSet | isInterceptorsSet; + if( first && second ) { + String msg = + "{controller,template,controllerDesc,templateDesc} on one side"+ + " and {desc,generator,interceptors} on the other side "+ + "cannot be set jointly in "+mdef+" for class "+cl.getName(); + throw new IllegalArgumentException(msg); + } + if( !first && !second ) { + String msg = + "Either {controller,template,controllerDesc,templateDesc} "+ + "or {desc,generator,interceptors} should be set in "+ + mdef+" for class "+cl.getName(); + throw new IllegalArgumentException(msg); + } + + /* + * Check that the inheritance hierarchy contains at least one @Membrane + * annotated class. + */ + List> classes = new ArrayList>(); + addSuperClasses(cl,classes); + boolean membraneAnnotated = false; + for (Class c : classes) { + Membrane m = c.getAnnotation(Membrane.class); + if( m != null ) { + membraneAnnotated = true; + break; + } + } + if( ! membraneAnnotated ) { + String msg = + "No @Membrane annotated class in the inheritance hierarchy of "+ + cl.getName(); + throw new IllegalArgumentException(msg); + } + } + + /** + * Return the generator class associated with the specified membrane + * definition. Return null if no generator class is defined. + */ + public static Class getGenerator( Class cl ) + throws IllegalStateException { + + List> classes = new ArrayList>(); + addSuperClasses(cl,classes); + + for (Class c : classes) { + Membrane mdef = c.getAnnotation(Membrane.class); + if( mdef != null ) { + Class generator = mdef.generator(); + if( ! generator.equals(Constants.class) ) { + return generator; + } + } + } + + // No generator specified + return null; + } + + /** + * Return the interceptor classes associated with the specified membrane + * definition. Return null if no interceptor class is defined. + */ + public static Class[] getInterceptors( Class cl ) + throws IllegalStateException { + + List> classes = new ArrayList>(); + addSuperClasses(cl,classes); + + for (Class c : classes) { + Membrane mdef = c.getAnnotation(Membrane.class); + if( mdef != null ) { + Class[] interceptors = mdef.interceptors(); + if( interceptors.length != 0 ) { + return interceptors; + } + } + } + + // No interceptor class specified + return null; + } + + /** + * Add the super membrane definitions of the specified membrane definition + * to the specified list. Recurse into the inheritance hierarchy. + */ + public static void addSuperClasses( Class cl, List> classes ) { + + // Stop the recursion when java.lang.Object is reached + if( cl.equals(Object.class) ) { + return; + } + classes.add(cl); + + // Super class + Class sup = cl.getSuperclass(); + addSuperClasses(sup,classes); + } + + /** + * Return the list of {@link Controller}-annotated fields declared in the + * inheritance hierarchy of the specified class. + */ + public static List getControllerAnnotatedFields( Class cl ) { + + List> classes = new ArrayList>(); + MembraneHelper.addSuperClasses(cl,classes); + + List fields = new ArrayList(); + Set names = new HashSet(); + + for (Class c : classes) { + Field[] fs = c.getDeclaredFields(); + for (Field f : fs) { + + // Skip fields with no @Controller annotation + if( ! f.isAnnotationPresent(Controller.class) ) { + continue; + } + + String name = f.getName(); + /* + * Do not add the field if another one with the same name has + * already been declared previously in the inheritance + * hierarchy. + */ + if( ! names.contains(name) ) { + fields.add(f); + names.add(name); + } + } + } + + return fields; + } +} diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java index d6b833e17d..a853667029 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java @@ -161,16 +161,6 @@ implements FCSourceCodeGeneratorItf { return jloader; } - /** - * Return the loader for membrane configurations associated with this - * generator. - * - * @since 2.3 - */ - public MembraneLoaderItf getMembraneLoader() { - return mloader; - } - /** * Return true if the current source code generator handles the * specified controller descriptor. diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java index 4d49345e4b..83c58e7e07 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java @@ -31,7 +31,6 @@ import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.conf.JuliaLoader; -import org.objectweb.fractal.juliac.conf.MembraneLoaderItf; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; @@ -67,14 +66,6 @@ public interface FCSourceCodeGeneratorItf { */ public JuliaLoader getJuliaLoader(); - /** - * Return the loader for membrane configurations associated with this - * generator. - * - * @since 2.3 - */ - public MembraneLoaderItf getMembraneLoader(); - /** * Test whether the current source code generator accepts the specified * controller descriptor. diff --git a/juliac/opt/ultra-comp/runtime/src/main/java/org/objectweb/fractal/koch/factory/MPrimitiveImpl.java b/juliac/opt/ultra-comp/runtime/src/main/java/org/objectweb/fractal/koch/factory/MPrimitiveImpl.java index 2d7c72624d..098da3b91f 100644 --- a/juliac/opt/ultra-comp/runtime/src/main/java/org/objectweb/fractal/koch/factory/MPrimitiveImpl.java +++ b/juliac/opt/ultra-comp/runtime/src/main/java/org/objectweb/fractal/koch/factory/MPrimitiveImpl.java @@ -42,8 +42,8 @@ import org.objectweb.fractal.api.control.LifeCycleController; import org.objectweb.fractal.api.control.NameController; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; -import org.objectweb.fractal.fraclet.annotations.Controller; import org.objectweb.fractal.fraclet.annotations.Requires; +import org.objectweb.fractal.fraclet.extensions.Controller; import org.objectweb.fractal.fraclet.types.Constants; import org.objectweb.fractal.julia.ComponentInterface; import org.objectweb.fractal.julia.control.binding.ChainedIllegalBindingException; diff --git a/juliac/opt/ultra-merge/fraclet/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/FracletUltraMerge.java b/juliac/opt/ultra-merge/fraclet/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/FracletUltraMerge.java index acdfd7cda6..ba987b888f 100644 --- a/juliac/opt/ultra-merge/fraclet/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/FracletUltraMerge.java +++ b/juliac/opt/ultra-merge/fraclet/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/FracletUltraMerge.java @@ -30,8 +30,8 @@ import java.util.HashMap; import java.util.List; import org.objectweb.fractal.fraclet.annotations.Attribute; -import org.objectweb.fractal.fraclet.annotations.Controller; import org.objectweb.fractal.fraclet.annotations.Requires; +import org.objectweb.fractal.fraclet.extensions.Controller; import org.objectweb.fractal.fraclet.types.Cardinality; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; diff --git a/juliac/pom.xml b/juliac/pom.xml index 0a6d0aaabf..0ae1d394d8 100644 --- a/juliac/pom.xml +++ b/juliac/pom.xml @@ -19,7 +19,7 @@ - 3.2 + 3.3-SNAPSHOT 2.0.2 1.1.2 2.5.2 -- GitLab From 25da3a2c8793b15a29946dc1c3c6a1f21daf3295 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Mon, 21 Mar 2011 11:05:57 +0000 Subject: [PATCH 14/24] Package refactoring. More main Juliac interfaces to the api package. --- .../org/objectweb/fractal/juliac/CompilationRound.java | 2 +- .../main/java/org/objectweb/fractal/juliac/Juliac.java | 10 +++++----- .../juliac/{plugin => api}/ADLParserSupportItf.java | 2 +- .../fractal/juliac/{opt => api}/ClassGeneratorItf.java | 2 +- .../juliac/{plugin => api}/CompileSupportItf.java | 2 +- .../juliac/{opt => api}/FCSourceCodeGeneratorItf.java | 3 ++- .../juliac/{plugin => api}/SpoonSupportItf.java | 2 +- .../org/objectweb/fractal/juliac/conf/ADLParser.java | 2 +- .../objectweb/fractal/juliac/conf/JuliacConfig.java | 6 +++--- .../objectweb/fractal/juliac/desc/ComponentDesc.java | 4 ++-- .../opt/AbstractComponentFactoryClassGenerator.java | 1 + .../objectweb/fractal/juliac/opt/ClassGenerator.java | 1 + .../fractal/juliac/opt/FCSourceCodeGenerator.java | 2 ++ .../fractal/juliac/opt/InitializerClassGenerator.java | 1 + .../fractal/juliac/proxy/ProxyClassGeneratorItf.java | 2 +- .../proxy/InterceptorClassGeneratorTestCase.java | 2 +- .../proxy/SimpleSourceCodeGeneratorTestCase.java | 2 +- .../fractal/juliac/osgi/ActivatorClassGenerator.java | 2 +- .../juliac/osgi/FCActivatorSourceCodeGenerator.java | 4 ++-- .../juliac/osgi/DynServiceActivatorClassGenerator.java | 2 +- .../fractal/juliac/osgi/FCOOCtrlGenerator.java | 2 +- .../juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java | 4 ++-- .../opt/comp/InitializerCompCtrlClassGenerator.java | 2 +- .../opt/mergeall/FCMergeAllSourceCodeGenerator.java | 4 ++-- .../opt/mergeall/RuntimeExceptionClassGenerator.java | 2 +- .../juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java | 2 +- .../juliac/opt/oo/InitializerOOCtrlClassGenerator.java | 2 +- .../oo/MembraneInitializerOOCtrlClassGenerator.java | 4 ++-- .../opt/ultracomp/FCUltraCompSourceCodeGenerator.java | 4 ++-- .../juliac/opt/ultramerge/AbstractUltraMerge.java | 2 +- .../fractal/juliac/opt/ultramerge/UMClasses.java | 2 +- .../fractal/juliac/adl/FractalADLSupportImpl.java | 2 +- .../adl/JuliacAbstractImplementationBuilder.java | 6 +++--- .../juliac/adl/stati/JuliacImplementationBuilder.java | 4 ++-- .../fractal/juliac/mind/MindADLParserSupportImpl.java | 4 ++-- .../juliac/compile/jdk6/CompileSupportImpl.java | 2 +- .../fractal/juliac/compile/jdt/CompileSupportImpl.java | 2 +- .../juliac/compile/jdt/CompileSupportImplTestCase.java | 2 +- .../fractal/juliac/spoon/SpoonSupportImpl.java | 2 +- 39 files changed, 57 insertions(+), 51 deletions(-) rename juliac/core/src/main/java/org/objectweb/fractal/juliac/{plugin => api}/ADLParserSupportItf.java (95%) rename juliac/core/src/main/java/org/objectweb/fractal/juliac/{opt => api}/ClassGeneratorItf.java (95%) rename juliac/core/src/main/java/org/objectweb/fractal/juliac/{plugin => api}/CompileSupportItf.java (94%) rename juliac/core/src/main/java/org/objectweb/fractal/juliac/{opt => api}/FCSourceCodeGeneratorItf.java (94%) rename juliac/core/src/main/java/org/objectweb/fractal/juliac/{plugin => api}/SpoonSupportItf.java (94%) diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/CompilationRound.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/CompilationRound.java index 95bb22cf28..35a90874c2 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/CompilationRound.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/CompilationRound.java @@ -29,8 +29,8 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; +import org.objectweb.fractal.juliac.api.CompileSupportItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.CompileSupportItf; /** * This class holds data about the input files which are compiled by Juliac. diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java index d309ea9d92..da7e462490 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java @@ -46,18 +46,18 @@ import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.type.BasicComponentType; import org.objectweb.fractal.julia.type.BasicInterfaceType; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.CompileSupportItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Compiler; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacGeneratorMap; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; -import org.objectweb.fractal.juliac.plugin.CompileSupportItf; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.ucf.UClassFactory; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/ADLParserSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java similarity index 95% rename from juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/ADLParserSupportItf.java rename to juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java index 912451d4e6..4a21cd73b3 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/ADLParserSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java @@ -21,7 +21,7 @@ * Author: Lionel Seinturier */ -package org.objectweb.fractal.juliac.plugin; +package org.objectweb.fractal.juliac.api; import java.io.IOException; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ClassGeneratorItf.java similarity index 95% rename from juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGeneratorItf.java rename to juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ClassGeneratorItf.java index a3fa4bb64e..e53eef81a4 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ClassGeneratorItf.java @@ -21,7 +21,7 @@ * Author: Lionel Seinturier */ -package org.objectweb.fractal.juliac.opt; +package org.objectweb.fractal.juliac.api; import java.io.IOException; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/CompileSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java similarity index 94% rename from juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/CompileSupportItf.java rename to juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java index 63c5024cb2..545f19ddae 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/CompileSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java @@ -21,7 +21,7 @@ * Author: Lionel Seinturier */ -package org.objectweb.fractal.juliac.plugin; +package org.objectweb.fractal.juliac.api; import java.io.File; import java.io.IOException; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java similarity index 94% rename from juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java rename to juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java index 83c58e7e07..1851a84568 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java @@ -21,7 +21,7 @@ * Author: Lionel Seinturier */ -package org.objectweb.fractal.juliac.opt; +package org.objectweb.fractal.juliac.api; import java.io.IOException; @@ -32,6 +32,7 @@ import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.conf.JuliaLoader; import org.objectweb.fractal.juliac.desc.MembraneDesc; +import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; /** diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/SpoonSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java similarity index 94% rename from juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/SpoonSupportItf.java rename to juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java index 1524eff9b1..b0acd33700 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/plugin/SpoonSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java @@ -22,7 +22,7 @@ * Author: Frédéric Loiret */ -package org.objectweb.fractal.juliac.plugin; +package org.objectweb.fractal.juliac.api; import java.io.IOException; import java.util.List; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java index 6ea62ad2a4..8e2ae1bef7 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/ADLParser.java @@ -23,7 +23,7 @@ package org.objectweb.fractal.juliac.conf; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; /** * The default ADL parsers registered with Juliac. diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java index 975170b586..4548b58a1b 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java @@ -44,9 +44,9 @@ import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.SourceFile; import org.objectweb.fractal.juliac.Utils; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; /** diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/desc/ComponentDesc.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/desc/ComponentDesc.java index d6c0ce493c..4af43a6569 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/desc/ComponentDesc.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/desc/ComponentDesc.java @@ -39,8 +39,8 @@ import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.type.BasicComponentType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.ucf.UnifiedClass; import org.objectweb.fractal.juliac.ucf.UnifiedMethod; import org.objectweb.fractal.util.Fractal; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/AbstractComponentFactoryClassGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/AbstractComponentFactoryClassGenerator.java index c1a0da73a0..260e2b561e 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/AbstractComponentFactoryClassGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/AbstractComponentFactoryClassGenerator.java @@ -43,6 +43,7 @@ import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.factory.ChainedInstantiationException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.desc.CompDesc; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGenerator.java index 604b3db8ac..b97556e769 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/ClassGenerator.java @@ -26,6 +26,7 @@ package org.objectweb.fractal.juliac.opt; import java.lang.reflect.Modifier; import java.util.Date; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java index a853667029..13deb42de8 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java @@ -36,6 +36,8 @@ import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliaLoader; import org.objectweb.fractal.juliac.conf.JuliacConfig; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/InitializerClassGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/InitializerClassGenerator.java index c06bc68471..66407aaf55 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/InitializerClassGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/InitializerClassGenerator.java @@ -35,6 +35,7 @@ import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.Interceptor; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/proxy/ProxyClassGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/proxy/ProxyClassGeneratorItf.java index 35f7df2e26..9a7ff4f1f3 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/proxy/ProxyClassGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/proxy/ProxyClassGeneratorItf.java @@ -25,8 +25,8 @@ package org.objectweb.fractal.juliac.proxy; import org.objectweb.fractal.api.type.InterfaceType; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.desc.MembraneDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.ucf.UnifiedClass; import org.objectweb.fractal.juliac.ucf.UnifiedMethod; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; diff --git a/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/InterceptorClassGeneratorTestCase.java b/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/InterceptorClassGeneratorTestCase.java index 88a103e85a..3899109846 100644 --- a/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/InterceptorClassGeneratorTestCase.java +++ b/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/InterceptorClassGeneratorTestCase.java @@ -33,8 +33,8 @@ import org.junit.Test; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.test.Console; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.FileSourceCodeWriter; diff --git a/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/SimpleSourceCodeGeneratorTestCase.java b/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/SimpleSourceCodeGeneratorTestCase.java index 4f1b7e8361..fb30a15fc4 100644 --- a/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/SimpleSourceCodeGeneratorTestCase.java +++ b/juliac/core/src/test/java/org/objectweb/fractal/juliac/proxy/SimpleSourceCodeGeneratorTestCase.java @@ -31,8 +31,8 @@ import org.junit.Test; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.test.Console; import org.objectweb.fractal.juliac.ucf.UnifiedMethod; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; diff --git a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/ActivatorClassGenerator.java b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/ActivatorClassGenerator.java index 789f76873c..0c5e3f2cbb 100644 --- a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/ActivatorClassGenerator.java +++ b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/ActivatorClassGenerator.java @@ -31,7 +31,7 @@ import org.objectweb.fractal.api.Component; import org.objectweb.fractal.api.factory.Factory; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; diff --git a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java index 46ae8dcbff..cb63cc3902 100644 --- a/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java +++ b/juliac/extension/osgi/adlparser/src/main/java/org/objectweb/fractal/juliac/osgi/FCActivatorSourceCodeGenerator.java @@ -27,10 +27,10 @@ import java.io.IOException; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.juliac.adl.FractalADLSupportImpl; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.desc.ComponentDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; /** * This ADL parser generates the OSGi activator class for a specified ADL diff --git a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/DynServiceActivatorClassGenerator.java b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/DynServiceActivatorClassGenerator.java index 1baad2c5b0..b6ac81f76e 100644 --- a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/DynServiceActivatorClassGenerator.java +++ b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/DynServiceActivatorClassGenerator.java @@ -28,7 +28,7 @@ import java.lang.reflect.Modifier; import java.util.Date; import org.objectweb.fractal.api.type.InterfaceType; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; diff --git a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlGenerator.java b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlGenerator.java index 958f7c4422..113a343894 100644 --- a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlGenerator.java +++ b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlGenerator.java @@ -39,9 +39,9 @@ import org.objectweb.fractal.api.Type; import org.objectweb.fractal.api.control.AttributeController; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.juliac.Juliac; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.desc.MembraneDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; import org.objectweb.fractal.juliac.ucf.UnifiedClass; diff --git a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java index ff309071bd..06a32a86d6 100644 --- a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java +++ b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java @@ -36,6 +36,8 @@ import org.objectweb.fractal.julia.loader.BasicLoader; import org.objectweb.fractal.julia.loader.Tree; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacConfig; @@ -46,9 +48,7 @@ import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.desc.SimpleMembraneDesc; import org.objectweb.fractal.juliac.opt.FCSourceCodeGenerator; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; diff --git a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/InitializerCompCtrlClassGenerator.java b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/InitializerCompCtrlClassGenerator.java index b3d84c0e7c..818af7a159 100644 --- a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/InitializerCompCtrlClassGenerator.java +++ b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/InitializerCompCtrlClassGenerator.java @@ -44,9 +44,9 @@ import org.objectweb.fractal.julia.Interceptor; import org.objectweb.fractal.julia.factory.ChainedInstantiationException; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; diff --git a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java index 9a687bb796..065e701e96 100644 --- a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java +++ b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java @@ -45,14 +45,14 @@ import org.objectweb.fractal.julia.loader.BasicLoader; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.SourceFile; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.desc.SimpleMembraneDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.opt.FCSourceCodeGenerator; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; diff --git a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/RuntimeExceptionClassGenerator.java b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/RuntimeExceptionClassGenerator.java index 3b1a7cca73..4d88e79284 100644 --- a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/RuntimeExceptionClassGenerator.java +++ b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/RuntimeExceptionClassGenerator.java @@ -26,7 +26,7 @@ package org.objectweb.fractal.juliac.opt.mergeall; import java.lang.reflect.Modifier; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.FileSourceCodeVisitor; diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java index 772017db46..90fc2c45f1 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java @@ -31,11 +31,11 @@ import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.loader.BasicLoader; import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.desc.SimpleMembraneDesc; import org.objectweb.fractal.juliac.opt.FCSourceCodeGenerator; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; /** diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java index fb3a38c6e9..73ebff095f 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java @@ -34,9 +34,9 @@ import org.objectweb.fractal.julia.InitializationContext; import org.objectweb.fractal.julia.factory.ChainedInstantiationException; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; import org.objectweb.fractal.juliac.proxy.AttributeControllerClassGenerator; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java index 43b2964b85..79fd7a1676 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java @@ -39,12 +39,12 @@ import org.objectweb.fractal.julia.loader.Tree; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.opt.ClassGenerator; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.ucf.UnifiedClass; import org.objectweb.fractal.juliac.visit.BlockSourceCodeVisitor; import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; diff --git a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java index b5b5b36363..9aab753755 100644 --- a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java +++ b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java @@ -39,6 +39,8 @@ import org.objectweb.fractal.julia.type.BasicComponentType; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacConfig; @@ -53,9 +55,7 @@ import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.desc.SimpleMembraneDesc; import org.objectweb.fractal.juliac.opt.FCSourceCodeGenerator; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; import org.objectweb.fractal.juliac.proxy.InterceptorSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; import org.objectweb.fractal.koch.control.interceptor.InterceptorController; diff --git a/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/AbstractUltraMerge.java b/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/AbstractUltraMerge.java index 41edb5f7ca..e1fcd9fdda 100644 --- a/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/AbstractUltraMerge.java +++ b/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/AbstractUltraMerge.java @@ -41,11 +41,11 @@ import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.desc.AttributeDesc; import org.objectweb.fractal.juliac.desc.BindingDesc; import org.objectweb.fractal.juliac.desc.ComponentDesc; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.spoon.SpoonHelper; import org.objectweb.fractal.juliac.spoon.SpoonSupportImpl; import org.objectweb.fractal.juliac.ucf.UnifiedClass; diff --git a/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/UMClasses.java b/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/UMClasses.java index 219a38f77a..56cb26542c 100644 --- a/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/UMClasses.java +++ b/juliac/opt/ultra-merge/core/src/main/java/org/objectweb/fractal/juliac/opt/ultramerge/UMClasses.java @@ -33,9 +33,9 @@ import java.util.Map; import java.util.Set; import org.objectweb.fractal.juliac.Juliac; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.desc.BindingDesc; import org.objectweb.fractal.juliac.desc.ComponentDesc; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import spoon.reflect.Factory; import spoon.reflect.declaration.CtClass; diff --git a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java index fc2a0ebb4c..33d550cbb6 100644 --- a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java +++ b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java @@ -33,8 +33,8 @@ import org.objectweb.fractal.adl.Factory; import org.objectweb.fractal.adl.FactoryFactory; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.adl.stati.ComponentFactoryClassGenerator; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; /** * This class implements the services provided by Fractal ADL to Juliac. diff --git a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/JuliacAbstractImplementationBuilder.java b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/JuliacAbstractImplementationBuilder.java index 29488efb97..beb3f8badc 100644 --- a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/JuliacAbstractImplementationBuilder.java +++ b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/JuliacAbstractImplementationBuilder.java @@ -34,10 +34,10 @@ import org.objectweb.fractal.julia.loader.Tree; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.conf.JuliaLoader; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.proxy.AttributeControllerClassGenerator; /** diff --git a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/stati/JuliacImplementationBuilder.java b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/stati/JuliacImplementationBuilder.java index e7f2c5a0dd..d312399488 100644 --- a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/stati/JuliacImplementationBuilder.java +++ b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/stati/JuliacImplementationBuilder.java @@ -32,9 +32,9 @@ import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.Utils; import org.objectweb.fractal.juliac.adl.JuliacAbstractImplementationBuilder; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.desc.CompDesc; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; /** * Implementation of the backend component which generates component diff --git a/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java b/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java index 3331333367..b8b66c757f 100644 --- a/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java +++ b/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java @@ -40,14 +40,14 @@ import org.objectweb.fractal.julia.type.BasicComponentType; import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacRuntimeException; +import org.objectweb.fractal.juliac.api.ADLParserSupportItf; +import org.objectweb.fractal.juliac.api.ClassGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; import org.objectweb.fractal.juliac.desc.AttributeDesc; import org.objectweb.fractal.juliac.desc.BindingDesc; import org.objectweb.fractal.juliac.desc.BindingType; import org.objectweb.fractal.juliac.desc.ComponentDesc; import org.objectweb.fractal.juliac.desc.ComponentDescFactoryClassGenerator; -import org.objectweb.fractal.juliac.opt.ClassGeneratorItf; -import org.objectweb.fractal.juliac.plugin.ADLParserSupportItf; import org.ow2.mind.adl.graph.ComponentGraph; /** diff --git a/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java b/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java index ffdbae48cc..62da9cfd2a 100644 --- a/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java +++ b/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java @@ -41,9 +41,9 @@ import javax.tools.JavaCompiler.CompilationTask; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.SourceFile; +import org.objectweb.fractal.juliac.api.CompileSupportItf; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.CompileSupportItf; /** * This class implements a compilation service based on the Java Compilation API diff --git a/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java b/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java index 6aa8c487a0..c5fb8f8615 100644 --- a/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java +++ b/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java @@ -42,9 +42,9 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.SourceFile; import org.objectweb.fractal.juliac.Utils; +import org.objectweb.fractal.juliac.api.CompileSupportItf; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.CompileSupportItf; /** * This class implements a compilation service based on the Eclipse JDT diff --git a/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java b/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java index 6de013404b..2557d9bf44 100644 --- a/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java +++ b/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java @@ -35,9 +35,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.SourceFile; +import org.objectweb.fractal.juliac.api.CompileSupportItf; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.CompileSupportItf; /** * Class for testing the functionalities of the JDT compilation support. diff --git a/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java b/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java index 00b3ef9a37..49363365ec 100644 --- a/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java +++ b/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java @@ -34,9 +34,9 @@ import org.objectweb.fractal.juliac.CompilationRound; import org.objectweb.fractal.juliac.CompilationRounds; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.SourceFile; +import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.compile.jdt.CompileSupportImpl; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.plugin.SpoonSupportItf; import org.objectweb.fractal.juliac.ucf.UnifiedClassFactoryItf; import spoon.processing.Environment; -- GitLab From 663af973c3c8232428d637407de1b33b03bc3933 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 22 Mar 2011 20:59:34 +0000 Subject: [PATCH 15/24] Fix package name. --- .../src/main/java/example/hw/HelloWorldTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java b/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java index 471951e8f5..c187fd4612 100644 --- a/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java +++ b/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java @@ -46,8 +46,8 @@ import org.objectweb.fractal.juliac.CompilationRounds; import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.SourceFile; +import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.opt.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator; import org.objectweb.fractal.juliac.runtime.JuliacBootstrapComponentImpl; import org.objectweb.fractal.juliac.test.Console; -- GitLab From 81054311d041e1c43cf8db65d8787ff4ba7ceb56 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Tue, 22 Mar 2011 21:37:26 +0000 Subject: [PATCH 16/24] Isolate controller instantiations in a separate method to enable specialization in sub classes, e.g. for per-content SCA Content Controller in Tinfi. --- ...mbraneInitializerOOCtrlClassGenerator.java | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java index 79fd7a1676..1bb0d8d263 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java @@ -91,6 +91,7 @@ public class MembraneInitializerOOCtrlClassGenerator extends ClassGenerator { @Override public void generateMethods( ClassSourceCodeVisitor cv ) { generateNewFcInitializationContextMethod(cv); + generateNewFcControllerInstantiationMethod(cv); } protected void generateNewFcInitializationContextMethod( ClassSourceCodeVisitor cv ) { @@ -116,40 +117,7 @@ public class MembraneInitializerOOCtrlClassGenerator extends ClassGenerator { } // Instantiate controllers - mv.visitln(" Object ctrl = null;"); - mv.visitln(" "+Component.class.getName()+" compctrl = null;"); - UnifiedClass ucinitializable = jc.create(Initializable.class.getName()); - UnifiedClass uccomponent = jc.create(Component.class.getName()); - for (ControllerDesc ctrlDesc : ctrlDescs) { - String ctrlImplName = ctrlDesc.getImplName(); - if( ctrlImplName.charAt(0) == '(' ) { - /* - * Skip CloneableAttributeController implementations. - * The controller implementation class name is in this case - * something like: - * - * ((attribute-controller org.objectweb.fractal.julia.conform.components.CAttributes)) - */ - continue; - } - mv.visitln(" ic.controllers.add(ctrl = new "+ctrlImplName+"());"); - UnifiedClass uc = jc.create(ctrlImplName); - if( ucinitializable.isAssignableFrom(uc) ) { - Tree tree = ctrlDesc.getTree(); - if( tree != null ) { - mv.visitln(" "+Tree.class.getName()+" tree = "+Utils.javaify(tree)+';'); - mv.visitln(" try {"); - mv.visitln(" (("+Initializable.class.getName()+")ctrl).initialize(tree);"); - mv.visitln(" }"); - mv.visitln(" catch( Exception e ) {"); - mv.visitln(" throw new "+ChainedInstantiationException.class.getName()+"(e,null,\"\");"); - mv.visitln(" }"); - } - } - if( uccomponent.isAssignableFrom(uc) ) { - mv.visitln(" compctrl = ("+Component.class.getName()+")ctrl;"); - } - } + mv.visitln(" "+Component.class.getName()+" compctrl = newFcControllerInstantiation(ic);"); InterfaceType compctrlit = new BasicInterfaceType( @@ -171,6 +139,7 @@ public class MembraneInitializerOOCtrlClassGenerator extends ClassGenerator { mv.visitln("("+Component.class.getName()+") proxy;"); // Controllers other than the component controller + mv.visitln(" Object ctrl = null;"); for (int i=0; i < membraneits.length; i++) { InterfaceType membraneit = membraneits[i]; @@ -227,6 +196,59 @@ public class MembraneInitializerOOCtrlClassGenerator extends ClassGenerator { mv.visitln(" return ic;"); } + protected void generateNewFcControllerInstantiationMethod( ClassSourceCodeVisitor cv ) { + BlockSourceCodeVisitor mv = + cv.visitMethod( + Modifier.PUBLIC, null, Component.class.getName(), + "newFcControllerInstantiation", + new String[]{InitializationContext.class.getName()+" ic"}, + new String[]{InstantiationException.class.getName()} ); + generateNewFcControllerInstantiationMethod(mv); + mv.visitEnd(); + } + + protected void generateNewFcControllerInstantiationMethod( BlockSourceCodeVisitor mv ) { + + List ctrlDescs = membraneDesc.getCtrlDescs(); + UnifiedClass ucinitializable = jc.create(Initializable.class.getName()); + UnifiedClass uccomponent = jc.create(Component.class.getName()); + + mv.visitln(" Object ctrl = null;"); + + for (ControllerDesc ctrlDesc : ctrlDescs) { + String ctrlImplName = ctrlDesc.getImplName(); + if( ctrlImplName.charAt(0) == '(' ) { + /* + * Skip CloneableAttributeController implementations. + * The controller implementation class name is in this case + * something like: + * + * ((attribute-controller org.objectweb.fractal.julia.conform.components.CAttributes)) + */ + continue; + } + mv.visitln(" ic.controllers.add(ctrl = new "+ctrlImplName+"());"); + UnifiedClass uc = jc.create(ctrlImplName); + if( ucinitializable.isAssignableFrom(uc) ) { + Tree tree = ctrlDesc.getTree(); + if( tree != null ) { + mv.visitln(" "+Tree.class.getName()+" tree = "+Utils.javaify(tree)+';'); + mv.visitln(" try {"); + mv.visitln(" (("+Initializable.class.getName()+")ctrl).initialize(tree);"); + mv.visitln(" }"); + mv.visitln(" catch( Exception e ) {"); + mv.visitln(" throw new "+ChainedInstantiationException.class.getName()+"(e,null,\"\");"); + mv.visitln(" }"); + } + } + if( uccomponent.isAssignableFrom(uc) ) { + mv.visitln(" "+Component.class.getName()+" compctrl = ("+Component.class.getName()+")ctrl;"); + } + } + + mv.visitln(" return compctrl;"); + } + protected void generateNCICMProxyCreation( BlockSourceCodeVisitor mv, boolean typedef, String fcitfClassname, String delegate, String itname, InterfaceType it ) { -- GitLab From af5e42bc5988dc605ac1d8b1e9dcd7f41667169c Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Wed, 23 Mar 2011 16:02:53 +0000 Subject: [PATCH 17/24] API extension to propagate more information about the generation. --- .../opt/oo/InitializerOOCtrlClassGenerator.java | 2 +- .../MembraneInitializerOOCtrlClassGenerator.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java index 73ebff095f..031256e739 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/InitializerOOCtrlClassGenerator.java @@ -258,7 +258,7 @@ extends InitializerClassGenerator> { getMembraneInitializerClassGenerator() { MembraneInitializerOOCtrlClassGenerator micg = new MembraneInitializerOOCtrlClassGenerator( - jc,fcscg,this,membraneDesc); + jc,fcscg,this,membraneDesc,ct,contentDesc); return micg; } } diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java index 1bb0d8d263..5fa069f503 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/MembraneInitializerOOCtrlClassGenerator.java @@ -31,6 +31,7 @@ import java.util.List; import org.objectweb.fractal.api.Component; import org.objectweb.fractal.api.Interface; import org.objectweb.fractal.api.factory.InstantiationException; +import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.InitializationContext; import org.objectweb.fractal.julia.factory.ChainedInstantiationException; @@ -60,20 +61,25 @@ import org.objectweb.fractal.juliac.visit.ClassSourceCodeVisitor; */ public class MembraneInitializerOOCtrlClassGenerator extends ClassGenerator { - private Juliac jc; - private FCSourceCodeGeneratorItf> fcscg; - private MembraneDesc> membraneDesc; - private InitializerOOCtrlClassGenerator icg; + protected Juliac jc; + protected FCSourceCodeGeneratorItf> fcscg; + protected MembraneDesc> membraneDesc; + protected InitializerOOCtrlClassGenerator icg; + protected ComponentType ct; + protected Object contentDesc; public MembraneInitializerOOCtrlClassGenerator( Juliac jc, FCSourceCodeGeneratorItf> fcscg, InitializerOOCtrlClassGenerator icg, - MembraneDesc> membraneDesc ) { + MembraneDesc> membraneDesc, ComponentType ct, + Object contentDesc ) { this.jc = jc; this.fcscg = fcscg; this.icg = icg; this.membraneDesc = membraneDesc; + this.ct = ct; + this.contentDesc = contentDesc; } public String getTargetClassName() { -- GitLab From 657530e0e9019c1d956f299901b8ea5789ac3440 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Thu, 24 Mar 2011 07:49:19 +0000 Subject: [PATCH 18/24] Bug fix contributed by Philippe. --- .../juliac/osgi/InitializerOOCtrlClassGenerator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/InitializerOOCtrlClassGenerator.java b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/InitializerOOCtrlClassGenerator.java index a2c00efbad..714b6b3e1b 100644 --- a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/InitializerOOCtrlClassGenerator.java +++ b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/InitializerOOCtrlClassGenerator.java @@ -19,7 +19,7 @@ * Contact: fractal@ow2.org * * Author: Lionel Seinturier - * Contributor: Romain Rouvoy + * Contributors: Romain Rouvoy, Philippe Merle */ package org.objectweb.fractal.juliac.osgi; @@ -42,6 +42,7 @@ import org.osgi.framework.Bundle; * * @author Lionel Seinturier * @author Romain Rouvoy + * @author Philipe Merle * @since 2.1.5 */ public class InitializerOOCtrlClassGenerator @@ -246,6 +247,13 @@ extends org.objectweb.fractal.juliac.opt.oo.InitializerOOCtrlClassGenerator { mv.visit(" "); mv.visit(ReflectionHelper.class.getName()); mv.visitln(".initBundledProxy(bundledProxy,proxy);"); + + /* + * Move to the next client interface. + * Patch contributed by Philippe on March 23, 2011 for experiments + * conducted by Christophe Munilla. + */ + clientItfIdx++; } } } -- GitLab From ec5de3ba4268e0f5946b9b21bb486393aaded72e Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Sat, 26 Mar 2011 15:18:14 +0000 Subject: [PATCH 19/24] API refactoring: JuliacModuleItf interface introduced for all dynamically loaded modules (optimization level source code generators, ADL parsers, services - compile and Spoon.) --- juliac/README.txt | 6 +-- juliac/RELEASE_NOTES.txt | 7 +-- .../main/resources/assemble/bin/README.txt | 6 +-- .../org/objectweb/fractal/juliac/Juliac.java | 14 +++-- .../juliac/api/ADLParserSupportItf.java | 11 +--- .../fractal/juliac/api/CompileSupportItf.java | 15 +----- .../juliac/api/FCSourceCodeGeneratorItf.java | 33 ++++-------- .../fractal/juliac/api/JuliacModuleItf.java | 51 +++++++++++++++++++ .../fractal/juliac/api/SpoonSupportItf.java | 18 +------ .../fractal/juliac/conf/JuliacConfig.java | 11 ++-- .../juliac/opt/FCSourceCodeGenerator.java | 27 +++++----- .../osgi/FCOOCtrlSourceCodeGenerator.java | 32 +++++------- .../fractal/juliac/AbstractJuliacMojo.java | 2 +- .../comp/FCCompCtrlSourceCodeGenerator.java | 18 +++---- .../FCMergeAllSourceCodeGenerator.java | 14 ++--- .../opt/oo/FCOOCtrlSourceCodeGenerator.java | 19 +------ .../FCUltraCompSourceCodeGenerator.java | 25 ++++----- .../juliac/adl/FractalADLSupportImpl.java | 11 +++- .../juliac/mind/MindADLParserSupportImpl.java | 11 ++++ .../compile/jdk6/CompileSupportImpl.java | 22 ++++---- .../compile/jdt/CompileSupportImpl.java | 20 +++++--- .../jdt/CompileSupportImplTestCase.java | 4 +- .../juliac/spoon/SpoonSupportImpl.java | 25 +++++---- 23 files changed, 196 insertions(+), 206 deletions(-) create mode 100644 juliac/core/src/main/java/org/objectweb/fractal/juliac/api/JuliacModuleItf.java diff --git a/juliac/README.txt b/juliac/README.txt index 0859e9babd..6f13a1bcb6 100644 --- a/juliac/README.txt +++ b/juliac/README.txt @@ -21,8 +21,8 @@ Contact: fractal@ow2.org Author: Lionel Seinturier ============================================================================ -Juliac 2.3.1 ------------- +Juliac 2.4 +---------- Juliac is a framework for generating and compiling the source code of the infrastructure (so called membranes) which is needed to run a Fractal/Java @@ -207,4 +207,4 @@ implements the org.objectweb.fractal.juliac.FCSourceCodeGeneratorItf interface. For any question, please contact: fractal@ow2.org Date of creation of this file: June 4, 2007. -Last modified: February 7, 2011. +Last modified: March 26, 2011. diff --git a/juliac/RELEASE_NOTES.txt b/juliac/RELEASE_NOTES.txt index fdcdb415e7..8c44654f9b 100755 --- a/juliac/RELEASE_NOTES.txt +++ b/juliac/RELEASE_NOTES.txt @@ -1,11 +1,12 @@ -Juliac 2.3.1 ------------- +Juliac 2.4 +---------- +* API refactoring * bug fix when generating the membrane factory: support membrane types where the first type is not necessarily the component control interface * Juliet annotation definitions moved to Fraclet * new service for generating proxy (interface and interceptor) implementations (requested by Remi M and Philippe) -* several alternative ADL parsers can be specified when generating code +* multiple ADL parsers support Juliac 2.3 diff --git a/juliac/all/src/main/resources/assemble/bin/README.txt b/juliac/all/src/main/resources/assemble/bin/README.txt index cddf9cb07e..95edb1bb18 100644 --- a/juliac/all/src/main/resources/assemble/bin/README.txt +++ b/juliac/all/src/main/resources/assemble/bin/README.txt @@ -21,8 +21,8 @@ Contact: fractal@ow2.org Author: Lionel Seinturier ============================================================================ -Juliac 2.3.1 ------------- +Juliac 2.4 +---------- Juliac is a framework for generating and compiling the source code of the infrastructure (so called membranes) which is needed to run a Fractal/Java @@ -101,4 +101,4 @@ See http://forge.objectweb.org/plugins/scmsvn/index.php?group_id=22 for that. For any question, please contact: fractal@ow2.org Date of creation of this file: May 23, 2008. -Last modified: February 7, 2011. +Last modified: March 26, 2011. diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java index da7e462490..d37bf238d4 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/Juliac.java @@ -53,9 +53,9 @@ import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.conf.ADLParser; import org.objectweb.fractal.juliac.conf.Compiler; +import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JDKLevel; import org.objectweb.fractal.juliac.conf.JuliacConfig; -import org.objectweb.fractal.juliac.conf.Constants; import org.objectweb.fractal.juliac.conf.JuliacGeneratorMap; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; import org.objectweb.fractal.juliac.proxy.InterceptorClassGenerator; @@ -77,9 +77,7 @@ public class Juliac { * Juliac command line entry point. */ public static void main( String[] args ) - throws - IOException, InstantiationException, - ClassNotFoundException, JuliacException { + throws IOException, InstantiationException, ClassNotFoundException { if( args.length == 0 ) { usage(); @@ -414,7 +412,7 @@ public class Juliac { /** * Close the resources managed by Juliac. */ - public void close() throws IOException, JuliacException { + public void close() throws IOException { /* * Close optimization level source code generators. @@ -426,10 +424,10 @@ public class Juliac { * Close the services. */ if( compiler != null ) { - compiler.close(); + compiler.close(this); } if( spoon != null ) { - spoon.close(); + spoon.close(this); } } @@ -1089,7 +1087,7 @@ public class Juliac { /** * Return the reference of the compilation service. */ - public CompileSupportItf getCompiler() { + public CompileSupportItf getCompiler() throws IOException { if( compiler == null ) { diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java index 4a21cd73b3..44b4cd5554 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/ADLParserSupportItf.java @@ -25,23 +25,14 @@ package org.objectweb.fractal.juliac.api; import java.io.IOException; -import org.objectweb.fractal.juliac.Juliac; - /** * This interface describes the services provided by an ADL parser to Juliac. * * @author Lionel Seinturier * @since 2.0 */ -public interface ADLParserSupportItf { +public interface ADLParserSupportItf extends JuliacModuleItf { - /** - * Initialize the service. - * - * @param jc the instance of Juliac used by this service - */ - public void init( Juliac jc ); - /** * Test whether this ADL parser accepts the specified ADL descriptor. * diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java index 545f19ddae..2437a8a033 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/CompileSupportItf.java @@ -27,7 +27,6 @@ import java.io.File; import java.io.IOException; import java.util.List; -import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.SourceFile; /** @@ -35,14 +34,7 @@ import org.objectweb.fractal.juliac.SourceFile; * * @author Lionel Seinturier */ -public interface CompileSupportItf { - - /** - * Initialize the service. - * - * @param jc the instance of Juliac used by this service - */ - public void init( Juliac jc ); +public interface CompileSupportItf extends JuliacModuleItf { /** * Compile the specified source files and dump the resulting bytecode files @@ -57,9 +49,4 @@ public interface CompileSupportItf { */ public List compile( List sfs, File classDir ) throws IOException; - - /** - * Close the service. - */ - public void close(); } diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java index 1851a84568..34b78c05d9 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/FCSourceCodeGeneratorItf.java @@ -28,8 +28,6 @@ import java.io.IOException; import org.objectweb.fractal.api.Type; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; -import org.objectweb.fractal.juliac.Juliac; -import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.conf.JuliaLoader; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; @@ -43,22 +41,16 @@ import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; * @author Lionel Seinturier * @since 1.2 */ -public interface FCSourceCodeGeneratorItf { +public interface FCSourceCodeGeneratorItf extends JuliacModuleItf { - /** - * Initialize this reference to the Juliac instance which uses this - * generator. - * - * @param jc the instance of Juliac using this source code generator - * @since 2.3 - */ - public void setJuliac( Juliac jc ); - - /** - * Initialize this generator. - */ - public void init() throws IOException; - + /** + * A post initialization phase in the lifecycle of this optimization level + * source code generator. + * + * @since 1.4 + */ + public void postInit() throws IOException; + /** * Return the loader for Julia configuration files associated with this * generator. @@ -124,11 +116,4 @@ public interface FCSourceCodeGeneratorItf { */ public ProxyClassGeneratorItf getInterfaceClassGenerator( InterfaceType it, MembraneDesc membraneDesc ); - - /** - * Close this generator. - * - * @since 2.1.6 - */ - public void close() throws IOException, JuliacException; } diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/JuliacModuleItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/JuliacModuleItf.java new file mode 100644 index 0000000000..71aa27383b --- /dev/null +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/JuliacModuleItf.java @@ -0,0 +1,51 @@ +/*** + * Juliac + * Copyright (C) 2011 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: fractal@ow2.org + * + * Author: Lionel Seinturier + */ + +package org.objectweb.fractal.juliac.api; + +import java.io.IOException; + +import org.objectweb.fractal.juliac.Juliac; + +/** + * Root interface for Juliac modules. + * + * @author Lionel + * @since 2.4 + */ +public interface JuliacModuleItf { + + /** + * Initialize the module. + * + * @param jc the instance of Juliac that loads this module + */ + public void init( Juliac jc ) throws IOException; + + /** + * Close the module. + * + * @param jc the instance of Juliac that closes this module + */ + public void close( Juliac jc ) throws IOException; +} diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java index b0acd33700..94f287b6a4 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/api/SpoonSupportItf.java @@ -27,8 +27,6 @@ package org.objectweb.fractal.juliac.api; import java.io.IOException; import java.util.List; -import org.objectweb.fractal.juliac.Juliac; - /** * This interface describes the services provided by Spoon to Juliac. * @@ -36,15 +34,8 @@ import org.objectweb.fractal.juliac.Juliac; * @author Frederic Loiret * @since 1.3 */ -public interface SpoonSupportItf { +public interface SpoonSupportItf extends JuliacModuleItf { - /** - * Initialize the Spoon service. - * - * @param jc the instance of Juliac used by this service - */ - public void init( Juliac jc ) throws IOException; - /** * Mix the layers whose class names are specified and generate the resulting * mixed class. @@ -64,11 +55,4 @@ public interface SpoonSupportItf { * @author Frederic Loiret */ public T getSpoonFactory(); - - /** - * Close the service. - * - * @since 2.2.6 - */ - public void close(); } diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java index 4548b58a1b..27cc2cab88 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/conf/JuliacConfig.java @@ -40,7 +40,6 @@ import java.util.logging.Logger; import org.objectweb.fractal.juliac.CompilationRound; import org.objectweb.fractal.juliac.CompilationRounds; import org.objectweb.fractal.juliac.Juliac; -import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.JuliacRuntimeException; import org.objectweb.fractal.juliac.SourceFile; import org.objectweb.fractal.juliac.Utils; @@ -65,10 +64,10 @@ public class JuliacConfig { /** * Close the source code generators registered with the current instance. */ - public void close() throws IOException, JuliacException { + public void close() throws IOException { Collection> fcscgs = optLevels.values(); for (FCSourceCodeGeneratorItf fcscg : fcscgs) { - fcscg.close(); + fcscg.close(jc); } } @@ -442,7 +441,7 @@ public class JuliacConfig { /** * @since 2.3.1 */ - public void loadADLParsers() throws ClassNotFoundException { + public void loadADLParsers() throws ClassNotFoundException, IOException { for (ADLParser adlParser : adlParsers) { String clname = adlParser.getClassName(); Class cl = null; @@ -557,8 +556,8 @@ public class JuliacConfig { for (String optLevelName : copy) { Class> cl = load(optLevelName); FCSourceCodeGeneratorItf fcscg = instantiate(cl); - fcscg.setJuliac(jc); - fcscg.init(); + fcscg.init(jc); + fcscg.postInit(); optLevels.put(optLevelName,fcscg); } } diff --git a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java index 13deb42de8..e98240e501 100644 --- a/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java +++ b/juliac/core/src/main/java/org/objectweb/fractal/juliac/opt/FCSourceCodeGenerator.java @@ -66,30 +66,20 @@ import org.objectweb.fractal.juliac.ucf.UnifiedClass; public abstract class FCSourceCodeGenerator implements FCSourceCodeGeneratorItf { - public FCSourceCodeGenerator() {} - - // ----------------------------------------------------------------------- - // Implementation of the FCSourceCodeGeneratorItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- protected Juliac jc; protected JuliaLoader jloader; protected MembraneLoaderItf mloader; - /** - * Initialize this reference to the Juliac instance which uses this - * generator. - * - * @param jc the instance of Juliac using this source code generator - * @since 2.3 - */ - public void setJuliac( Juliac jc ) { + public void init( Juliac jc ) throws IOException { this.jc = jc; /* - * Initialiaze the Julia and membrane loader. + * Initialize the Julia and membrane loaders. */ JuliacConfig jconf = jc.getJuliacConfig(); ClassLoader classloader = jconf.getClassLoader(); @@ -104,7 +94,7 @@ implements FCSourceCodeGeneratorItf { * order to be able to customize in subclasses, the julia.config system * property used by this method. */ - public void init() throws IOException { + public void postInit() throws IOException { /* * There is no problem in executing several times the init() method. @@ -153,6 +143,15 @@ implements FCSourceCodeGeneratorItf { } private boolean initialized = false; + public void close( Juliac jc ) throws IOException { + // Indeed nothing + } + + + // ----------------------------------------------------------------------- + // Implementation of the FCSourceCodeGeneratorItf interface + // ----------------------------------------------------------------------- + /** * Return the loader for Julia configuration files associated with this * generator. diff --git a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlSourceCodeGenerator.java b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlSourceCodeGenerator.java index c5f78d490b..acf2521fc9 100644 --- a/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlSourceCodeGenerator.java +++ b/juliac/extension/osgi/opt/oo/src/main/java/org/objectweb/fractal/juliac/osgi/FCOOCtrlSourceCodeGenerator.java @@ -29,7 +29,7 @@ import java.util.List; import org.objectweb.fractal.api.Type; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; -import org.objectweb.fractal.juliac.JuliacException; +import org.objectweb.fractal.juliac.Juliac; import org.objectweb.fractal.juliac.desc.ControllerDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.opt.InitializerClassGenerator; @@ -49,10 +49,6 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator { private FCOOCtrlGenerator osgig; - public FCOOCtrlSourceCodeGenerator() { - super(); - } - /** Configuration file for OSGi. */ public static final String DEFAULT_CONFIGURATION = "osgi-bundled.cfg"; @@ -68,12 +64,23 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator { * order to be able to customize the julia.config system property. */ @Override - public void init() throws IOException { + public void postInit() throws IOException { jloader.loadConfigFile(DEFAULT_CONFIGURATION); osgig = new FCOOCtrlGenerator(jc); - super.init(); + super.postInit(); } + @Override + public void close( Juliac jc ) throws IOException { + osgig.close(); + super.close(jc); + } + + + // ----------------------------------------------------------------------- + // Implementation of the FCSourceCodeGeneratorItf interface + // ----------------------------------------------------------------------- + /** * Return true if the current source code generator handles the * specified controller descriptor. @@ -159,17 +166,6 @@ extends org.objectweb.fractal.juliac.opt.oo.FCOOCtrlSourceCodeGenerator { return pcg; } - /** - * Close this generator. - * - * @since 2.1.6 - */ - @Override - public void close() throws IOException, JuliacException { - osgig.close(); - super.close(); - } - // ------------------------------------------------------------------ // Implementation of methods defined in FCSourceCodeGenerator diff --git a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java index 440be44cc5..6277adf80f 100644 --- a/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java +++ b/juliac/mojo/src/main/java/org/objectweb/fractal/juliac/AbstractJuliacMojo.java @@ -383,7 +383,7 @@ implements JuliacMojoItf { MojoExecutionException, IOException, InstantiationException, MalformedURLException, DependencyResolutionRequiredException, ArtifactResolutionException, - ArtifactNotFoundException, ClassNotFoundException, JuliacException, + ArtifactNotFoundException, ClassNotFoundException, ArtifactMetadataRetrievalException { Juliac jc = new Juliac(); diff --git a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java index 06a32a86d6..8a6a16463b 100644 --- a/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java +++ b/juliac/opt/comp/src/main/java/org/objectweb/fractal/juliac/opt/comp/FCCompCtrlSourceCodeGenerator.java @@ -69,12 +69,8 @@ import org.objectweb.fractal.koch.loader.TreeParserException; public class FCCompCtrlSourceCodeGenerator extends FCSourceCodeGenerator> { - public FCCompCtrlSourceCodeGenerator() { - super(); - } - // ----------------------------------------------------------------------- - // Implementation of the FCSourceCodeGeneratorItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- /** @@ -84,24 +80,28 @@ extends FCSourceCodeGenerator> { * order to be able to customize the julia.config system property. */ @Override - public void init() throws IOException { + public void postInit() throws IOException { jloader.loadConfigFile(BasicLoader.DEFAULT_CONFIGURATION); jloader.loadConfigFile(Koch.DEFAULT_CONFIGURATION); - super.init(); + super.postInit(); /* * Register the optimization level for control components. */ FCSourceCodeGeneratorItf fcscg = new FCmCompCtrlSourceCodeGenerator(); - fcscg.setJuliac(jc); - fcscg.init(); + fcscg.init(jc); + fcscg.postInit(); JuliacConfig jconf = jc.getJuliacConfig(); jconf.addOptLevel(null,fcscg); } + // ----------------------------------------------------------------------- + // Implementation of the FCSourceCodeGeneratorItf interface + // ----------------------------------------------------------------------- + /** * Return true if the current source code generator handles the * specified controller descriptor. diff --git a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java index 065e701e96..e290e8dc46 100644 --- a/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java +++ b/juliac/opt/merge-all/src/main/java/org/objectweb/fractal/juliac/opt/mergeall/FCMergeAllSourceCodeGenerator.java @@ -82,12 +82,8 @@ import spoon.reflect.reference.CtTypeReference; public class FCMergeAllSourceCodeGenerator extends FCSourceCodeGenerator> { - public FCMergeAllSourceCodeGenerator() { - super(); - } - // ----------------------------------------------------------------------- - // Implementation of the FCSourceCodeGeneratorItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- /** @@ -97,11 +93,15 @@ extends FCSourceCodeGenerator> { * order to be able to customize the julia.config system property. */ @Override - public void init() throws IOException { + public void postInit() throws IOException { jloader.loadConfigFile(BasicLoader.DEFAULT_CONFIGURATION); - super.init(); + super.postInit(); } + // ----------------------------------------------------------------------- + // Implementation of the FCSourceCodeGeneratorItf interface + // ----------------------------------------------------------------------- + /** * Generate the implementation of the membrane associated to a Fractal * component. diff --git a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java index 90fc2c45f1..a2ec4c49fd 100644 --- a/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java +++ b/juliac/opt/oo/src/main/java/org/objectweb/fractal/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java @@ -29,7 +29,6 @@ import java.util.List; import org.objectweb.fractal.api.type.ComponentType; import org.objectweb.fractal.api.type.InterfaceType; import org.objectweb.fractal.julia.loader.BasicLoader; -import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.Utils; import org.objectweb.fractal.juliac.api.SpoonSupportItf; import org.objectweb.fractal.juliac.desc.ControllerDesc; @@ -50,10 +49,6 @@ import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; public class FCOOCtrlSourceCodeGenerator extends FCSourceCodeGenerator> { - public FCOOCtrlSourceCodeGenerator() { - super(); - } - // ----------------------------------------------------------------------- // Implementation of the FCSourceCodeGeneratorItf interface // ----------------------------------------------------------------------- @@ -65,9 +60,9 @@ extends FCSourceCodeGenerator> { * order to be able to customize the julia.config system property. */ @Override - public void init() throws IOException { + public void postInit() throws IOException { jloader.loadConfigFile(BasicLoader.DEFAULT_CONFIGURATION); - super.init(); + super.postInit(); } /** @@ -166,16 +161,6 @@ extends FCSourceCodeGenerator> { return new InitializerOOCtrlClassGenerator(); } - /** - * Close this generator. - * - * @since 2.1.6 - */ - public void close() throws IOException, JuliacException { - // Indeed nothing - // Exceptions are thrown by subclasses (see extension/felix) - } - // ----------------------------------------------------------------------- // Implementation specific diff --git a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java index 9aab753755..4a4563d156 100644 --- a/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java +++ b/juliac/opt/ultra-comp/core/src/main/java/org/objectweb/fractal/juliac/opt/ultracomp/FCUltraCompSourceCodeGenerator.java @@ -73,12 +73,8 @@ import org.objectweb.fractal.koch.loader.TreeParserException; public class FCUltraCompSourceCodeGenerator extends FCSourceCodeGenerator { - public FCUltraCompSourceCodeGenerator() { - super(); - } - // ----------------------------------------------------------------------- - // Implementation of the FCSourceCodeGeneratorItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- /** @@ -97,27 +93,21 @@ extends FCSourceCodeGenerator { */ public final static String CONTENT_ITF_NAME = "content-itf"; - /** - * Initialize this generator. - * - * The initialization process is kept separated from the constructor in - * order to be able to customize the julia.config system property. - */ @Override - public void init() throws IOException { + public void postInit() throws IOException { jloader.loadConfigFile(BasicLoader.DEFAULT_CONFIGURATION); jloader.loadConfigFile("koch-bundled.cfg"); jloader.loadConfigFile(DEFAULT_CONFIGURATION); - super.init(); + super.postInit(); /* * Register the optimization level for control components. */ FCSourceCodeGeneratorItf fcscg = new FCmCompCtrlSourceCodeGenerator(); - fcscg.setJuliac(jc); - fcscg.init(); + fcscg.init(jc); + fcscg.postInit(); JuliacConfig jconf = jc.getJuliacConfig(); jconf.addOptLevel(null,fcscg); @@ -134,6 +124,11 @@ extends FCSourceCodeGenerator { iscg ); } + + // ----------------------------------------------------------------------- + // Implementation of the FCSourceCodeGeneratorItf interface + // ----------------------------------------------------------------------- + /** * Generate the implementation of the membrane associated to a Fractal * component. diff --git a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java index 33d550cbb6..2f8971e560 100644 --- a/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java +++ b/juliac/plugin/adlparser/fractaladl/src/main/java/org/objectweb/fractal/juliac/adl/FractalADLSupportImpl.java @@ -67,7 +67,7 @@ public class FractalADLSupportImpl implements ADLParserSupportItf { // ----------------------------------------------------------------------- - // Implementation of the FractalADLSupportItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- protected Juliac jc; @@ -80,6 +80,15 @@ public class FractalADLSupportImpl implements ADLParserSupportItf { public void init( Juliac jc ) { this.jc = jc; } + + public void close( Juliac jc ) { + // Indeed nothing + } + + + // ----------------------------------------------------------------------- + // Implementation of the ADLParserSupportItf interface + // ----------------------------------------------------------------------- /** * Return true if the current source code generator handles the diff --git a/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java b/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java index b8b66c757f..7a9dc83832 100644 --- a/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java +++ b/juliac/plugin/adlparser/mindadl/src/main/java/org/objectweb/fractal/juliac/mind/MindADLParserSupportImpl.java @@ -58,6 +58,10 @@ import org.ow2.mind.adl.graph.ComponentGraph; */ public class MindADLParserSupportImpl implements ADLParserSupportItf { + // ----------------------------------------------------------------------- + // Implementation of the JuliacModuleItf interface + // ----------------------------------------------------------------------- + /** * Initialize the service. * @@ -68,6 +72,9 @@ public class MindADLParserSupportImpl implements ADLParserSupportItf { } private Juliac jc; + public void close( Juliac jc ) { + // Indeed nothing + } /** * Return true if the current source code generator handles the @@ -89,6 +96,10 @@ public class MindADLParserSupportImpl implements ADLParserSupportItf { return exist; } + // ----------------------------------------------------------------------- + // Implementation of the ADLParserSupportItf interface + // ----------------------------------------------------------------------- + /** * Parse the specified ADL descriptor and return a model of it. * diff --git a/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java b/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java index 62da9cfd2a..a1d34f5607 100644 --- a/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java +++ b/juliac/plugin/compiler/jdk6/src/main/java/org/objectweb/fractal/juliac/compile/jdk6/CompileSupportImpl.java @@ -55,19 +55,22 @@ import org.objectweb.fractal.juliac.conf.JuliacConfig; public class CompileSupportImpl implements CompileSupportItf { // ----------------------------------------------------------------------- - // Implementation of the CompileSupportItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- - /** - * Initialize the service. - * - * @param jc the instance of Juliac used by this service - */ public void init( Juliac jc ) { this.jc = jc; } private Juliac jc; + public void close( Juliac jc ) { + // Indeed nothing + } + + // ----------------------------------------------------------------------- + // Implementation of the CompileSupportItf interface + // ----------------------------------------------------------------------- + /** * Compile the specified source files and dump the resulting bytecode files * into the specified directory. @@ -178,11 +181,4 @@ public class CompileSupportImpl implements CompileSupportItf { return outputFileNames; } - - /** - * Close the service. - */ - public void close() { - // Indeed nothing - } } diff --git a/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java b/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java index c5fb8f8615..c88655a1ce 100644 --- a/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java +++ b/juliac/plugin/compiler/jdt/src/main/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImpl.java @@ -57,19 +57,23 @@ import org.objectweb.fractal.juliac.conf.JuliacConfig; public class CompileSupportImpl implements CompileSupportItf { // ----------------------------------------------------------------------- - // Implementation of the CompileSupportItf interface + // Implementation of the JuliacModuleItf interface // ----------------------------------------------------------------------- - /** - * Initialize the service. - * - * @param jc the instance of Juliac used by this service - */ + private Juliac jc; + public void init( Juliac jc ) { this.jc = jc; - } - private Juliac jc; + } + + public void close( Juliac jc ) { + // Indeed nothing + } + // ----------------------------------------------------------------------- + // Implementation of the CompileSupportItf interface + // ----------------------------------------------------------------------- + /** * Compile the specified source files and dump the resulting bytecode files * into the specified directory. diff --git a/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java b/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java index 2557d9bf44..3f4df79b05 100644 --- a/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java +++ b/juliac/plugin/compiler/jdt/src/test/java/org/objectweb/fractal/juliac/compile/jdt/CompileSupportImplTestCase.java @@ -116,7 +116,7 @@ public class CompileSupportImplTestCase { CompileSupportItf compil = new CompileSupportImpl(); compil.init(jc); compil.compile(sfs,t1ClassDir); - compil.close(); + compil.close(jc); } /** @@ -166,6 +166,6 @@ public class CompileSupportImplTestCase { CompileSupportItf compil = new CompileSupportImpl(); compil.init(jc); compil.compile(sfs,t1ClassDir); - compil.close(); + compil.close(jc); } } diff --git a/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java b/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java index 49363365ec..46c6b66c73 100644 --- a/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java +++ b/juliac/plugin/spoon/src/main/java/org/objectweb/fractal/juliac/spoon/SpoonSupportImpl.java @@ -59,10 +59,13 @@ import spoon.support.builder.JDTTreeBuilder; public class SpoonSupportImpl implements SpoonSupportItf { // ---------------------------------------------------------------------- - // Implementation of the SpoonSupportItf interface + // Implementation of the JuliacModuleItf interface // ---------------------------------------------------------------------- private Juliac jc; + private JavaOutputProcessor jop; + private JuliacSpoonFactory factory; + private CompileSupportImpl compiler; /** * Initialize the Spoon service. @@ -136,10 +139,15 @@ public class SpoonSupportImpl implements SpoonSupportItf { jc.register(ucf); } - private JavaOutputProcessor jop; - private JuliacSpoonFactory factory; - private CompileSupportImpl compiler; + public void close( Juliac jc ) { + factory.close(); + } + + // ---------------------------------------------------------------------- + // Implementation of the SpoonSupportItf interface + // ---------------------------------------------------------------------- + /** * Mix the layers whose class names are specified and generate the resulting * mixed class. @@ -172,15 +180,6 @@ public class SpoonSupportImpl implements SpoonSupportItf { return factory; } - /** - * Close the service. - * - * @since 2.2.6 - */ - public void close() { - factory.close(); - } - // ---------------------------------------------------------------------- // Implementation specific // ---------------------------------------------------------------------- -- GitLab From 685d08b9563b1904f992df14b7d150eb7eb97fbc Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Sat, 26 Mar 2011 16:30:03 +0000 Subject: [PATCH 20/24] Move to new API. --- .../src/main/java/example/hw/HelloWorldTestCase.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java b/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java index c187fd4612..5a0949a731 100644 --- a/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java +++ b/juliac/examples/advanced/foobar-cases/generate-in-jar/src/main/java/example/hw/HelloWorldTestCase.java @@ -44,7 +44,6 @@ import org.objectweb.fractal.julia.type.BasicInterfaceType; import org.objectweb.fractal.juliac.CompilationRound; import org.objectweb.fractal.juliac.CompilationRounds; import org.objectweb.fractal.juliac.Juliac; -import org.objectweb.fractal.juliac.JuliacException; import org.objectweb.fractal.juliac.SourceFile; import org.objectweb.fractal.juliac.api.FCSourceCodeGeneratorItf; import org.objectweb.fractal.juliac.conf.JuliacConfig; @@ -76,13 +75,13 @@ public class HelloWorldTestCase { jconf.setBaseDir(baseDir); FCSourceCodeGeneratorItf fcscg = new FCOOCtrlSourceCodeGenerator(); - fcscg.setJuliac(jc); - fcscg.init(); + fcscg.init(jc); + fcscg.postInit(); jconf.addOptLevel(null,fcscg); } @After - public void tearDown() throws IOException, JuliacException { + public void tearDown() throws IOException { jc.close(); jc = null; } -- GitLab From 1e26807bfa9286cdb3b035356d5c310b6b9bde34 Mon Sep 17 00:00:00 2001 From: Munilla Christophe Date: Wed, 30 Mar 2011 15:34:01 +0000 Subject: [PATCH 21/24] add knopflerfish runtime --- .../osgi/runtime/knopflerfish/pom.xml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 juliac/extension/osgi/runtime/knopflerfish/pom.xml diff --git a/juliac/extension/osgi/runtime/knopflerfish/pom.xml b/juliac/extension/osgi/runtime/knopflerfish/pom.xml new file mode 100644 index 0000000000..5a34bd71e2 --- /dev/null +++ b/juliac/extension/osgi/runtime/knopflerfish/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + + org.objectweb.fractal.juliac.osgi + juliac-osgi-runtime-parent + 2.3.1-SNAPSHOT + + + org.objectweb.fractal.juliac.osgi + juliac-osgi-runtime-knopflerfish + jar + + Juliac OSGi Runtime Knopflerfish + + + knopflerfish + knopflerfish repository + + true + always + + http://www.knopflerfish.org/maven2/ + + + + objectweb-release + + ObjectWeb Maven Repository + http://maven.objectweb.org/maven2 + + true + + + + false + + + + + objectweb-snapshot + ObjectWeb Maven Repository + http://maven.objectweb.org/maven2-snapshot + + + false + + + true + + daily + + + + + + + + org.objectweb.fractal.juliac.osgi + juliac-osgi-runtime-core + ${project.version} + + + org.knopflerfish + framework + 5.1.6 + + + org.osgi + org.osgi.core + ${osgi.version} + provided + + + + + -- GitLab From 82bc135c369e184251dd79704d7739c319c2cac7 Mon Sep 17 00:00:00 2001 From: Munilla Christophe Date: Wed, 30 Mar 2011 15:37:22 +0000 Subject: [PATCH 22/24] add knopflerfish runtime part 3 --- .../fractal/juliac/osgi/PlatformImpl.java | 220 ++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java diff --git a/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java b/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java new file mode 100644 index 0000000000..77b32bb0b9 --- /dev/null +++ b/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java @@ -0,0 +1,220 @@ +/*** + * Juliac + * Copyright (C) 2009-2011 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: fractal@ow2.org + * + * Author: Christophe Munilla + */ + +package org.objectweb.fractal.juliac.osgi; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.knopflerfish.framework.FrameworkFactoryImpl; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.launch.Framework; +import org.osgi.framework.launch.FrameworkFactory; + +/** + * Helper methods for dealing with OSGi/Knopflerfish. + * + * @author Christophe Munilla + */ +public class PlatformImpl implements PlatformItf { + + /* + public static void main(String arg[]){ + PlatformImpl impl = new PlatformImpl(); + try { + System.out.println(impl.getBundleContext()); + impl.stop(); + } catch (IOException e) { + e.printStackTrace(); + } catch (BundleException e) { + e.printStackTrace(); + } + } + */ + + /** + * Return the bundle context of the platform. + */ + public BundleContext getBundleContext() throws IOException, BundleException { + Framework knopflerfish = getKnopflerfish(); + BundleContext bc = knopflerfish.getBundleContext(); + return bc; + } + + /** + * Stop the platform. + */ + public void stop() throws BundleException, IOException { + Framework knopflerfish = getKnopflerfish(); + knopflerfish.stop(0); + } + + // --------------------------------------------------------------------- + // Implementation specific + // --------------------------------------------------------------------- + + /** The instance of the OSGi/Knopflerfish framework. */ + private static Framework knopflerfish = null; + + /** + * Return the singleton instance of the OSGi/Knopflerfish framework. + */ + @SuppressWarnings("unchecked") + private static Framework getKnopflerfish() throws IOException, + BundleException { + + Map fwProps/* */= new HashMap/* */(); + /* Properties for configuring Knopflerfish. */ + if (knopflerfish == null) { + + /* Prepare a cache directory for Knopflerfish. */ + File tmpFile = null; + try { + tmpFile = File.createTempFile("knopflerfish", ".tmp"); + } catch (IOException e) { + e.printStackTrace(); + } + tmpFile.delete(); + // Retrieve the directory containing temporary files + File dir = tmpFile.getParentFile(); + File cache = new File(dir, "knopflerfish"); + // Delete files which may have been stored by a previous run + deleteAllRecursively(cache); + cache.mkdir(); + + fwProps.put("org.osgi.provisioning.spid", "knopflerfish"); + fwProps.put("org.osgi.framework.storage", cache.getAbsolutePath()); + fwProps.put("org.knopflerfish.osgi.setcontextclassloader", "false"); + fwProps.put("org.knopflerfish.osgi.registerserviceurlhandler", + "true"); + fwProps.put("org.knopflerfish.framework.debug.classloader", "false"); + fwProps.put("org.knopflerfish.framework.debug.automanifest", "false"); + fwProps.put("org.knopflerfish.framework.debug.packages", "false"); + fwProps.put("org.knopflerfish.framework.debug.patch", "false"); + fwProps.put("org.knopflerfish.framework.debug.lazy_activation", + "false"); + fwProps.put("org.knopflerfish.framework.debug.permissions", "false"); + fwProps.put("org.knopflerfish.framework.debug.certificates", "false"); + fwProps.put("org.knopflerfish.framework.debug.startlevel", "true"); + fwProps.put("org.knopflerfish.framework.debug.framework", "true"); + fwProps.put("org.knopflerfish.framework.debug.service_reference", + "false"); + fwProps.put("org.knopflerfish.framework.debug.bundle_resource", + "true"); + ; + fwProps.put("org.knopflerfish.framework.debug.url", "false"); + fwProps.put("org.knopflerfish.framework.debug.hooks", "false"); + fwProps.put("org.knopflerfish.framework.debug.errors", "true"); + fwProps.put("org.knopflerfish.log.memory.size", "250"); + fwProps.put("org.knopflerfish.log.level", "debug"); + fwProps.put("org.knopflerfish.log.grabio", "false"); + fwProps.put("org.knopflerfish.log.file", "false"); + fwProps.put("org.knopflerfish.log.out", "true"); + fwProps.put("org.knopflerfish.gosg.jars", ""); + fwProps.put("org.knopflerfish.consoletelnet.port", "2323"); + fwProps.put("org.knopflerfish.consoletelnet.user", "admin"); + fwProps.put("org.knopflerfish.consoletelnet.pwd", "admin"); + fwProps.put("org.knopflerfish.prodver", "5.1.6"); + fwProps.put("org.knopflerfish.bundle.cm.store", "cmdir"); + fwProps.put("org.knopflerfish.http.dnslookup", "false"); + fwProps.put("org.osgi.service.http.port", "8080"); + fwProps.put("org.knopflerfish.framework.system.packages.base", ""); + fwProps.put("org.knopflerfish.framework.system.packages.file", ""); + String[] versions = System.getProperty("java.version").split("\\."); + String version = versions[0] + "." + versions[1]; + fwProps.put("org.knopflerfish.framework.system.packages.version", + version); + fwProps.put("org.knopflerfish.framework.bundlestorage", "file"); + fwProps.put("org.knopflerfish.framework.bundlestorage.checksigned", + "true"); + fwProps.put( + "org.knopflerfish.framework.bundlestorage.file.reference", + "true"); + fwProps.put("org.knopflerfish.framework.bundlestorage.file.unpack", + "true"); + fwProps.put( + "org.knopflerfish.framework.bundlestorage.file.trusted", + "true"); + fwProps.put( + "org.knopflerfish.framework.bundlestorage.file.always_unpack", + "false"); + fwProps.put("org.knopflerfish.framework.startlevel.compat", "false"); + fwProps.put("org.knopflerfish.framework.patch.configurl", + "!!/patches.props"); + fwProps.put("org.knopflerfish.framework.automanifest.config", + "!!/automanifest.props"); + fwProps.put( + "org.knopflerfish.framework.is_doublechecked_locking_safe", + "true"); + fwProps.put("org.knopflerfish.framework.strictbootclassloading", + "false"); + fwProps.put("org.knopflerfish.framework.all_signed", "false"); + fwProps.put("org.knopflerfish.framework.automanifest", "false"); + fwProps.put("org.knopflerfish.framework.main.class.activation", ""); + fwProps.put("org.knopflerfish.framework.patch", "false"); + fwProps.put("org.knopflerfish.framework.ldap.nocache", "false"); + fwProps.put("org.knopflerfish.framework.service.permissionadmin", + "true"); + fwProps.put( + "org.knopflerfish.framework.service.conditionalpermissionadmin", + "true"); + fwProps.put("org.knopflerfish.framework.patch.dumpclasses.dir", + "patchedclasses"); + fwProps.put("org.knopflerfish.framework.patch.dumpclasses", "false"); + fwProps.put("org.knopflerfish.startlevel.use", "true"); + fwProps.put("org.knopflerfish.framework.validator", "none"); + + FrameworkFactory factory = new FrameworkFactoryImpl(); + knopflerfish = factory.newFramework(fwProps); + + try { + knopflerfish.start(); + } catch (BundleException e) { + e.printStackTrace(); + } + } + + return knopflerfish; + } + + /** + * Delete recursively all the files contained in the specified file if the + * specified file is a directory, and the specified file itself. + * + * @param f + * the file to delete + */ + private static void deleteAllRecursively(File f) { + if (f.isDirectory()) { + File[] subs = f.listFiles(); + for (int i = 0; i < subs.length; i++) { + deleteAllRecursively(subs[i]); + } + } + f.delete(); + } + +} \ No newline at end of file -- GitLab From 012678a8480a22fd23608327938a9f0a3d5e75d3 Mon Sep 17 00:00:00 2001 From: Lionel Seinturier Date: Wed, 30 Mar 2011 19:11:46 +0000 Subject: [PATCH 23/24] Cosmetic. Ignore target/ directory. Documenting previously commited feature. --- juliac/README.txt | 1 + juliac/RELEASE_NOTES.txt | 1 + .../java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java | 5 +++-- juliac/extension/osgi/runtime/pom.xml | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/juliac/README.txt b/juliac/README.txt index 6f13a1bcb6..b4bba40efb 100644 --- a/juliac/README.txt +++ b/juliac/README.txt @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: fractal@ow2.org Author: Lionel Seinturier +Contributors: Philippe Merle, Frédéric Loiret, Romain Rouvoy, Christophe Munilla ============================================================================ Juliac 2.4 diff --git a/juliac/RELEASE_NOTES.txt b/juliac/RELEASE_NOTES.txt index 8c44654f9b..75c5f52860 100755 --- a/juliac/RELEASE_NOTES.txt +++ b/juliac/RELEASE_NOTES.txt @@ -1,5 +1,6 @@ Juliac 2.4 ---------- +* OSGi/Knopflerfish support (contributed by Christophe Munilla) * API refactoring * bug fix when generating the membrane factory: support membrane types where the first type is not necessarily the component control interface diff --git a/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java b/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java index 77b32bb0b9..068acb3a91 100644 --- a/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java +++ b/juliac/extension/osgi/runtime/knopflerfish/src/main/java/org/objectweb/fractal/juliac/osgi/PlatformImpl.java @@ -1,6 +1,6 @@ /*** * Juliac - * Copyright (C) 2009-2011 INRIA, USTL + * Copyright (C) 2011 INRIA, USTL * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -37,7 +37,8 @@ import org.osgi.framework.launch.FrameworkFactory; /** * Helper methods for dealing with OSGi/Knopflerfish. * - * @author Christophe Munilla + * @author Christophe Munilla + * @since 2.4 */ public class PlatformImpl implements PlatformItf { diff --git a/juliac/extension/osgi/runtime/pom.xml b/juliac/extension/osgi/runtime/pom.xml index e419a17b56..e5487b3519 100644 --- a/juliac/extension/osgi/runtime/pom.xml +++ b/juliac/extension/osgi/runtime/pom.xml @@ -17,6 +17,7 @@ core equinox felix + knopflerfish -- GitLab From 466e9eb5872bc8bde7bc7ec148da67ac91ef9ca6 Mon Sep 17 00:00:00 2001 From: Romain Rouvoy Date: Fri, 1 Apr 2011 07:39:41 +0000 Subject: [PATCH 24/24] [maven-release-plugin] prepare release fraclet-annotations-3.3 --- .../fraclet-java/fraclet-annotations/pom.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fraclet/fraclet-java/fraclet-annotations/pom.xml b/fraclet/fraclet-java/fraclet-annotations/pom.xml index bb3751051d..23fcd04eea 100644 --- a/fraclet/fraclet-java/fraclet-annotations/pom.xml +++ b/fraclet/fraclet-java/fraclet-annotations/pom.xml @@ -14,9 +14,7 @@ with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> - + 4.0.0 org.objectweb.fractal.fraclet.java @@ -26,7 +24,7 @@ fraclet-annotations Fraclet Java5 annotations - 3.3-SNAPSHOT + 3.3 Fraclet programming model definition @@ -64,13 +62,17 @@ true .svn - - + + + + + scm:svn:ssh://svn.forge.objectweb.org/svnroot/fractal/tags/fraclet-annotations-3.3 + scm:svn:svn+ssh://rouvoy@svn.forge.objectweb.org/svnroot/fractal/tags/fraclet-annotations-3.3 + http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/fractal/tags/fraclet-annotations-3.3 + \ No newline at end of file -- GitLab