> Can you give me a demo that about integrate scala into guice?

Well, it's actually almost as referred to you in the link from the other answer:

http://jonasboner.com/2008/10/06/real-world-scala-dependency-injection-di/

class MyClient {
  @Inject val toBeInjected: AnotherClass = toBeInjected // !!
}

trait ServiceInjector {
  ServiceInjector.inject( this )
}

object ServiceInjector {
  private val injector = Guice.createInjector( Array[Module]( new YourModule ) )
  def inject( obj: AnyRef ) = injector.injectMembers( obj )
}

Usage:

val client = new MyClient with ServiceInjector

or:

class InjectedMyClient extends MyClient with ServiceInjector

Best regards, --- Jan.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to