Hello,
After having doing some more implementation of autowiring during the
weekend on 0.5-SNAPSHOT, I decided to drop "class" or "type"
autowiring in favor of function autowiring (it mean autowire[T] will
be removed in next release).
In 0.4, only Function1 and Function2 are supported but I just added
the boilerplate in 0.5-SNAPSHOT up to Function22.
And by doing function autowiring on class constructor, this solve your
issue!
Here is how:
val c = autowire(new Class2(_: Class1[String]))
Unfortunatly due to some limitation in Scala type inferance you need
to specify "Class1[String]" explicity, but it's not the case with a
Companion object:
object Class2 { def apply(c: Class1[String]) = new Class2(c) }
Then you can do:
val c = autowire(Class2(_))
Neat!!
As a side note I would recommend avoiding instanciating class directly
and prefer the usage of Companion as much as possible.
Cheers,
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:43)
>
> > at java.lang.reflect.Method.invoke(Method.java:616)
>
> > Caused by: sindi.exception.TypeNotBoundException: Unable to inject
> >> scala1.Class2 during autowiring: type is not bound.
>
> > at sindi.context.Wirable$$anonfun$wireFirst$1.apply(context.scala:96)
>
> > at sindi.context.Wirable$$anonfun$wireFirst$1.apply(context.scala:96)
>
> > at scala.Option.getOrElse(Option.scala:108)
>
> > at sindi.context.Wirable$class.wireFirst(context.scala:95)
>
> > at sindi.context.Wirable$class.autowire(context.scala:76)
>
> > at scala1.AppContext$.autowire(Main.scala:8)
>
> > at scala1.AppContext$.<init>(Main.scala:12)
>
> > at scala1.AppContext$.<clinit>(Main.scala)
>
> > at scala1.Main$.main(Main.scala:17)
>
> > at scala1.Main.main(Main.scala)
>
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> > at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:5 7)
>
> > at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:43)