Mahesh Hegde

Greenhorn
+ Follow
since Apr 24, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mahesh Hegde

XML consists of 3 main parts:
1. DTD (or Schema which is gaining grounds) in a text file defines all the valid tags for the current application domain
2. The data itself is in a text file and should conform to the DTD
3. The presentation of Data - It can be done either by XSL or HTML+CSS. You always need a presentation component for XML data file because unlike HTML, XML does not have any pre-defined appearances for its tags. You have to define your own presentation information for each tag you define in your DTD.
After defining the presentation information you have to associate the XML data file with the presentation file.
If you define the presentation part in HTML+CSS combination then any normal CSS aware web browser can display the XML data using the presentation information.
If you define it using XSL then any XSL aware browser (like IE 5.0) can display it.
Ther are XML validators which can validate an XML data file for conformance to the DTD defined in the DTD file. XML data files conforming fully to its DTD are said to be 'Valid'. Also all XML tags have to be 'Well formed' i.e. each opening tag should have a matching closing tag. Hanging tags like <P> in HTML are not allowed. XML documents should be both Well formed and Valid.
There can be DTDless XML also. In this case you do not have a separate DTD file. You define your tags inline as you go along XML data file. But these XML files still have to be Well formed and Valid.
To programmatically process XML data file you will use a parser. There are 2 main types of parsers. SAX (Simple API for XML) and DOM (Document Object Model).
SAX parsers generate events for each XML tag encountered and the program receiving these events decides what to do with the corresponding data.
DOM parsers create a 'tree' out of XML data and the program can walk thru the tree of data to process them.
Hope this helps.
Regards
Mahesh
Thanks a lot jply. I had read some very good articles on Inheritance, Interfaces, Composition etc. by Bill Venners at www.artima.com. But still had those doubts which are now cleared by your excellent reply.
To summarize my understanding, with multiple inheritance of Java interfaces(in the scenario considered), implementations are not inherited and the child classes' implementation will override both I1.M1() and I2.M1(). C4.M1() will be the only one available, thus avoiding the conflict at compile time.
Even with more complex situations, at run time also there will not be any conflict because the method invoked will depend on - class of the actual object(C4) reference and not the type of the variable holding it (c1, C2, C3 or C4).
Thanks again
Regards,
Mahesh.
21 years ago
Hi,
I have a doubt (a pretty common one I should say). No doubt it might have been discussed elsewhere, but I would appreciate any feedback to help clear my doubts. Let me elaborate a bit ..
I read in many places that one of Java's positive points is that, it got rid of 'confusing and sparingly used multiple inheritance' feature of C++ and Java provides similar facility with a 'better' solution - 'interfaces' which can be used to mimic MI.
One of the classic problems with MI is the 'Diamond problem':
1. Child classes C2 and C3 inherit from parent class - C1
2. Grandchild C4 inherits from C2 and C3
Now the problems here are:
1. How many copies of C1 should be there in an instance of
C4 ?
2. If C2 and C3 both have a method M1()with exactly same signature, how will the conflict be resolved ?
3. Should C4.M1() message be be sent to C2.M1() or C3.M1()implementation?(assuming that C4 does not override M1() )
Problem 1 could be resolved in C++ by declaring C1 as 'virtual'.
Could someone shed somelight on how the other 2 problems are overcome in C++ ?
Also what is Java's solution for situation 2 occuring with its
interfaces? Say interfaces I1 and I2 both have a method with exactly same signature - M1(). If Class C1 wants to implement both I1 and I2 how is the conflict resolved ? At compile time or runtime ?
Remember, the main question is still in the subject line !!
Thanks for all your inputs.
Regards,
Mahesh
21 years ago
Ben,
Could you please elaborate a bit on 'virtual concurrency' ?
How can we block on a file pointer ? File pointer is not an object, it is part of the File object. But if we block on File object, only one thread can access a file(for reading or writing) which will really slow down the things.
Thanks,
RMI
Milind,
Could you please explain exact steps required to test RMI using File:// URL ? I was trying to test an RMI application using file:// URLs for codebase but was unsuccessful. I was able to run RMI applciation using the minimal class server from Sun. But I would like to understand the details of using file:/// URL also.
All the tutorials I read do confirm that we can use file:/// URL as server's codebase if both RMI server and client are running on the same machine. But all of them have examples only on HTTP:// codebase and most of the time using applets only.
If I use HTTP URL, HTTP server dynamically downloads the _stub and other class files from server's codebase to RMI client right ? With file:/// URL as codebase, is there still a need to download the .class files to client JVM ? if yes how does it take place ?
Thanks for your help,
Mahesh H.
21 years ago
Thanks Ben. I will try out the methods suggested by you. Meanwhile I am having a hard time testing dynamic stub downloading in RMI. Here is the long mail on the problems I am facing and my efforts to solve it..
Have you or anyone else tested Dynamic stub download in RMI using File URL as Codebase ? I am trying to do that and not able to make it work and can not figure out why it won't work. I tried all the methods mentioned in different tutorials and books but to no avail.
I have following directory structure (all on same PC):
c:\rmi - no .class files in this directory
c:\rmi\server - all server related .class files (including _stub)
c:\rmi\client - all client related .class files
my CLASSPATH is - .;.. (current and parent directory only)
Now I do the following to execute the RMI application:
1. start rmiregistry with 'start rmiregistry' command from c:\rmi directory (note that no .class files are in this directory and hence rmiregistry should not find _stub class file in its CLASSPATH).
2. start RMI server from c:\rmi\server directory with codebase set to c:\rmi\server.
This step works fine. I know that because, if I do not specify the correct directory on the File URL, I get a 'Unmarshalling error' during Naming.rebind() call. This means that rmiregistry is indeed anotating _stub properly with server's codebase, right ? Is there a way to verify (by a System.out.println() may be) _stub's codebase as annotated by rmiregistry, after Naming.rebind() call ?
But I do have a question here. I am on Win95 and any of the following 3 forms of file URLs seem to work fine:
file:///c:/rmi/server/
file:/c:/rmi/server/
file:///c:\rmi\server/
which one is correct as per you ?
3. start RMI client from c:\rmi\client directory.
This is where I get 'Unmarshalling error'. (Client does work fine if I copy _stub to c:\rmi\client directory. Of course then I have not used dynamic downloading of _stub).
As per all tutorials I read, dynamic downloading should happen if:
-rmiregistry does not find download classes in its classpath
-server has correct codebase
-client does not find _stub in it's local classpath
I think I am satisfying all the three criteria. What am I missing ?
I also have other questions:
1. If I have a HTTP server running and I use an HTTP URL for
codebase, _stub is downloaded to client using HTTP protocol, right? How does the download take place when I use a File URL? FTP ? If FTP, who provides the FTP service ?
2. Do I need to set codebase for RMI client also, to make it work ?
3. I had to set java.policy on client also (besides server) to come to 'unamrshalling error' on client side. Is that always necessary ?
4. My PC has Computer name = 'D071479' on Control
Pannel/Network/Identification panel. I tried setting
java.rmi.server.hostname=D071479 also. But it did not work either
5. Do you think I should go for HTTP URL instead of File URL for server codebase ? Which method did you use for RMI testing ?
All your time and help are greatly appreciated.
Thanks,
Mahesh H
Hi,
I am BE in EE with 3+ years of development experience. Consultant in US on H-1 since 2.5+ years. Have mostly mainframe experience. Currently involved in a Java pilot project using WebSphere/JSP/Servlets.
SCJP2 - 86%, Brainbench Java 2 Master - 4.21/5.0 (in top 30 list)
Online transcript at - http://www.brainbench.com/transcript.jsp?pid=161210
Currently working on SCJD2 assignment
Solid conceptual understanding of OO, C/S, Distributed computing.
Highly resourceful, Self motivated, Good communication skills.
Will need H-1 processing.
Interested ? Please e-mail me: hegdemk@hotmail.com
Thanks.
21 years ago
Nope. As per RMI FAQ, if your server implements java.rmi.Unreferenced, it will be notified only when the server stub has no references in the registry (i.e. there are no clients left) and not when each client ends. I have not tried that out though.
Why I wanted to know this ? - to be able to shut down the server gracefully without affecting any active clients. I would like to do something like this:
1. Server admin selects 'Stop Server' from the menu
2. Server checks if there are any client requests currently active.
3. If no clients are active, server exits immediately else it sets 'do not accept any more connections' flag to true. From this point onwards any client requests will be rejected by the server.
4. Server waits in a loop, occassionally checking for completion of active client requests. When all active client requests complete server exits.
Do not exactly know whether this approach is appropriate or even possible!
-Mahesh H.
Hi all, In socket based networking code we can take care of keeping track of the number of active clients or spawning a new server thread for each client request, pretty easily. The socket sever does an accept() for each client connection request and waits in a loop. So we can incrment the activeclients count after accept() and decrement it when the server thread completes.
I do read that RMI automatically takes care of multithreading the server part for you, but your code should be thread safe. I would like to know how can we keep track of or get information about the number of currently active client requests and when they finish.
Any information on this are highly appreciated.
Thanks.
Thanx Ben. Even my requirements does not specifically mention anything about passenger information. But without any Date and Passenger information in the database, all you will be able to reserve is just aginst the number of seats available on an airlines. Without a name you can not query or cancel a reservation. The functionality of the whole system from the practical view point is NULL. That's what Sun wants us to develop ?
Hi Ben,
I have a doubt on the record locking scheme. From your description it looks like for doing some writing / reading your client follows the steps:
1. call server.lock()
2. Read/Write
3. call server.unlock()
What hppens when the client terminates anywhere before step 3. The server will have the lock on and no other client will be able to read/write from the locked record.
I would think that all the 3 steps should happen as an atomic operation on the server side. Say your client calls server.read(), then within read you should :
1. lock()
2. read data
3. unlock()
But the disadvantage here is that if lock() in read() blocks to obtain lock, then client will just wait, probably frustrating the user. But this will at least maintain data integrity.
Correct me if I am wrong on understanding your design.
-mahesh
I think so. Becuase as per my knowledge there is no form of sleep() without any delay as parameter. The only 2 forms of sleep() are - sleep(long ms) and sleep(long ms, int ns).
21 years ago
I think that both over-riding and overloading are forms of Polymorphism - "one interface, multiple implementations". But most of the OOP books claim that over-riding is the 'true polymorphism' as it allows runtime polymorphism.

Originally posted by VVed:
Method overloading is one of the ways that Java implements polymorphism.
Overridden methods allow Java to support run-time polymorphism.
ie. Overridden methods are another way that Java implements the "one interface, multiple methods" aspect of polymorphism.
this answer is according to my knowledge gained from a book called "The Complete Reference (JAVA2 third edition)"
please check pg.158(Overloading Methods) & pg.215(Overridden Methods)
if this is not the case then please give me a detailed explaination for this.


21 years ago