Thursday, May 27, 2010

Modificator for @Autowire

Is it the same?
@Autowired
public indentifier name
@Autowired
private indentifier name

1. Speed issuer. With a private modificator reflection algorith adds only one additional call which is nano seconds time.
name.setAccessible(true);
2. But with a private modificator you don't break object encapsulation