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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2