How can I get a handle to an InputStream my SimpleProcessor class extension?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen-2
Hi everyone,

I am writing a custom processor, and I have a question about the
Orbeon SimpleProcessor API I'm hoping someone can help me out with:
How can I get a handle to an InputStream my SimpleProcessor class
extension?

My processor has two inputs coming in:
1. The processor configuration xml
2. An XML document to be imported into my content management system

#2 can potentially be very big, and so I have written an import
routine which handles it all as an inputstream / sax events. Here is
the signature for my import action method:

    public void doImport(InputStream xmlInputStream) throws ImporterException{
        ...
    }

I then have a customer processor, extending Orbeon's SimpleProcessor
class. Now, I know how to generate SAX events from an
org.xml.sax.ContentHandler in my SimpleProcessor extension:

 public void generateData(PipelineContext context, ContentHandler
contentHandler)
        ...
    ContentHandler myContentHandler = ...
    readInputAsSAX(context, INPUT_DATA, myContentHandler);
       ...
}

but I'm not sure how to get a handle to a java.io.InputStream for my
XML input. There seems to me two potential solutions:
1. Do something fancy with JAXP, ContentHandler, and InputStream. JAXP
gives me headaches....
2. Get the InputStream directly from some magical Orbeon /
SimpleProcessor functionality.

Any ideas, people?

Many thanks!

Sincerely,
Henrik Pettersen

