Extending a ClassLoader's Resource-Finding Functionality

First Question:
Is there a difference between:
<class_name>.class.getResource()
and
this.getClass().getResource()
Is one done natively? How does the VM see these two - as equivalent?
Second Question:
I know that when getClass().getResource() (or the other) is called, that it delegates the check to the Class's ClassLoader. So really the call is to the ClassLoader. So when you normally do a call for getResource() it just creates a path by changing the class's package dots into "/" and looking in the folder structure. Here's what I want to do:
1. Have XML config files for Objects in a package
a. Have these XML files available either through Http, file, etc.
2. Be able to tie the domain address to the ProtectionDomain of a package
   EXAMPLE
        If I have "http://www.site.com/Person.cfg" as the config file for
        the object of class: com.site.dept.Person, then when the Person
        object calls: this.getClass().getResource( "http://www.site.com/Person.cfg" );
        the resource should be found (and as well, if they call:
        this.getClass().getResource( "http://www.evil.com/Person.cfg" ) it
        should return null ). Also, just as with any resource actually in
        the folder: com/site/dept (inside the jar or whatever), it will be
        a part of that ProtectionDomain and have the same security settings
        as a file in that folder would have.Does anyone have any ideas on the best way to do this? I am obviously sub-classing the ClassLoader (which I've done), and already I have set up my ClassLoader to be able to load either http (or any other protocol) files, as well as normal system files. (NOTE: URLClassLoader does NOT do this. Give it a try: myURLClassLoader.getResourceAsStream( "http://..." ) and you'll find it returns null)
I want this to be as clean and secure as possible. I also know that I should delegate to the super class (URLClassLoader) as much as possible. So I'm at a loss as to what's the best way to tie the http addresses (or other protocol addresses) to the correct package spots. Just to give you all more info, when I create the classloader I can pass it the info of what address is supposed to go with what object. So maybe something like this:
   <ConfigResource>
      <Location>"http://www.site.com/Person.cfg"</Location>
      <Object>com.site.dept.Person</Object>
   </ConfigResource>Thanks and please let me know if anything here needs more explaining!
-Robert

Let me try this
First Question:
Is there a difference between:
<class_name>.class.getResource()
and
this.getClass().getResource()
Is one done natively? How does the VM see these two
wo - as equivalent?
To chech whether this (getResource()) is native or not you require to refer the source code of the java.lang.Class file.In fact there it is not defined as native method It returns URL object.But within the implementation of getResource you can see the getClassLoader0() method whuch returns the classLoader and the getClassLoader0() is a native type.
They are not equivalent,there can be multiple instances of the same object loaded by different Classloaders then your first type will be obtained to get the same objects instance in the different classLoader.Hope you get what I am trying,All this I am expaining as per my undestanding......So I hope some one really try to rectify it if I am describing it wrong....
Your second Question :
For that what you are doing is fine by inheriting the ClassLoader features but then sun have come up with the URLClassLoader where many more features are implemented which we have to implement when only the classloader is inherited.For the application specified where you are trying to load the object by the HTTP protocol/file protocol I feel you can rely on the URLCLassLoader functionality....But if you want more like checking in the repository,loading from database,cache etc you require to implement all this in both the Classes......in defineClass()......For better implementation of ClassLoader you can see the source code of the AdaptiveClassLoader class which is implemented by the Tomcat .........
Hope this helps......
regards vicky

