commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sameer Nanda <sam5...@gmail.com>
Subject Re: [betwixt] Problem loading a Bean in Betwixt
Date Mon, 17 Oct 2005 18:44:30 GMT
>
>
> But I wonder why Betwixt accesses this SessionStatisticsImpl object in
> the first place. I mean, it does not sound like a business object, so
> perhaps you should hide it via the mapping - define a class mapping
> for the business class in question and avoid addDefault in it.
>
>
Tom,
I am trying this right now, just had a quick question, are we supposed to
put the mapping.xml file (containing the class mapping) into the
classpath??? Just like we do for .betwixt file. OR do we read it using a
StringReader, as I remember you should me the last time we were talking.


public Object readXML(Reader mappingReader, Reader xmlReader)
throws IOException, SAXException, IntrospectionException
{
BeanReader beanReader = new BeanReader();

beanReader.registerMultiMapping(new InputSource(mappingReader));
return beanReader.parse(xmlReader);
}

public void writeXML(Reader mappingReader, Writer xmlWriter,
Object obj) throws IOException, SAXException, IntrospectionException
{
xmlWriter.write("<?xml version='1.0' ?>\n");

BeanWriter beanWriter = new BeanWriter(xmlWriter);

beanWriter.getXMLIntrospector().register(new
InputSource(mappingReader));
beanWriter.enablePrettyPrint();
beanWriter.write(obj);
}


where mappingReader is a Reader that retrieves the above mapping (eg.
a FileReader or StringReader).

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message