PS! Mr. Bruchez, Mr. Vernet, I'm working on an internal Orbeon
application for the Daily Telegraph at the moment
(http://telegraph.co.uk). Spreading the gospel :-)


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Florent Georges-3
Henrik Pettersen wrote:

  Hi

> #2 can potentially be very big, and so I have written an import
> routine which handles it all as an inputstream / sax events. Here is
> the signature for my import action method:

>     public void doImport(InputStream xmlInputStream) throws
> ImporterException{

  Can't you make your code to return the SAX Handler it uses to handle
the SAX events?  If you could, you'd be able, in your custom processor,
to get the handler and pass it to readInputAsSAX().

  Regards,

--drkm
























      _____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
I wish...

I'm integrating a 3rd party API that only takes and InputStream, so
this is not possible.

Thanks, though!

Henrik

2008/8/6 Florent Georges <[hidden email]>:

> Henrik Pettersen wrote:
>
>  Hi
>
>> #2 can potentially be very big, and so I have written an import
>> routine which handles it all as an inputstream / sax events. Here is
>> the signature for my import action method:
>
>>     public void doImport(InputStream xmlInputStream) throws
>> ImporterException{
>
>  Can't you make your code to return the SAX Handler it uses to handle
> the SAX events?  If you could, you'd be able, in your custom processor,
> to get the handler and pass it to readInputAsSAX().
>
>  Regards,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>      _____________________________________________________________________________
> Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
All,

has anyone had any success getting an (XML) InputStream from the
pipeline, in an extension of SimpleProcessor? I'd rather not attempt
to go from a ContentHandler to an InputStream using JAXP (if even
possible...)

Thanks!

Henrik

2008/8/6 Henrik Pettersen <[hidden email]>:

> I wish...
>
> I'm integrating a 3rd party API that only takes and InputStream, so
> this is not possible.
>
> Thanks, though!
>
> Henrik
>
> 2008/8/6 Florent Georges <[hidden email]>:
>> Henrik Pettersen wrote:
>>
>>  Hi
>>
>>> #2 can potentially be very big, and so I have written an import
>>> routine which handles it all as an inputstream / sax events. Here is
>>> the signature for my import action method:
>>
>>>     public void doImport(InputStream xmlInputStream) throws
>>> ImporterException{
>>
>>  Can't you make your code to return the SAX Handler it uses to handle
>> the SAX events?  If you could, you'd be able, in your custom processor,
>> to get the handler and pass it to readInputAsSAX().
>>
>>  Regards,
>>
>> --drkm
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>      _____________________________________________________________________________
>> Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
Ok, in the public interface ResourceManager in package
org.orbeon.oxf.resources, we have:
    public InputStream getContentAsStream(String key);

And here is a sample implementation of this, in the FileSystemResourceManager:
    public InputStream getContentAsStream(final String key) {
        return (InputStream) delegate(new Operation() {
            public Object run(ResourceManager resourceManager) {
                return resourceManager.getContentAsStream(key);
            }
        });
    }

Nice! This is what I need. But how can I get access to the appropriate
resource manager? Are ResourceManagers even used to get access to XPL
defined inputs? Not sure if this is barking up the wrong tree...

Anny ideas?

Thanks!

Henrik

PS! Perhaps getContentAsStream would be an appropriate extension to
the SimpleProcessor class?


2008/8/7 Henrik Pettersen <[hidden email]>:

> All,
>
> has anyone had any success getting an (XML) InputStream from the
> pipeline, in an extension of SimpleProcessor? I'd rather not attempt
> to go from a ContentHandler to an InputStream using JAXP (if even
> possible...)
>
> Thanks!
>
> Henrik
>
> 2008/8/6 Henrik Pettersen <[hidden email]>:
>> I wish...
>>
>> I'm integrating a 3rd party API that only takes and InputStream, so
>> this is not possible.
>>
>> Thanks, though!
>>
>> Henrik
>>
>> 2008/8/6 Florent Georges <[hidden email]>:
>>> Henrik Pettersen wrote:
>>>
>>>  Hi
>>>
>>>> #2 can potentially be very big, and so I have written an import
>>>> routine which handles it all as an inputstream / sax events. Here is
>>>> the signature for my import action method:
>>>
>>>>     public void doImport(InputStream xmlInputStream) throws
>>>> ImporterException{
>>>
>>>  Can't you make your code to return the SAX Handler it uses to handle
>>> the SAX events?  If you could, you'd be able, in your custom processor,
>>> to get the handler and pass it to readInputAsSAX().
>>>
>>>  Regards,
>>>
>>> --drkm
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>      _____________________________________________________________________________
>>> Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=help
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>>>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Alessandro Vernet
Administrator
Henrik,

On Thu, Aug 7, 2008 at 6:47 AM, Henrik Pettersen
<[hidden email]> wrote:
> Ok, in the public interface ResourceManager in package
> org.orbeon.oxf.resources, we have:
>    public InputStream getContentAsStream(String key);

getContentAsStream() is the resource manager is something different:
it reads a file from disk and returns a stream of bytes for this file.
As Florent mentioned, what flows between processors is XML in the form
of SAX events. So at that stage, the XML has already been parsed. It
would be best if your library could provide a SAX ContentHandler, into
which you can send the SAX events with readInputAsSAX(). Otherwise you
will have to serialize the XML so you can get a InputStream.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Erik Bruchez
Administrator
> getContentAsStream() is the resource manager is something different:
> it reads a file from disk and returns a stream of bytes for this file.
> As Florent mentioned, what flows between processors is XML in the form
> of SAX events. So at that stage, the XML has already been parsed. It
> would be best if your library could provide a SAX ContentHandler, into
> which you can send the SAX events with readInputAsSAX(). Otherwise you
> will have to serialize the XML so you can get a InputStream.

The issue comes from the fact that SAX will push the content, while  
your API which expects an InputStream excpects to pull the content. In  
general, with this kind of situations, you either need two threads, or  
you need to first read the content into a temporary location.

You would need something similar to NetUtils.inputStreamToAnyURI(),  
except:

* you would read a SAX stream and serialize it into the temporary file  
item
* you would then pass the file item's InputStream to your API

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
Erik, Alessandro,

thank you, this makes a lot of sense to me.

I can see how you may write the contents to a local file and open up a
new inputstream to this, or do something fancy with threads, possibly
using Java pipes.

However, I've decided to overcome this problem by exposing my java
functionality as a REST webservice, and calling this using:

    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission method="put"
action="http://localhost:8080/timmy/import"/>
        </p:input>
        <p:input name="request" href="#escenicXml" />
        <p:output name="response" ref="data" />
    </p:processor>

The REST webservice is exposed through a custom Servlet. Here is the
servlet definition from web.xml:

    <servlet>
        <servlet-name>timmy</servlet-name>
        <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>timmy</servlet-name>
        <url-pattern>/import</url-pattern>
    </servlet-mapping>

Please find the source for the Servlet attached.

By defining a REST API like this, and calling this from my pipeline
over HTTP. I'm able to get my handle on the inputstream (see
ImportServlet, attached):
... (new ImportAction()).doImport(request.getInputStream());

This, I hope, should work, and should achieve the transformation from
a push architecture (Orbeon), to a pull architecture (Servlet).

Thank you, everyone!

Sincerely,
Henrik Pettersen


On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:

>> getContentAsStream() is the resource manager is something different:
>> it reads a file from disk and returns a stream of bytes for this file.
>> As Florent mentioned, what flows between processors is XML in the form
>> of SAX events. So at that stage, the XML has already been parsed. It
>> would be best if your library could provide a SAX ContentHandler, into
>> which you can send the SAX events with readInputAsSAX(). Otherwise you
>> will have to serialize the XML so you can get a InputStream.
>
> The issue comes from the fact that SAX will push the content, while your API
> which expects an InputStream excpects to pull the content. In general, with
> this kind of situations, you either need two threads, or you need to first
> read the content into a temporary location.
>
> You would need something similar to NetUtils.inputStreamToAnyURI(), except:
>
> * you would read a SAX stream and serialize it into the temporary file item
> * you would then pass the file item's InputStream to your API
>
> -Erik
>
> --
> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> http://www.orbeon.com/
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

ImportServlet.java (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
All,

I've finally come up with a solution for this problem, which should
work for general cases. If you ever find yourself wanting to get a
handle to an inputstream of the input data in your SimpleProcessor
extension, this should work.

Please find attached:
1. A new class containing the implementation of this solution
(StreamingSimpleProcessorBase.java)
2. A template class showing how to roll your own SimpleProcessor
extensions with access to an InputStream of any input
(StreamingProcessorTemplate)

The documentation and implementation details has been marked up with
Javadoc, which I've put up here:
http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html

You will most likely have to refactor the package structure, and the
javadoc does not provide any links to any other libraries, classes and
methods.

Any comments, suggestions, or bugs found are welcome.

Hope this will be useful for someone else out there!

Sincerely,
Henrik Pettersen

2008/8/15 Henrik Pettersen <[hidden email]>:

> Erik, Alessandro,
>
> thank you, this makes a lot of sense to me.
>
> I can see how you may write the contents to a local file and open up a
> new inputstream to this, or do something fancy with threads, possibly
> using Java pipes.
>
> However, I've decided to overcome this problem by exposing my java
> functionality as a REST webservice, and calling this using:
>
>    <p:processor name="oxf:xforms-submission">
>        <p:input name="submission">
>            <xforms:submission method="put"
> action="http://localhost:8080/timmy/import"/>
>        </p:input>
>        <p:input name="request" href="#escenicXml" />
>        <p:output name="response" ref="data" />
>    </p:processor>
>
> The REST webservice is exposed through a custom Servlet. Here is the
> servlet definition from web.xml:
>
>    <servlet>
>        <servlet-name>timmy</servlet-name>
>        <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
>    </servlet>
>    <servlet-mapping>
>        <servlet-name>timmy</servlet-name>
>        <url-pattern>/import</url-pattern>
>    </servlet-mapping>
>
> Please find the source for the Servlet attached.
>
> By defining a REST API like this, and calling this from my pipeline
> over HTTP. I'm able to get my handle on the inputstream (see
> ImportServlet, attached):
> ... (new ImportAction()).doImport(request.getInputStream());
>
> This, I hope, should work, and should achieve the transformation from
> a push architecture (Orbeon), to a pull architecture (Servlet).
>
> Thank you, everyone!
>
> Sincerely,
> Henrik Pettersen
>
>
> On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:
>>> getContentAsStream() is the resource manager is something different:
>>> it reads a file from disk and returns a stream of bytes for this file.
>>> As Florent mentioned, what flows between processors is XML in the form
>>> of SAX events. So at that stage, the XML has already been parsed. It
>>> would be best if your library could provide a SAX ContentHandler, into
>>> which you can send the SAX events with readInputAsSAX(). Otherwise you
>>> will have to serialize the XML so you can get a InputStream.
>>
>> The issue comes from the fact that SAX will push the content, while your API
>> which expects an InputStream excpects to pull the content. In general, with
>> this kind of situations, you either need two threads, or you need to first
>> read the content into a temporary location.
>>
>> You would need something similar to NetUtils.inputStreamToAnyURI(), except:
>>
>> * you would read a SAX stream and serialize it into the temporary file item
>> * you would then pass the file item's InputStream to your API
>>
>> -Erik
>>
>> --
>> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>> http://www.orbeon.com/
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

StreamingProcessorTemplate.java (3K) Download Attachment
StreamingSimpleProcessorBase.java (16K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
All,

I forgot to attach a 3rd party library which my implementation depends
upon. You can download it directly from here (Look for XMLWriter):
http://megginson.com/downloads/

I have also attached the jar file to this email.

Henrik

2008/9/4 Henrik Pettersen <[hidden email]>:

> All,
>
> I've finally come up with a solution for this problem, which should
> work for general cases. If you ever find yourself wanting to get a
> handle to an inputstream of the input data in your SimpleProcessor
> extension, this should work.
>
> Please find attached:
> 1. A new class containing the implementation of this solution
> (StreamingSimpleProcessorBase.java)
> 2. A template class showing how to roll your own SimpleProcessor
> extensions with access to an InputStream of any input
> (StreamingProcessorTemplate)
>
> The documentation and implementation details has been marked up with
> Javadoc, which I've put up here:
> http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
> http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html
>
> You will most likely have to refactor the package structure, and the
> javadoc does not provide any links to any other libraries, classes and
> methods.
>
> Any comments, suggestions, or bugs found are welcome.
>
> Hope this will be useful for someone else out there!
>
> Sincerely,
> Henrik Pettersen
>
> 2008/8/15 Henrik Pettersen <[hidden email]>:
>> Erik, Alessandro,
>>
>> thank you, this makes a lot of sense to me.
>>
>> I can see how you may write the contents to a local file and open up a
>> new inputstream to this, or do something fancy with threads, possibly
>> using Java pipes.
>>
>> However, I've decided to overcome this problem by exposing my java
>> functionality as a REST webservice, and calling this using:
>>
>>    <p:processor name="oxf:xforms-submission">
>>        <p:input name="submission">
>>            <xforms:submission method="put"
>> action="http://localhost:8080/timmy/import"/>
>>        </p:input>
>>        <p:input name="request" href="#escenicXml" />
>>        <p:output name="response" ref="data" />
>>    </p:processor>
>>
>> The REST webservice is exposed through a custom Servlet. Here is the
>> servlet definition from web.xml:
>>
>>    <servlet>
>>        <servlet-name>timmy</servlet-name>
>>        <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
>>    </servlet>
>>    <servlet-mapping>
>>        <servlet-name>timmy</servlet-name>
>>        <url-pattern>/import</url-pattern>
>>    </servlet-mapping>
>>
>> Please find the source for the Servlet attached.
>>
>> By defining a REST API like this, and calling this from my pipeline
>> over HTTP. I'm able to get my handle on the inputstream (see
>> ImportServlet, attached):
>> ... (new ImportAction()).doImport(request.getInputStream());
>>
>> This, I hope, should work, and should achieve the transformation from
>> a push architecture (Orbeon), to a pull architecture (Servlet).
>>
>> Thank you, everyone!
>>
>> Sincerely,
>> Henrik Pettersen
>>
>>
>> On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:
>>>> getContentAsStream() is the resource manager is something different:
>>>> it reads a file from disk and returns a stream of bytes for this file.
>>>> As Florent mentioned, what flows between processors is XML in the form
>>>> of SAX events. So at that stage, the XML has already been parsed. It
>>>> would be best if your library could provide a SAX ContentHandler, into
>>>> which you can send the SAX events with readInputAsSAX(). Otherwise you
>>>> will have to serialize the XML so you can get a InputStream.
>>>
>>> The issue comes from the fact that SAX will push the content, while your API
>>> which expects an InputStream excpects to pull the content. In general, with
>>> this kind of situations, you either need two threads, or you need to first
>>> read the content into a temporary location.
>>>
>>> You would need something similar to NetUtils.inputStreamToAnyURI(), except:
>>>
>>> * you would read a SAX stream and serialize it into the temporary file item
>>> * you would then pass the file item's InputStream to your API
>>>
>>> -Erik
>>>
>>> --
>>> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>>> http://www.orbeon.com/
>>>
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing
>>> list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=help
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>>>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

xml-writer.jar (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
In reply to this post by Henrik Pettersen
All,

this mailing list software is giving me gray hairs. Either I don't
receive my own postings, or attachments means an automatic quarantine.
I've tried modifying my mailing list settings at
http://www.objectweb.org/wws/suboptions/ops-users, without having any
luck: I've set the receiving option to 'standard(direct receiption)',
but the help menu next to it does not contain any information on this
menu option, as far as I can see.

Why not use something like Google Groups or Yahoo Groups? Your current
mailing list software does look a bit like it's 1998 ;-)

My 2 cents :-)

Henrik

2008/9/4 Henrik Pettersen <[hidden email]>:

> All,
>
> I've finally come up with a solution for this problem, which should
> work for general cases. If you ever find yourself wanting to get a
> handle to an inputstream of the input data in your SimpleProcessor
> extension, this should work.
>
> Please find attached:
> 1. A new class containing the implementation of this solution
> (StreamingSimpleProcessorBase.java)
> 2. A template class showing how to roll your own SimpleProcessor
> extensions with access to an InputStream of any input
> (StreamingProcessorTemplate)
>
> The documentation and implementation details has been marked up with
> Javadoc, which I've put up here:
> http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
> http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html
>
> You will most likely have to refactor the package structure, and the
> javadoc does not provide any links to any other libraries, classes and
> methods.
>
> Any comments, suggestions, or bugs found are welcome.
>
> Hope this will be useful for someone else out there!
>
> Sincerely,
> Henrik Pettersen
>
> 2008/8/15 Henrik Pettersen <[hidden email]>:
>> Erik, Alessandro,
>>
>> thank you, this makes a lot of sense to me.
>>
>> I can see how you may write the contents to a local file and open up a
>> new inputstream to this, or do something fancy with threads, possibly
>> using Java pipes.
>>
>> However, I've decided to overcome this problem by exposing my java
>> functionality as a REST webservice, and calling this using:
>>
>>    <p:processor name="oxf:xforms-submission">
>>        <p:input name="submission">
>>            <xforms:submission method="put"
>> action="http://localhost:8080/timmy/import"/>
>>        </p:input>
>>        <p:input name="request" href="#escenicXml" />
>>        <p:output name="response" ref="data" />
>>    </p:processor>
>>
>> The REST webservice is exposed through a custom Servlet. Here is the
>> servlet definition from web.xml:
>>
>>    <servlet>
>>        <servlet-name>timmy</servlet-name>
>>        <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
>>    </servlet>
>>    <servlet-mapping>
>>        <servlet-name>timmy</servlet-name>
>>        <url-pattern>/import</url-pattern>
>>    </servlet-mapping>
>>
>> Please find the source for the Servlet attached.
>>
>> By defining a REST API like this, and calling this from my pipeline
>> over HTTP. I'm able to get my handle on the inputstream (see
>> ImportServlet, attached):
>> ... (new ImportAction()).doImport(request.getInputStream());
>>
>> This, I hope, should work, and should achieve the transformation from
>> a push architecture (Orbeon), to a pull architecture (Servlet).
>>
>> Thank you, everyone!
>>
>> Sincerely,
>> Henrik Pettersen
>>
>>
>> On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:
>>>> getContentAsStream() is the resource manager is something different:
>>>> it reads a file from disk and returns a stream of bytes for this file.
>>>> As Florent mentioned, what flows between processors is XML in the form
>>>> of SAX events. So at that stage, the XML has already been parsed. It
>>>> would be best if your library could provide a SAX ContentHandler, into
>>>> which you can send the SAX events with readInputAsSAX(). Otherwise you
>>>> will have to serialize the XML so you can get a InputStream.
>>>
>>> The issue comes from the fact that SAX will push the content, while your API
>>> which expects an InputStream excpects to pull the content. In general, with
>>> this kind of situations, you either need two threads, or you need to first
>>> read the content into a temporary location.
>>>
>>> You would need something similar to NetUtils.inputStreamToAnyURI(), except:
>>>
>>> * you would read a SAX stream and serialize it into the temporary file item
>>> * you would then pass the file item's InputStream to your API
>>>
>>> -Erik
>>>
>>> --
>>> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>>> http://www.orbeon.com/
>>>
>>>
>>>
>>> --
>>> You receive this message as a subscriber of the [hidden email] mailing
>>> list.
>>> To unsubscribe: mailto:[hidden email]
>>> For general help: mailto:[hidden email]?subject=help
>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>
>>>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Fwd: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
In reply to this post by Henrik Pettersen
Re-post. my apologies if you've already received this. This time with no attachments :-)

H

All,

I've finally come up with a general solution for this problem. If you ever find yourself wanting to get a handle to an inputstream of the input data in your SimpleProcessor extension, this should work.

The documentation and implementation details has been marked up with Javadoc, which I've put up here:
http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html

Here is the source code itself:
http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.java
http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.java

you will also need this 3rd party library from http://megginson.com:
http://sparklingideas.co.uk/orbeon/streaming/xml-writer.jar

You will most likely have to refactor the package structure, and the javadoc does not provide any links to any other libraries, classes and methods.

Any comments, suggestions, or bugs are welcome. Hope this will be useful for someone :-)

Sincerely,
Henrik Pettersen

2008/8/15 Henrik Pettersen <[hidden email]>:
> Erik, Alessandro,
>
> thank you, this makes a lot of sense to me.
>
> I can see how you may write the contents to a local file and open up a
> new inputstream to this, or do something fancy with threads, possibly
> using Java pipes.
>
> However, I've decided to overcome this problem by exposing my java
> functionality as a REST webservice, and calling this using:
>
>    <p:processor name="oxf:xforms-submission">
>        <p:input name="submission">
>            <xforms:submission method="put"
> action="http://localhost:8080/timmy/import"/>
>        </p:input>
>        <p:input name="request" href="#escenicXml" />
>        <p:output name="response" ref="data" />
>    </p:processor>
>
> The REST webservice is exposed through a custom Servlet. Here is the
> servlet definition from web.xml:
>
>    <servlet>
>        <servlet-name>timmy</servlet-name>
>        <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
>    </servlet>
>    <servlet-mapping>
>        <servlet-name>timmy</servlet-name>
>        <url-pattern>/import</url-pattern>
>    </servlet-mapping>
>
> Please find the source for the Servlet attached.
>
> By defining a REST API like this, and calling this from my pipeline
> over HTTP. I'm able to get my handle on the inputstream (see
> ImportServlet, attached):
> ... (new ImportAction()).doImport(request.getInputStream());
>
> This, I hope, should work, and should achieve the transformation from
> a push architecture (Orbeon), to a pull architecture (Servlet).
>
> Thank you, everyone!
>
> Sincerely,
> Henrik Pettersen
>
>
> On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:
>>> getContentAsStream() is the resource manager is something different:
>>> it reads a file from disk and returns a stream of bytes for this file.
>>> As Florent mentioned, what flows between processors is XML in the form
>>> of SAX events. So at that stage, the XML has already been parsed. It
>>> would be best if your library could provide a SAX ContentHandler, into
>>> which you can send the SAX events with readInputAsSAX(). Otherwise you
>>> will have to serialize the XML so you can get a InputStream.
>>
>> The issue comes from the fact that SAX will push the content, while your API
>> which expects an InputStream excpects to pull the content. In general, with
>> this kind of situations, you either need two threads, or you need to first
>> read the content into a temporary location.
>>
>> You would need something similar to NetUtils.inputStreamToAnyURI(), except:
>>
>> * you would read a SAX stream and serialize it into the temporary file item
>> * you would then pass the file item's InputStream to your API
>>
>> -Erik
>>
>> --
>> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>> http://www.orbeon.com/
>>
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>>
>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Erik Bruchez
Administrator
In reply to this post by Henrik Pettersen
The web-based interface is old... But so far, the mailing-list has  
seemed to work, mostly ;-) It also seems that your message with the  
attachment made it to the list. You can also do a lot through Nabble:

