Running pipelines from the command line

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

Running pipelines from the command line

Jonathan J Wright
Hi,

I've followed the documentation in the user guide for running
processors from the command line, however there are a number of things
I'm still unclear about:

1. I can run a custom processor from the command line, but how do I run
a custom pipeline?
2. How do I define a custom pipeline programmatically?
3. Can I create a ProcessorDefinition from and XPL file?
4. I can write a custom processor that works fine when configured in an
XPL file (extends SimpleProcessor, implementing some generateXXX()
methods, DOESN'T override start()), but how do I run such a processor
from the command line when it doesn't implement start()?
5. How do I programmatically read the output generated by my custom
processor?

Any help greatly appreciated,

Jonathan



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Running pipelines from the command line

Erik Bruchez
Administrator
Jonathan,

 > I've followed the documentation in the user guide for running
 > processors from the command line, however there are a number of things
 > I'm still unclear about:
 >
 > 1. I can run a custom processor from the command line, but how do I run
 > a custom pipeline?

Can't you just pass the name of the pipeline to the command-line?

 > 2. How do I define a custom pipeline programmatically?

Not sure I understand this question.

 > 3. Can I create a ProcessorDefinition from and XPL file?

In fact you can. Check this example in processors.xml:

     <processor name="oxf:xforms-submission">
         <instantiation name="oxf:pipeline">
             <input name="config"
href="oxf:/ops/xforms/xforms-submission.xpl"/>
         </instantiation>
     </processor>

 > 4. I can write a custom processor that works fine when configured in an
 > XPL file (extends SimpleProcessor, implementing some generateXXX()
 > methods, DOESN'T override start()), but how do I run such a processor
 > from the command line when it doesn't implement start()?

You will probably have to call it from another pipeline which doesn't
have any output, and make sure that pipeline reads your pipeline's
output(s) and discards them, for example with oxf:null-serializer.

 > 5. How do I programmatically read the output generated by my custom
 > processor?

Not sur I understand this question: this is not related to the
command-line execution, right?

-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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Running pipelines from the command line

Jonathan J Wright
Erik,

I'm running a pipeline using the following code:

CommandLineExternalContext externalCtx = new
CommandLineExternalContext();
PipelineContext pipelineCtx = new PipelineContext();

try
{
        PipelineEngineFactory.instance().executePipeline(processorDefinition,
externalCtx, pipelineCtx, LOG);
        // read pipeline output?
} catch (Exception e) {
        e.printStackTrace(System.err);
        LocationData locationData =
ValidationException.getRootLocationData(e);
        Throwable throwable = OXFException.getRootThrowable(e);
        String message = locationData == null ? "Exception with no
location data" : "Exception at " + locationData;
        LOG.error(message, throwable);
}

How do I get the pipeline's output? I could call getOutputByName() but
I don't have a reference to the Processor, only it's
ProcessorDefinition. When I debug the PipelineContext and
CommandLineExternalContext both are devoid of any output.

Rather than creating a ProcessorDefinition should I instead be using
ProcessorFactoryRegistry to get a handle on the pipeline processor,
configure it to run my custom xpl file and then call getOutput?

Thanks,

Jonathan

>>> Erik Bruchez <[hidden email]> 7/12/2006 5:40 a.m. >>>
Jonathan,

 > I've followed the documentation in the user guide for running
 > processors from the command line, however there are a number of
things
 > I'm still unclear about:
 >
 > 1. I can run a custom processor from the command line, but how do I
run
 > a custom pipeline?

Can't you just pass the name of the pipeline to the command-line?

 > 2. How do I define a custom pipeline programmatically?

Not sure I understand this question.

 > 3. Can I create a ProcessorDefinition from and XPL file?

In fact you can. Check this example in processors.xml:

     <processor name="oxf:xforms-submission">
         <instantiation name="oxf:pipeline">
             <input name="config"
href="oxf:/ops/xforms/xforms-submission.xpl"/>
         </instantiation>
     </processor>

 > 4. I can write a custom processor that works fine when configured in
an
 > XPL file (extends SimpleProcessor, implementing some generateXXX()
 > methods, DOESN'T override start()), but how do I run such a
processor
 > from the command line when it doesn't implement start()?

You will probably have to call it from another pipeline which doesn't
have any output, and make sure that pipeline reads your pipeline's
output(s) and discards them, for example with oxf:null-serializer.

 > 5. How do I programmatically read the output generated by my custom
 > processor?

Not sur I understand this question: this is not related to the
command-line execution, right?

-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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Running pipelines from the command line

Jonathan J Wright
In the end I managed to achieve what I wanted with the following code:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:foo="http://www.foo.com/ops/processors">

        <p:param type="output" name="data" schema-href="foo-schema.xsd"
/>

        <p:processor name="foo:dummyxml">
                <p:output name="model" ref="data" />
        </p:processor>

</p:config>

...
processorDefinition.setName(new QName("pipeline",
XMLConstants.OXF_PROCESSORS_NAMESPACE));
processorDefinition.addInput("config", "oxf:xml/dummy-xml.xpl");

InitUtils.initializeProcessorDefinitions();

PipelineContext pipelineCtx = new PipelineContext();
Processor processor = InitUtils.createProcessor(processorDefinition);
                               
try {
        processor.createOutput("data");
        InitUtils.runProcessor(processor, new
CommandLineExternalContext(), pipelineCtx, LOG);
                       
        DOMSerializer serializer = new DOMSerializer();
        PipelineUtils.connect(processor, "data", serializer, "data");
        serializer.start(pipelineCtx);
        Document document = serializer.getDocument(pipelineCtx);
        return document.asXML();
} catch (Exception e) {
        throw new RuntimeException("error running pipeline", e);
}


>>> "Jonathan J Wright" <[hidden email]> 7/12/2006 12:37 p.m.
>>>
Erik,

I'm running a pipeline using the following code:

CommandLineExternalContext externalCtx = new
CommandLineExternalContext();
PipelineContext pipelineCtx = new PipelineContext();

try
{
        PipelineEngineFactory.instance().executePipeline(processorDefinition,
externalCtx, pipelineCtx, LOG);
        // read pipeline output?
} catch (Exception e) {
        e.printStackTrace(System.err);
        LocationData locationData =
ValidationException.getRootLocationData(e);
        Throwable throwable = OXFException.getRootThrowable(e);
        String message = locationData == null ? "Exception with no
location data" : "Exception at " + locationData;
        LOG.error(message, throwable);
}

How do I get the pipeline's output? I could call getOutputByName() but
I don't have a reference to the Processor, only it's
ProcessorDefinition. When I debug the PipelineContext and
CommandLineExternalContext both are devoid of any output.

Rather than creating a ProcessorDefinition should I instead be using
ProcessorFactoryRegistry to get a handle on the pipeline processor,
configure it to run my custom xpl file and then call getOutput?

Thanks,

Jonathan

>>> Erik Bruchez <[hidden email]> 7/12/2006 5:40 a.m. >>>
Jonathan,

 > I've followed the documentation in the user guide for running
 > processors from the command line, however there are a number of
things
 > I'm still unclear about:
 >
 > 1. I can run a custom processor from the command line, but how do I
run
 > a custom pipeline?

Can't you just pass the name of the pipeline to the command-line?

 > 2. How do I define a custom pipeline programmatically?

Not sure I understand this question.

 > 3. Can I create a ProcessorDefinition from and XPL file?

In fact you can. Check this example in processors.xml:

     <processor name="oxf:xforms-submission">
         <instantiation name="oxf:pipeline">
             <input name="config"
href="oxf:/ops/xforms/xforms-submission.xpl"/>
         </instantiation>
     </processor>

 > 4. I can write a custom processor that works fine when configured
in
an
 > XPL file (extends SimpleProcessor, implementing some generateXXX()
 > methods, DOESN'T override start()), but how do I run such a
processor
 > from the command line when it doesn't implement start()?

You will probably have to call it from another pipeline which doesn't
have any output, and make sure that pipeline reads your pipeline's
output(s) and discards them, for example with oxf:null-serializer.

 > 5. How do I programmatically read the output generated by my custom
 > processor?

Not sur I understand this question: this is not related to the
command-line execution, right?

-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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws