-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Using Java based IoC frameworks in Scala is uglier than using pure Java.
Examples here...
http://www.nabble.com/-scala--Annotating-a-field-without-annotating-the-associated-methods---Spring--@Autowired-annotation-td23596908.html
or section 3
http://www.brainoutprintln.com/?p=166
In Java code we can write code like this...
// Java
class MyComponent {
@Autowired
private Service service;
}
however we cannot do this in Scala...
// Scala
class MyComponent {
@Autowired
var service = _
}
as by default Scala adds the annotation to the field, getter and setter methods which make all the IoC frameworks barf.
A scala compiler plugin which by default knew about all the standard & common IoC annotations would be cool.
e.g. out of the box any of these annotations would by default be placed only on the setter method...
- javax.annotation.Resource
- org.springframework.beans.factory.annotation.Autowired
- com.google.inject.Inject
- javax.inject.Inject
common IoC frameworks for further reference...
Am thinking a compiler plugin which allowed you to define rules of which elements get the annotation (field, getter, setter) - which came out of the box with rules for all the common Java frameworks & standards - but maybe let folks extend it to add other frameworks?
Then folks using spring/guice/JSR250/JSR299/JSR330 could just depend on the IoC compiler plugin and all of a sudden annotation based IoC becomes much more scala-ish