runnning the org.orbeon.oxf.main.OPS.java

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

runnning the org.orbeon.oxf.main.OPS.java

Hamilton Lima (athanazio)
I'm not sure what is the "PipeLine URL" that the program requires ...
is it the Xforms to be preocessed ?



--
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: runnning the org.orbeon.oxf.main.OPS.java

Erik Bruchez
Administrator
Hamilton,

Please provide context about where you are seeing mention of "pipeline
URL", and what you mean by "program".

-Erik

Hamilton Lima Jr wrote:
> I'm not sure what is the "PipeLine URL" that the program requires ...
> is it the Xforms to be preocessed ?

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
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: runnning the org.orbeon.oxf.main.OPS.java

Hamilton Lima (athanazio)
Im trying to run the OPS.java bellow :

And I dont know how to use it to test the "Xform 2 XHTML" parser
I tried to pass as parameter the file with the Xforms defs, but it dont seem to be the correct data as input parameter.
is there any doc that explain how to do this ?

thanks !

OPS.java
-------------------------------------------
import org.apache.commons.cli.*;
import org.apache.log4j.Logger;
import org.dom4j.QName ;
import org.orbeon.oxf.common.OXFException;
import org.orbeon.oxf.common.ValidationException;
import org.orbeon.oxf.common.Version;
import org.orbeon.oxf.pipeline.CommandLineExternalContext;
import org.orbeon.oxf.pipeline.api.PipelineContext ;
import org.orbeon.oxf.pipeline.api.PipelineEngineFactory;
import org.orbeon.oxf.pipeline.api.ProcessorDefinition;
import org.orbeon.oxf.resources.OXFProperties;
import org.orbeon.oxf.resources.ResourceManagerWrapper ;
import org.orbeon.oxf.util.LoggerFactory;
import org.orbeon.oxf.util.NetUtils;
import org.orbeon.oxf.xml.XMLConstants;
import org.orbeon.oxf.xml.dom4j.LocationData;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class OPS {

    private static Logger logger = Logger.getLogger(OPS.class);

    private String resourceManagerSandbox;
    private String[] otherArgs;

    private ProcessorDefinition processorDefinition;

    public OPS(String[] args) {
        // 1. Parse the command-line arguments
        parseArgs(args);
    }

    public void init() {

        // Initialize a basic logging configuration until the resource manager is setup
        LoggerFactory.initBasicLogger();

        // Signal that we are starting

        // 2. Initialize resource manager
        // Resources are first searched in a file hierarchy, then from the classloader
        Map props = new HashMap();
        props.put("oxf.resources.factory", "org.orbeon.oxf.resources.PriorityResourceManagerFactory");
        if (resourceManagerSandbox != null) {
            // Use a sandbox
            props.put("oxf.resources.filesystem.sandbox-directory", resourceManagerSandbox);
        }
        props.put("oxf.resources.priority.1", "org.orbeon.oxf.resources.FilesystemResourceManagerFactory ");
        props.put("oxf.resources.priority.2", "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory");
        ResourceManagerWrapper.init(props);

        // 3. Initialize properties with default properties file.
        OXFProperties.init(OXFProperties.DEFAULT_PROPERTIES_URI);

        // 4. Initialize log4j (using the properies this time)
        LoggerFactory.initLogger();

        // 5. Build processor definition from command-line parameters
        if (otherArgs != null && otherArgs.length == 1) {
            // Assume the pipeline processor and a config input
            processorDefinition = new ProcessorDefinition();
            processorDefinition.setName (new QName("pipeline", XMLConstants.OXF_PROCESSORS_NAMESPACE));

            String configURL;
            if (!NetUtils.urlHasProtocol(otherArgs[0])) {
                // URL is considered relative to current directory
                try {
                    // Create absolute URL, and switch to the oxf: protocol
                    String fileURL = new URL(new File(".").toURL(), otherArgs[0]).toExternalForm();
                    configURL = "oxf:" + fileURL.substring(fileURL.indexOf(':') + 1);
                } catch (MalformedURLException e) {
                    throw new OXFException(e);
                }
            } else {
                configURL = otherArgs[0];
            }

            processorDefinition.addInput("config", configURL);
        } else {
            throw new OXFException("No main processor definition found.");
        }
    }

    public void parseArgs(String[] args) {
        Options options = new Options();
        {
            Option o = new Option("r", "root", true, "Resource manager root");
            o.setRequired(false);
            options.addOption(o);
        }
        try {
            // Parse the command line options
            CommandLine cmd = new PosixParser().parse(options, args, true);

            // Get resource manager root if any
            resourceManagerSandbox = cmd.getOptionValue('r');

            // Check for remaining args
            otherArgs = cmd.getArgs();
            if (otherArgs == null || otherArgs.length != 1) {
                new HelpFormatter().printHelp("Pipeline URL is required", options);
                System.exit(1);
            }

        } catch (MissingArgumentException e) {
            new HelpFormatter().printHelp("Missing argument", options);
            System.exit(1);
        } catch (UnrecognizedOptionException e) {
            new HelpFormatter().printHelp("Unrecognized option", options);
            System.exit(1);
        } catch (MissingOptionException e) {
            new HelpFormatter().printHelp("Missing option", options);
            System.exit(1);
        } catch (Exception e) {
            new HelpFormatter().printHelp("Unknown error", options);
            System.exit(1);
        }
    }

    public void start() {

        // 6. Initialize a PipelineContext
        PipelineContext pipelineContext = new PipelineContext();

        // Some processors may require a JNDI context. In general, this is not required.
        Context jndiContext;
        try {
            jndiContext = new InitialContext();
        } catch (NamingException e) {
            throw new OXFException(e);
        }
        pipelineContext.setAttribute(PipelineContext.JNDI_CONTEXT, jndiContext);

        try {
            // 7. Run the pipeline from the processor definition created earlier. An ExternalContext
            // is supplied for those processors using external contexts, such as most serializers.
            PipelineEngineFactory.instance().executePipeline(processorDefinition, new CommandLineExternalContext(), pipelineContext, logger);
        } catch (Exception e) {
            // 8. Display exceptions if needed
            LocationData locationData = ValidationException.getRootLocationData(e);
            Throwable throwable = OXFException.getRootThrowable (e);
            String message = locationData == null
                    ? "Exception with no location data"
                    : "Exception at " + locationData.toString();
        }
    }

    public static void main(String[] args) {
        try {
            OPS oxf = new OPS(args);
            oxf.init();
            oxf.start();
        } catch (Exception e) {
            System.out.println (e.getMessage());
            OXFException.getRootThrowable(e).printStackTrace();
        }
    }
}


