1 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.8 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.2 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 kumpf 1.8 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
|
13 kumpf 1.8 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
16 kumpf 1.8 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
25 //
|
26 kumpf 1.10 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
27 // (carolann_graves@hp.com)
|
28 mike 1.2 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31 #include <Pegasus/Common/Config.h>
|
32 kumpf 1.5 #include <Pegasus/Common/PegasusVersion.h>
33
|
34 mike 1.2 #include <iostream>
35 #include <Pegasus/ExportClient/CIMExportClient.h>
36 #include <Pegasus/Handler/CIMHandler.h>
37 #include <Pegasus/Repository/CIMRepository.h>
38
39 PEGASUS_NAMESPACE_BEGIN
40
41 PEGASUS_USING_STD;
42
43 //#define DDD(X) X
44 #define DDD(X) // X
45
46 DDD(static const char* _CIMXMLINDICATIONHANDLER = "CIMxmlIndicationHandler::";)
47
48 class PEGASUS_HANDLER_LINKAGE CIMxmlIndicationHandler: public CIMHandler
49 {
50 public:
51
52 CIMxmlIndicationHandler()
53 {
54 DDD(cout << _CIMXMLINDICATIONHANDLER << "CIMxmlIndicationHandler()" << endl;)
55 mike 1.2 }
56
57 virtual ~CIMxmlIndicationHandler()
58 {
59 DDD(cout << _CIMXMLINDICATIONHANDLER << "~CIMxmlIndicationHandler()" << endl;)
60 }
61
62 void initialize(CIMRepository* repository)
63 {
64 DDD(cout << _CIMXMLINDICATIONHANDLER << "initialize()" << endl;)
65 }
66
67 void terminate()
68 {
69 DDD(cout << _CIMXMLINDICATIONHANDLER << "terminate()" << endl;)
70 }
71
72 void handleIndication(
73 CIMInstance& indicationHandlerInstance,
74 CIMInstance& indicationInstance,
75 String nameSpace)
76 mike 1.2 {
77 //get destination for the indication
|
78 kumpf 1.10 Uint32 pos = indicationHandlerInstance.findProperty
79 (CIMName ("destination"));
|
80 mike 1.2 if (pos == PEG_NOT_FOUND)
81 {
82 // ATTN: Deal with a malformed handler instance
83 }
84
85 CIMProperty prop = indicationHandlerInstance.getProperty(pos);
86
87 String dest;
88 try
89 {
90 prop.getValue().get(dest);
91 }
|
92 kumpf 1.9 catch (TypeMismatchException& e)
|
93 mike 1.2 {
94 // ATTN: Deal with a malformed handler instance
95 }
96
97 try
98 {
99 Monitor* monitor = new Monitor;
100 HTTPConnector* httpConnector = new HTTPConnector(monitor);
101 CIMExportClient exportclient(monitor, httpConnector);
|
102 kumpf 1.11 Uint32 colon = dest.find (":");
103 Uint32 slash = dest.find ("/");
104 Uint32 portNumber = 0;
105 if ((colon != PEG_NOT_FOUND) && (slash != PEG_NOT_FOUND))
106 {
107 String portStr = dest.subString (colon + 1, slash);
108 sscanf (portStr.getCString (), "%u", &portNumber);
109 }
110 exportclient.connect (dest.subString (0, colon), portNumber);
|
111 kumpf 1.4 exportclient.exportIndication(
|
112 kumpf 1.6 dest.subString(dest.find("/")), indicationInstance);
|
113 mike 1.2 }
114 catch(Exception& e)
115 {
|
116 karl 1.7 PEGASUS_STD(cerr) << "CIMxmlIndicationHandler Error: " << e.getMessage()
117 << PEGASUS_STD(endl);
|
118 mike 1.2 }
119 }
120 };
121
122 // This is the dynamic entry point into this dynamic module. The name of
123 // this handler is "CIMxmlIndicationHandler" which is appened to "PegasusCreateHandler_"
124 // to form a symbol name. This function is called by the HandlerTable
125 // to load this handler.
126
127 extern "C" PEGASUS_EXPORT CIMHandler*
128 PegasusCreateHandler_CIMxmlIndicationHandler() {
129 DDD(cout << "Called PegasusCreateHandler_CIMxmlIndicationHandler" << endl;)
130 return new CIMxmlIndicationHandler;
131 }
132
133 PEGASUS_NAMESPACE_END
|