-
Notifications
You must be signed in to change notification settings - Fork 54
Add LocationResolver framework #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
11ece51 to
c85c5eb
Compare
|
@ctrueden I updated the code based on our discussion on Friday, should be good to merge now. |
c85c5eb to
4a697a1
Compare
|
@ctrueden I moved the implementation of the resolve method into the interface, as discussed. |
ctrueden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good! Two main things: 1) get rid of the resolve subpackage; and 2) change the FileLocationResolver-related tests to not use getClass().getResource(...).
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this in org.scijava.io.location without the resolve subpackage. The service, while focused on location resolution right now, might do other things as well in the future; it is called LocationService after all and not LocationResolverService.
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up one package level.
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up one package level.
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up one package level.
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up one package level.
| * #L% | ||
| */ | ||
|
|
||
| package org.scijava.io.location.resolve; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move up one package level.
| public void testURIResolve() throws URISyntaxException { | ||
| URI uri = new URI(getClass().getResource("/").toString()); | ||
| Location loc = resolver.resolve(uri); | ||
| assertTrue(loc instanceof FileLocation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that really work always? It seems dicey. Maybe use ClassUtils.getLocation instead? Or just hardcode something like new File(".").getAbsolutePath() which is guaranteed to work on every platform?
| final URI uri = getClass().getResource("/").toURI(); | ||
| final LocationResolver res = loc.getResolver(uri); | ||
|
|
||
| assertTrue(res instanceof FileLocationResolver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not convinced that getClass().getResource(...) URIs will always end up as files. Let's be safer about this.
4a697a1 to
e8cf3e3
Compare
|
@ctrueden I included your suggestions |
The LocationService manages LocationResolver plugins that provide translation from URI to Location. The LocationService itself contains convenience methods to translate from String to Location.
e8cf3e3 to
e3babc8
Compare
The LocationResolverService manages LocationResolver plugins that
provide translation from URI to Location.