On Mon, 13 Sep 2004 14:30:37 +0800, [EMAIL PROTECTED] said:
> Hi there,
>
> How can I achive, that the Scheduler loads a task the very moment the
> application server starts? We run Tomcat5
> :-) stw

More info can be found here :

 http://www.orbeon.com/ois/doc/processors-other

and here :

  http://www.orbeon.com/ois/doc/reference-listeners

.  But basically you need

1. In web.xml specify load on startup. e.g. 
<servlet>     
  <servlet-name>oxf</servlet-name>     
  <servlet-class>org.orbeon.oxf.servlet.OXFServlet</servlet-class>     
  <load-on-startup>1</load-on-startup> 
</servlet>

2. Make sure the context listener is specified. e.g. 
<listener>     
  <listener-class>org.orbeon.oxf.servlet.OXFServletContextListener</listener-class> 
</listener>

3. Specify processor to run on context init.  If you are only scheduling
   the xml below would suffice. 
<context-param>     
  <param-name>oxf.context-initialized-processor.name</param-name>     
  <param-value>{http://www.orbeon.com/oxf/processors}scheduler</param-value>
</context-param> 
<context-param>     
  <param-name>oxf.context-initialized-processor.input.config</param-name> 
  <param-value>oxf:/config/schedule.xml</param-value> 
</context-param>

4. Specify the schedule. 
<config> 
  <start-task>     
    <name>Task Scheduled From Context Initialization Pipeline</name>     
    <start-time>now</start-time>     
    <interval>10000</interval>
    <synchronized>true</synchronized>     
    <processor-uri>oxf/processor/pipeline</processor-uri>     
    <input name="config" url="oxf:/scheduled-task.xpl"/>
  </start-task> 
</config>

A small example is in the attached zip file.

Also the examples in orbeon.war, what used to be oxf.war, show this is
well. To see it in action you need to uncomment the apropriate listener
sections in web.xml.  ( Have also attached that. )

-- Dan S

Attachment: scheduled.not-a-zip-honest
Description: Zip compressed data

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
    <!-- Initialize resource manager -->
    <context-param>
        <param-name>oxf.resources.factory</param-name>
        <param-value>org.orbeon.oxf.resources.PriorityResourceManagerFactory</param-value>
    </context-param>
    <!-- Uncomment this for the Web app. resource manager -->
    <context-param>
        <param-name>oxf.resources.webapp.rootdir</param-name>
        <param-value>/WEB-INF/resources</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.resources.priority.1</param-name>
        <param-value>org.orbeon.oxf.resources.WebAppResourceManagerFactory</param-value>
    </context-param>
    <!-- End Web app. resource manager -->
    <!-- Uncomment this for the flat file resource manager -->
    <!--
    <context-param>
        <param-name>oxf.resources.flatfile.rootdir</param-name>
        <param-value>C:/path/to/my/resources</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.resources.priority.1</param-name>
        <param-value>org.orbeon.oxf.resources.FlatFileResourceManagerFactory</param-value>
    </context-param>-->
    <!-- End flat file resource manager -->
    <context-param>
        <param-name>oxf.resources.priority.2</param-name>
        <param-value>org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory</param-value>
    </context-param>
    <!-- Set location of properties.xml (read by resource manager) -->
    <context-param>
        <param-name>oxf.properties</param-name>
        <param-value>oxf:/config/properties.xml</param-value>
    </context-param>
    <!-- Set main processor -->
    <context-param>
        <param-name>oxf.main-processor.name</param-name>
        <param-value>{http://www.orbeon.com/oxf/processors}page-flow</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.main-processor.input.controller</param-name>
        <param-value>oxf:/page-flow.xml</param-value>
    </context-param>
    <!-- Set context listener processors -->
    <!-- Uncomment this for the context listener processors -->
    <!-- -->
    <context-param>
        <param-name>oxf.context-initialized-processor.name</param-name>
        <param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.context-initialized-processor.input.config</param-name>
        <param-value>oxf:/context/context-initialized.xpl</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.context-destroyed-processor.name</param-name>
        <param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.context-destroyed-processor.input.config</param-name>
        <param-value>oxf:/context/context-destroyed.xpl</param-value>
    </context-param><!-- -->
    <!-- End context listener processors -->
    <!-- Set session listener processors -->
    <!-- Uncomment this for the session listener processors -->
    <!-- 
    <context-param>
        <param-name>oxf.session-created-processor.name</param-name>
        <param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.session-created-processor.input.config</param-name>
        <param-value>oxf:/context/session-created.xpl</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.session-destroyed-processor.name</param-name>
        <param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
    </context-param>
    <context-param>
        <param-name>oxf.session-destroyed-processor.input.config</param-name>
        <param-value>oxf:/context/session-destroyed.xpl</param-value>
    </context-param>   -->
    <!-- End session listener processors -->
    <!-- Set listeners -->
    <!-- Uncomment this for the listeners -->
    <!-- -->
    <listener>
        <listener-class>org.orbeon.oxf.servlet.OXFServletContextListener</listener-class>
    </listener>
    <!--
    <listener>
        <listener-class>org.orbeon.oxf.servlet.OXFSessionListener</listener-class>
    </listener> -->
    <!-- End listeners -->
    <servlet>
        <servlet-name>oxf</servlet-name>
        <servlet-class>org.orbeon.oxf.servlet.OXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>DisplayChart</servlet-name>
        <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>struts</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>config/examples/struts/module</param-name>
            <param-value>/WEB-INF/struts-module.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <!-- Uncomment this for the SQL example -->
    <!--
    <servlet>
        <servlet-name>hsqldb</servlet-name>
        <servlet-class>org.hsqldb.Servlet</servlet-class>
        <init-param>
            <param-name>hsqldb.server.database</param-name>
            <param-value>oxf</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>-->
    <!-- End SQL example -->
    <servlet-mapping>
        <servlet-name>oxf</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>struts</servlet-name>
        <url-pattern>/struts/*</url-pattern>
    </servlet-mapping>
    <!-- Uncomment this for the SQL example -->
    <!--
    <servlet-mapping>
        <servlet-name>hsqldb</servlet-name>
        <url-pattern>/db</url-pattern>
    </servlet-mapping>-->
    <!-- End SQL example -->
    <servlet-mapping>
        <servlet-name>DisplayChart</servlet-name>
        <url-pattern>/chartDisplay</url-pattern>
    </servlet-mapping>
    <!-- Uncomment this for the SQL example -->
    <!--
    <resource-ref>
        <description>DataSource</description>
        <res-ref-name>jdbc/db</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>-->
    <!-- End SQL example -->
    <!-- Uncomment this for the authentication example -->
    <!--
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Administration</web-resource-name>
            <url-pattern>/examples-standalone/authentication</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>administrator</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/examples-standalone/authentication/login</form-login-page>
            <form-error-page>/examples-standalone/authentication/login-error</form-error-page>
        </form-login-config>
    </login-config>
    <security-role>
        <role-name>administrator</role-name>
    </security-role>-->
    <!-- End authentication example -->
</web-app>

Reply via email to