#116 Path to ResourceLoader to accept any URL

closed
5
2007-09-27
2007-07-20
No

I use Dozer and it's great. Thank you very much.
I have some beanMapping.xml inside jar files and I had to change ResourceLoader to accept any URL formatted String.

Discussion

  • Franz Garsombke

    Franz Garsombke - 2007-07-20

    Logged In: YES
    user_id=550744
    Originator: NO

    We will apply this to the next release.

    Thanks for looking.

    Franz

     
  • Franz Garsombke

    Franz Garsombke - 2007-07-20
    • assigned_to: nobody --> fgarsombke
     
  • Franz Garsombke

    Franz Garsombke - 2007-07-31

    Logged In: YES
    user_id=550744
    Originator: NO

    It looks like this has already been patched to take anything prefixed with 'file:'.

    // Patch to load mapping file from outside of classpath.
    if (resource.startsWith(MapperConstants.FILE_PREFIX)) {
    try {
    return new File(resource.substring(MapperConstants.FILE_PREFIX.length())).toURL();
    } catch (MalformedURLException e) {
    MappingUtils.throwMappingException(e);
    }
    }

    Will this take care of your use case?

    Franz

     
  • Jonás Ansó

    Jonás Ansó - 2007-08-06

    Logged In: YES
    user_id=1849512
    Originator: YES

    From my point of view, my use case take care of the previous patch.

    I don't know how to test it but I think it will work.
    file: is one of URL protocols as http: ftp: or jar: so I think the better way to accept any URL formatted String is "new URL(resource)".

    I don't understand exactly why somebody did
    new
    File(resource.substring(MapperConstants.FILE_PREFIX.length())).toURL();

    instead of doing :
    new URL( resource);

    the only problem I found it's commented in code:
    //throw new MappingException(e);
    // I don't throw exception because other classes in dozer library don't catch it.
    // For example, loading dozer.properties, that is not mandatory, should catch it.

    Finally I would like to say that I would prefer to throw the exception and catch it in appropiated places. But it's your decission how to do it.

     
  • Franz Garsombke

    Franz Garsombke - 2007-08-06

    Logged In: YES
    user_id=550744
    Originator: NO

    Your points are valid. I changed this in the current_release branch to be:

    // one more time
    if (result == null) {
    try {
    result = new URL(resource);
    } catch (MalformedURLException e) {
    MappingUtils.throwMappingException(e);
    }
    }

    We wrap the checked exception (MalformedURLException) and throw it as a dozer runtime. That is how we handle all checked exceptions.

    This will be released in dozer 4.1.

     
  • Franz Garsombke

    Franz Garsombke - 2007-08-06
    • status: open --> pending
     
  • SourceForge Robot

    • status: pending --> closed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 45 days (the time period specified by
    the administrator of this Tracker).

     
  • Franz Garsombke

    Franz Garsombke - 2007-09-21
    • status: closed --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2007-09-27
    • status: pending --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks