Skip to content

Add LocationResolver framework - #311

Merged
ctrueden merged 3 commits into
masterfrom
uri-to-location
Feb 20, 2018
Merged

Add LocationResolver framework#311
ctrueden merged 3 commits into
masterfrom
uri-to-location

Conversation

@gab1one

@gab1one gab1one commented Jan 5, 2018

Copy link
Copy Markdown
Contributor

The LocationResolverService manages LocationResolver plugins that
provide translation from URI to Location.

@gab1one

gab1one commented Jan 29, 2018

Copy link
Copy Markdown
Contributor Author

@ctrueden I updated the code based on our discussion on Friday, should be good to merge now.

@gab1one

gab1one commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

@ctrueden I moved the implementation of the resolve method into the interface, as discussed.

@ctrueden ctrueden left a comment

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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;

Copy link
Copy Markdown
Member

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);

Copy link
Copy Markdown
Member

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);

Copy link
Copy Markdown
Member

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.

@gab1one

gab1one commented Feb 12, 2018

Copy link
Copy Markdown
Contributor Author

@ctrueden I included your suggestions

Gabriel Einsdorf and others added 3 commits February 20, 2018 09:10
The LocationService manages LocationResolver plugins that provide
translation from URI to Location. The LocationService itself
contains convenience methods to translate from String to Location.
@ctrueden
ctrueden merged commit 80ce9ac into master Feb 20, 2018
@ctrueden
ctrueden deleted the uri-to-location branch February 20, 2018 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants