(file) Return to ProviderRegistrarInitializer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2

  1 karl  1.6 //%2005////////////////////////////////////////////////////////////////////////
  2 chip  1.1 //
  3 karl  1.5 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4           // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5           // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.3 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.5 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.6 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10           // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 chip  1.1 //
 12           // Permission is hereby granted, free of charge, to any person obtaining a copy
 13           // of this software and associated documentation files (the "Software"), to
 14           // deal in the Software without restriction, including without limitation the
 15           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16           // sell copies of the Software, and to permit persons to whom the Software is
 17           // furnished to do so, subject to the following conditions:
 18 karl  1.3 // 
 19 chip  1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27           //
 28           //==============================================================================
 29           //
 30           // Author: Chip Vincent (cvincent@us.ibm.com)
 31           //
 32           // Modified By:
 33           //
 34           //%/////////////////////////////////////////////////////////////////////////////
 35           
 36           #include "ProviderRegistrarInitializer.h"
 37           
 38           #include <Pegasus/Repository/CIMRepository.h>
 39           #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
 40 chip  1.1 
 41           #include <Pegasus/Common/Constants.h>
 42           #include <Pegasus/Common/Tracer.h>
 43           #include <Pegasus/Common/Logger.h>
 44           
 45           PEGASUS_NAMESPACE_BEGIN
 46           
 47 chip  1.2 Array<RegistrationRecord> _globalRegistrationTable;
 48 chip  1.1 
 49           ProviderRegistrarInitializer::ProviderRegistrarInitializer(void)
 50           {
 51           }
 52           
 53           ProviderRegistrarInitializer::~ProviderRegistrarInitializer(void)
 54           {
 55           }
 56           
 57           void ProviderRegistrarInitializer::initialize(CIMRepository * repository)
 58           {
 59               PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrarInitializer::initialize()");
 60           
 61               Array<RegistrationRecord> records;
 62           
 63               //
 64               // get all relevant registration instances from the repository and cache them locally.
 65               //
 66               // validate instances and remove any that have dangling (incomplete) references. the simplest way to do this with
 67               // the current schema is to ensure that each provider capabilities instance has an associated provider module instance and
 68               // provider instance. Keep in mind that each class must have an entry. The provider capability instance is one-to-one
 69 chip  1.1     // correlated to a class, so it makes sense to start there.
 70               //
 71           
 72               Array<CIMInstance> providerCapabilityInstances;
 73               Array<CIMInstance> providerInstances;
 74               Array<CIMInstance> providerModuleInstances;
 75           
 76               try
 77               {
 78                   providerCapabilityInstances = repository->enumerateInstances("root/PG_interop", "PG_ProviderCapabilities");
 79                   providerInstances = repository->enumerateInstances("root/PG_Interop", "PG_Provider");
 80                   providerModuleInstances = repository->enumerateInstances("root/PG_Interop", "PG_ProviderModule");
 81               }
 82               catch(...)
 83               {
 84                   // suppress exceptions
 85               }
 86           
 87               //
 88               // create registration records for each class entry
 89               //
 90 chip  1.1 
 91               for(Uint32 i = 0, n = providerCapabilityInstances.size(); i < n; i++)
 92               {
 93                   RegistrationRecord record;
 94           
 95                   Uint32 pos = 0;
 96           
 97                   // get class name
 98                   if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
 99                   {
100 chip  1.2             providerInstances[i].getProperty(pos).getValue().get(record.className);
101 chip  1.1         }
102           
103                   // get namespace
104                   if((pos = providerInstances[i].findProperty("NameSpace")) != PEG_NOT_FOUND)
105                   {
106                       // ATTN: must create duplicate entries for each namespace. for now, only
107                       // one namespace is support (0 is invalid).
108           
109 chip  1.2             //Array<String> temp;
110 chip  1.1 
111 chip  1.2             //providerInstances[i].getProperty(pos).getValue().get(temp);
112 chip  1.1 
113 chip  1.2             //record._namespace = temp[0];
114 chip  1.1         }
115           
116                   // get provider name
117                   if((pos = providerInstances[i].findProperty("ProviderName")) != PEG_NOT_FOUND)
118                   {
119 chip  1.2             providerInstances[i].getProperty(pos).getValue().get(record.providerName);
120 chip  1.1         }
121           
122                   // get provider module name
123                   if((pos = providerInstances[i].findProperty("ProviderModuleName")) != PEG_NOT_FOUND)
124                   {
125 chip  1.2             providerInstances[i].getProperty(pos).getValue().get(record.moduleName);
126 chip  1.1         }
127               }
128           
129               // validate current registration records using cached instances.
130           
131               for(Uint32 i = 0, n = records.size(); i < n; i++)
132               {
133                   Uint32 pos = 0;
134           
135                   // find the provider for this record.
136                   for(Uint32 i = 0, n = providerInstances.size(); i < n; i++)
137                   {
138                       String s;
139           
140                       // get name
141                       if((pos = providerInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
142                       {
143                           providerInstances[i].getProperty(pos).getValue().get(s);
144                       }
145           
146                       // compare record._providerName to PG_Provider.Name
147 chip  1.2             if(String::equalNoCase(s, records[i].providerName))
148 chip  1.1             {
149                           break;
150                       }
151                   }
152           
153                   if(i == n)
154                   {
155                       // not found: must be an invalid entry
156           
157                       // drop record and log
158                   }
159           
160                   // find the provider module for this record.
161                   for(Uint32 i = 0, n = providerModuleInstances.size(); i < n; i++)
162                   {
163                       String s;
164           
165                       // get name
166                       if((pos = providerModuleInstances[i].findProperty("Name")) != PEG_NOT_FOUND)
167                       {
168                           providerModuleInstances[i].getProperty(pos).getValue().get(s);
169 chip  1.1             }
170           
171                       // compare record._moduleName to PG_ProviderModule.Name
172 chip  1.2             if(String::equalNoCase(s, records[i].moduleName))
173 chip  1.1             {
174                           break;
175                       }
176                   }
177           
178                   if(i == n)
179                   {
180                       // not found: must be an invalid entry
181           
182                       // drop record and log
183                   }
184           
185                   // extract the location property, fully qualify and update the record._moduleName;
186               }
187           
188               PEG_METHOD_EXIT();
189           }
190           
191           PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2