spring-projects / spring-plugin

Apache License 2.0
441 stars 117 forks source link

Allow deferred exception creation if plugin lookup fails #19

Closed odrotbohm closed 8 years ago

odrotbohm commented 8 years ago

The methods taking an exception in PluginRegistry currently require the exception instance to be create even if the plugin lookup actually succeeds and the exception instance is never used at all.

We should rather provide a Supplier variant that allows the callers to delay the exception creation based on a lambda:

registry.getPluginFor(delimiter, () -> new IllegalStateException("No plugin found for delimiter ".concat(delimiter)));