Skip to content
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

SPR-10608 Add Path based resource #295

Closed
wants to merge 1 commit into from

Conversation

marschall
Copy link
Contributor

FileSystemResource uses the "old" java.io.File instead of the "new"
java.nio.file.Path. One of the disadvantages is that it only works with
the default file system and not with custom ones. Since the minimum
requirement is still Java 6 FileSystemResource can't be retrofitted
(and no #getPath can be added to Resource).

  • add PathResource
  • add PathResourceTests
  • update Resource with a reference to PathResource

PathResource delegates to the underlying file system instead of
StringUtils like FileSystemResource. It has therefore slightly
different semantics. First when building relative resources via
#createRelative the relative path will apply to this path (like URL or
Unix). If the same switchable behavior like FileSystemResource is
wanted that could be done with a boolean switch. Second equality is
delegated to the underlying file system provider so it's
case-insensitive on Windows.

PathResourceTests contains only minimal tests
(FileSystemResource has no tests) as writing tests for
file code is tricky. I could write more elaborate tests using
https://github.com/marschall/memoryfilesystem if that's wanted and OK.

I did sign the Spring CLA

Issue: SPR-10608

@ghost ghost assigned philwebb May 31, 2013
@cbeams
Copy link
Contributor

cbeams commented May 31, 2013

Philippe, thanks for the submission and your clear attention to detail!

@philwebb, I've assigned the JIRA issue to you for review and merging. I'm recommending that we go with PathResource naming as opposed to FileSystemPathResource, but otherwise this looks good on cursory review.

FileSystemResource uses the "old" java.io.File instead of the "new"
java.nio.file.Path. One of the disadvantages is that it only works with
the default file system and not with custom ones. Since the minimum
requirement is still Java 6 FileSystemResource can't be retrofitted
(and no #getPath can be added to resource).

* add PathResource
* add PathResourceTests
* update Resource with a reference to PathResource

PathResource delegates to the underlying file system instead of
StringUtils like FileSystemResource. It has therefore slightly
different semantics. First when building relative resources via
createRelative the relative path will apply to this path (like URL or
Unix). If the same switchable behavior like FileSystemResource is
wanted that could be done with a boolean switch. Second equality is
delegated to the underlying file system provider so it's
case-insensitive on Windows.

PathResourceTests contains only minimal tests (FileSystemResource has
no tests) as writing tests for file code is tricky. I could write more
elaborate tests using https://github.com/marschall/memoryfilesystem
if that's wanted and OK.

Issue: SPR-10608
@marschall
Copy link
Contributor Author

I renamed FileSystemPathResource to PathResource

philwebb added a commit that referenced this pull request Jun 3, 2013
# By Philippe Marschall
* SPR-10608-rebase:
  Introduce java.nio.file.Path based Resource
@philwebb
Copy link
Member

philwebb commented Jun 3, 2013

@marschall,

Thanks a lot for this excellent contribution. I have committed it with some minor modifications [1] to master so it should be part of the 4.0 release.

[1] philwebb@323ffb2

@philwebb philwebb closed this Jun 3, 2013
@marschall
Copy link
Contributor Author

Awesome, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants