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.
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.
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
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?