Hello
I am using log4j in scala and i created a custom Lookup by extending from
StrLookup. The problem i have is my class depends on
an external configuration object. I can not pass it imlpicitly in the default
constructor coz. log4 complains about not finding an
empty default constructor. An ugly solution is to make the config object
accesible in the companion object and then use it in
the instance but thats a very ugly way.
Is there any factory oder manager class where i can enumerate or access my
plugin instance and call a setter ? How can
i inject or set my dependency ?
Thx
@Plugin(name = "syncer", category = "Lookup")
class SyncerLookup extends StrLookup {
override def lookup(key: String) : String = {
SyncerLookup.config.getOrElse[String](key, null) // BAD
}
override def lookup(event: LogEvent, key: String): String = {
SyncerLookup.config.getOrElse[String](key, null) // BAD
}
}
object SyncerLookup{
var config:Config = _
}
--
Patrick Brunmayr
LINZ AG für Energie, Telekommunikation, Verkehr und Kommunale Dienste
A-4021 Linz, Wiener Straße 151, Postfach 1300, Tel. +43/732/3400-0, E-Mail:
[email protected]