Interface DialectFactory
- All Known Implementing Classes:
JdbcDialectFactory
Dialect
objects.
If you create a class that implements Dialect
, you may optionally
provide a factory by creating a constant field in that class. For
example:
public class MyDialect implements Dialect { public static final DialectFactory FACTORY = new JdbcDialectFactory(MyDialect.class, null); public MyDialect(Connection connection) { ... } ... }
(The field must be public, static, final, named "FACTORY", of type
DialectFactory
or a subclass, and its value must not be
null.)
Explicitly providing a factory gives you more control about how dialects are produced.
If you do not provide such a field, Mondrian requires that the dialect has
a public constructor that takes a Connection
as a parameter,
and automatically creates a factory that calls the class's public
constructor.
However, an explicit DialectFactory is superior:
- When a dialect cannot handle a given connection, a dialect factory can
return
null
, whereas a dialect's constructor can only throw an exception. - A dialect factory can maintain a pool or cache of dialect objects.
If your dialect is a subclass of JdbcDialectImpl
you may wish to use a dialect factory that is a subclass of
JdbcDialectFactory
.
- Since:
- Jan 13, 2009
- Author:
- jhyde
-
Method Summary
Modifier and TypeMethodDescriptioncreateDialect
(DataSource dataSource, Connection connection) Creates a Dialect.
-
Method Details
-
createDialect
Creates a Dialect.If the dialect cannot handle this connection, returns null.
- Parameters:
dataSource
- JDBC data sourceconnection
- JDBC connection- Returns:
- dialect for this connection, or null if this factory's dialect is not appropriate for the connection
- Throws:
RuntimeException
- if underlying systems give an error
-