What's a dialect?
A dialect defines how Pentaho Metadata should generate SQL for a given database type.
Metadata's Dialect Plugin System (SPI)
Introduced in release 3.7 Pentaho Metadata supports additional dialects through a self-registering plugin system: Java's ServiceLoader API. A dialect is a concrete implementation of SQLDialectInterface
and, in order for Pentaho Metadata to recognize it, you must declare it as a Service Provider and package it in a jar. That being said, a it's Service Provider Interface (SPI): SQLDialectInterface
. A Pentaho Metadata Dialect Plugin is a jar file that consists of a dialect implementation and some configuration. The SPI enables developers to develop new database dialects which Pentaho Metadata will automatically detect and register.
Implementing SQLDialectInterface
Declaring your Dialect as a Service Provider
The Pentaho Metdata utilizes the Java Service Loader API to dynamically look up dialect implementations. The ServiceLoader API requires you list all Service Provider implementations in a file named after the interface of the service they provide in the META-INF/services
directory of the jar file:
Code Block |
---|
META-INF/services/org.pentaho.pms.mql.dialect.SQLDialectInterface: org.pentaho.pms.mql.dialect.SampleDialect |
Where org.pentaho.pms.mql.dialect.SampleDialect
is the implementation of META-INF/services/org.pentaho.pms.mql.dialect.SQLDialectInterface
for our Sample database type.
To define a Pentaho Metadata Dialect you must implement org.pentaho.pms.mql.SQLDialectInterface and define the implementation as a Service Provider[1].
For more information see Jar Service Provider Packaging Notes from Oracle.
Using your plugin
[1]: All that is required is the jar file to be in the classpath. In most applications this is a /lib
directory within the application's installation directory.
For more general information about Java's ServiceLoader API see these links:
http://download.oracle.com/javase/6/docs/technotesapi/guidesjava/jarutil/jarServiceLoader.html#Service%20Provider|html
http://downloadjava.oraclesun.com/javasedeveloper/6technicalArticles/docsjavase/technotes/guides/jar/jar.html#Service%20Provider]extensible/index.html