version 1.1, 2003/08/15 14:10:29
|
version 1.9, 2005/04/01 17:26:54
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Author: Dong Xiang, EMC Corporation (xiang_dong@emc.com) | // Author: Dong Xiang, EMC Corporation (xiang_dong@emc.com) |
// | // |
// Modified By: |
// Modified By: Seema Gupta (gseema@in.ibm.com) for PEP135 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
#include <Pegasus/Listener/List.h> | #include <Pegasus/Listener/List.h> |
#include <Pegasus/Consumer/CIMIndicationConsumer.h> | #include <Pegasus/Consumer/CIMIndicationConsumer.h> |
|
#include <Pegasus/Common/ContentLanguages.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
class CIMListenerIndicationDispatchEvent | class CIMListenerIndicationDispatchEvent |
{ | { |
public: | public: |
CIMListenerIndicationDispatchEvent(CIMIndicationConsumer* consumer, String url, CIMInstance instance); |
CIMListenerIndicationDispatchEvent(CIMIndicationConsumer* consumer, |
|
String url, |
|
CIMInstance instance, |
|
ContentLanguages contentLangs); |
~CIMListenerIndicationDispatchEvent(); | ~CIMListenerIndicationDispatchEvent(); |
| |
CIMIndicationConsumer* getConsumer() const; | CIMIndicationConsumer* getConsumer() const; |
| |
String getURL() const; | String getURL() const; |
CIMInstance getIndicationInstance() const; | CIMInstance getIndicationInstance() const; |
|
ContentLanguages getContentLanguages() const; |
| |
private: | private: |
CIMIndicationConsumer* _consumer; | CIMIndicationConsumer* _consumer; |
String _url; | String _url; |
CIMInstance _instance; | CIMInstance _instance; |
|
ContentLanguages _contentLangs; |
}; | }; |
| |
CIMListenerIndicationDispatchEvent::CIMListenerIndicationDispatchEvent(CIMIndicationConsumer* consumer, String url, CIMInstance instance) |
CIMListenerIndicationDispatchEvent::CIMListenerIndicationDispatchEvent(CIMIndicationConsumer* consumer, |
:_consumer(consumer),_url(url),_instance(instance) |
String url, |
|
CIMInstance instance, |
|
ContentLanguages contentLangs) |
|
:_consumer(consumer),_url(url),_instance(instance), _contentLangs(contentLangs) |
{ | { |
} | } |
CIMListenerIndicationDispatchEvent::~CIMListenerIndicationDispatchEvent() | CIMListenerIndicationDispatchEvent::~CIMListenerIndicationDispatchEvent() |
|
|
{ | { |
return _instance; | return _instance; |
} | } |
|
ContentLanguages CIMListenerIndicationDispatchEvent::getContentLanguages() const |
|
{ |
|
return _contentLangs; |
|
} |
| |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
// CIMListenerIndicationDispatcherRep | // CIMListenerIndicationDispatcherRep |
|
|
static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL deliver_routine(void *param); | static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL deliver_routine(void *param); |
| |
private: | private: |
void deliverIndication(String url, CIMInstance instance); |
void deliverIndication(String url, CIMInstance instance, ContentLanguages contentLangs); |
| |
ThreadPool* _thread_pool; | ThreadPool* _thread_pool; |
PtrList* _consumers; | PtrList* _consumers; |
}; | }; |
| |
static struct timeval create_time = {0, 1}; |
static struct timeval deallocateWait = {15, 0}; |
static struct timeval destroy_time = {15, 0}; |
|
static struct timeval deadlock_time = {0, 0}; |
|
| |
| |
CIMListenerIndicationDispatcherRep::CIMListenerIndicationDispatcherRep() | CIMListenerIndicationDispatcherRep::CIMListenerIndicationDispatcherRep() |
:_thread_pool(new ThreadPool(0, "ListenerIndicationDispatcher", 0, 0, | :_thread_pool(new ThreadPool(0, "ListenerIndicationDispatcher", 0, 0, |
create_time, destroy_time, deadlock_time)) |
deallocateWait)) |
,_consumers(new PtrList()) | ,_consumers(new PtrList()) |
{ | { |
| |
} | } |
CIMListenerIndicationDispatcherRep::~CIMListenerIndicationDispatcherRep() | CIMListenerIndicationDispatcherRep::~CIMListenerIndicationDispatcherRep() |
{ | { |
if(_thread_pool!=NULL) |
|
{ |
|
_thread_pool->kill_dead_threads(); |
|
delete _thread_pool; | delete _thread_pool; |
} |
|
if(_consumers!=NULL) |
|
delete _consumers; | delete _consumers; |
} | } |
| |
|
|
| |
CIMInstance instance = request->indicationInstance; | CIMInstance instance = request->indicationInstance; |
String url = request->destinationPath; | String url = request->destinationPath; |
|
ContentLanguages contentLangs =((ContentLanguageListContainer)request->operationContext. |
|
get(ContentLanguageListContainer::NAME)).getLanguages(); |
| |
deliverIndication(url,instance); |
deliverIndication(url,instance,contentLangs); |
| |
// compose a response message | // compose a response message |
CIMException cimException; | CIMException cimException; |
|
|
return response; | return response; |
} | } |
| |
void CIMListenerIndicationDispatcherRep::deliverIndication(String url, CIMInstance instance) |
void CIMListenerIndicationDispatcherRep::deliverIndication(String url, |
|
CIMInstance instance, |
|
ContentLanguages contentLangs) |
{ | { |
// go thru all consumers and broadcast the result; should be run in seperate thread | // go thru all consumers and broadcast the result; should be run in seperate thread |
Iterator* it = _consumers->iterator(); | Iterator* it = _consumers->iterator(); |
while(it->hasNext()==true) | while(it->hasNext()==true) |
{ | { |
CIMIndicationConsumer* consumer = static_cast<CIMIndicationConsumer*>(it->next()); | CIMIndicationConsumer* consumer = static_cast<CIMIndicationConsumer*>(it->next()); |
CIMListenerIndicationDispatchEvent* event = new CIMListenerIndicationDispatchEvent(consumer,url,instance); |
CIMListenerIndicationDispatchEvent* event = new CIMListenerIndicationDispatchEvent( |
|
consumer, |
|
url, |
|
instance, |
|
contentLangs); |
_thread_pool->allocate_and_awaken(event,deliver_routine); | _thread_pool->allocate_and_awaken(event,deliver_routine); |
} | } |
} | } |
|
|
{ | { |
CIMIndicationConsumer* consumer = event->getConsumer(); | CIMIndicationConsumer* consumer = event->getConsumer(); |
OperationContext context; | OperationContext context; |
|
context.insert(ContentLanguageListContainer(event->getContentLanguages())); |
if(consumer) | if(consumer) |
{ | { |
consumer->consumeIndication(context,event->getURL(),event->getIndicationInstance()); | consumer->consumeIndication(context,event->getURL(),event->getIndicationInstance()); |
|
|
CIMListenerIndicationDispatcher::~CIMListenerIndicationDispatcher() | CIMListenerIndicationDispatcher::~CIMListenerIndicationDispatcher() |
{ | { |
if(_rep!=NULL) | if(_rep!=NULL) |
delete _rep; |
delete static_cast<CIMListenerIndicationDispatcherRep*>(_rep); |
| |
_rep=NULL; | _rep=NULL; |
} | } |