Closed ghost closed 5 years ago
Hi @adityamandhare
Each implementation of FormatAttribute
, ContentMimeType
, and ContentEncodingScheme
interface defined in the spi
package, are instantiated once at startup and the single instance will be shared between ALL schemas and validations.
This is intentionally designed. I have updated the Javadoc to clarify this design.
Object creation through ServiceLoader
mechanism is considerably slow. If many instances should be created, we must introduce new factory interfaces to implement such as FormatAttributeFactory
in addition to the current interfaces.
okay I got that. Thanks @leadpony 🙂
I am implementing a custom validation by implementing the interface
FormatAttribute
.In the above example, I have
attribute1
initialized totrue
value. In the methodtest
say a customTestLogic sets thisattribute1
value tofalse
. Now, on second invocation, thefalse
value ofattribute1
persists. I guess every new request should create a new object of this class. For example with current implementation this is the output: First invocation:Second invocation:
The correct expected behavior should be: First invocation:
Second invocation: