Hi,

It sounds like an interesting idea! What about using the "service loader"
API, similar to how Java drivers are auto-loaded in Java 6. For this, a
text file META-INF/services/org.h2.Extension could be used that contains
the list of extension classes.

As a staring point, the class could have a method with the signature:

    public static void register(Connection conn) throws SQLException

same as in org.h2.mode.FunctionsMySQL. Probably we want to add an interface
that defines this method. Function names could be defined using an
annotations, but the register method might be more flexible (allows to
install triggers, create tables / views,...) so I think the register method
would be nice.

For extensions that are to be auto-loaded when a certain mode is used, what
about org.h2.ExtensionMySQL / ExtensionPostgreSQL / ExtensionOracle and so
on.

Regards,
Thomas




On Monday, July 9, 2012, Alfred Reibenschuh wrote:

> hi!
>
> i'd like to propose a simple but effective methodology to auto register
> additional db-functions to h2 just by having the user/admin making
> additional jar files available on the classpath.
>
> The H2-DB Engine would have to use the classloader to lookup all files
> named '/META-INF/org.h2.ext.FunctionClass' (or similar) which would be a
> simple text file containing one class-name by line to be considered.
>
> then:
>
> for each $class
> {
>   if $class instanceof org.h2.api.AggregateFunction
>   {
>     registerFunctionClass($class)
>   }
>   else
>   {
>     scan $class for methods starting with 'FN_'
>       then registerFunctionMethod($class, $method, $fname)
>   }
> }
>
> for the MODE-Support already in H2 a filename
> like '/META-INF/org.h2.ext.FunctionClass.$MODE' could be used.
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/NXzf0yf1S8AJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to