Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generating Java code from java classes in RCP
Generating Java code from java classes in RCP [message #1631178] Mon, 23 February 2015 16:35 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
I have an RCP application and i would like to generate java code at run time using EMF JET. I have seen the documents and tutorial, they are generating only one java file. I want to create multiple java files and compile and load them in RCP application.
Do i need to create one template for each file?

What is the best of generating java code at run time using JET? Is there any book or tutorial available showing how to generate multiple packages with java files, compile them and load them into class path?

Cheers?
Re: Generating Java code from java classes in RCP [message #1632078 is a reply to message #1631178] Tue, 24 February 2015 04:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 23.02.2015 17:35, ModelGeek Mising name wrote:
> I have an RCP application and i would like to generate java code at run
> time using EMF JET. I have seen the documents and tutorial, they are
> generating only one java file. I want to create multiple java files and
> compile and load them in RCP application.
Generally a template has inputs and generates something for each input
depending on how you orchestrate them.

> Do i need to create one template for each file?
>
> What is the best of generating java code at run time using JET? Is there
> any book or tutorial available showing how to generate multiple packages
> with java files, compile them and load them into class path?

No tutorial but you can see how the GenModel infrastructure is
implemented on top of JET.

>
> Cheers?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generating Java code from java classes in RCP [message #1632484 is a reply to message #1632078] Tue, 24 February 2015 09:52 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks!

Now i have understood how to generate multiple java files and packages. Now i am having RCP application so either i need to generate one new plugin at run time, compile it and add it in dependency list at run time or i need to generate code compile it as jar file and add to class path of plugin at the run time. Can you please guide me in this?


Do i need to download code/plugins related to GenModel and try to understand it? how can i get that code?

Cheers
Re: Generating Java code from java classes in RCP [message #1633371 is a reply to message #1632484] Tue, 24 February 2015 20:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
There are a great many things you need to get working and I certainly
can't guide you through them all. If you have the EMF SDK installed you
can import the project into the workspace or use Oomph to install a
development environment with all the EMF source:

http://projects.eclipse.org/projects/tools.oomph


On 24.02.2015 10:52, ModelGeek Mising name wrote:
> thanks!
>
> Now i have understood how to generate multiple java files and packages.
> Now i am having RCP application so either i need to generate one new
> plugin at run time, compile it and add it in dependency list at run time
> or i need to generate code compile it as jar file and add to class path
> of plugin at the run time. Can you please guide me in this?
>
>
> Do i need to download code/plugins related to GenModel and try to
> understand it? how can i get that code?
>
> Cheers


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generating Java code from java classes in RCP [message #1634394 is a reply to message #1633371] Wed, 25 February 2015 08:44 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks!

It would be really helpful for me if you can just give me some hints to start. Actually there is no book or tutorial and the search space for the topic is very large so if i can get some hints or some initial direction then it can be huge help for me.

May be i should break down my problem and should only ask about first step. I understand that. JetEmitter folder will be generated in the workspace containing generated code. How can put this .JetEmitter project into class path of my plugin at run time? Becuase i want to use the generated code using reflection API at run time.


thanks again for the help!

Cheers

[Updated on: Wed, 25 February 2015 21:25]

Report message to a moderator

Re: Generating Java code from java classes in RCP [message #1636371 is a reply to message #1634394] Thu, 26 February 2015 06:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
The hint is to look at the GenModel source code. It's rather a huge
example but the only one I have.

On 25.02.2015 09:44, ModelGeek Mising name wrote:
> thanks!
>
> It would be really helpful for me if you can just give me some hints to
> start. Actually there is no book or tutorial and the search space for
> the topic is very large so if i can get some hints or some initial
> direction then it can be huge help for me.
>
> thanks again for the help!
>
> Cheers


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generating Java code from java classes in RCP [message #1648357 is a reply to message #1636371] Tue, 03 March 2015 22:14 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
i am able to generate java source files using JET Templates and i am using java compiler API to compile the generated source code at the run time. Now i need to add generated and compiled java classes to the class path of plugin which generated and compiled the code.
I am trying to use Bundle-Classpath artifact in manifist.mf.
Can i mention aboslute path of the directory containing .class files? I am placing the compiled code in the work space as project. how can i specify the relative path in manifist.mf using Bundle-Classpath.
I am thinking of using
Bundle-Classpath : ., c:/aboslutepath/generatedcode
or

Bundle-Classpath : ., ../generatedcode
When the plugin will load the generated code will not be available but will be generated during rum time and i am using Bundle-ActivationPolicy: lazy


Am i in the right direction?

Cheers,
Re: Generating Java code from java classes in RCP [message #1649184 is a reply to message #1648357] Wed, 04 March 2015 07:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 03/03/2015 11:14 PM, ModelGeek Mising name wrote:
> i am able to generate java source files using JET Templates and i am
> using java compiler API to compile the generated source code at the
> run time. Now i need to add generated and compiled java classes to the
> class path of plugin which generated and compiled the code.
> I am trying to use Bundle-Classpath artifact in manifist.mf.
> Can i mention aboslute path of the directory containing .class files?
> I am placing the compiled code in the work space as project. how can i
> specify the relative path in manifist.mf using Bundle-Classpath.
> I am thinking of using Bundle-Classpath : .,
> c:/aboslutepath/generatedcode
> or
>
> Bundle-Classpath : ., ../generatedcode
> When the plugin will load the generated code will not be available but
> will be generated during rum time and i am using
> Bundle-ActivationPolicy: lazy
For EMF's generator, org.eclipse.emf.codegen.jet.JETEmitter is used to
load and run dynamic templates. It uses a URLClassLoader.
>
> Am i in the right direction?
> Cheers,


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generating Java code from java classes in RCP [message #1651879 is a reply to message #1649184] Thu, 05 March 2015 15:14 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 550
Registered: June 2011
Senior Member
thanks!
Now i am able to compile and load java programmes at run time and use loaded classes in RCP applications.

Cheers,

Previous Topic:Two editors with different editing domain
Next Topic:[CDO] dispose event for CDOResource
Goto Forum:
  


Current Time: Thu Apr 25 09:25:43 GMT 2024

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

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

Back to the top