Re: Implemeting an ExtensionHeader
"M. Rangnathan" <[email protected]>
| Newsgroups | gmane.comp.voip.nist-sip |
|---|---|
| Message-ID | <[email protected]> |
Hi There is no Java trick involved. You implement ExtensionHeader just the same way as you implement any interface. However, what you are attempting to do will not work. Yes you will get a ClassCastException and thats because the stack keeps a NAME to Class mapping for the Factory and expects an header of NAME "Contact" to be of a type that implements javax.sip.header.ContactHeader and of type gov.nist.javax.sip.header.Contact Did you consider the suggestion of changing AddressImpl.encode() to remove quotes ? Also, you cannot extend Contact to do what you want it to. My suggestion would be to make yourself a custom version of gov.nist.javx.sip.Contact which is not checked into cvs if thats what you really want to do. If you dont care about standards compliance, you should not expect that your solution will be portable across JAIN-SIP implementations nor should you expect interoperability but neither appears to be a concern in your case. Regards, Ranga [email protected] wrote: > OK, so I apologize for my ignorance of Java, but I'm hoping you guys > will be willing to bear with me a little bit longer. I thought about > what you said about just working with the interfaces, and thought maybe I > could create my own Header class that does what I want. So I did that: > created a class that implements ExtensionHeader. But when I pass that > in as a header (using addHeader), I get that ClassCastException you were > worried about earlier. > > So how is one actually supposed to implement an ExtensionHeader? > I'm imagining there is some basic Java trick that I am missing here.... > > (Obviously I just did some stub stuff here pending showing that > this is actually going to work) > > ------------------------------------------------- > > package stp; > > import javax.sip.header.ExtensionHeader; > > public class AsterixTransferHeader implements ExtensionHeader { > > private String uri; > > public AsterixTransferHeader() {} > > public AsterixTransferHeader(String uri) { this.uri = uri; } > > public String getName() { return "Contact"; } > > public String getValue() { return "Transfer <" + uri + ">"; } > > public void setValue(String uri) { this.uri = uri; } > > public Object clone() { > System.out.println("AsterixTransferHeader.clone called"); return new > AsterixTransferHeader(this.uri);} > > public boolean equals(Object obj) { > System.out.println("AsterixTransferHeader.equals called"); return false;} > > public int hashCode() { > System.out.println("AsterixTransferHeader.hashCode called"); return > super.hashCode();} > > public String toString() { return this.getName() + ": " + > this.getValue(); } > > }; > > --David > _______________________________________________ > nist-sip mailing list > [email protected] > http://www-x.antd.nist.gov/mailman/listinfo/nist-sip > -- M. Ranganathan Advanced Networking Technologies Division, National Institute of Standards and Technology (NIST), 100 Bureau Drive, Stop 8920, Gaithersburg, MD 20899. tel:301 975 3664 , fax:301 590 0932 http://w3.antd.nist.gov/ Advanced Networking Technologies For the People!