Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Calling Java methods
[Acceleo] Calling Java methods [message #61819] Tue, 26 May 2009 20:50 Go to next message
Eclipse UserFriend
Originally posted by: no.email.com

Salut to the team Acceleo,

I'd like to call java code in Acceleo, is it possible?
I have an old generator made in Java and I'm trying to update it by
converting some parts to MTL but I'd like to keep other parts in Java,
like complex queries to retrieve / filter / sort some model elements,
and call them from MTL templates.

Thanks,
Jeremy
Re: [Acceleo] Calling Java methods [message #61866 is a reply to message #61819] Wed, 27 May 2009 10:00 Go to previous messageGo to next message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090407060402010806000102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

hi Jeremy,

Java services in Acceleo is not possible yet.

We ( EEF team ) use Acceleo for a while and didn't have any specials
needs for a java service for now.

OCL can't fit your needs ?

Cheers,

St
Re: [Acceleo] Calling Java methods [message #62052 is a reply to message #61866] Thu, 28 May 2009 17:52 Go to previous messageGo to next message
Jonathan MUSSET is currently offline Jonathan MUSSETFriend
Messages: 43
Registered: July 2009
Member
It is coming soon...
The engine is ready but not the compiler...
We've finally planned to do that after the galileo release
But stephane is right ;-)
Perhaps OCL can fit your need, you can make queries...
At the moment, there is a way to pass Java arguments to the code generator :
(I'm not sure to help you with this solution)
You can modify the generated Java class (code generation entry point
@main) and give the instance of your Java Class as an argument of the
code generation

Cheers,

Jonathan






Stéphane Bouchet a écrit :
> hi Jeremy,
>
> Java services in Acceleo is not possible yet.
>
> We ( EEF team ) use Acceleo for a while and didn't have any specials
> needs for a java service for now.
>
> OCL can't fit your needs ?
>
> Cheers,
>
> Stéphane
>
> Jeremy Lavean a écrit :
>> Salut to the team Acceleo,
>>
>> I'd like to call java code in Acceleo, is it possible?
>> I have an old generator made in Java and I'm trying to update it by
>> converting some parts to MTL but I'd like to keep other parts in Java,
>> like complex queries to retrieve / filter / sort some model elements,
>> and call them from MTL templates.
>>
>> Thanks,
>> Jeremy
>
Re: [Acceleo] Calling Java methods [message #62075 is a reply to message #62052] Thu, 28 May 2009 20:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: no.email.com

Thanks for your answers.
I know I could do what I want in OCL but, hmm, I'm lazy :).
By the way, is the code of your future unfinished version available on a
public repository? I'd be glad to look at the code to see the new
features if that was possible or even contribute some parts.


Jonathan MUSSET a écrit :
> It is coming soon...
> The engine is ready but not the compiler...
> We've finally planned to do that after the galileo release
> But stephane is right ;-)
> Perhaps OCL can fit your need, you can make queries...
> At the moment, there is a way to pass Java arguments to the code
> generator :
> (I'm not sure to help you with this solution)
> You can modify the generated Java class (code generation entry point
> @main) and give the instance of your Java Class as an argument of the
> code generation
>
> Cheers,
>
> Jonathan
>
>
>
>
>
>
> Stéphane Bouchet a écrit :
>> hi Jeremy,
>>
>> Java services in Acceleo is not possible yet.
>>
>> We ( EEF team ) use Acceleo for a while and didn't have any specials
>> needs for a java service for now.
>>
>> OCL can't fit your needs ?
>>
>> Cheers,
>>
>> Stéphane
>>
>> Jeremy Lavean a écrit :
>>> Salut to the team Acceleo,
>>>
>>> I'd like to call java code in Acceleo, is it possible?
>>> I have an old generator made in Java and I'm trying to update it by
>>> converting some parts to MTL but I'd like to keep other parts in
>>> Java, like complex queries to retrieve / filter / sort some model
>>> elements, and call them from MTL templates.
>>>
>>> Thanks,
>>> Jeremy
>>
Re: [Acceleo] Calling Java methods [message #62147 is a reply to message #62075] Fri, 29 May 2009 16:15 Go to previous messageGo to next message
Jonathan MUSSET is currently offline Jonathan MUSSETFriend
Messages: 43
Registered: July 2009
Member
Thank you,
I'll be happy to have such a contribution ;-)

The Eclipse Acceleo code is available at :
CVS host : dev.eclipse.org
Repository : /cvsroot/modeling/org.eclipse.m2t/org.eclipse.acceleo

You can checkout all the org.eclipse.acceleo* plugins and features...
(Eclipse Galileo)

You have to define a way in the parser to store the dynamic Java
services as new OCL services

The class OCLParser is a good entry point because I think that you'll
have to register Java Classes like the templates and the queries

Other important classes for this task are AcceleoWorkspaceUtil (common),
and AcceleoEnvironment (parser)...

Let me know when you have problem, and good luck ;-)

Cheers,

Jonathan



Jeremy Lavean a écrit :
> Thanks for your answers.
> I know I could do what I want in OCL but, hmm, I'm lazy :).
> By the way, is the code of your future unfinished version available on a
> public repository? I'd be glad to look at the code to see the new
> features if that was possible or even contribute some parts.
>
>
> Jonathan MUSSET a écrit :
>> It is coming soon...
>> The engine is ready but not the compiler...
>> We've finally planned to do that after the galileo release
>> But stephane is right ;-)
>> Perhaps OCL can fit your need, you can make queries...
>> At the moment, there is a way to pass Java arguments to the code
>> generator :
>> (I'm not sure to help you with this solution)
>> You can modify the generated Java class (code generation entry point
>> @main) and give the instance of your Java Class as an argument of the
>> code generation
>>
>> Cheers,
>>
>> Jonathan
>>
>>
>>
>>
>>
>>
>> Stéphane Bouchet a écrit :
>>> hi Jeremy,
>>>
>>> Java services in Acceleo is not possible yet.
>>>
>>> We ( EEF team ) use Acceleo for a while and didn't have any specials
>>> needs for a java service for now.
>>>
>>> OCL can't fit your needs ?
>>>
>>> Cheers,
>>>
>>> Stéphane
>>>
>>> Jeremy Lavean a écrit :
>>>> Salut to the team Acceleo,
>>>>
>>>> I'd like to call java code in Acceleo, is it possible?
>>>> I have an old generator made in Java and I'm trying to update it by
>>>> converting some parts to MTL but I'd like to keep other parts in
>>>> Java, like complex queries to retrieve / filter / sort some model
>>>> elements, and call them from MTL templates.
>>>>
>>>> Thanks,
>>>> Jeremy
>>>
Re: [Acceleo] Calling Java methods [message #62171 is a reply to message #62147] Sat, 30 May 2009 00:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nomail.email.com

I must admit I don't have the time to really understand the code of
Acceleo and to be able to add the Java service call.
I'll try to contribute another time.
Sorry for the bother,
Jeremy

Jonathan MUSSET a écrit :
> Thank you,
> I'll be happy to have such a contribution ;-)
>
> The Eclipse Acceleo code is available at :
> CVS host : dev.eclipse.org
> Repository : /cvsroot/modeling/org.eclipse.m2t/org.eclipse.acceleo
>
> You can checkout all the org.eclipse.acceleo* plugins and features...
> (Eclipse Galileo)
>
> You have to define a way in the parser to store the dynamic Java
> services as new OCL services
>
> The class OCLParser is a good entry point because I think that you'll
> have to register Java Classes like the templates and the queries
>
> Other important classes for this task are AcceleoWorkspaceUtil (common),
> and AcceleoEnvironment (parser)...
>
> Let me know when you have problem, and good luck ;-)
>
> Cheers,
>
> Jonathan
>
>
>
> Jeremy Lavean a écrit :
>> Thanks for your answers.
>> I know I could do what I want in OCL but, hmm, I'm lazy :).
>> By the way, is the code of your future unfinished version available on
>> a public repository? I'd be glad to look at the code to see the new
>> features if that was possible or even contribute some parts.
>>
>>
>> Jonathan MUSSET a écrit :
>>> It is coming soon...
>>> The engine is ready but not the compiler...
>>> We've finally planned to do that after the galileo release
>>> But stephane is right ;-)
>>> Perhaps OCL can fit your need, you can make queries...
>>> At the moment, there is a way to pass Java arguments to the code
>>> generator :
>>> (I'm not sure to help you with this solution)
>>> You can modify the generated Java class (code generation entry point
>>> @main) and give the instance of your Java Class as an argument of the
>>> code generation
>>>
>>> Cheers,
>>>
>>> Jonathan
>>>
>>>
>>>
>>>
>>>
>>>
>>> Stéphane Bouchet a écrit :
>>>> hi Jeremy,
>>>>
>>>> Java services in Acceleo is not possible yet.
>>>>
>>>> We ( EEF team ) use Acceleo for a while and didn't have any specials
>>>> needs for a java service for now.
>>>>
>>>> OCL can't fit your needs ?
>>>>
>>>> Cheers,
>>>>
>>>> Stéphane
>>>>
>>>> Jeremy Lavean a écrit :
>>>>> Salut to the team Acceleo,
>>>>>
>>>>> I'd like to call java code in Acceleo, is it possible?
>>>>> I have an old generator made in Java and I'm trying to update it by
>>>>> converting some parts to MTL but I'd like to keep other parts in
>>>>> Java, like complex queries to retrieve / filter / sort some model
>>>>> elements, and call them from MTL templates.
>>>>>
>>>>> Thanks,
>>>>> Jeremy
>>>>
Re: [Acceleo] Calling Java methods [message #62705 is a reply to message #62171] Mon, 22 June 2009 14:25 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070406050409020802070304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Jeremy,

Sorry for the delay, I didn't pay enough attention to this thread ... We
don't have a "nice" way to call java methods from acceleo templates yet;
and we the MTL specification doesn't allow for anything of the sort either.

We do provide a workaround though, in the form of a non-standard
operation allowing you to call java code from any template. Its syntax is :
[invoke(<qualified class name>, <full method name>, Sequence{<arguments>})/]

For example, let's say you have a service class
"domain.host.StringService" providing a method "toLower(String)". This
method could then be called with :
[invoke("domain.host.StringService", "toLower(java.lang.String)",
Sequence{'TEST'}/]

As you can see for yourself, this isn't really the readable way of doing
things ... and you can expect this to change on later versions of
Acceleo. It is merely provided as a workaround for now in wait for
proper tooling.

Laurent Goubet
Obeo

Jeremy Lavean a
Re: [Acceleo] Calling Java methods [message #62827 is a reply to message #62705] Fri, 26 June 2009 12:41 Go to previous messageGo to next message
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
Hi,

this is better than having no black-box support at all. Unfortunately I
cannot invoke methods that have no parameters. Example:
[invoke('de.fuberlin.m2t.test.Helper', 'test()', Sequence{})/]
creates the output
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@19aa8db (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@c3f2e6 (name: Invalid_Class)
(instanceClassName: null) (abstract: false, interface: false))

When adding a dummy string-attribute to the java method and pass a dummy
string on invokation, everything works fine. Did I do something wrong, or
is it a bug?
Re: [Acceleo] Calling Java methods [message #63101 is a reply to message #62827] Fri, 26 June 2009 12:53 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080000070908000701000900
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Max,

This feature comes from the "old" Acceleo where invoking Java services
was frequent. In this "old" version, Java services had to be defined
with a first parameter being the "receiver" of the service. This
behavior has been kept in this implementation.

It is true though that having a parameter is not always mandatory ...
we'll have to think about this when we give this feature its needed
overhaul :). For now and as you've discovered, passing the methods a
dummy argument is a workaround.

Do not hesitate to raise bugzillas about the things you'd like to see
evolve or you think ar not intuitive/usable enough. This feature is a
good example of a thing we provide "non-standard" yet would like to see
added to the OMG specification sooner or later. Ideas to improve such
features will always be warmly welcomed.

Laurent Goubet
Obeo

Max Bureck a
Re: [Acceleo] Calling Java methods [message #523192 is a reply to message #63101] Thu, 25 March 2010 08:38 Go to previous messageGo to next message
Kevin Missing name is currently offline Kevin Missing nameFriend
Messages: 10
Registered: October 2009
Junior Member
laurent Goubet schrieb:
> Hi Max,
>
> This feature comes from the "old" Acceleo where invoking Java services
> was frequent. In this "old" version, Java services had to be defined
> with a first parameter being the "receiver" of the service. This
> behavior has been kept in this implementation.
>
> It is true though that having a parameter is not always mandatory ...
> we'll have to think about this when we give this feature its needed
> overhaul :). For now and as you've discovered, passing the methods a
> dummy argument is a workaround.
>
> Do not hesitate to raise bugzillas about the things you'd like to see
> evolve or you think ar not intuitive/usable enough. This feature is a
> good example of a thing we provide "non-standard" yet would like to see
> added to the OMG specification sooner or later. Ideas to improve such
> features will always be warmly welcomed.
>
> Laurent Goubet
> Obeo
>
> Max Bureck a écrit :
>> Hi,
>>
>> this is better than having no black-box support at all. Unfortunately
>> I cannot invoke methods that have no parameters. Example:
>> [invoke('de.fuberlin.m2t.test.Helper', 'test()', Sequence{})/]
>> creates the output
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@19aa8db (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@c3f2e6 (name: Invalid_Class)
>> (instanceClassName: null) (abstract: false, interface: false))
>>
>> When adding a dummy string-attribute to the java method and pass a
>> dummy string on invokation, everything works fine. Did I do something
>> wrong, or is it a bug?
>>
>
Hi,

i have another question. When i am invoking a java method and i am
returning a String or something, its always comes out with brackets like
"[myString]". Is there a way do work around that ? Sry, its my first
week with Acceleo ;).
Re: [Acceleo] Calling Java methods [message #523195 is a reply to message #523192] Thu, 25 March 2010 13:32 Go to previous messageGo to next message
Kevin Missing name is currently offline Kevin Missing nameFriend
Messages: 10
Registered: October 2009
Junior Member
Kevin Barwich schrieb:
> laurent Goubet schrieb:
>> Hi Max,
>>
>> This feature comes from the "old" Acceleo where invoking Java services
>> was frequent. In this "old" version, Java services had to be defined
>> with a first parameter being the "receiver" of the service. This
>> behavior has been kept in this implementation.
>>
>> It is true though that having a parameter is not always mandatory ...
>> we'll have to think about this when we give this feature its needed
>> overhaul :). For now and as you've discovered, passing the methods a
>> dummy argument is a workaround.
>>
>> Do not hesitate to raise bugzillas about the things you'd like to see
>> evolve or you think ar not intuitive/usable enough. This feature is a
>> good example of a thing we provide "non-standard" yet would like to
>> see added to the OMG specification sooner or later. Ideas to improve
>> such features will always be warmly welcomed.
>>
>> Laurent Goubet
>> Obeo
>>
>> Max Bureck a écrit :
>>> Hi,
>>>
>>> this is better than having no black-box support at all. Unfortunately
>>> I cannot invoke methods that have no parameters. Example:
>>> [invoke('de.fuberlin.m2t.test.Helper', 'test()', Sequence{})/]
>>> creates the output
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@19aa8db (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@c3f2e6 (name: Invalid_Class)
>>> (instanceClassName: null) (abstract: false, interface: false))
>>>
>>> When adding a dummy string-attribute to the java method and pass a
>>> dummy string on invokation, everything works fine. Did I do something
>>> wrong, or is it a bug?
>>>
>>
> Hi,
>
> i have another question. When i am invoking a java method and i am
> returning a String or something, its always comes out with brackets like
> "[myString]". Is there a way do work around that ? Sry, its my first
> week with Acceleo ;).

Ok, never mind.
Re: [Acceleo] Calling Java methods [message #523382 is a reply to message #523195] Fri, 26 March 2010 04:22 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060604020905000303040108
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Kevin,

I guess from this second mail that you've figured out the why. Please
create new threads for new questions instead of reusing old ones :).

Laurent Goubet
Obeo

Kevin Barwich wrote:
> Kevin Barwich schrieb:
>> laurent Goubet schrieb:
>>> Hi Max,
>>>
>>> This feature comes from the "old" Acceleo where invoking Java
>>> services was frequent. In this "old" version, Java services had to be
>>> defined with a first parameter being the "receiver" of the service.
>>> This behavior has been kept in this implementation.
>>>
>>> It is true though that having a parameter is not always mandatory ...
>>> we'll have to think about this when we give this feature its needed
>>> overhaul :). For now and as you've discovered, passing the methods a
>>> dummy argument is a workaround.
>>>
>>> Do not hesitate to raise bugzillas about the things you'd like to see
>>> evolve or you think ar not intuitive/usable enough. This feature is a
>>> good example of a thing we provide "non-standard" yet would like to
>>> see added to the OMG specification sooner or later. Ideas to improve
>>> such features will always be warmly welcomed.
>>>
>>> Laurent Goubet
>>> Obeo
>>>
>>> Max Bureck a
Previous Topic:[XPAND] Iterate over elements from imported models
Next Topic:[Acceleo] Headless exeuction after installation
Goto Forum:
  


Current Time: Thu Mar 28 18:11:51 GMT 2024

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

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

Back to the top