http://www.nabble.com/How-can-I-get-a-handle-to-an-InputStream-my-SimpleProcessor-class-extension--td18851540.html

Not sure if we should migrate at this point. Migrating is also quite a  
pain. Updating to Nabble 2 would also be an option to make the list  
appear smoother to the outside world.

-Erik

On Sep 5, 2008, at 3:48 AM, Henrik Pettersen wrote:

> All,
>
> this mailing list software is giving me gray hairs. Either I don't
> receive my own postings, or attachments means an automatic quarantine.
> I've tried modifying my mailing list settings at
> http://www.objectweb.org/wws/suboptions/ops-users, without having any
> luck: I've set the receiving option to 'standard(direct receiption)',
> but the help menu next to it does not contain any information on this
> menu option, as far as I can see.
>
> Why not use something like Google Groups or Yahoo Groups? Your current
> mailing list software does look a bit like it's 1998 ;-)
>
> My 2 cents :-)
>
> Henrik
>
> 2008/9/4 Henrik Pettersen <[hidden email]>:
>> All,
>>
>> I've finally come up with a solution for this problem, which should
>> work for general cases. If you ever find yourself wanting to get a
>> handle to an inputstream of the input data in your SimpleProcessor
>> extension, this should work.
>>
>> Please find attached:
>> 1. A new class containing the implementation of this solution
>> (StreamingSimpleProcessorBase.java)
>> 2. A template class showing how to roll your own SimpleProcessor
>> extensions with access to an InputStream of any input
>> (StreamingProcessorTemplate)
>>
>> The documentation and implementation details has been marked up with
>> Javadoc, which I've put up here:
>> http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
>> http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html
>>
>> You will most likely have to refactor the package structure, and the
>> javadoc does not provide any links to any other libraries, classes  
>> and
>> methods.
>>
>> Any comments, suggestions, or bugs found are welcome.
>>
>> Hope this will be useful for someone else out there!
>>
>> Sincerely,
>> Henrik Pettersen
>>
>> 2008/8/15 Henrik Pettersen <[hidden email]>:
>>> Erik, Alessandro,
>>>
>>> thank you, this makes a lot of sense to me.
>>>
>>> I can see how you may write the contents to a local file and open  
>>> up a
>>> new inputstream to this, or do something fancy with threads,  
>>> possibly
>>> using Java pipes.
>>>
>>> However, I've decided to overcome this problem by exposing my java
>>> functionality as a REST webservice, and calling this using:
>>>
>>>   <p:processor name="oxf:xforms-submission">
>>>       <p:input name="submission">
>>>           <xforms:submission method="put"
>>> action="http://localhost:8080/timmy/import"/>
>>>       </p:input>
>>>       <p:input name="request" href="#escenicXml" />
>>>       <p:output name="response" ref="data" />
>>>   </p:processor>
>>>
>>> The REST webservice is exposed through a custom Servlet. Here is the
>>> servlet definition from web.xml:
>>>
>>>   <servlet>
>>>       <servlet-name>timmy</servlet-name>
>>>       <servlet-
>>> class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
>>>   </servlet>
>>>   <servlet-mapping>
>>>       <servlet-name>timmy</servlet-name>
>>>       <url-pattern>/import</url-pattern>
>>>   </servlet-mapping>
>>>
>>> Please find the source for the Servlet attached.
>>>
>>> By defining a REST API like this, and calling this from my pipeline
>>> over HTTP. I'm able to get my handle on the inputstream (see
>>> ImportServlet, attached):
>>> ... (new ImportAction()).doImport(request.getInputStream());
>>>
>>> This, I hope, should work, and should achieve the transformation  
>>> from
>>> a push architecture (Orbeon), to a pull architecture (Servlet).
>>>
>>> Thank you, everyone!
>>>
>>> Sincerely,
>>> Henrik Pettersen
>>>
>>>
>>> On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez  
>>> <[hidden email]> wrote:
>>>>> getContentAsStream() is the resource manager is something  
>>>>> different:
>>>>> it reads a file from disk and returns a stream of bytes for this  
>>>>> file.
>>>>> As Florent mentioned, what flows between processors is XML in  
>>>>> the form
>>>>> of SAX events. So at that stage, the XML has already been  
>>>>> parsed. It
>>>>> would be best if your library could provide a SAX  
>>>>> ContentHandler, into
>>>>> which you can send the SAX events with readInputAsSAX().  
>>>>> Otherwise you
>>>>> will have to serialize the XML so you can get a InputStream.
>>>>
>>>> The issue comes from the fact that SAX will push the content,  
>>>> while your API
>>>> which expects an InputStream excpects to pull the content. In  
>>>> general, with
>>>> this kind of situations, you either need two threads, or you need  
>>>> to first
>>>> read the content into a temporary location.
>>>>
>>>> You would need something similar to  
>>>> NetUtils.inputStreamToAnyURI(), except:
>>>>
>>>> * you would read a SAX stream and serialize it into the temporary  
>>>> file item
>>>> * you would then pass the file item's InputStream to your API
>>>>
>>>> -Erik
>>>>
>>>> --
>>>> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>>>> http://www.orbeon.com/
>>>>
>>>>
>>>>
>>>> --
>>>> You receive this message as a subscriber of the [hidden email]  
>>>> mailing
>>>> list.
>>>> To unsubscribe: mailto:[hidden email]
>>>> For general help: mailto:[hidden email]?subject=help
>>>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>>>
>>>>
>>>
>>
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: How can I get a handle to an InputStream my SimpleProcessor class extension?

