# Copyright (c) 2002-2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: JobBase.pm,v 2.6 2010/04/22 20:05:40 nagler Exp $ package Bivio::Biz::Action::JobBase; use strict; use Bivio::Base 'Biz.Action'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.6 $ =~ /\d+/g); my($_SENTINEL) = __PACKAGE__ . '.internal_execute'; sub enqueue_task { my($proto, $task_id, $attrs, $req) = @_; b_use('AgentJob.Dispatcher')->enqueue( $req, $task_id, { %{$attrs || {}}, $_SENTINEL => 1, }, ); return; } sub execute { my($proto, $req) = @_; die($proto, ': does not implement internal_execute') unless $proto->can('internal_execute'); return $proto->internal_execute($req) if $req->unsafe_get($_SENTINEL); $proto->enqueue_task($req->get('task_id'), undef, $req); my($buffer) = ''; $req->get('reply')->set_output(\$buffer); return 0; } sub set_sentinel { my(undef, $req) = @_; return $req->put($_SENTINEL => 1); } 1;