I have an instance of a business-class which is created at runtime (using "new"). I want to inject primitive property values into this entity. I cannot use @autowired, for I do not want to inject beans, but primitive properties. I am aware that since the class is not initialized by the Bean Factory itself I need some sort of trick to inject the values anyway. So I came along using AspectJ: http://docs.spring.io/spring/docs/3.0.0.RC2/reference/html/ch07s08.html
But apparently this does not seem to apply for my problem as is states: [...] then Spring will validate after configuration that all properties (which are not primitives or collections) have been set. [...]
I want to avoid requesting my object directly from the spring-context. It appears a violation of the DI thought. I mean the point is not to actively call something, but to passively get all dependencies injected, right?
So what can I do to have the primitives injected?
EDIT: Or is it rather because it is uncommon to inject dependencies besides service-beans into business classes?
Maybe you should have a look to the @Configurable annotation : http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/aop.html#aop-atconfigurable
Then to inject a value, use @Value, example : @Value("${some.property:defaultvalue}")
The primitive exclusion doesn't seem to affect the @Value annotation. "it is preferable to specify explicit, annotation-driven dependency injection for your @Configurable beans by using @Autowired or @Inject at the field or method level" And @Autowired and @Value are processed by the same beanpostprocessor (http://grepcode.com/file/repository.springsource.com/org.springframework/org.springframework.beans/3.2.3/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java)