Java Interface

Version 0.3.0

To make a generator visible within SQL Developer, implement the oddgen Java interface in a JVM language of your choice such as Java, Scala, Groovy, Clojure, JRuby, Jython or Xtend. oddgen looks for classes implementing the OddgenGenerator interface in JAR files in the SQL Developer extension directory. This allows you to distribute your client generators as a SQL Developer extension or an ordinary JAR file. See Tutorial 3 – Extended 1:1 View Generator (Xtend) for an example how to create a client generator.

The Java interface is very similar to the PL/SQL interface. Basically there are four differences:

  • Every method of the Java interface has a parameter named conn to access the active database connection.
  • The method getParams returns a LinkedHashMap, this means the parameters are ordered by entry. Hence no equivalent for the PL/SQL method get_orderd_params is necessary.
  • The additional method isSupported determines the executability under the current connection. No equivalent exist for PL/SQL, since it is being expected that all installed and valid PL/SQL packages are executable.
  • Every method of the Java interface must be implemented.

oddgen for SQL Developer is backward compatible, hence the deprecated  Java interface v0.2.0 ist still fully functional. In fact it is possible to implement both interfaces making the generator work in older and current installations. Just the newest version of an interface is used, if a class implements more than one oddgen interface.

OddgenGenerator2

oddgen for SQL Developer is completely developed in Xtend, mainly because of its excellent template expression support. However, for the interface itself the language does not really matter.

Here’s the interface in Java, based on OddgenGenerator2.xtend:

Node

The interface references in several methods a Node type. Here is the Java equivalent of the Node definition in Node.xtend:

Example

Here’s an example of a simple oddgen Java interface implementation, based on HelloWorldClientGenerator.xtend . Please note that this generator is supported for every JDBC connection.