Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to use xtext inferred JVM model outside of xtext project?
How to use xtext inferred JVM model outside of xtext project? [message #892716] Fri, 29 June 2012 10:36 Go to next message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member
In the **Inferring a JVM Model** section of the Xtext documentation it starts by saying:
"In many cases, you will want your DSLs concepts to be usable as Java elements. E.g. an Entity will become a Java class and should be usable as such".

In the example above, how can I use the generated Entity class **outside** of xbase, i.e. in real Java code in a different project to the xtext one?

What I am essentially asking is if the Java classes created my by the model Inferrer can actually be used as real java classes, which can have their methods called and fields accessed from java code, in an altogether different project, and if so how this can be done?

My going through the documentation has lead me to fear that the generated "Java classes" are only Xbase types, only referenceabe in an xtext context, and are not therefore real java classes...
Re: How to use xtext inferred JVM model outside of xtext project? [message #892952 is a reply to message #892716] Mon, 02 July 2012 07:07 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
When using Xbase as described in the docs, it will automatically
generate Java classes from your DSL artifacts. It's these classes that
are referrable by Java.

In contrast to the traditional model > text code generation approach, in
Xbase you define a transformation of your DSL model to a Java model. As
the Java model is comprehensive, the Xbase infrastructure can generate
the Java code from it.

Am 29.06.12 12:36, schrieb Marcus Mathioudakis:
> In the **Inferring a JVM Model** section of the Xtext documentation it
> starts by saying:
> "In many cases, you will want your DSLs concepts to be usable as Java
> elements. E.g. an Entity will become a Java class and should be usable
> as such".
>
> In the example above, how can I use the generated Entity class
> **outside** of xbase, i.e. in real Java code in a different project to
> the xtext one?
>
> What I am essentially asking is if the Java classes created my by the
> model Inferrer can actually be used as real java classes, which can have
> their methods called and fields accessed from java code, in an
> altogether different project, and if so how this can be done?
> My going through the documentation has lead me to fear that the
> generated "Java classes" are only Xbase types, only referenceabe in an
> xtext context, and are not therefore real java classes...
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: How to use xtext inferred JVM model outside of xtext project? [message #892966 is a reply to message #892952] Mon, 02 July 2012 08:01 Go to previous messageGo to next message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member

Quote:
When using Xbase as described in the docs, it will automatically
generate Java classes from your DSL artifacts. It's these classes that
are referrable by Java.

In contrast to the traditional model > text code generation approach, in
Xbase you define a transformation of your DSL model to a Java model. As
the Java model is comprehensive, the Xbase infrastructure can generate
the Java code from it.



Ok so it gererates the classes, but how do I access them? I'm assuming you mean it loads them into the JVM (as opposed to actually generating code for them) but then how do you refer to them? I can't seem to find any kind of service for doing thihs, or an example of someone inferring a JVM model, and then referring to the resulting Java classes from a java context.

[Updated on: Mon, 02 July 2012 08:03]

Report message to a moderator

Re: How to use xtext inferred JVM model outside of xtext project? [message #892967 is a reply to message #892966] Mon, 02 July 2012 08:01 Go to previous messageGo to next message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member
No Message Body

[Updated on: Mon, 02 July 2012 08:02]

Report message to a moderator

Re: How to use xtext inferred JVM model outside of xtext project? [message #892993 is a reply to message #892966] Mon, 02 July 2012 08:49 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
No, it generates Java source code that is picked up by JDT and thus
compiled. At execution time, it is only the Java class file that is
executed.

Am 02.07.12 10:01, schrieb Marcus Mathioudakis:
> Ok so it gererates the classes, but how do I access them? I'm assuming
> you mean it loads them into the JVM (as opposed to actually generating
> code for them) but then how do you refer to them? I can't seem to find
> any kind of service for doing thihs, or an example of someone inferring
> a JVM model, and then referring to the resulting Java classes from a
> java context.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:how to create reference for xtext
Next Topic:Crossreferences in an embedded editor
Goto Forum:
  


Current Time: Tue Apr 23 09:12:00 GMT 2024

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

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

Back to the top