ServiceRequestDeliveryTask.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename ServiceRequestDeliveryTask.cpp
00024  * @Description ServiceRequestDeliveryTask implementation
00025  * @Status Work in Progress
00026  * @Version $Id: ServiceRequestDeliveryTask.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer
00028  */
00029 
00030 
00031 #include "config.h"
00032 
00033 #include "ServiceRequestDeliveryTask.hpp"
00034 
00035 #include <Exception.hpp>
00036 
00037 #include <Time.hpp>
00038 
00039 #include <iostream>
00040 
00041 using namespace mermaid::support::service;
00042 using mermaid::support::errorhandling::Exception;
00043 using mermaid::support::system::Time;
00044 
00045 ServiceRequestDeliveryTask::ServiceRequestDeliveryTask (shared_ptr<Service> service, shared_ptr<ServiceRequest> request) : Task()
00046 {
00047   //std::cerr << "ServiceRequestDeliveryTask::ServiceRequestDeliveryTask(this=" << this << "service=" << service.get() << "request=" << request.get() << std::endl;
00048   service_ = service;
00049   request_ = request;
00050 }; // ServiceRequestDeliveryTask()
00051 
00052 void ServiceRequestDeliveryTask::run()
00053 {
00054   //std::cerr << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << std::endl;
00055   //std::cerr << "ServiceRequestDeliveryTask::run()" << std::endl;
00056   
00057   Time now = Time::getCurrentTime();
00058   
00059   Time delta = now - getScheduledTime();
00060   //std::cerr << "\tlateness = " << delta.toString() << std::endl;
00061   
00062   try {
00063     //process request
00064     service_->processServiceRequest (request_);
00065   }
00066   catch (Exception &e) {
00067     std::cerr << "ServiceRequestDeliveryTask : caught an exception while Service was processing a Service Request" << std::endl;
00068     std::cerr << "\tException : " << e.what() << std::endl;
00069     std::cerr << "\tRequester Entity Name : " << request_->getRequesterEntityName() << std::endl;
00070     std::cerr << "\tRequester Service Instance Name : " << request_->getRequesterServiceName() << std::endl;
00071     std::cerr << "\tTarget Entity Name : " << request_->getTargetEntityName() << std::endl;
00072     std::cerr << "\tTarget Service Instance Name : " << request_->getTargetServiceName() << std::endl;
00073     std::cerr << "\tTarget Service Interface Name : " << request_->getTargetServiceInterfaceName() << std::endl;
00074     std::cerr << "\tRequest Data Box contents : " << static_cast<std::string> (* (request_->getRequestDataBox())) << std::endl;
00075   }
00076   
00077   //std::cerr << "leaving ServiceRequestDeliveryTask::run()" << std::endl;
00078   //std::cerr << "----------------------------------------" << std::endl;
00079 }; // run()
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3