You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Markus Wiederkehr <ma...@gmail.com> on 2005/02/10 14:45:17 UTC

DataSqueezer problem

I have an interface called Document and a couple of classes
implementing that interface. I also have a custom squeeze adaptor that
uses the document's identifier as external representation.

So far so good. Now, for reasons not related to Tapestry, my classes
also have to implement the Serializable interface. And here's the
problem, Tapestry uses its own SerializableAdaptor instead of my
document adaptor.

Is there a solution/workaround for this problem?

Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: DataSqueezer problem - Java problem?

Posted by Konstantin Iignatyev <kg...@yahoo.com>.
Jonathan Millett wrote:

> In your class declaration, is the Document interface is specified first?
> If I remember correctly, Tapestry searches the interfaces in order and 
> uses the first applicable adapator it finds.

Even Java guarantee that class.getInterfaces() returns  interfaces in 
the order of their declaration I do not think Tapestry should rely on it:
- Serializable should be a last resort IMO, if there is something usable 
- than it should be used;
- I guess that I could have superclass that implements Document and then 
declare that my subclass implements Serializable. Javadoc is silent 
about inherited interfaces the method class.getInterfaces() does not 
return them!

I made quick test that prints out
*/usr/java/j2sdk1.4.2_06/bin/java -Didea.launcher.port=7535 -.........
0 = interface java.io.Serializable*
*is Dog? = true*

Kind of weird, I expected that getInterfaces() returns  all interfaces 
of a class......... but  *instanceOf  *knows that class is instance of 
/*Dog*/ interface .... weird

public class Utils{

  static interface Dog{
    boolean isDog();
  }

  static interface Cat{
    boolean isCat();
  }

  static class A implements Dog{

    public boolean isDog(){
      return true;
    }
  }

  static class B extends A implements Cat{

    public boolean isCat(){
      return true;
    }
  }

  static class D extends B implements Serializable{

  }

  public static void main( String[] args ){
    Class[] interfaces = D.class.getInterfaces();
    for( int i = 0; i < interfaces.length; i++ ){
      Class anInterface = interfaces[i];
     * System.out.println( i + " = " + anInterface );*
    }
    D d = new D();
    *System.out.println( "is Dog? = " + ( d instanceof Dog) );*
  }
}



-- 
Thanks,

Konstantin Ignatyev

http://www.kgionline.com





PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2.700 tons of CFCs to the stratosphere, and increase their population by 263.000

Bowers, C.A.  The Culture of Denial:  
Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools.  
New York:  State University of New York Press, 1997: (4) (5) (p.206)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: DataSqueezer problem

Posted by Markus Wiederkehr <ma...@gmail.com>.
I had the following situation:

interface Document { ... }
interface ImageDocument extends Document { ... }
class ImageDocumentImpl implements ImageDocument, Serializable {...}

Now I have changed it into:

class ImageDocumentImpl implements Document, ImageDocument, Serializable {...}

...and it's working, thanks for your help. But I'm a bit concerned
about the reliability of this approach. For example, what happens if I
use a different Java compiler?

Markus

On Thu, 10 Feb 2005 11:37:01 -0300, Jonathan Millett <jo...@millett.net> wrote:
> In your class declaration, is the Document interface is specified first?
> If I remember correctly, Tapestry searches the interfaces in order and
> uses the first applicable adapator it finds.
> 
> Example:
> public class NewsArticle implements Document, Serializable
> 
> Jon
> 
> Markus Wiederkehr wrote:
> 
> >I have an interface called Document and a couple of classes
> >implementing that interface. I also have a custom squeeze adaptor that
> >uses the document's identifier as external representation.
> >
> >So far so good. Now, for reasons not related to Tapestry, my classes
> >also have to implement the Serializable interface. And here's the
> >problem, Tapestry uses its own SerializableAdaptor instead of my
> >document adaptor.
> >
> >Is there a solution/workaround for this problem?
> >
> >Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: DataSqueezer problem

Posted by Jonathan Millett <jo...@millett.net>.
In your class declaration, is the Document interface is specified first?
If I remember correctly, Tapestry searches the interfaces in order and 
uses the first applicable adapator it finds.

Example:
public class NewsArticle implements Document, Serializable

Jon

Markus Wiederkehr wrote:

>I have an interface called Document and a couple of classes
>implementing that interface. I also have a custom squeeze adaptor that
>uses the document's identifier as external representation.
>
>So far so good. Now, for reasons not related to Tapestry, my classes
>also have to implement the Serializable interface. And here's the
>problem, Tapestry uses its own SerializableAdaptor instead of my
>document adaptor.
>
>Is there a solution/workaround for this problem?
>
>Markus
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org