interface Processor {
void do(); // only do, no setAuth method
}
@Component
class ProcessorImpl implements Processor {
private Service service;
private Authorization auth;
// only service should be injected, and auth set by the client
Processor (Service service, Authorization auth) {
this.service = ...
this.auth = ...
}
@Override
void do() {
...
}
...
}
@Component
class Service {
...
}
// no Spring component!
class Authorization {
...
}
@Component
class ProcessorFactory {
private Processor processor;
@Inject
ProcessorContainer(Processor processor) {
...
}
...
}
Jak kulturalnie ustawić Authorization
dla ProcessorImpl
w klasie ProcessorFactory
? Tak by nie dopisywać do interfejsu Processor
metody setAuthorization...
i żeby wszystkie te klasy poza Authorization
były magicznie tworzonymi komponentami przez Springa?