Hi I'm trying to modify a Confluence Plugin to check every Network request against the OutboundWhitelist, however the plugin is written in a way where adding it into the constructor breaks quite a few things and causes quite a headache.
I wanted to know if it is possible to somehow do this in a different way.
I tried using @ComponentImport on the field itself and tried other things like @Inject and @Autowired.
However with all of these the OutboundWhitelist was null and the resulting code did not work.
Did I miss something or is adding @ComponentImport to the Constructor really the only way to achieve this behaviour?
Any help is appreciated. Edit: Added Code Samples.
This is what I'd like to avoid
private final OutboundWhitelist outboundWhitelist;
public YourMacro(@ComponentImport OutboundWhitelist outboundWhitelist) {
this.outboundWhitelist = outboundWhitelist;
}
This is what I'd like to do:
public void setOutboundWhitelist(OutboundWhitelist ow) {
this.outboundWhitelist = ow;
}
If OutboundWhitelist is a bean, you can use ComponentAccessor to get it directly in the code depending on the environment: