For now, classloaders are not really an issue, but we'll need to tread
carefully, especially when we start to push further into the server side.
- James
Martin Cooper wrote:
> On 6/11/06, James M Snell <[EMAIL PROTECTED]> wrote:
>>
>> The generics are an API optimization. The code autodetects what is
>> being parsed. In every case, Document.getRoot() returns some derivative
>> of the FOM Element interface. If you know what you're parsing, use the
>> generics; if you're not sure what you're parsing, don't use the generics
>> and do an instanceof to see what you ended up with. I'm not sure I see
>> the "problem".
>
>
> Using instanceof can fail if the object you are testing was created via a
> different instance of the class than the one you are comparing it to (i.e.
> when multiple class loaders are in play). Is that a non-issue here,
> somehow,
> or do we need to guard against it?
>
> --
> Martin Cooper
>
>
> Alternatively, plug in an Atom 0.3 Extension Factory and provide a set
>> of classes that implement the FOM on top of the Atom 0.3 model. Then
>> you could continue to use the generics form. By Tuesday I should be
>> able to post some sample code that illustrates this...
>>
>> Document<Feed> doc = Parser.INSTANCE.parse(atom03FeedStream);
>> Feed feed = doc.getRoot();
>> System.out.println(feed.getClass()); // outputs sample.Atom03Feed
>>
>> - James
>>
>> Garrett Rooney wrote:
>> > On 6/10/06, James M Snell <[EMAIL PROTECTED]> wrote:
>> >> Abdera will successfully parse any well-formed XML. The trick is not
>> to
>> >> use generics when parsing.
>> >>
>> >> Document doc = Parser.INSTANCE.parse(someInputStream);
>> >>
>> >> The parser will automatically detect whether the XML stream is an Atom
>> >> document (Feed, Entry or Atom Publishing Protocol Introspection
>> doc) or
>> >> whether it is some other XML.
>> >>
>> >> Element element = doc.getRoot();
>> >>
>> >> if (element instanceof Feed) {
>> >> // it was an Atom Feed document }
>> >> if (element instanceof Entry) {
>> >> // it was an Atom Entry document }
>> >> if (element instanceof Service) {
>> >> // it was an APP Introspection document }
>> >> if (element instanceof ExtensionElement) {
>> >> // it was arbitrary XML }
>> >>
>> >> More below.
>> >
>> > Makes one wonder what the point of the generics is, if you can't use
>> > them if you want to be able to recover gracefully from such
>> > problems...
>> >
>> > -garrett
>> >
>>
>