InternalModule

net.codingwell.scalaguice.InternalModule
trait InternalModule[B <: Binder]

Allows binding via type parameters. Mix into AbstractModule (or subclass) to allow using a type parameter instead of classOf[Foo] or new TypeLiteral[Bar[Foo\]\] {}.

For example, instead of

class MyModule extends AbstractModule {
 def configure {
   bind(classOf[Service]).to(classOf[ServiceImpl]).in(classOf[Singleton])
   bind(classOf[CreditCardPaymentService])
   bind(new TypeLiteral[Bar[Foo]]{}).to(classOf[FooBarImpl])
   bind(classOf[PaymentService]).to(classOf[CreditCardPaymentService])

   bindInterceptor(Matchers.any(), Matchers.annotatedWith(classOf[AOP]), new AOPI())
 }
}

use

class MyModule extends AbstractModule with ScalaModule {
 def configure {
   bind[Service].to[ServiceImpl].in[Singleton]
   bind[CreditCardPaymentService]
   bind[Bar[Foo]].to[FooBarImpl]
   bind[PaymentService].to[CreditCardPaymentService]

   bindInterceptor[AOPI](methodMatcher = annotatedWith[AOP])
 }
}

'''Note''' This syntax allows binding to and from generic types. It doesn't currently allow bindings between wildcard types because the manifests for wildcard types don't provide access to type bounds.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Concise view

Type members

Classlikes

class BindingBuilder[T](typeLit: TypeLiteral[T]) extends ScalaAnnotatedBindingBuilder[T]

Attributes

Graph
Supertypes
trait AnnotatedBindingBuilder[T]
trait LinkedBindingBuilder[T]
trait ScopedBindingBuilder
class Object
trait Matchable
class Any