Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Java class as source
Java class as source [message #45200] Wed, 07 May 2008 19:48 Go to next message
Jeffrey Ricker is currently offline Jeffrey RickerFriend
Messages: 18
Registered: July 2009
Junior Member
I want to create a set of decorator classes for a set of existing
interfaces. Most of the methods are pass through methods. For instance,

public class MyDecoratorImpl extends EObjectImpl{
private MyDecoratedObject decorated;

public Foo getFoo(){
decorated.getFoo();
}
....

I want to walk the methods of the input class and generate the output
EObject classes. The problem is the class loading. I cannot simply call
Class.forName("com.foo.MyDecoratedObject") from within the template or
within a custom tag library.

Any thoughts?

- Ricker
Re: Java class as source [message #45234 is a reply to message #45200] Thu, 08 May 2008 17:11 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Ricker:

Getting JET to read on existing meta-model (such as the Java reflective
APIs) involves two things:

1) creating a set of XPath 'inspectors' that let the XPath engine understand
model elements in terms of the XPath infoset.

2) (optional) if you want to such meta-models from the Eclipse workspace,
you must also create a 'model loader'.

JET has extension points for both.

I have an example of these as an example in CVS. Co-incidentally, the
example my do what you want. The 'loader' loads a .java file by creating an
JDT Abstract Syntax Tree (AST). The inspector traverses the tree.

Details on how to check out the example are found in bug 227819
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=227819).

Working from an AST allow you to do what you want. If it does, I'd
appreciate feedback on the loader/inspector. It would be nice to incorprate
it into JET proper one day.

Paul



"Jeffrey Ricker" <ricker@jeffreyricker.com> wrote in message
news:fvt122$dt$1@build.eclipse.org...
>I want to create a set of decorator classes for a set of existing
>interfaces. Most of the methods are pass through methods. For instance,
>
> public class MyDecoratorImpl extends EObjectImpl{
> private MyDecoratedObject decorated;
>
> public Foo getFoo(){
> decorated.getFoo();
> }
> ...
>
> I want to walk the methods of the input class and generate the output
> EObject classes. The problem is the class loading. I cannot simply call
> Class.forName("com.foo.MyDecoratedObject") from within the template or
> within a custom tag library.
>
> Any thoughts?
>
> - Ricker
Re: Java class as source [message #45264 is a reply to message #45200] Fri, 09 May 2008 11:56 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey Jeffrey,

when I click on a java file, and do open with... I can select
"Java Model Editor" somewhere down the list. It seems like EMF provides a java
ecore model, that makes it possible to inspect java classes via emf. As jet can
do emf this would maybe be an elegant (but possibly slower) way to solve your
problem?


Felix
Previous Topic:ensure import programatically
Next Topic:run ant task passing variables
Goto Forum:
  


Current Time: Fri Mar 29 13:44:45 GMT 2024

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

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

Back to the top