Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Loading operator extension from Jar file
Loading operator extension from Jar file [message #1734022] Fri, 03 June 2016 06:43 Go to next message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 122
Registered: July 2014
Location: Belfort, France
Senior Member
Dear all.

I'm writing an library that is providing math primitives such as vectors, matrices, etc.

Currently, I have hard-coded the Xbase operators in the primitives by creating functions like:
public Vector operator_plus(Vector a) {
    Vector v = new Vector(this);
    v.add(a);
    return v;
}


The use of the operators in my DSL is working.

Now, I would like to move these functions into a static utility class similar to the MapExtensions provided by Xtext.

The problem is:
is it possible for the DSL compiler to automatically load this extension when the Jar file of my math library is present in the classpath of the compiled project?

I would like to find some automatic approach that do not requires to change neither the compiler's configuration nor its code.

I know how to add an extension in the DSL compiler. But I would like to know if the Xtext provides tools for dynamic loading.

All the best.
St├ęphane.
Re: Loading operator extension from Jar file [message #1734149 is a reply to message #1734022] Sun, 05 June 2016 08:45 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13219
Registered: July 2009
Senior Member
hi i am not sure if i get your question, but extension classes like MapExtensions are registered through ImplicitlyImportedFeatures respectively StaticImplicitMethodsFeatureForTypeProvider

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Loading operator extension from Jar file [message #1734160 is a reply to message #1734149] Sun, 05 June 2016 14:34 Go to previous messageGo to next message
Stephane Galland is currently offline Stephane GallandFriend
Messages: 122
Registered: July 2014
Location: Belfort, France
Senior Member
Thank you for your reply.
Are the ImplicityImportedFeatures or StaticImplicitMethodsFeatureForTypeProvider able to dynamically load the extensions by reading the MANIFEST file of a JAr file in the classpath.
In other words, is it possible to implicitly load features stored in a Jar file, just by adding this Jar file.

If not, I should specialize ImplicityImportedFeatures or StaticImplicitMethodsFeatureForTypeProvider in my DSL compiler.

All the best.
St├ęphane.
Re: Loading operator extension from Jar file [message #1734164 is a reply to message #1734160] Sun, 05 June 2016 14:52 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13219
Registered: July 2009
Senior Member
I'd make the extension static and adapt implicitelyimortedfeatures. And yes the class file needed to be on the class path of the dsl file

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:ISerializationContext cannot be resolved to a type
Next Topic:Referring an xcore enum in xtext
Goto Forum:
  


Current Time: Thu Nov 21 19:06:29 GMT 2019

Powered by FUDForum. Page generated in 0.01452 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top