|
XCC/J 3.2-9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.marklogic.xcc.examples.OutputStreamInserter
This class illustrates a sample usage of the
OutputStreamContent class.
Click here for the source code for this class
A simple inner class is defined here which generates some
content programmatically and writes it to an OutputStream.
It makes use of OutputStreamContent to obtain an
OutputStream instance tied to a Content
object.
The way this works is that OutputStreamContent creates
a pipe (double-ended stream). A thread is spawned which writes
data to the sink end of the pipe. The OutputStreamContent
object is passed to Session.insertContent(com.marklogic.xcc.Content)
which will ultimately read data from the source end of the pipe.
It's therefore important that the writer thread be started
before doing the insert.
To make use of OutputStreamContent, you simply need
to implement the standard Runnable interface and put
your data transfer logic in the Runnable.run() method.
See the source code for the main() method.
OutputStreamContent| Nested Class Summary | |
static class |
OutputStreamInserter.DocBuilder
A simple dummy content generator which writes to an OutputStream. |
| Method Summary | |
static void |
main(String[] args)
Looks for a server URI and a document URI on the command line, then spawns a thread to generate and insert some content there. |
static Thread |
spawnThread(Runnable runnable)
Create and start a new Thread for the given
Runnable. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void main(String[] args)
throws Exception
args - Server URI: xcc://user:password@host:port/contentbase,
Doc URI: any valid URI string to assign to the new content.
Exception - If anything bad happens.public static Thread spawnThread(Runnable runnable)
Thread for the given
Runnable. The run() method of this object
will be invoked in a new thread and should write the
desired content to the OutputStream.
runnable - An instance of Runnable.
Thread.
The new thread may or may not have begun executing
upon return from this method.
|
XCC/J 3.2-9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com