java - Autowire in spring -


i trying check piece of code within spring framework autowired functionality coded.

let me give example.

@component public lass service{    @autowired    private daolayer daolayer; } 

my question is: how spring can inject daolayer or instance when respective field marked using autowired.

  1. make using reflection? , if reflection used: reflection can access private fields?
  2. make using new created proxy? , inject references on it?, if happens happens when getters , setters not present?
  3. use other technique , one?

could point me can find information or explain me more process.

i remember in sring2.5 getters , setter need present no more in spring3.2, spring created them own? or not used anymore?

thanks.

make using reflection? , if reflection used: reflection can access private fields?

yes, spring uses reflection everywhere. reflection can many things, access private fields, methods, constructors, , classes.

make using new created proxy? , inject references on it?, if happens happens when getters , setters not present?

spring resolves @autowired on fields directly. needs getters , setters (with java bean conventional names) resolve <property> elements of <bean> declaration while creating bean. note spring again uses reflection invoke these getters/setters.

use other technique , one?

doesn't need else.

if you're interested in actual class this, autowiredannotationbeanpostprocessor. spring documentation explains of (look ioc chapter).


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -