Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » calling genmodel dynamic templates stored into plugins
calling genmodel dynamic templates stored into plugins [message #415810] Tue, 08 January 2008 10:16 Go to next message
Cyril Faucher is currently offline Cyril FaucherFriend
Messages: 63
Registered: July 2009
Member
Hi,

In a genmodel file, I have tried to call dynamic templates files that
are stored into my current workspace: it works.
After that, I have tried to call the same dynamic templates files that
are stored into my plugin installation: it does not work.

Is there a workaround to call dynamic templates that are stored into
plugins ?

Best regards,
Cyril.

--
Cyril Faucher
IRISA-INRIA - Rennes, France
[Breathe life into your metamodels www.kermeta.org]
Re: calling genmodel dynamic templates stored into plugins [message #415819 is a reply to message #415810] Tue, 08 January 2008 13:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000605080200050308020302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Cyril,

If you use platform:/plugin/<plugin-ID> in the template path it should
end up in this code path in JETEmitter to look for the compiled
templates in the runtime environment

else if (templateURI.isPlatformPlugin())
{
final Bundle bundle =
Platform.getBundle(templateURI.segment(1));
if (bundle != null)
{
// Define a class loader that will look up the class in
the bundle,
// and if it doesn't find it there, will look in the parent.
//
theClassLoader =
new URLClassLoader(new URL [0], jetEmitter.classLoader)
{
@Override
public Class<?> loadClass(String className) throws
ClassNotFoundException
{
try
{
return bundle.loadClass(className);
}
catch (ClassNotFoundException classNotFoundException)
{
return super.loadClass(className);
}
}
};
}
}


Cyril Faucher wrote:
> Hi,
>
> In a genmodel file, I have tried to call dynamic templates files that
> are stored into my current workspace: it works.
> After that, I have tried to call the same dynamic templates files that
> are stored into my plugin installation: it does not work.
>
> Is there a workaround to call dynamic templates that are stored into
> plugins ?
>
> Best regards,
> Cyril.
>


--------------000605080200050308020302
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Cyril,<br>
<br>
If you use platform:/plugin/&lt;plugin-ID&gt; in the template path it
should end up in this code path in JETEmitter to look for the compiled
templates in the runtime environment<br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if (templateURI.isPlatformPlugin())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final Bundle bundle =
Platform.getBundle(templateURI.segment(1));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (bundle != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Define a class loader that will look up the class in
the bundle,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // and if it doesn't find it there, will look in the
parent.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; theClassLoader = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; new URLClassLoader(new URL [0], jetEmitter.classLoader)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @Override<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Class&lt;?&gt; loadClass(String className)
throws ClassNotFoundException<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; try<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return bundle.loadClass(className);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; catch (ClassNotFoundException
classNotFoundException)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return super.loadClass(className);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; };<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<br>
<br>
Cyril Faucher wrote:
<blockquote cite="mid:flviii$c7c$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
In a genmodel file, I have tried to call dynamic templates files that
are stored into my current workspace: it works.
<br>
After that, I have tried to call the same dynamic templates files that
are stored into my plugin installation: it does not work.
<br>
<br>
Is there a workaround to call dynamic templates that are stored into
plugins ?
<br>
<br>
Best regards,
<br>
Cyril.
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------000605080200050308020302--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: calling genmodel dynamic templates stored into plugins [message #415839 is a reply to message #415819] Wed, 09 January 2008 12:57 Go to previous message
Cyril Faucher is currently offline Cyril FaucherFriend
Messages: 63
Registered: July 2009
Member
Hi Ed,

Thanks to your reply, for further reasons I have my own "generator"
class, so I have added the missing plugin id like that:
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries , xyz, xyz)
and now it works in deployed mode.

Regards,
Cyril.

Ed Merks a écrit :
> Cyril,
>
> If you use platform:/plugin/<plugin-ID> in the template path it should
> end up in this code path in JETEmitter to look for the compiled
> templates in the runtime environment
>
> else if (templateURI.isPlatformPlugin())
> {
> final Bundle bundle =
> Platform.getBundle(templateURI.segment(1));
> if (bundle != null)
> {
> // Define a class loader that will look up the class in
> the bundle,
> // and if it doesn't find it there, will look in the parent.
> //
> theClassLoader =
> new URLClassLoader(new URL [0], jetEmitter.classLoader)
> {
> @Override
> public Class<?> loadClass(String className) throws
> ClassNotFoundException
> {
> try
> {
> return bundle.loadClass(className);
> }
> catch (ClassNotFoundException classNotFoundException)
> {
> return super.loadClass(className);
> }
> }
> };
> }
> }
>
>
> Cyril Faucher wrote:
>> Hi,
>>
>> In a genmodel file, I have tried to call dynamic templates files that
>> are stored into my current workspace: it works.
>> After that, I have tried to call the same dynamic templates files that
>> are stored into my plugin installation: it does not work.
>>
>> Is there a workaround to call dynamic templates that are stored into
>> plugins ?
>>
>> Best regards,
>> Cyril.
>>
>


--
Cyril Faucher
IRISA-INRIA - Rennes, France
[Breathe life into your metamodels www.kermeta.org]
Previous Topic:EMF Change plugin
Next Topic:different behaviour when run from the IDE to when ran the exported product ..
Goto Forum:
  


Current Time: Tue Mar 19 09:03:54 GMT 2024

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

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

Back to the top