Henrik Pettersen
Hi Erik,

thank you for confirming that my attachment do arrive :-) I never realised you had this Nabble interface - I always go through Objectweb: http://mail-archive.ow2.org/ops-users/index.html. Nabble should really help :-)

Many thanks!

Henrik

2008/9/5 Erik Bruchez <[hidden email]>
The web-based interface is old... But so far, the mailing-list has seemed to work, mostly ;-) It also seems that your message with the attachment made it to the list. You can also do a lot through Nabble:

http://www.nabble.com/How-can-I-get-a-handle-to-an-InputStream-my-SimpleProcessor-class-extension--td18851540.html

Not sure if we should migrate at this point. Migrating is also quite a pain. Updating to Nabble 2 would also be an option to make the list appear smoother to the outside world.

-Erik


On Sep 5, 2008, at 3:48 AM, Henrik Pettersen wrote:

All,

this mailing list software is giving me gray hairs. Either I don't
receive my own postings, or attachments means an automatic quarantine.
I've tried modifying my mailing list settings at
http://www.objectweb.org/wws/suboptions/ops-users, without having any
luck: I've set the receiving option to 'standard(direct receiption)',
but the help menu next to it does not contain any information on this
menu option, as far as I can see.

Why not use something like Google Groups or Yahoo Groups? Your current
mailing list software does look a bit like it's 1998 ;-)

My 2 cents :-)

Henrik

2008/9/4 Henrik Pettersen <[hidden email]>:
All,

I've finally come up with a solution for this problem, which should
work for general cases. If you ever find yourself wanting to get a
handle to an inputstream of the input data in your SimpleProcessor
extension, this should work.

Please find attached:
1. A new class containing the implementation of this solution
(StreamingSimpleProcessorBase.java)
2. A template class showing how to roll your own SimpleProcessor
extensions with access to an InputStream of any input
(StreamingProcessorTemplate)

The documentation and implementation details has been marked up with
Javadoc, which I've put up here:
http://sparklingideas.co.uk/orbeon/streaming/StreamingProcessorTemplate.html
http://sparklingideas.co.uk/orbeon/streaming/StreamingSimpleProcessorBase.html

You will most likely have to refactor the package structure, and the
javadoc does not provide any links to any other libraries, classes and
methods.

Any comments, suggestions, or bugs found are welcome.

Hope this will be useful for someone else out there!

Sincerely,
Henrik Pettersen

2008/8/15 Henrik Pettersen <[hidden email]>:
Erik, Alessandro,

thank you, this makes a lot of sense to me.

I can see how you may write the contents to a local file and open up a
new inputstream to this, or do something fancy with threads, possibly
using Java pipes.

However, I've decided to overcome this problem by exposing my java
functionality as a REST webservice, and calling this using:

 <p:processor name="oxf:xforms-submission">
     <p:input name="submission">
         <xforms:submission method="put"
action="http://localhost:8080/timmy/import"/>
     </p:input>
     <p:input name="request" href="#escenicXml" />
     <p:output name="response" ref="data" />
 </p:processor>

The REST webservice is exposed through a custom Servlet. Here is the
servlet definition from web.xml:

 <servlet>
     <servlet-name>timmy</servlet-name>
     <servlet-class>com.telegraph.online.timmy.rest.ImportServlet</servlet-class>
 </servlet>
 <servlet-mapping>
     <servlet-name>timmy</servlet-name>
     <url-pattern>/import</url-pattern>
 </servlet-mapping>

Please find the source for the Servlet attached.

By defining a REST API like this, and calling this from my pipeline
over HTTP. I'm able to get my handle on the inputstream (see
ImportServlet, attached):
... (new ImportAction()).doImport(request.getInputStream());

This, I hope, should work, and should achieve the transformation from
a push architecture (Orbeon), to a pull architecture (Servlet).

Thank you, everyone!

Sincerely,
Henrik Pettersen


On Fri, Aug 8, 2008 at 12:14 AM, Erik Bruchez <[hidden email]> wrote:
getContentAsStream() is the resource manager is something different:
it reads a file from disk and returns a stream of bytes for this file.
As Florent mentioned, what flows between processors is XML in the form
of SAX events. So at that stage, the XML has already been parsed. It
would be best if your library could provide a SAX ContentHandler, into
which you can send the SAX events with readInputAsSAX(). Otherwise you
will have to serialize the XML so you can get a InputStream.

The issue comes from the fact that SAX will push the content, while your API
which expects an InputStream excpects to pull the content. In general, with
this kind of situations, you either need two threads, or you need to first
read the content into a temporary location.

You would need something similar to NetUtils.inputStreamToAnyURI(), except:

* you would read a SAX stream and serialize it into the temporary file item
* you would then pass the file item's InputStream to your API

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing
list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws