X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FBase.pm;h=912fdc6fd85c63e0390e3a56d53f3b47e215ae69;hb=a3335295fe8ac1acdb4b55324812c70af1e43b47;hp=44702d84d666cbc2f7ef32d096620b7a0dd07beb;hpb=ee71ba3372b47b7de1e30d56db92c1315ae1e104;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/Base.pm b/SL/BackgroundJob/Base.pm index 44702d84d..912fdc6fd 100644 --- a/SL/BackgroundJob/Base.pm +++ b/SL/BackgroundJob/Base.pm @@ -4,7 +4,14 @@ use strict; use parent qw(Rose::Object); +use IO::Dir; use SL::DB::BackgroundJob; +use SL::System::Process; + +sub get_known_job_classes { + tie my %dir_h, 'IO::Dir', File::Spec->catdir(File::Spec->splitdir(SL::System::Process->exe_dir), 'SL', 'BackgroundJob'); + return sort map { s/\.pm$//; $_ } grep { m/\.pm$/ && !m/(?: ALL | Base) \.pm$/x } keys %dir_h; +} sub create_standard_job { my $self_or_class = shift; @@ -29,3 +36,45 @@ sub create_standard_job { } 1; + +__END__ + +=encoding utf8 + +=head1 NAME + +SL::BackgroundJob::Base - Base class for all background jobs + +=head1 SYNOPSIS + +All background jobs are derived from this class. Each job gets its own +class which must implement the C method. + +There are two types of background jobs: periodic jobs and jobs that +are run once. Periodic jobs have a CRON spec associated with them that +determines the points in time when the job is supposed to be run. + +=head1 FUNCTIONS + +=over 4 + +=item C + +Creates or updates an entry in the database for the current job. If +the C table contains an entry for the current class +(as determined by C) then that entry is updated and +re-activated if it was disabled. Otherwise a new entry is created. + +This function can be called both as a member or as a class function. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut