1 2 Previous Next 23 Replies Latest reply: Jun 12, 2010 1:44 PM by 843798 Go to original post RSS
      • 15. Re: Search for extending classes.
        843798
        I'll also check this, thanks.
        • 16. Re: Search for extending classes.
          843798
          There are still some issues in loading the list of packages...
          • 17. Re: Search for extending classes.
            843798
            I'm using the RTSI class with some modifications and checks to avoid (strange) exceptions at runtime. Anyway. The code I'm currently using to search the data I need is:
                    descrImpl = RTSI.findFiltered(MAIN,
                                                  MAIN
                                                  + ".frameworks.commfwk.ICommDescription");
            where MAIN is the highest level package naming, say "com.MYCOMPANY.somepackage";

            The problems seems to be in the Package.getPackages() statement.

            Excerpt from findFiltered method:
                        for (int i = 0; i < Package.getPackages().length; i++) {
                            if (Package.getPackages().getName().startsWith(pPackage)) {
            temp.add(Package.getPackages()[i].getName());
            } else {
            RTSI.LOG_RTSI.trace("Package [" + Package.getPackages()[i].getName()
            + "] filtered by " + pPackage);
            }
            }
            and the package I need is not present. Then, once the list of packages is ready, I simply do:
            for (String pkg : temp) {
            RTSI.LOG_RTSI.debug("Working on [" + pkg + "]");
            result.addAll(RTSI.find(pkg, tosubclass));
            }
            and this works... the problems is the part above, that does not have the whole list of packages. Ideas?
            
            I'm using NetBeans and I've set two different classpaths: one for "compile" and the other one for "run". Then, running the application, the classpath is correct and contains all the JArs I need. But, using the Package.getPackages() statement, most of the packages, that are not used in the application because I have to load them dinamically, are not listed.
            
            So, for example, I have to search for a class that extends the ICommDescription interface I pass to the RTSI finder and that class is inside one of the "runtime" packages, present in classpath. But, since the class is not used, the Package.getPackages() statement does not list such class' package... :-(
            
            Any idea? I have the classpath, how can I list all packages available in the classpath, not only the used ones? :-(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            • 18. Re: Search for extending classes.
              jtahlborn
              marco.bresciani wrote:
              So, for example, I have to search for a class that extends the ICommDescription interface I pass to the RTSI finder and that class is inside one of the "runtime" packages, present in classpath. But, since the class is not used, the Package.getPackages() statement does not list such class' package... :-(

              Any idea? I have the classpath, how can I list all packages available in the classpath, not only the used ones? :-(
              yes, you are back to the main problem. until a class is loaded, the class/package will not be available via the class metadata. the only way to find stuff which is not loaded yet is to search the classloaders. why did you not use the ServiceLoader utility i mentioned? it's the simplest, most straightforward way to do this, and all the work is already done for you by the jdk.
              • 19. Re: Search for extending classes.
                843798
                You're absolutely right... :-( The fact is that I was not able to find some time to read something and study the usage of the ServiceLoader API and I'm also late with the project. Boss is pretty angry... :-( and I have to finish this thing within Monday or Tuesday... better Monday... :-( So since the fact that I didn't know yet anything about the Service Loader, today I had to go to work to explore the URLs packages in order to find those classes...
                • 20. Re: Search for extending classes.
                  791266
                  marco.bresciani wrote:
                  You're absolutely right... :-( The fact is that I was not able to find some time to read something and study the usage of the ServiceLoader API and I'm also late with the project. Boss is pretty angry... :-( and I have to finish this thing within Monday or Tuesday... better Monday... :-( So since the fact that I didn't know yet anything about the Service Loader, today I had to go to work to explore the URLs packages in order to find those classes...
                  Hmm... It would have taken you only about an hour to read that, and you have now lost about a week because you didn't want to read that. I also told you about an alternative way, and implementing that doesn't take long time.
                  • 21. Re: Search for extending classes.
                    843798
                    Again, you're right...
                    I'm in the middle of a lot of problems, not only work, and I'm the first that want to read and learn new things... but really had no time.

                    I'll try. :-(
                    Together with the JavaDoc, do you have some reading to suggest?
                    • 22. Re: Search for extending classes.
                      843798
                      I'll use the ServiceLoader. Thanks all.
                      • 23. Re: Search for extending classes.
                        EJP
                        but really had no time.
                        A lesson that you don't have time not to do the reading ...
                        1 2 Previous Next