syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Syncope > ScheduledTaskJobClass
Date Wed, 16 Jan 2013 13:39:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/3/_/styles/combined.css?spaceKey=SYNCOPE&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SYNCOPE/ScheduledTaskJobClass">ScheduledTaskJobClass</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~ilgrosso">Francesco
Chicchiricco</a>
    </h4>
        <br/>
                         <h4>Changes (22)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h1. Implementation <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">A
scheduled task job is a Java implementation of _org.quartz.StatefulJob_ interface. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In
order to simplify the implementation, the abstract Java class _AbstractJob_ has been provided.
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2.
Syncope &lt; 1.1.0 <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">_AbstractJob_
implements _StatefulJob_ interface taking care by default of all the things about task information
update. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">[Quartz|http://quartz-scheduler.org/]
1.8.X is used. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">This
is the reason why it is strongly recommended to implement scheduled task jobs by extending
_AbstractJob_. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">A
scheduled task job is a Java implementation of _org.quartz.StatefulJob_ interface. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">A
sample job has been provided below. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">In
order to simplify the implementation, the abstract Java class _AbstractJob_ has been provided.
_AbstractJob_ implements _StatefulJob_ and also takes care of all necessary settings. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Take
a look at [sample job class|https://svn.apache.org/repos/asf/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SampleJob.java].
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{code}</span>
<span class="diff-added-words"style="background-color: #dfd;"> </span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">package
org.apache.syncope.core.scheduling; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2.
Syncope &gt;= 1.1.0 <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">import
org.quartz.JobExecutionException; <br>import org.apache.syncope.core.persistence.beans.SchedTask;
<br>import org.apache.syncope.core.persistence.beans.TaskExec; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">[Quartz|http://quartz-scheduler.org/]
2.1.X is used. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">/**
<br> * Simple scheduled task job. <br> * <br> * @see SchedTask <br>
*/ <br>public class DemoJob extends AbstractJob { <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">A
scheduled task job is a Java implementation of _org.quartz.Job_ interface. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
   @Override <br>    protected String doExecute(final boolean dryRun) <br>   
        throws JobExecutionException { <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">In
order to simplify the implementation, the abstract Java class _AbstractJob_ has been provided.
_AbstractJob_ implements _StatefulJob_, is annotated with _[@DisallowConcurrentExecution|http://quartz-scheduler.org/api/2.0.0/org/quartz/DisallowConcurrentExecution.html]_
and also takes care of all necessary settings. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
       if (!(task instanceof SchedTask)) { <br>            throw new JobExecutionException(&quot;Task
&quot; + taskId + &quot; isn&#39;t a SchedTask&quot;); <br>        }
<br>        final SchedTask schedTask = (SchedTask) this.task; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Take
a look at [sample job class|https://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SampleJob.java].
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
       LOG.info( <br>            &quot;SampleJob {} running [SchedTask {}]&quot;,
(dryRun ? &quot;dry &quot; : &quot;&quot;), schedTask.getId()); <br>
<br>        return (dryRun ? &quot;DRY &quot; : &quot;&quot;) + &quot;RUNNING&quot;;
<br>    } <br> <br>    @Override <br>    protected boolean hasToBeRegistered(final
TaskExec execution) { <br>        return true; <br>    } <br>} <br>{code}
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. Deploy <br>A job class can
be deployed: <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="ScheduledTaskJobClass-Introduction"></a>Introduction
   </h1>
<p>A scheduled task job class is a Java class that implements the logic of a scheduled
task.</p>

<p>The same job can be assigned to more than one <a href="/confluence/display/SYNCOPE/Tasks#Tasks-ScheduledTask">Scheduled
Task</a>.</p>

<h1><a name="ScheduledTaskJobClass-Implementation"></a>Implementation</h1>

<h2><a name="ScheduledTaskJobClass-Syncope%3C1.1.0"></a>Syncope &lt;
1.1.0</h2>

<p><a href="http://quartz-scheduler.org/" class="external-link" rel="nofollow">Quartz</a>
1.8.X is used.</p>

<p>A scheduled task job is a Java implementation of <em>org.quartz.StatefulJob</em>
interface.</p>

<p>In order to simplify the implementation, the abstract Java class <em>AbstractJob</em>
has been provided. <em>AbstractJob</em> implements <em>StatefulJob</em>
and also takes care of all necessary settings.</p>

<p>Take a look at <a href="https://svn.apache.org/repos/asf/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/scheduling/SampleJob.java"
class="external-link" rel="nofollow">sample job class</a>.</p>

<h2><a name="ScheduledTaskJobClass-Syncope%3E%3D1.1.0"></a>Syncope &gt;=
1.1.0</h2>

<p><a href="http://quartz-scheduler.org/" class="external-link" rel="nofollow">Quartz</a>
2.1.X is used.</p>

<p>A scheduled task job is a Java implementation of <em>org.quartz.Job</em>
interface.</p>

<p>In order to simplify the implementation, the abstract Java class <em>AbstractJob</em>
has been provided. <em>AbstractJob</em> implements <em>StatefulJob</em>,
is annotated with <em><a href="http://quartz-scheduler.org/api/2.0.0/org/quartz/DisallowConcurrentExecution.html"
class="external-link" rel="nofollow">@DisallowConcurrentExecution</a></em>
and also takes care of all necessary settings.</p>

<p>Take a look at <a href="https://svn.apache.org/repos/asf/syncope/trunk/core/src/main/java/org/apache/syncope/core/quartz/SampleJob.java"
class="external-link" rel="nofollow">sample job class</a>.</p>

<h1><a name="ScheduledTaskJobClass-Deploy"></a>Deploy</h1>
<p>A job class can be deployed:</p>

<ul>
	<li>at project definition time<br/>
 by adding own implementation into the <a href="/confluence/display/SYNCOPE/Create+a+new+Syncope+project#CreateanewSyncopeproject-Createnewproject">overlay
project</a>, before to build Syncope. </li>
	<li>at run-time<br/>
 by adding into the container classpath own implementation (container must be re-started to
reload the classpath).</li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SYNCOPE/ScheduledTaskJobClass">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27841554&revisedVersion=7&originalVersion=6">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SYNCOPE/ScheduledTaskJobClass?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message