lyfeyaj / jaql

Automatically exported from code.google.com/p/jaql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatic Function Loading by using Annotations

GoogleCodeExporter opened this issue · comments

The current process of determing the list of available functions
in jaql is to manually add them to a hash table. This process can
be simplified because  all jaql functions are marked with the 
"JaqlFn" Annotation.
The idea now is to add automatically add all classes annotated with
this Annotation to the hashtable. There are two ways to accomplish
this. First through runtime reflection of all classes or with a 
special annotation processing step during compile time. Because a
one time effort is generally better i chose to process the annotations
during compile time.

To accomplish this a custom Processor class is required that handles
the annotations. Based on the information provided by them it creates
a new class source file which contains a list of all functions. This
class is then used by FunctionLib to fill its hashtable.
Because the new class is generated after FunctionLib is compiled it
can only be indirectly referenced by using a ClassLoader. FunctionLib
also needs to know which methods the generated class provides so a new
interface was added that is implemented by the generated class.

Because the build process has changed the build.xml needs to be changed.
Two new steps where added to the compile task. After the first compilation
phase a second run of the java compiler is needed this time just with the
processor. It generates a new source file. This file is then compiled in
third compilation run.

When reviewing my code changes, please focus on:
- One big problem that is still left is that eclipse does not support that
the annotation processor is in the same project as the code it should
process. The proposed solutions to this are: 
1. A seperate project for the processor. 
2. Supply a jar containing the processor and use that for processing. This
jar needs to be recreated after each change to the processor. This should
happen only seldom.
Which way should we choose? 

- I also checked both the original function list and the generated one. The
generated one contains additionally hdfsRead / hdfsWrite. Is that a
problem?



After the review, I'll merge this patch into:
/trunk



Original issue reported on code.google.com by moritzka...@web.de on 19 Jun 2009 at 7:32

Attachments:

[deleted comment]
Are you saying that the source code of the functions is touched by your 
processor?
Why is this necessary? 

Original comment by Rainer.G...@gmx.de on 22 Jun 2009 at 10:05

Original comment by moritzka...@web.de on 12 Sep 2009 at 12:38

  • Changed state: Duplicate