You're in fact using a closure here so I'm not sure if that's causing issues. Can you add following
debug statements?
var r = new java.lang.Runnable() {
run: function() {
//add following print statements
print("fmt= " + fmt);
print("output_stream = " + ouput_stream);
// gives an exception here on the console
cocoon.processPipelineTo(fmt+"_pipe/"+url,{}, output_stream);
output_stream.close();
}
};
-----Original Message-----
From: Fawzib Rojas [mailto:f_rojas@spectron-msim.com]
Sent: Friday, March 19, 2010 7:22 PM
To: users@cocoon.apache.org
Subject: Re: Runnable in flowscript?
I changed the '' to {} like u said, not needed because when I dont use
the thread it works. Same with the pipelines, they work when I don't use
the thread (use_background_thread=false). I think I just need to be able
to set the environment (context?) inside the thread, check the
exceptions I get in the first message:
"org.apache.avalon.framework.context.ContextException: Unable to locate
object-model (No environment available)"
Relevant sitemap sections (which work when not using the thread):
<map:match pattern="pdf2_pipe/**">
<map:generate src="cocoon:/xsl-fo/{1}"/>
<map:serialize type="fo2pdf"/>
</map:match>
<map:match pattern="*.pdf2">
<map:call function="create_pdf">
<map:parameter name="report" value="{1}"/>
<map:parameter name="format" value="pdf2"/>
</map:call>
</map:match>
<map:match pattern="pdf2_display/**">
<map:read src="module:flow-attribute:file_name"
mime-type="application/pdf" />
</map:match>
On 3/19/2010 2:12 PM, Robby Pelssers wrote:
> function create_pdf() {
> var use_background_thread=true;
> var path=cocoon.parameters["report"];
> var fmt=cocoon.parameters["format"];
> var queryInfo=getRequestParameters();
> var url=path+"?"+queryInfo;
> var output_file=java.io.File.createTempFile(path,".pdf");
> var output_stream=new com.spectron.io.FileProgressOutputStream(output_file);
>
> if(use_background_thread){
> var r = new java.lang.Runnable() {
> run: function() {
> // gives an exception here on the console
> cocoon.processPipelineTo(fmt+"_pipe/"+url,'',output_stream); //COMMENT:
CAN I SEE relevant sitemap snippets and corresponding generator for this pipeline?? And still
replace the '' by {} just to be sure
> output_stream.close();
> }
> };
> new java.lang.Thread(r).start();
> // this works, just never finishes because of exception in thread
> while(!output_stream.isClosed()) {
> cocoon.sendPageAndWait(
> "progress.jx",
> {
> "length" : output_file.length(),
> "output_path" : output_file.getCanonicalPath(), //COMMENT: REMOVE
the COMMA
> }
> );
> }
> } else{
> cocoon.processPipelineTo(fmt+"_pipe/"+url,'',output_stream); //COMMENT: And
still replace the '' by {} just to be sure
> output_stream.close();
> }
> cocoon.sendPage(
> fmt+"_pipe/"+url,
> {
> file_name : output_file.getCanonicalPath()
> }
> );
> }
>
> -----Original Message-----
> From: Fawzib Rojas [mailto:f_rojas@spectron-msim.com]
> Sent: Friday, March 19, 2010 7:00 PM
> To: users@cocoon.apache.org
> Subject: Re: Runnable in flowscript?
>
> On 3/19/2010 1:56 PM, Robby Pelssers wrote:
>
>> Function processPipelineTo([String] uri, [Object] bizData, [java.io.OutputStream]
stream)
>>
>> The api says is should be an object...
>>
>> So maybe try
>>
>> cocoon.processPipelineTo(fmt+"_pipe/"+url, {} ,output_stream); //using object literal
>>
>>
>>
> Thats not it, because when I set use_background_thread to false to do it
> directly without a thread (the else) it works.
>
>
>> I don't know if you need a context but you sure aren't setting any...
>>
>>
>>
> I'm not setting a context in the thread, I guess I need to use the
> context from the create_pdf function. How would I do that? Is there some
> documentation for that somewhere?
>
>
>> Cheers,
>> Robby
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
|