Skip to content

Instantly share code, notes, and snippets.

@santail
Created May 24, 2012 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santail/2780166 to your computer and use it in GitHub Desktop.
Save santail/2780166 to your computer and use it in GitHub Desktop.
import org.elasticsearch.plugins.AbstractPlugin
import org.elasticsearch.common.inject.{Inject, AbstractModule, Module}
import org.elasticsearch.river._
import org.elasticsearch.client.Client
class JdbcRiverPlugin extends AbstractPlugin {
def name: String = {
"jdbc-river"
}
def description: String = {
"River to index subscription rows from Oma Elisa database"
}
override def processModule(module: Module) {
if (module.isInstanceOf[RiversModule]) {
(module.asInstanceOf[RiversModule]).registerRiver("jdbc-river", classOf[JdbcRiverModule])
}
}
}
class JdbcRiverModule extends AbstractModule {
protected def configure() {
bind(classOf[River]).to(classOf[JdbcRiver]).asEagerSingleton()
}
}
class JdbcRiver @Inject()(riverName: RiverName, settings: RiverSettings, client: Client)
extends AbstractRiverComponent(riverName, settings) with River {
val jdbcIndexer: OracleJdbcIndexer = new OracleJdbcIndexer(client, logger, settings, riverName.name)
def start() {
new Thread(jdbcIndexer).start()
logger.info("Started JdbcRiver")
}
def close() {
jdbcIndexer.stop()
logger.info("JdbcRiver stopped")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment