I guess I'm missing your point. Do you mean support multiple-extends not 
multiple-implements? Java does support multiple-implements?

Have you reviewed some common object patterns to see if they will satisfy what 
you need? You may have to re-model what your thinking but it may be a cleaner 
'Java' way of doing it.

http://www.dofactory.com/Patterns/Patterns.aspx


If this is not what you want, and your are talking about delegates then your 
are stuck thinking outside the 'Java' box. .Net has this capability but I don't 
think Java has it in the JDK 1.5.


Hope this helps alittle.



---------- Original Message ----------------------------------
From: Christopher L Merrill <[EMAIL PROTECTED]>
Reply-To: "Research Triangle Java User's Group mailing 
list."<[email protected]>
Date:  Mon, 28 Mar 2005 13:35:51 -0500

>I'm looking for a technique or pattern to solve the following problem:
>
>I have a class (TheClass) which needs to implement multiple interfaces (iA,
>iB and iC).  Each has a default implementation which is sufficient for my
>needs (AImpl, BImpl and CImpl).  In C++, you would use multiple inheritance
>to solve this problem - inheriting from all three default implementations
>in order to inherit all the default behavior.  Of course, this is not
>possible in Java (and frankly, I don't miss the complexity of multiple
>inheritance).
>
>In the past, I simply implement the interface and pass on method
>calls to an aggregated class (e.g. AImpl).  It's simple, but ugly.
>
>I think this could be done with a dynamic proxy, but I'm concerned about
>the performance of the heavy use of reflection.  Some parts of our application
>are extremely performance-sensitive.  In my case, it is a compile-time
>problem -- no run-time variability is required (in terms of the interfaces
>implemented).  So using reflection to direct every method call seems
>like overkill.
>
> From a language standpoint, it seems to me that some way of combining
>the "implements" clause with a contained (aggregated) member would be
>the ideal way to solve the problem.  I think of it as
>"hyper-aggregation".  For example:
>
>class TheClass implements iA, iB, iC
>     {
>     AImpl _myvarA provides iA = new AImpl();
>     AImpl _myvarB provides iB = new BImpl();
>     AImpl _myvarC provides iV = new CImpl();
>     }
>
>Thus, the interface iA of AImpl would be exposed as the implementation
>of iA for TheClass.  Ideally, one would be able to override the
>implementations of each interface within TheClass, when required.
>In essence, it is an automatic usage of a dynamic proxy implemented
>by the compiler.  The method-call forwarding would be decided by
>the compiler, rather than run-time reflection.
>
>Assuming that I am not the first person to run into the problem (nor
>the brightest), I have to ask how others solve this problem?  Is there
>some obvious problems with my solution above that has kept something
>like this from being added to Java?  I can't be the first person to
>have thought of it.
>
>
>TIA,
>C
>
>
>-- 
>-------------------------------------------------------------------------
>Chris Merrill                  |  http://www.webperformanceinc.com
>Web Performance Inc.
>
>Website Load Testing and Stress Testing Software
>-------------------------------------------------------------------------
>
>_______________________________________________
>Juglist mailing list
>[email protected]
>http://trijug.org/mailman/listinfo/juglist_trijug.org
>

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to