Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: JRuby 1.2
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      All
    • Number of attachments :
      0

      Description

      LoadService#smartLoad performs two functions: finding a required file and loading it. I would like to request a new LoadService method that performs the first function: given a file name argument, return the full path to the file.

      I'm requesting this change because the 10gen app server needs to be able to force the reload of required files in certain circumstances. Those circumstances include the changing of the contents of the required file. So, we have to be able to find the file that will be loaded so we can check its modification time.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        On second thought, I'll add a basic version of the method you seek. You can submit a separate enhancement if you like.

        It will basically look like this:

            public SearchState findFileForLoad(String file) throws AlreadyLoaded {
                SearchState state = new SearchState(file);
                state.prepareRequireSearch(file);
        
                for (LoadSearcher searcher : searchers) {
                    if (searcher.shouldTrySearch(state)) {
                        searcher.trySearch(state);
                    } else {
                        continue;
                    }
                }
        
                return state;
            }
        
        Show
        Charles Oliver Nutter added a comment - On second thought, I'll add a basic version of the method you seek. You can submit a separate enhancement if you like. It will basically look like this: public SearchState findFileForLoad(String file) throws AlreadyLoaded { SearchState state = new SearchState(file); state.prepareRequireSearch(file); for (LoadSearcher searcher : searchers) { if (searcher.shouldTrySearch(state)) { searcher.trySearch(state); } else { continue; } } return state; }
        Hide
        Charles Oliver Nutter added a comment -

        New API added in r9107.

        Show
        Charles Oliver Nutter added a comment - New API added in r9107.
        Hide
        Jim Menard added a comment -

        So I can get the file that will be loaded from the SearchState instance, then? I don't see how. Perhaps I was asking for something impossible. All I want is the full file system path to the file that will get loaded when I "require 'foo'". If 'foo' isn't a plain Ruby file, then I don't care — return nil, return the class/jar/lib file, whatever.

        Show
        Jim Menard added a comment - So I can get the file that will be loaded from the SearchState instance, then? I don't see how. Perhaps I was asking for something impossible. All I want is the full file system path to the file that will get loaded when I "require 'foo'". If 'foo' isn't a plain Ruby file, then I don't care — return nil, return the class/jar/lib file, whatever.
        Hide
        Charles Oliver Nutter added a comment -

        Have a look at SearchState...it should contain both the "require name" used for $" and the full path, possibly as a URL. It just holds the data and the eventual found path from the search. A separate API could be added that just returns the full path, but it should be easy to build off what's there right now. Have a look at the source.

        Show
        Charles Oliver Nutter added a comment - Have a look at SearchState...it should contain both the "require name" used for $" and the full path, possibly as a URL. It just holds the data and the eventual found path from the search. A separate API could be added that just returns the full path, but it should be easy to build off what's there right now. Have a look at the source.
        Hide
        Jim Menard added a comment -

        Got it. Thank you. I didn't notice that the ivars were public.

        Show
        Jim Menard added a comment - Got it. Thank you. I didn't notice that the ivars were public.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Jim Menard
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: