I need to run a static method on a Java class (provided as a jar
dependency).
I also wanted to be able to write test on that. I created a wrapper class
in Scala that will call this method. It looks like
object CurrentLogProcessor {
}
class CurrentLogProcessor {
def run: Unit = LogReaderDisruptor.main(Array())
}
case object LogProcessRequest
object LProcessor {
def props(currentLogProcessor: CurrentLogProcessor) = Props(new
LProcessor(currentLogProcessor))
}
class LProcessor(currentLogProcessor: CurrentLogProcessor) extends Actor {
val log = Logging(context.system, this)
def receive = {
case LogProcessRequest => log.debug("starting log processing")
currentLogProcessor run
}
}
and in my App I call this actor as
val logProcessor = system.actorOf(LProcessor.props(new
CurrentLogProcessor), "logProcessor")
logProcessor ! LogProcessRequest
This compiles and works fine. Also, I am planning to
mock(CurrentLogProcessor) so that I may be able to test it.
Does this approach looks good? I am new to akka so wanted to make sure I am
not making mistakes here
Thank you
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.