giacomo     2003/09/04 09:01:33

  Added:       src/blocks/cron/samples cron.js cron.xml
  Removed:     src/blocks/cron/samples cron.xsp
  Log:
  added samples
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/cron/samples/cron.js
  
  Index: cron.js
  ===================================================================
  function cron( realPath )
  {
        var done = false;
        var scheduler = 
cocoon.getComponent(Packages.org.apache.cocoon.components.cron.JobScheduler.ROLE);
        while( ! done )
        {
                var jobnames = scheduler.getJobNames();
                var list = [];
                for( i = 0; i < jobnames.length; i++ ) 
                {
                        list[ i ] = scheduler.getJobSchedulerEntry( jobnames[ i 
] );
                }
                
                var fileName = realPath + "/WEB-INF/logs/cron.log";
                var rdr = new java.io.BufferedReader( java.io.FileReader( 
fileName ) );
                var count = 0;
                var lines = new java.util.LinkedList();
                var line = rdr.readLine();
                while( line != null )
                {
                        count++;
                        lines.addLast( line );
                        if( count > 20 )
                        {
                                lines.removeFirst();
                        }
                        line = rdr.readLine();
                }
                print( "sending page" );
                cocoon.sendPageAndWait( "cron.view", { "entries" : list, "log" 
: lines } );
                print( "back again" );
                var action = cocoon.request.getParameter( "action" );
                print( "action=" + action );
                if( action == "remove" )
                {
                        print( "going to remove job " + name );
                        var name = cocoon.request.getParameter( "name" );
                        scheduler.removeJob( name );
                        print( "job " + name + " removed" );
                }
        }
  }
  
  
  1.1                  cocoon-2.1/src/blocks/cron/samples/cron.xml
  
  Index: cron.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <document xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";>
      <body>
          <row>
              <column>
                  <section>
                      <title>List of Cron Job scheduled</title>
      
                      <table border="1">
                          <tr>
                              <th>Entry name</th>
                              <th>Job name</th>
                              <th>Next scheduled run</th>
                              <th>Is running</th>
                              <th>Action</th>
                          </tr>
                          <jx:forEach var="entry" items="${entries}">
                              <tr>
                                  <td>${entry.name}</td>
                                  <td>${entry.jobName}</td>
                                  <td>${entry.nextTime}</td>
                                  <td>${entry.isRunning()}</td>
                                  <td><a 
href="continue.${continuation.id}?action=remove&amp;name=${entry.name}">remove</a></td>
                              </tr>
                          </jx:forEach>
                      </table>
                  </section>
              </column>
          </row>
          <row>
              <column>
                  <section>
                      <title>Manage Cron Jobs scheduled</title>
  
                      <p>
                          Some sample will follow ...
                      </p>
                  </section>
              </column>
          </row>
          <row>
              <column>
                  <section>
                      <title>The Cron Scheduler Logfile</title>
                      <p><a href="continue.${continuation.id}">refresh</a></p>
                      <jx:forEach var="line" items="${log}">
                        <code>${line}</code><br/>
                      </jx:forEach>
                  </section>
              </column>
          </row>
      </body>
  </document>
  
  
  

Reply via email to