Hi Dmitry,
Just to add some detail to Nuno's explanation, you can do what you want
with some simple custom code to wrap the marshal handling. Get a
marshaller instance as normal, then cast it to the implementation class
org.jibx.runtime.impl.MarshallingContext. Start with calls to
startDocument() and startTag(), passing 0 as the namespace index if
you're not using namespaces. As long as the Security class has a
<mapping> in the binding you'll be able to case instances to the
org.jibx.runtime.IMarshallable interface, then use the marshal(mctx)
call on that interface to have the object write itself to the output.
Repeat this as many times as you want, with whatever processing you want
in between, for all the objects you want to include in the output
document, then finish with calls to endTag() and endDocument().
- Dennis
Nuno Ferreira wrote:
Hi,
You just don´t call the endDocument() method and the OutputStream
isn´t closed, maintain the outstream open and marshall again, and
again, how many objects you have.
the method call sequence is this :
mctx.startDocument();
marshall()
if(end)
mctx.endDocument();
This was made inside a Writer, i don´t know what is you class
structure, but i hope this will help.
cheers
On 26/09/05, *Dmitry* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
wrote:
Hello all,
Does anybody know how can I marshal a huge set of objects, which I
get in
chunks into ONE output file.
My problem is that I'm running out of memory if I attempt to
collect all
objects that need to be marchaled at once.
What I need to do is to get chunks of results in , say chunks of
100,000
objects and as I get them have JiBX output them into a file
I have a working mapping that does what it needs to do, but it
will create a
COMPLETE XML file with all ROOT tags for every chunk of results I
pass to
JiBX.
I've noticed that there seems to be a way to do what I need:
There are methods startDocument and endDocument on IMarshallingContext
object.
public void marshalDocument(java.lang.Object root,
java.lang.String enc,
java.lang.Boolean alone,
java.io.Writer outw)
throws JiBXException
Marshal document from root object to writer. The effect of this
method
is the same as the sequence of a call to startDocument(
java.lang.String,
java.lang.Boolean), a call to marshal the root object using this
context,
and finally a call to endDocument().
But what is the method I need to call that would just marshal the
chunks of
results without closing the document..
Basically I need this
1. Output enclosing tag: <Securities>
2. In chunks marshal <Security> objects themselves.. It'll have
chunks of
"Collection" of 100,000 objects each chunk.
3. Output closing final tag </Securities>
4. And close the output file at this moment.
What kind of mappings I need for that? What methods and in which
sequence to
call?
Thanks to all in advance.
Dmitry.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App
Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/jibx-users
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users