This discussion is archived
2 Replies Latest reply: Oct 20, 2010 10:45 AM by Antonio Sánchez RSS

Locally persisting URLClassLoader remote classes

Antonio Sánchez Newbie
Currently Being Moderated
Hi.

I will use URLClassLoader for loading classes from remote URL (http).

I require persisting locally downloaded classes for reuse in future JVM invocations running my application in order to improve performance in server and response time in client.

I understand URLClassLoader does not behave this way (please correct me if I'm wrong) but before coding a custom class loader I wonder if you know of any utility or project providing this functionality .

I also require:
- Class loader loads the latest version of the classes, checking timestamp or UUID of downloaded cached local classes against those in server.
- Downloading the .jar where the .class is packaged instead of just downloading the .class.

Finally I have some questions about network class loading:
- Does remote class loading overloads the system serving the classes? The same system will also serve web applications and possible database and I want system resources devoted to web applications, not streaming classes all the time.
- Is remote URL required to be a public folder? I want tokeep my classes private and streaming them through a front servlet.

Thanks for your time. Regards.
Antonio.
  • 1. Re: Locally persisting URLClassLoader remote classes
    EJP Guru
    Currently Being Moderated
    I understand URLClassLoader does not behave this way
    Not sure about that. I would investigate further before committing yourself to any code.
    I wonder if you know of any utility or project providing this functionality .
    JNLP.
    - Class loader loads the latest version of the classes, checking timestamp or UUID of downloaded cached local classes against those in server.
    JNLP.
    - Downloading the .jar where the .class is packaged instead of just downloading the .class.
    URLClassLoader already does that. See the Javadoc. It explicitly says that the jar is downloaded.
    Finally I have some questions about network class loading:
    - Does remote class loading overloads the system serving the classes?
    Compared to what? JAR files aren't particularly large, and they are downloaded once at most in the lifetime of the URLClassLoader. Even if URLClassLoader downloaded individual classes, that would only happen once per class per client JVM.
    - Is remote URL required to be a public folder? I want tokeep my classes private
    I guess you could use an Authenticator for that but you'll get tangled up with other uses of it.
    and streaming them through a front servlet.
    You're worried about performance and you're adding extra processing? Just stick them somewhere on an Apache web server, or in a Tomcat under the path to an existing application. You don't need your own servlet for this, it doesn't add anything.
  • 2. Re: Locally persisting URLClassLoader remote classes
    Antonio Sánchez Newbie
    Currently Being Moderated
    EJP, thanks for your reply.

    Let me explain the context:

    Client application queries to a scalable web application so client application only performs presentation logic. Client application will be downloading "modules" on demand as it requires them. These modules are simple jars with classes to be loaded in client application for presentation logic. There will be a huge number of modules and only some of them will be used by each user so it doesn't make sense to have a huge jar with all the modules; that's why they will be downloaded as required. More on the context on [this other post|http://forums.oracle.com/forums/thread.jspa?threadID=1773299] .

    My question:

    I thought JNLP is for downloading the whole application once for all and keeping it updated. Can I use JNLP also for downloading independent jars on demand?

    Regarding your other answers:

    1. Client only knows a key of the jar to be downloaded, so it must query a servlet that maps the key to the actual jar for downloading. Anyway I think I can manage it without this mapping by providing client with the full URL.

    2. I researched URLClassLoader time ago and found that I can't use it for my requirements without developing. I don't know the location where it downloads the .class and .jar files, even if it does. Besides I would have latency problems if it has to find a class hidden somewhere in a huge jungle of thousands of remote jars . That's why client must exactly know what it need and where to get it from.

    Thanks again. Regards.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points