Similar Messages

  • VISA Find function to VISA Resource Name

    Hi,
    Can anyone help me with this VISA question. I'm kind of new to
    instrument control, but have been using LV for quite a long time. I'm
    using version 6.02. I discovered the VISA Find Resource function, and
    thought it would be really neat to find the instruments that are sitting
    on my GPIB bus, and then make sure they are the ones I need for my
    testing. The Find resource works great, and returns an array of strings
    that are the resource names of the instruments. i.e. GPIB0::5::INSTR.
    However, the VISA Open (and all the other VISA functions) require a VISA
    resource name control (One of those pruple doohickies with I/O in it).
    I haven't been able to figure out how to get that string from the find
    function into the VISA resou
    rce name control (It looks like a pulldown
    on the front panel) so that I can do a *IDN? query to find out what
    instrument is actually at this address. I've tried property nodes, even
    looked at the invoke node, but to no avail. By the way, the property
    node DID have the VISA resource name, but it was read only.
    Thanks in advance for any help you folks might be able to provide.
    David Dupont
    Airvana Inc. http://www.airvananet.com

    Hello, David!
    I'll do my best to answer your question.
    In LabVIEW 6, you have to assign VISA aliases in Measurement and Automation Explorer. You can assign meaningful VISA Aliases to your instruments that you control using VISA in the Devices and Interfaces section in Measurement & Automation Explorer. The aliases can be used in your LabVIEW application development to refer to your instrument.
    Once you have assigned aliases in MAX, you simply place a VISA Resource Name Constant in your block diagram. Type the alias name into the resource name constant and wire the name constant to the VISA Resuorce Name input of the VISA Write and VISA Read functions to control your instrument.
    I hope this helps.
    Mark Ridgley

  • HTTP 404 Not Found while accessing Human Resource Intelligence functions

    Hi,
    Can anyone help me in resolving
    HTTP 404 Not Found while accessing Human Resource Intelligence functions
    error
    Instance : R12
    Thanks

    Hi,
    Apache log file is not showing any errors.What log files have you checked? Please check error_log and access_log files, you should find more details about the error in these logs.
    Thanks,
    Hussein

  • Override and extend default ClassLoader

    Hi,
    I've been messing around with the ClassLoader for a long time now (maybe 8 hours) and i just dont get it.
    What it try ist to do the following:
    Store the class Test.class in a package. (somewhere) The class Test can have many versions (plugin-system).
    A developer should be able to code like this without bothering which version the Test.class has.
    Test t = new Test();
    Now the problem comes:
    I want MY ClassLoader to load the Test.class defined in a XML with the newest version. Or (maybe) an other version defined by an XML file. Again the programmer should not have to work with reflect to use the Test.class.
    I've written my own ArchiveLoader class which extends the ClassLoader and used the -Djava.system.class.loader=ArchiveLoader setting. But: My ArchiveLoader.loadClass()-Method is only called to load the Main Class and i just dont get why. Any other class is loaded by the AppClassLoader.
    If ANYONE could just post an complete example how to tell java to look at mine loader first.... I'd build a skyscraper with a swimmingpool with my own hands for him...
    thnx a lot.

    Just figured out a solution by my self:
    If you are using a kind of a plugin system and want all your library content (all plugin classes together) to be accessible by any active plugin class. You MUST load
    your entry point class of the plugin with your own ClassLoader.
    example:
    //Write your own ClassLoader
    public ArchiveLoader() {
              super();
         public ArchiveLoader(ClassLoader cl) {
              super(cl);
              System.out.println("Initialized by "+getClass().getClassLoader()+" parent: "+cl);
         public synchronized Class loadClass(String name) throws ClassNotFoundException {
              //check if class is loaded          
              Class cl = findLoadedClass(name); 
              if (cl != null)   return cl;
                   try {
                        return findClass(name);
                   } catch (ClassNotFoundException CNFe) {
                        return getParent().loadClass(name);
         public synchronized Class findClass(String name) throws ClassNotFoundException {     
              if (i can find my class)
                   defineClass(...)
              else return getParent().loadClass(name);
    class Start {
         public static void main(String...) {
              Class c = new ArchiveLoader().loadClass("plugin_entry_point");
              c.getMethod("go", null).invoke(null, null);
    class plugin_entry_point {
         public void go() {
              //use any class you can load.... from wherever
    }hoped it helped anyone. At least it would have helped me.

  • How to find function code for buttons on toolbar in oops alv

    Hi experts,
    I want to remove some buttons from toolbar in oops alv, i know the procedure like get function code and pass the value in a table and pass that table to IT_TOOLBAR_EXCLUDING of
    method set_table_for_first_display but I WANT TO KNOW HOW TO FIND FUNCTION CODE FOR BUTTONS ON TOOLBAR IN OOPS ALV

    Hi Prakash,
    -->First you have to set the pf status in your alv program by,
    {FORM pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'FIRST'.
    ENDFORM.                    "PF_STATUS}
    -->Pass this Subroutine name in the Function module, Reuse_alv_grid_display's parameters i.e,
          i_callback_pf_status_set          = 'PF_STATUS'}
    *-->Then doble click on that pf status,
    From the menu bar, select Extras->Adjust Template->List Viewer,
    This will give you the existing statndard gui status of the program*
    ->Then catch that function codes in the User command Parameter of the Function module Reuse.. i.e,
          i_callback_user_command           = 'COMM'
    And make a subroutine of the name 'COMM'i.e,
    FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA: okcode TYPE sy-ucomm.
      okcode = ucomm.
      CASE okcode.
        WHEN 'REF'.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel         = 'MANSI'
            txt1          = 'CREATED BY'
            txt2          = SY-UNAME
          TXT3          = ' '
          TXT4          = ' '
    endcase.
    Hope it helps you
    Regrds
    Mansi

  • How do I export a .dwg file so the Search/Find function can be used on it?

    I have some .dwg files that my co-worker exported to PDF. It is crucial for me to have the ability to use the search or "Find" function in Reader. There are 11 different .dwg files exported into an 11 page PDF, but some of the were exported with different properties. I can search on 4 of them, but the other 7 are unsearchable. I believe my co-worker user Autodesk TrueView to export the .dwg files to PDF. So my question is what program I should use (I believe that TrueView is capable of what I am trying to do, but I'm not sure) and how should I set up the the settings before I export it to PDF. Thanks.

    You need to contact Autodesk, almost no one here is likely to be familiar with what Autodesk can or cannot do.

  • Need help in finding the root cause the error 'Could not find function:'

    Hi fokls,
    In my workflow notification , when I click on the notification to process it , it says ' 'Could not find function:' error.
    I found the this message is coming out from the Fnd_new_messages table from the message_name 'FND_FUNCTION_NOT_FOUND'.
    Here are my questions ...
    1. FND_FUNCTION_NOT_FOUND - Is it a oracle Seeded message ?
    2. If so the error I am getting is a oracle product Bug ?
    And In between , I am getting this error for few transaction only. ( out of 100 , i am getting this error at the rate of 5 per 100 ... or less)
    3 .If its a oracle product bug then , how is 95 out of 100 transaction are succssfully wokring ?
    4. If is a custom bug , how it os not though for some other 95 transaction ?
    5. Can I expect it as Data issue ? If so what kind of data issue.
    Folks , any kind of info will be really , realy helpful for me ... please let me know your inputs for me.
    Thansk to all in advance
    Raghu

    In the error message 'Could not find function:' after colon what function name it is giving.
    'FND_FUNCTION_NOT_FOUND' is a seeded message only.
    As you are saying the error was throwing only for 5% or less notifications, is the error throwing for same kind of notifications? I mean the item type and message are same for these erroneous notifications?
    It can be that some function in particular type of workflow is error-ed out does not exists, when responding to those kind of notifications it might be throwing error.
    Please check that.
    Edited by: sarojak on Nov 12, 2010 6:16 AM

  • Find function no longer finds files

    Does anybody know why might my Find function in Finder no longer finds files and how to fix it? It finds only a limited number of files and they have nothing to do with the search term. I have selected "Computer" as the searchable entity.

    Instead of using the Find function,I use the free Find Any File app http://www.macupdate.com/app/mac/30079/find-any-file Try it.
     Cheers, Tom

  • 'Find' function doesn't work on some HP documents

    For some pdf doc's I downloaded from HP, if I copy some characters from the text and then paste them into the Find box, the characters show up as hieroglyphs (mostly squares) in the Find box. And then actually executing the Find using those characters doesn't work, because it can't find the very word that I copied them from! On top of that, if I manually type a word into the Find box (showing normal letters), it won't find it even though I can see it within the text on the page showing on the screen. Very strange! In documents other than these old HP documents, the Find function works fine.
    I looked into the document properties (menu: File >> Properties >> Fonts) and see that there are 9 fonts that have names I have never heard of before, and those fonts say "(Embedded Subset)" after the font name and "Encoding: Custom" in the font descriptions. There were a few normal fonts listed before these for that document as well.
    Anyone have any idea what is going on?
    - Brad

    It's hard to say without seeing the actual, source content, but given what you are describing, I would venture a guess that the source content is of too poor a quality to OCR reliably and accurately.  To test this theory, after running OCR, identify a term that you can confirm is present, but that the search feature cannot identify.  Then, copy and paste that term into Word or Notepad.  What I expect you will note is that a "0" (zero) has been identified as an "8," and other things of that nature.  OCR processing is garbage in, garbage out, so the source always has to be considered.  Repeat this process across the document to see if experience similar results. 
    You don't describe how exactly you are transferring the microfilm "images" to PDF, so it's difficult to say if that process is at issue or could be improved.  I suspect that's contributing to the problem, though.
    Finally, with regard to the degraded image quality, you want to make sure you are selecting "Searchable Image (Exact)" from the OCR dialogue.  ClearScan or any type of downsampling will likely cause or contribute to the type of issue you are describing.  In a situation with low-quality source material, you would not want to use these other options.
    Hope that helps!
    Jason Covey
    PDF Litigation Solutions, LLC
    www.pdflitigationguide.com

  • HP Deskjet 9600 Won't Print with 10.4.11 & Find function doesn't work.

    Hi, there seems to be some link between the find function not working and HP printers not working in Tiger. I read this forum - http://209.85.215.104/search?q=cache:-v3OvLGNYBwJ:forums.cnet.com/5208-6126_102- 0.html%3FforumID%3D10%26threadID%3D271686%26messageID%3D2667189find+function+not+working+intiger&hl=en&ct=clnk&cd=6&gl=us - and it seems like others have had this problem. Is there any other solution other than Archiving and Reinstalling system software? I don't have enough HD space to do that...?...I only have 1.74G. I've heard you need at least 10G available. Is that true? Thanks.

    It is not obvious the problems are related. I read the thread and one user had both issues but the others didn't seem to.
    Does Spotlight work?
    What exactly happens when you try to print?
    Have you tried repairing permissions yet? (/Applications/Utilities/Disk Utility - highlight your HD on the left and choose the First Aid tab and the repair permissions option.)
    If that doesn't work, see if the problem occurs in another account. If you are the only user, create another user in the Accounts pane of System Preferences.
    Do you have HP software installed or are you just using the drivers which come with OS X?
    - cfr

  • The Firefox find function seems to have become CAPS or non-caps specific, so that typing a word in non-caps will not find matching words with one or more capital letter.

    The find function seems to have changed in Firefox. Before, when doing a (CTRL + F) find, the search was not CAPS-specific or non-caps-specific. In other words, if I typed in "firefox" (no caps), it would find the words "firefox", Firefox", or "FIREFOX", regardless of capitalization. Now, however, the find function will only match the exact same capitalization. This totally undermines the usefulness of the function, and is a major hassle. Please fix it.
    == This happened ==
    A few times a week
    == I noticed in in the last two or so weeks.

    I am having a similar problem. The following page has the word Dangerfield in several times. My browser will get to Dang and turns pink
    http://www.genuki.org.uk/big/eng/HEF/ProbateRecords/WillsD.html
    Is it my Browser or is there a problem with Mozilla?
    I have also noted on other Google searches the same problem. Te term is listed in the page but Ctl F will not find the term

  • How does one install non-English character sets for use with the "find" function in Acrabat Pro 11?

    I have pdf files in European languages and want to be able to enter non-English characters in the "find" function. How does one install other character sets for use with Acrobat Pro XI?

    Have you tried applying the update by going to Help>Updates within Photoshop Lightroom?  The update should be using the same licensing?  Did you perhaps customize the installation location?  Finally which operating system are you using?

  • Acrobat 9 Find Function Needs to Highlight the found text

    Searching existing documents for a word using "Find" sometimes results in the word being highlighted and sometimes only the cursor is placed at the found word with no highlight. This is a problem because the cursor is very hard to locate without highlighting.
    The "Find" function should insure that found text is always highlighted.
    Or maybe there is a setting for this?
    (Also still waiting for a default View/Page Display to "Two Up Continous" as it constantly defaults to One Page which is a waste of the wide monitors.)
    Thank you.

    This bug has been fixed in the Acrobat 9.4.6 update:
    Windows:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=5244
    Mac:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=5238

  • How to use search/find function in a whole book?

    Hi,
    New to indesign... working on a book file which comprises 25 chapters.
    I'd like to do a final proof to ensure all double spaces have gone, all quote marks are right etc
    Instead of opening each chapter and using "search/find" through each chapter, can i tell the "search/find" function through the whole book?
    Appreciate any feedback
    Thanks heaps

    Apparently Adobe thought that would be more appreciated than a book-wide Search/Replace.
    You can read all about CS5's new features, and their selection procedure, on http://indesignsecrets.com/michael-ninness-answers-indesign-cs5-critics.php. The "Book" feature doesn't even get mentioned under "Sorry, we didn't change that at all." Also make sure to read the comments -- it seems lots of people really want more book features.
    If you're one of them (so it seems), you might want to pay a visit to https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

  • Adding 'FIND' functionality in toolbar of ALV Web Dynpro ABAP

    Hi Friends,
    I need to know whether we can add FIND functionality in toolbar of ALV display. If yes than which class will help in that, or do i need to code it.
    Pls help on this.
    Regards,
    Saud

    Hi Saud,
        If you mean that you need to highlight the Field-Value then, you can use Set Focus On A Table Cell .
    You can use the method REQUEST_FOCUS_ON_VIEW_ELEM of if_wd_view.
    For this, you can see this post --
                               How to set focus on a specific UI field at the start of an application?
    Further, you have to design 'find input-screen', submitting which will set focus on the cell that contains requested value.
    This way, you can add ( or somehow, simulate ) the Functionality of FIND, although not per se.
    Thanks.
    Kumar Saurav.

Maybe you are looking for