Ard Schrijvers wrote:
Does anybody have experience with calling a pipeline from a background task
resulting from an eventHandler?
So, on an event, a java class is executed which implements Contextualizable.
I am trying something like
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
implements Contextualizable, ...
private Context context;
public void contextualize(Context context) throws ContextException {
this.context = context;
}
PipelineUtil pipeUtil = new PipelineUtil();
try {
pipeUtil.contextualize(context);
pipeUtil.service(serviceManager);
pipeUtil.processToSAX(uri, null, somehandler);
} catch (Exception e) {
throw new CascadingRuntimeException("Cannot process pipeline from '" + uri +
"'", e);
} finally {
pipeUtil.dispose();
}
Now, this does not work, because it does not have a context, since the class is
not called from a sitemap but from an external event.
So, I tried instead of with the context, the SourceResolver, like
SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
and then something like
Source inputSource = resolver.resolveURI("cocoon://dasl/references/content/test/Passage.xml");
But, nothing happens, I suppose because the cocoon:// is only available when
the call is initiated from a sitemap (or flow of course)
So, does anybody know how to solve this/solved this before?
Yes. Running a Cocoon pipeline in a background task requires to setup a
"fake" environment so that the SourceResolver can do its job. You can
achieve that either by using the scheduler (cron block) to fire a job
immediately, or directly use the BackgroundEnvironment class that it
uses under the hoods.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://bluxte.net http://www.anyware-tech.com
Apache Software Foundation Member Research & Technology Director
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]