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

  1 karl  1.5 //%2004////////////////////////////////////////////////////////////////////////
  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 chip  1.1 //
 10           // Permission is hereby granted, free of charge, to any person obtaining a copy
 11           // of this software and associated documentation files (the "Software"), to
 12           // deal in the Software without restriction, including without limitation the
 13           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14           // sell copies of the Software, and to permit persons to whom the Software is
 15           // furnished to do so, subject to the following conditions:
 16 karl  1.3 // 
 17 chip  1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25           //
 26           //==============================================================================
 27           //
 28           // Author: Chip Vincent (cvincent@us.ibm.com)
 29           //
 30           // Modified By:
 31           //
 32           //%/////////////////////////////////////////////////////////////////////////////
 33           
 34           #include "ProviderRegistrarInitializer.h"
 35           
 36           #include <Pegasus/Repository/CIMRepository.h>
 37           #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
 38 chip  1.1 
 39           #include <Pegasus/Common/Constants.h>
 40           #include <Pegasus/Common/Tracer.h>
 41           #include <Pegasus/Common/Logger.h>
 42           
 43           PEGASUS_NAMESPACE_BEGIN
 44           
 45 chip  1.2 Array<RegistrationRecord> _globalRegistrationTable;
 46 chip  1.1 
 47           ProviderRegistrarInitializer::ProviderRegistrarInitializer(void)
 48           {
 49           }
 50           
 51           ProviderRegistrarInitializer::~ProviderRegistrarInitializer(void)
 52           {
 53           }
 54           
 55           void ProviderRegistrarInitializer::initialize(CIMRepository * repository)
 56           {
 57               PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderRegistrarInitializer::initialize()");
 58           
 59               Array<RegistrationRecord> records;
 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               // 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 chip  1.1     // 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               // create registration records for each class entry
 87               //
 88 chip  1.1 
 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