On 6/1/06, Erik Bruchez <[hidden email]> wrote:
Hamilton,

Please provide context about where you are seeing mention of "pipeline
URL", and what you mean by "program".

-Erik

Hamilton Lima Jr wrote:
> I'm not sure what is the "PipeLine URL" that the program requires ...
> is it the Xforms to be preocessed ?

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
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





--
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: runnning the org.orbeon.oxf.main.OPS.java

Erik Bruchez
Administrator
Hamilton,

To tell you the truth, we have never tried to run the
oxf:xforms-to-xhtml processor from the command-line. In theory, there is
no reason this couldn't be made to work though. In practice, you would
probably run this from a Servlet or Portlet environment, as do by
default the OPSServlet and OPSPortlet servlet and portlet respectively.

The command-line OPS application runs XML pipelines. So you need to pass
a pipeline as a parameter, not just an XForms file.

Currently, the oxf:xforms-to-xhtml processor is run from
xforms-epilogue.xpl. This is something you could use as a starting point.

-Erik

Hamilton Lima Jr wrote:

> Im trying to run the OPS.java bellow :
>
> And I dont know how to use it to test the "Xform 2 XHTML" parser
> I tried to pass as parameter the file with the Xforms defs, but it dont
> seem to be the correct data as input parameter.
> is there any doc that explain how to do this ?
>
> thanks !
>
> OPS.java
> -------------------------------------------
> import org.apache.commons.cli.*;
> import org.apache.log4j.Logger;
> import org.dom4j.QName ;
> import org.orbeon.oxf.common.OXFException;
> import org.orbeon.oxf.common.ValidationException;
> import org.orbeon.oxf.common.Version;
> import org.orbeon.oxf.pipeline.CommandLineExternalContext;
> import org.orbeon.oxf.pipeline.api.PipelineContext ;
> import org.orbeon.oxf.pipeline.api.PipelineEngineFactory;
> import org.orbeon.oxf.pipeline.api.ProcessorDefinition;
> import org.orbeon.oxf.resources.OXFProperties;
> import org.orbeon.oxf.resources.ResourceManagerWrapper ;
> import org.orbeon.oxf.util.LoggerFactory;
> import org.orbeon.oxf.util.NetUtils;
> import org.orbeon.oxf.xml.XMLConstants;
> import org.orbeon.oxf.xml.dom4j.LocationData;
>
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import java.io.File;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.HashMap;
> import java.util.Map;
>
> public class OPS {
>
>     private static Logger logger = Logger.getLogger(OPS.class);
>
>     private String resourceManagerSandbox;
>     private String[] otherArgs;
>
>     private ProcessorDefinition processorDefinition;
>
>     public OPS(String[] args) {
>         // 1. Parse the command-line arguments
>         parseArgs(args);
>     }
>
>     public void init() {
>
>         // Initialize a basic logging configuration until the resource
> manager is setup
>         LoggerFactory.initBasicLogger();
>
>         // Signal that we are starting
>
>         // 2. Initialize resource manager
>         // Resources are first searched in a file hierarchy, then from
> the classloader
>         Map props = new HashMap();
>         props.put("oxf.resources.factory",
> "org.orbeon.oxf.resources.PriorityResourceManagerFactory");
>         if (resourceManagerSandbox != null) {
>             // Use a sandbox
>             props.put("oxf.resources.filesystem.sandbox-directory",
> resourceManagerSandbox);
>         }
>         props.put("oxf.resources.priority.1",
> "org.orbeon.oxf.resources.FilesystemResourceManagerFactory ");
>         props.put("oxf.resources.priority.2",
> "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory");
>         ResourceManagerWrapper.init(props);
>
>         // 3. Initialize properties with default properties file.
>         OXFProperties.init(OXFProperties.DEFAULT_PROPERTIES_URI);
>
>         // 4. Initialize log4j (using the properies this time)
>         LoggerFactory.initLogger();
>
>         // 5. Build processor definition from command-line parameters
>         if (otherArgs != null && otherArgs.length == 1) {
>             // Assume the pipeline processor and a config input
>             processorDefinition = new ProcessorDefinition();
>             processorDefinition.setName (new QName("pipeline",
> XMLConstants.OXF_PROCESSORS_NAMESPACE));
>
>             String configURL;
>             if (!NetUtils.urlHasProtocol(otherArgs[0])) {
>                 // URL is considered relative to current directory
>                 try {
>                     // Create absolute URL, and switch to the oxf: protocol
>                     String fileURL = new URL(new File(".").toURL(),
> otherArgs[0]).toExternalForm();
>                     configURL = "oxf:" +
> fileURL.substring(fileURL.indexOf(':') + 1);
>                 } catch (MalformedURLException e) {
>                     throw new OXFException(e);
>                 }
>             } else {
>                 configURL = otherArgs[0];
>             }
>
>             processorDefinition.addInput("config", configURL);
>         } else {
>             throw new OXFException("No main processor definition found.");
>         }
>     }
>
>     public void parseArgs(String[] args) {
>         Options options = new Options();
>         {
>             Option o = new Option("r", "root", true, "Resource manager
> root");
>             o.setRequired(false);
>             options.addOption(o);
>         }
>         try {
>             // Parse the command line options
>             CommandLine cmd = new PosixParser().parse(options, args, true);
>
>             // Get resource manager root if any
>             resourceManagerSandbox = cmd.getOptionValue('r');
>
>             // Check for remaining args
>             otherArgs = cmd.getArgs();
>             if (otherArgs == null || otherArgs.length != 1) {
>                 new HelpFormatter().printHelp("Pipeline URL is
> required", options);
>                 System.exit(1);
>             }
>
>         } catch (MissingArgumentException e) {
>             new HelpFormatter().printHelp("Missing argument", options);
>             System.exit(1);
>         } catch (UnrecognizedOptionException e) {
>             new HelpFormatter().printHelp("Unrecognized option", options);
>             System.exit(1);
>         } catch (MissingOptionException e) {
>             new HelpFormatter().printHelp("Missing option", options);
>             System.exit(1);
>         } catch (Exception e) {
>             new HelpFormatter().printHelp("Unknown error", options);
>             System.exit(1);
>         }
>     }
>
>     public void start() {
>
>         // 6. Initialize a PipelineContext
>         PipelineContext pipelineContext = new PipelineContext();
>
>         // Some processors may require a JNDI context. In general, this
> is not required.
>         Context jndiContext;
>         try {
>             jndiContext = new InitialContext();
>         } catch (NamingException e) {
>             throw new OXFException(e);
>         }
>         pipelineContext.setAttribute(PipelineContext.JNDI_CONTEXT,
> jndiContext);
>
>         try {
>             // 7. Run the pipeline from the processor definition created
> earlier. An ExternalContext
>             // is supplied for those processors using external contexts,
> such as most serializers.
>            
> PipelineEngineFactory.instance().executePipeline(processorDefinition,
> new CommandLineExternalContext(), pipelineContext, logger);
>         } catch (Exception e) {
>             // 8. Display exceptions if needed
>             LocationData locationData =
> ValidationException.getRootLocationData(e);
>             Throwable throwable = OXFException.getRootThrowable (e);
>             String message = locationData == null
>                     ? "Exception with no location data"
>                     : "Exception at " + locationData.toString();
>         }
>     }
>
>     public static void main(String[] args) {
>         try {
>             OPS oxf = new OPS(args);
>             oxf.init();
>             oxf.start();
>         } catch (Exception e) {
>             System.out.println (e.getMessage());
>             OXFException.getRootThrowable(e).printStackTrace();
>         }
>     }
> }
>
>
> On 6/1/06, *Erik Bruchez* < [hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hamilton,
>
>     Please provide context about where you are seeing mention of "pipeline
>     URL", and what you mean by "program".
>
>     -Erik
>
>     Hamilton Lima Jr wrote:
>      > I'm not sure what is the "PipeLine URL" that the program requires ...
>      > is it the Xforms to be preocessed ?
--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
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: runnning the org.orbeon.oxf.main.OPS.java

Hamilton Lima (athanazio)
I understand, but My need on running the oxf:xforms-to-xhtml processor in a command line is to make that I can run it in a new portlet, that only use the Xform to define the interface, and with Xforms definitions that wont be in files, they will be stored in a server for example, and requested by webservice, or be in a database, or something like that.

For me its not clear what is an XML Pipeline. I'm my head I just need to say the input, where the resources are, and get the output ... :D

thanks

On 6/1/06, Erik Bruchez <[hidden email]> wrote:
Hamilton,

To tell you the truth, we have never tried to run the
oxf:xforms-to-xhtml processor from the command-line. In theory, there is
no reason this couldn't be made to work though. In practice, you would
probably run this from a Servlet or Portlet environment, as do by
default the OPSServlet and OPSPortlet servlet and portlet respectively.

The command-line OPS application runs XML pipelines. So you need to pass
a pipeline as a parameter, not just an XForms file.

Currently, the oxf:xforms-to-xhtml processor is run from
xforms-epilogue.xpl. This is something you could use as a starting point.

-Erik

Hamilton Lima Jr wrote:
> Im trying to run the OPS.java bellow :
>
> And I dont know how to use it to test the "Xform 2 XHTML" parser
> I tried to pass as parameter the file with the Xforms defs, but it dont
> seem to be the correct data as input parameter.

> is there any doc that explain how to do this ?
>
> thanks !
>
> OPS.java
> -------------------------------------------
> import org.apache.commons.cli.*;
> import org.apache.log4j.Logger;
> import org.dom4j.QName ;
> import org.orbeon.oxf.common.OXFException;
> import org.orbeon.oxf.common.ValidationException;
> import org.orbeon.oxf.common.Version;
> import org.orbeon.oxf.pipeline.CommandLineExternalContext;
> import org.orbeon.oxf.pipeline.api.PipelineContext ;
> import org.orbeon.oxf.pipeline.api.PipelineEngineFactory ;
> import org.orbeon.oxf.pipeline.api.ProcessorDefinition;
> import org.orbeon.oxf.resources.OXFProperties;
> import org.orbeon.oxf.resources.ResourceManagerWrapper ;
> import org.orbeon.oxf.util.LoggerFactory ;
> import org.orbeon.oxf.util.NetUtils;
> import org.orbeon.oxf.xml.XMLConstants;
> import org.orbeon.oxf.xml.dom4j.LocationData;
>
> import javax.naming.Context;
> import javax.naming.InitialContext ;
> import javax.naming.NamingException;
> import java.io.File;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.HashMap;
> import java.util.Map;
>
> public class OPS {
>
>     private static Logger logger = Logger.getLogger(OPS.class);
>
>     private String resourceManagerSandbox;
>     private String[] otherArgs;
>
>     private ProcessorDefinition processorDefinition;
>
>     public OPS(String[] args) {
>         // 1. Parse the command-line arguments
>         parseArgs(args);
>     }
>
>     public void init() {
>
>         // Initialize a basic logging configuration until the resource
> manager is setup
>         LoggerFactory.initBasicLogger();
>
>         // Signal that we are starting
>
>         // 2. Initialize resource manager
>         // Resources are first searched in a file hierarchy, then from
> the classloader
>         Map props = new HashMap();
>         props.put("oxf.resources.factory",
> "org.orbeon.oxf.resources.PriorityResourceManagerFactory");
>         if (resourceManagerSandbox != null) {
>             // Use a sandbox
>             props.put("oxf.resources.filesystem.sandbox-directory",
> resourceManagerSandbox);
>         }
>         props.put("oxf.resources.priority.1 ",
> "org.orbeon.oxf.resources.FilesystemResourceManagerFactory ");
>         props.put("oxf.resources.priority.2",
> "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory ");
>         ResourceManagerWrapper.init(props);
>
>         // 3. Initialize properties with default properties file.
>         OXFProperties.init(OXFProperties.DEFAULT_PROPERTIES_URI);
>
>         // 4. Initialize log4j (using the properies this time)
>         LoggerFactory.initLogger();
>
>         // 5. Build processor definition from command-line parameters
>         if (otherArgs != null && otherArgs.length == 1) {
>             // Assume the pipeline processor and a config input
>             processorDefinition = new ProcessorDefinition();
>             processorDefinition.setName (new QName("pipeline",
> XMLConstants.OXF_PROCESSORS_NAMESPACE));
>
>             String configURL;
>             if (!NetUtils.urlHasProtocol(otherArgs[0])) {
>                 // URL is considered relative to current directory
>                 try {
>                     // Create absolute URL, and switch to the oxf: protocol
>                     String fileURL = new URL(new File(".").toURL(),
> otherArgs[0]).toExternalForm();
>                     configURL = "oxf:" +
> fileURL.substring(fileURL.indexOf(':') + 1);
>                 } catch (MalformedURLException e) {
>                     throw new OXFException(e);
>                 }
>             } else {
>                 configURL = otherArgs[0];
>             }
>
>             processorDefinition.addInput("config", configURL);
>         } else {
>             throw new OXFException("No main processor definition found.");
>         }
>     }
>
>     public void parseArgs(String[] args) {
>         Options options = new Options();
>         {
>             Option o = new Option("r", "root", true, "Resource manager
> root");
>             o.setRequired(false);
>             options.addOption (o);
>         }
>         try {
>             // Parse the command line options
>             CommandLine cmd = new PosixParser().parse(options, args, true);
>
>             // Get resource manager root if any
>             resourceManagerSandbox = cmd.getOptionValue('r');
>
>             // Check for remaining args
>             otherArgs = cmd.getArgs();
>             if (otherArgs == null || otherArgs.length != 1) {
>                 new HelpFormatter().printHelp("Pipeline URL is
> required", options);
>                 System.exit(1);
>             }
>
>         } catch (MissingArgumentException e) {
>             new HelpFormatter().printHelp("Missing argument", options);
>             System.exit(1);
>         } catch (UnrecognizedOptionException e) {
>             new HelpFormatter().printHelp("Unrecognized option", options);
>             System.exit(1);
>         } catch (MissingOptionException e) {
>             new HelpFormatter().printHelp("Missing option", options);
>             System.exit(1);
>         } catch (Exception e) {
>             new HelpFormatter().printHelp("Unknown error", options);
>             System.exit(1);
>         }
>     }
>
>     public void start() {
>
>         // 6. Initialize a PipelineContext
>         PipelineContext pipelineContext = new PipelineContext();
>
>         // Some processors may require a JNDI context. In general, this
> is not required.
>         Context jndiContext;
>         try {
>             jndiContext = new InitialContext();
>         } catch (NamingException e) {
>             throw new OXFException(e);
>         }
>         pipelineContext.setAttribute (PipelineContext.JNDI_CONTEXT,
> jndiContext);
>
>         try {
>             // 7. Run the pipeline from the processor definition created
> earlier. An ExternalContext
>             // is supplied for those processors using external contexts,
> such as most serializers.
>
> PipelineEngineFactory.instance().executePipeline(processorDefinition,
> new CommandLineExternalContext(), pipelineContext, logger);
>         } catch (Exception e) {
>             // 8. Display exceptions if needed
>             LocationData locationData =
> ValidationException.getRootLocationData(e);
>             Throwable throwable = OXFException.getRootThrowable (e);
>             String message = locationData == null
>                     ? "Exception with no location data"
>                     : "Exception at " + locationData.toString();
>         }

>     }
>
>     public static void main(String[] args) {
>         try {
>             OPS oxf = new OPS(args);
>             oxf.init();
>             oxf.start();
>         } catch (Exception e) {
>             System.out.println (e.getMessage());
>             OXFException.getRootThrowable(e).printStackTrace();
>         }
>     }
> }
>
>

> On 6/1/06, *Erik Bruchez* < [hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hamilton,
>
>     Please provide context about where you are seeing mention of "pipeline
>     URL", and what you mean by "program".
>
>     -Erik
>
>     Hamilton Lima Jr wrote:
>      > I'm not sure what is the "PipeLine URL" that the program requires ...
>      > is it the Xforms to be preocessed ?

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
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





--
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: runnning the org.orbeon.oxf.main.OPS.java

Erik Bruchez
Administrator
Hamilton,

There is some doc about XML pipelines here:

   http://www.orbeon.com/ops/doc/reference-xpl-pipelines

XML pipelines are one of the two major technologies in OPS, with XForms.

BTW what you want to achieve (i.e. retrieving an XForms page from a web
service) does not seem to actually require that you run a pipeline from
the command-line. You could run the XForms to XHTML transformation
directly in a pipeline run in the portlet. This is pretty much what the
OPS portlet is configured to do by default, by going first through a
page flow.

-Erik

Hamilton Lima Jr wrote:

> I understand, but My need on running the oxf:xforms-to-xhtml processor
> in a command line is to make that I can run it in a new portlet, that
> only use the Xform to define the interface, and with Xforms definitions
> that wont be in files, they will be stored in a server for example, and
> requested by webservice, or be in a database, or something like that.
>
> For me its not clear what is an XML Pipeline. I'm my head I just need to
> say the input, where the resources are, and get the output ... :D
>
> thanks
>
> On 6/1/06, * Erik Bruchez* <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hamilton,
>
>     To tell you the truth, we have never tried to run the
>     oxf:xforms-to-xhtml processor from the command-line. In theory, there is
>     no reason this couldn't be made to work though. In practice, you would
>     probably run this from a Servlet or Portlet environment, as do by
>     default the OPSServlet and OPSPortlet servlet and portlet respectively.
>
>     The command-line OPS application runs XML pipelines. So you need to pass
>     a pipeline as a parameter, not just an XForms file.
>
>     Currently, the oxf:xforms-to-xhtml processor is run from
>     xforms-epilogue.xpl. This is something you could use as a starting
>     point.
>
>     -Erik
>
>     Hamilton Lima Jr wrote:
>      > Im trying to run the OPS.java bellow :
>      >
>      > And I dont know how to use it to test the "Xform 2 XHTML" parser
>      > I tried to pass as parameter the file with the Xforms defs, but
>     it dont
>      > seem to be the correct data as input parameter.
>      > is there any doc that explain how to do this ?
>      >
>      > thanks !
>      >
>      > OPS.java
>      > -------------------------------------------
>      > import org.apache.commons.cli.*;
>      > import org.apache.log4j.Logger;
>      > import org.dom4j.QName ;
>      > import org.orbeon.oxf.common.OXFException;
>      > import org.orbeon.oxf.common.ValidationException;
>      > import org.orbeon.oxf.common.Version;
>      > import org.orbeon.oxf.pipeline.CommandLineExternalContext;
>      > import org.orbeon.oxf.pipeline.api.PipelineContext ;
>      > import org.orbeon.oxf.pipeline.api.PipelineEngineFactory ;
>      > import org.orbeon.oxf.pipeline.api.ProcessorDefinition;
>      > import org.orbeon.oxf.resources.OXFProperties;
>      > import org.orbeon.oxf.resources.ResourceManagerWrapper ;
>      > import org.orbeon.oxf.util.LoggerFactory ;
>      > import org.orbeon.oxf.util.NetUtils;
>      > import org.orbeon.oxf.xml.XMLConstants;
>      > import org.orbeon.oxf.xml.dom4j.LocationData;
>      >
>      > import javax.naming.Context;
>      > import javax.naming.InitialContext ;
>      > import javax.naming.NamingException;
>      > import java.io.File;
>      > import java.net.MalformedURLException;
>      > import java.net.URL;
>      > import java.util.HashMap;
>      > import java.util.Map;
>      >
>      > public class OPS {
>      >
>      >     private static Logger logger = Logger.getLogger(OPS.class);
>      >
>      >     private String resourceManagerSandbox;
>      >     private String[] otherArgs;
>      >
>      >     private ProcessorDefinition processorDefinition;
>      >
>      >     public OPS(String[] args) {
>      >         // 1. Parse the command-line arguments
>      >         parseArgs(args);
>      >     }
>      >
>      >     public void init() {
>      >
>      >         // Initialize a basic logging configuration until the
>     resource
>      > manager is setup
>      >         LoggerFactory.initBasicLogger();
>      >
>      >         // Signal that we are starting
>      >
>      >         // 2. Initialize resource manager
>      >         // Resources are first searched in a file hierarchy, then
>     from
>      > the classloader
>      >         Map props = new HashMap();
>      >         props.put("oxf.resources.factory",
>      > "org.orbeon.oxf.resources.PriorityResourceManagerFactory");
>      >         if (resourceManagerSandbox != null) {
>      >             // Use a sandbox
>      >             props.put("oxf.resources.filesystem.sandbox-directory",
>      > resourceManagerSandbox);
>      >         }
>      >         props.put("oxf.resources.priority.1 ",
>      > "org.orbeon.oxf.resources.FilesystemResourceManagerFactory ");
>      >         props.put("oxf.resources.priority.2",
>      > "org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory ");
>      >         ResourceManagerWrapper.init(props);
>      >
>      >         // 3. Initialize properties with default properties file.
>      >         OXFProperties.init(OXFProperties.DEFAULT_PROPERTIES_URI);
>      >
>      >         // 4. Initialize log4j (using the properies this time)
>      >         LoggerFactory.initLogger();
>      >
>      >         // 5. Build processor definition from command-line parameters
>      >         if (otherArgs != null && otherArgs.length == 1) {
>      >             // Assume the pipeline processor and a config input
>      >             processorDefinition = new ProcessorDefinition();
>      >             processorDefinition.setName (new QName("pipeline",
>      > XMLConstants.OXF_PROCESSORS_NAMESPACE));
>      >
>      >             String configURL;
>      >             if (!NetUtils.urlHasProtocol(otherArgs[0])) {
>      >                 // URL is considered relative to current directory
>      >                 try {
>      >                     // Create absolute URL, and switch to the
>     oxf: protocol
>      >                     String fileURL = new URL(new File(".").toURL(),
>      > otherArgs[0]).toExternalForm();
>      >                     configURL = "oxf:" +
>      > fileURL.substring(fileURL.indexOf(':') + 1);
>      >                 } catch (MalformedURLException e) {
>      >                     throw new OXFException(e);
>      >                 }
>      >             } else {
>      >                 configURL = otherArgs[0];
>      >             }
>      >
>      >             processorDefinition.addInput("config", configURL);
>      >         } else {
>      >             throw new OXFException("No main processor definition
>     found.");
>      >         }
>      >     }
>      >
>      >     public void parseArgs(String[] args) {
>      >         Options options = new Options();
>      >         {
>      >             Option o = new Option("r", "root", true, "Resource
>     manager
>      > root");
>      >             o.setRequired(false);
>      >             options.addOption (o);
>      >         }
>      >         try {
>      >             // Parse the command line options
>      >             CommandLine cmd = new PosixParser().parse(options,
>     args, true);
>      >
>      >             // Get resource manager root if any
>      >             resourceManagerSandbox = cmd.getOptionValue('r');
>      >
>      >             // Check for remaining args
>      >             otherArgs = cmd.getArgs();
>      >             if (otherArgs == null || otherArgs.length != 1) {
>      >                 new HelpFormatter().printHelp("Pipeline URL is
>      > required", options);
>      >                 System.exit(1);
>      >             }
>      >
>      >         } catch (MissingArgumentException e) {
>      >             new HelpFormatter().printHelp("Missing argument",
>     options);
>      >             System.exit(1);
>      >         } catch (UnrecognizedOptionException e) {
>      >             new HelpFormatter().printHelp("Unrecognized option",
>     options);
>      >             System.exit(1);
>      >         } catch (MissingOptionException e) {
>      >             new HelpFormatter().printHelp("Missing option", options);
>      >             System.exit(1);
>      >         } catch (Exception e) {
>      >             new HelpFormatter().printHelp("Unknown error", options);
>      >             System.exit(1);
>      >         }
>      >     }
>      >
>      >     public void start() {
>      >
>      >         // 6. Initialize a PipelineContext
>      >         PipelineContext pipelineContext = new PipelineContext();
>      >
>      >         // Some processors may require a JNDI context. In
>     general, this
>      > is not required.
>      >         Context jndiContext;
>      >         try {
>      >             jndiContext = new InitialContext();
>      >         } catch (NamingException e) {
>      >             throw new OXFException(e);
>      >         }
>      >         pipelineContext.setAttribute (PipelineContext.JNDI_CONTEXT,
>      > jndiContext);
>      >
>      >         try {
>      >             // 7. Run the pipeline from the processor definition
>     created
>      > earlier. An ExternalContext
>      >             // is supplied for those processors using external
>     contexts,
>      > such as most serializers.
>      >
>      > PipelineEngineFactory.instance().executePipeline(processorDefinition,
>      > new CommandLineExternalContext(), pipelineContext, logger);
>      >         } catch (Exception e) {
>      >             // 8. Display exceptions if needed
>      >             LocationData locationData =
>      > ValidationException.getRootLocationData(e);
>      >             Throwable throwable = OXFException.getRootThrowable (e);
>      >             String message = locationData == null
>      >                     ? "Exception with no location data"
>      >                     : "Exception at " + locationData.toString();
>      >         }
>      >     }
>      >
>      >     public static void main(String[] args) {
>      >         try {
>      >             OPS oxf = new OPS(args);
>      >             oxf.init();
>      >             oxf.start();
>      >         } catch (Exception e) {
>      >             System.out.println (e.getMessage());
>      >             OXFException.getRootThrowable(e).printStackTrace();
>      >         }
>      >     }
>      > }
>      >
>      >
>      > On 6/1/06, *Erik Bruchez* < [hidden email]
>     <mailto:[hidden email]>
>      > <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>      >
>      >     Hamilton,
>      >
>      >     Please provide context about where you are seeing mention of
>     "pipeline
>      >     URL", and what you mean by "program".
>      >
>      >     -Erik
>      >
>      >     Hamilton Lima Jr wrote:
>      >      > I'm not sure what is the "PipeLine URL" that the program
>     requires ...
>      >      > is it the Xforms to be preocessed ?
>
>     --
>     Orbeon - XForms Everywhere:
>     http://www.orbeon.com/blog/
>
>
>
>
>     --
>     You receive this message as a subscriber of the
>     [hidden email] <mailto:[hidden email]> mailing list.
>     To unsubscribe: mailto: [hidden email]
>     <mailto:[hidden email]>
>     For general help: mailto:[hidden email]
>     <mailto:[hidden email]>?subject=help
>     ObjectWeb mailing lists service home page: http://www.objectweb.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
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
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: Re: runnning the org.orbeon.oxf.main.OPS.java

rachel.rajasthan
Hi,

I use only the pipeline and use OPS as a cli.  Everything was fine until I started using the XML database.  After I get the output by running "java -jar ....../cli-ops.jar my-pipeline.xpl", this java process doesn't stop.  But it keeps sync'ing the database every 5 minutes as it is defined in my conf file.  Is there a way to stop it (without doing Ctrl-C) ?

Any help is very much appreciated!!!

Thanks,
-rr



--
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: runnning the org.orbeon.oxf.main.OPS.java

Erik Bruchez
Administrator
Rachel,

What processors do you use?

What do you mean by "keep sync'ing" and "as it is defined in my conf
file"?

-Erik

[hidden email] wrote:
 > Hi,
 >
 > I use only the pipeline and use OPS as a cli.  Everything was fine
 > until I started using the XML database.  After I get the output by
 > running "java -jar ....../cli-ops.jar my-pipeline.xpl", this java
 > process doesn't stop.  But it keeps sync'ing the database every 5
 > minutes as it is defined in my conf file.  Is there a way to stop it
 > (without doing Ctrl-C) ?
 >
 > Any help is very much appreciated!!!
 >
 > Thanks,
 > -rr

--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/




--
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: Re: runnning the org.orbeon.oxf.main.OPS.java

rachel.rajasthan
sorry, I meant to say my "exist-db's configuration" file.  I'm using mostly xmldb-query processors and some url-generator and file-serializer.  I just added "System.exit(0);" in OPS.java's main() and it seems to stop now.

Thanks.

--
This message was sent on behalf of [hidden email] at openSubscriber.com
http://www.opensubscriber.com/message/ops-users@.../4195309.html



--
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