Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
General Resource provider
I am pretty new at Vaadin, and perhaps I am missing something.
What I want to achieve is to create a "ResourceProvider" which can provide me with a Resource (ExternalResource,FileResource, ClassResource, ... ) without that I have to specify what sort of Resource I need.
So that I can use through my application that ResourceProvider, without having to hardcode that I need a ClassResource for that specific file, and a FileResource for another file.
I looked at the API documentation of those classes and in the "Book of Vaadin", but I could not find any mechanism/method which allows me to at least verify whether the created Resource exists/isValid/... which would at least allow me to create a try ... catch based mechanism.
Anybody more experienced has a good suggestion ?
I'm not sure I understood the entire problem, but it seems to me your ResourceProvider could check if the resource is valid.
Checking whether or not a resource is valid depends on the type of resource (for a file you'd probably want to make sure it's a readable file, for an ExternalResource you'll have to do something else).
For instance, since the ResourceProvider would have to have a File to make a FileResource, it could just use the File API to check that the File exists and is readable. Alternatively you could go ahead and extend each Resource type you use, and implement an isValid() -method.