× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



hmmm... can you explain what the following is doing?

public class myClass extends HttpServlet implements SingleThreadModel

I know I have a class called myClass that inherits from HttpServlet.  I also
know that implementing SingleThreadModel changes the way the HttpServlet is
handled by WAS.  

thanks

dan


-----Original Message-----
From: Larry Loen [mailto:lwloen@us.ibm.com]
Sent: Tuesday, March 20, 2001 10:06 AM
To: JAVA400-L@midrange.com
Subject: RE: HTML to XML, vice versa



Aaron Bartell asked about the "interface" keyword.

"Interface" solves a set of problems that bedevil the O-O world.

The most important situation is this:

  class SwissArmyKnife extends  ......what??

A Swiss Army Knife "is a" knife.  But, it also "is a" screwdriver and
"is a" scissors.

How does one deal with this multitude of "is a" situations?

In C++, there is a scheme called "mulitple inheritance" and it sounds
straightforward, but it isn't.

You simply "extend" for all the objects you wish.  In Java syntax:

  class SwissArmyKnife extends knife, scissors, nailfile. . .

However, in terms of actual theory and practice, this is very difficult to
deal with.  I won't even try and repeat the bulging literature on this.

Java's solution is to permit exactly one "parent" for each child.  This
gets rid of multiple inheritance by definition.  But, what about Swiss Army
Knives?  Instead, to handle this, Java defines the notion called an
"interface" and it is a kind of special case class.

1.  No variables.
2.  No default implementation for methods in the interface proper.
3.  You can "implement" as many interfaces on your class as make sense.
4.  If a regular class "implements" an interface, it must supply a method
for every method the interface does.
5.  "instance of" for a class that implements a method, will return true if
the instance of targets the interface name.

So, assuming you understood it was coming at the start, you would not
design a "knife" class.  Or, if you did, you would add a "knifeinterface"
class and have "knife" implement it.

Thus:

class knife extends sharpobject  implements knifeinterface ...

class SwissArmyKnife implements knifeinterface,
      scissorsinterface, nailfileinterface....

And, illustrating 5 above:

SwissArmyKnife swiss =  Something();
 if (swiss instanceof knifeinterface) System.out.println("Will print
this");

knifeinterface ki = swiss;   // allowed


Interfaces, because they formally lack variables, are often used in Java
for items whose implementations are expected to vary radically.  Whether
this is really theoretically justified, I never have tracked down, but it
is a fact of life.

An interface important to us all is the JDBC definitions, for instance.

Any sort of "factory" type interface tends to be defined with a Java
interface rather than some sort of base class with a large number of
abstract methods.


Larry W. Loen  -   Senior Java and AS/400 Performance Analyst
                          Dept HP4, Rochester MN


+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.