Skip to content

Instantly share code, notes, and snippets.

@couragecowardlydog
Last active August 27, 2023 14:58
Show Gist options
  • Save couragecowardlydog/86dd1122d78a2c9796798cf8f82247f9 to your computer and use it in GitHub Desktop.
Save couragecowardlydog/86dd1122d78a2c9796798cf8f82247f9 to your computer and use it in GitHub Desktop.
import org.springframework.beans.factory.annotation.Lookup;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class ReportGenerator {
public void run(IReport report) {
var contextHolder = getContextHolder();
// some code dependent on context holder
// ...
// ...
report.generate(..args);
}
@Lookup("userContextHolder")
protected ContextHolder getContextHolder() {
return this.contextHolder;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment