| Custom scheme for import URIs [message #640675] |
Mon, 22 November 2010 13:54  |
Eclipse User |
|
|
|
Hi there,
I'd like to turn round the import URI mechanism and use a custom URI scheme. Whenever I import a "custom:/a/b/c", I want some CustomHandler to handle the URI and return the Resource.
I've already tried my best and looked through the code but I couldn't find the right hook. Could you give me a hint on that?
Thanks,
Michael
|
|
|
|
|
|
|
|
| Re: Custom scheme for import URIs [message #1836412 is a reply to message #640930] |
Sat, 02 January 2021 18:16  |
Eclipse User |
|
|
|
It's doubtful that this is of any help to the original poster more than a decade later, but for anybody who might be struggling with the same problem (like myself), I'd like to add this little tidbit:
In my particular circumstances, just using
resourceSet.getURIConverter().getURIHandlers().add(uriHandler)
did also not have any effect, mainly because the new URIHandler will be added at the very end of the list, and the default list in URIHandler.DEFAULT_HANDLERS already contains a "catch all" handler:
List<URIHandler> DEFAULT_HANDLERS =
Collections.unmodifiableList
(Arrays.asList
(new URIHandler []
{
new PlatformResourceURIHandlerImpl(),
new FileURIHandlerImpl(),
new EFSURIHandlerImpl(),
new ArchiveURIHandlerImpl(),
new URIHandlerImpl()
}));
The canHandle(...) method of that last new URIHandlerImpl() entry looks like this:
public boolean canHandle(URI uri)
{
return true;
}
so it will intercept all URI handling before any other handlers that come after it.
Therefore, the solution, in my case at least, was to add the new handler at the beginning of the list (or at least somewhere before that final "catch all" handler):
resourceSet.getURIConverter().getURIHandlers().add(0, uriHandler)
|
|
|
Powered by
FUDForum. Page generated in 0.04085 seconds