It is by all means possible to use assisted inject in Scala. If scala-guice does not provide tools for it, you just can use assisted inject API directly:
trait Entity { ... }
class EntityImpl @Inject (
@Assisted assistedDep: AssistedDependency,
normalDep: NormalDependency
) extends Entity { ... }
trait EntityFactory {
def create(assistedDep: AssistedDependency): Entity
}
class YourModule extends AbstractModule with ScalaModule {
def configure {
install(new FactoryModuleBuilder()
.implement(classOf[Entity], classOf[EntityImpl])
.build(classOf[EntityFactory])
)
bind[NormalDependency].to[NormalDependencyImpl]
}
}
True, it is not very pretty, but it gets the work done.
Also, you absolutely should not remove guice-3.0.jar
. Why did you think of it in the first place? javax.inject.jar
contains JSR-330 annotations, guice-3.0.jar
contains Guice itself, and guice-assistedinject-3.0.jar
contains assisted inject extension. All these jars are important if you need Guice with assisted inject support.