Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2005

Tip: Looking for answers? Try searching our database.

Using Reflection but no network connection

Thread view: 
Jean-Sébastien Goupil - 19 Sep 2005 02:48 GMT
Hi,

I'm currently using Java5 and SAX Builder to read an XML file and load
dynamically by reflection classes from my packages.
The code tries to load each class represented by a tag, but if the
class doesn't exist, it tries to use the tag as a String member in the
previous loaded class.

The problem is that if the class represented by a tag doesn't exist,
Java will try to connect to the current website and ask for the class
file in the current working directory. I would like to prevent this
access because it takes a lot of time to parse a big XML file.

So, when the class is not found in the current package, I don't want
Java checks the server. Is there a way to do that?

Thank you very much
Roedy Green - 19 Sep 2005 05:00 GMT
>So, when the class is not found in the current package, I don't want
>Java checks the server. Is there a way to do that?

If you write your own ClassLoader you can define whatever behaviour
you want for where it searches for classes.

It sounds like a custom class loader might be being used already.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Raymond DeCampo - 19 Sep 2005 14:18 GMT
> Hi,
>
[quoted text clipped - 7 lines]
> Java will try to connect to the current website and ask for the class
> file in the current working directory.

I'm assuming that we are talking about an applet?

I imagine that the problem is that the codebase is set to ".".  Try
packaging your applet in such a way that this is not the case.

> I would like to prevent this
> access because it takes a lot of time to parse a big XML file.
[quoted text clipped - 3 lines]
>
> Thank you very much

HTH,
Ray

Signature

XML is the programmer's duct tape.

Jean-Sébastien Goupil - 20 Sep 2005 21:04 GMT
Yes I'm using applet.
the classLoader is something like that :
       try {
           //qname = qname.substring(0, 1).toUpperCase() +
qname.substring(1);
           element = (SimpleElement) Class.forName("utils.xml." +
qname) //$NON-NLS-1$
                   .newInstance();
       } catch (Exception e) {
       }

The forName checks in the package AND if it is not existing it checks
in the folder /utils/xml/... This completely slow the loading of the
applet...

You said to check the codebase. I don't really understand what do you
mean...
My codebase is
<object
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,7"

And there is no codebase in the <embed> tag...
When I print the codebase in the applet, I get the name of the server.
(http://.../)

Do you understand more what is the problem ?

Thank you for your help

Jean-Sébastien Goupil
Raymond DeCampo - 22 Sep 2005 02:44 GMT
> Yes I'm using applet.
> the classLoader is something like that :
[quoted text clipped - 23 lines]
>
> Do you understand more what is the problem ?

Why don't you post the entire HTML snippet that defines your applet?

Ray

Signature

XML is the programmer's duct tape.

Jean-Sébastien Goupil - 22 Sep 2005 16:37 GMT
Ok, I didn't think it was a good place to post it...
There is the code

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trasitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Notificateur d'Alarme</title>
<style type="text/css">
body {
    padding: 0px;
    margin: 0px;
}
</style>
</head>
<body>

<object
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,7"
    name="appletCristal"
    standby="Please wait while downloading..."
    border="0"
    width="559"
    height="431">
    <param name="code" value="StartProgram" />
    <param name="archive" value="jar/alarm.jar, jar/mail.jar,
jar/saaj-api.jar, jar/saaj-impl.jar, jar/activation.jar,
jar/FastInfoset.jar" />
    <param name="type" value="application/x-java-applet;version=1.5" />
    <param name="name" value="appletCristal" />
    <param name="hostname" value="./WSDL/iLON100.WSDL" />
    <param name="beepDelay" value="500" />

    <comment>
        <embed
            type="application/x-java-applet;version=1.5"
            code="StartProgram"
            width="559"
            height="431"
            pluginspage="http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en"
            name="appletCristal"
            archive="
                jar/mail.jar,
                jar/saaj-api.jar,
                jar/saaj-impl.jar,
                jar/activation.jar,
                jar/FastInfoset.jar,
                jar/alarm.jar"
            hostname="./WSDL/iLON100.WSDL"
            beepDelay="500">
            <noembed>
                You don't have any Java Program Installed.
            </noembed>
        </embed>
    </comment>
</object>

</body>
</html>

Thank you !

Jean-Sébastien


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.