(file) Return to JMPIProvider.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / JMPI

  1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.18 //
  3 martin 1.17 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.18 //
 10 martin 1.17 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.18 //
 17 martin 1.17 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.18 //
 20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.18 //
 28 martin 1.17 //////////////////////////////////////////////////////////////////////////
 29 schuur 1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_JMPIProvider_h
 33             #define Pegasus_JMPIProvider_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36             #include <Pegasus/Provider/CIMOMHandle.h>
 37             #include <Pegasus/Provider/CIMInstanceProvider.h>
 38             #include <Pegasus/Provider/CIMAssociationProvider.h>
 39             #include <Pegasus/Provider/CIMMethodProvider.h>
 40 mark.hamzy 1.13 #include <Pegasus/Common/AtomicInt.h>
 41 schuur     1.1  
 42                 #include <Pegasus/Server/Linkage.h>
 43 mark.hamzy 1.16 #include <Pegasus/ProviderManager2/JMPI/Linkage.h>
 44                 #include <Pegasus/ProviderManager2/JMPI/JMPIImpl.h>
 45 schuur     1.1  
 46                 PEGASUS_NAMESPACE_BEGIN
 47                 
 48                 class JMPIProviderModule;
 49                 
 50                 struct ProviderVector {
 51                    jclass jProviderClass;
 52                    jobject jProvider;
 53                 };
 54                 
 55                 // The JMPIProvider class represents the logical provider extracted from a
 56                 // provider module. It is wrapped in a facade to stabalize the interface
 57                 // and is directly tied to a module.
 58                 
 59 mark.hamzy 1.16 class PEGASUS_JMPIPM_LINKAGE JMPIProvider :
 60 schuur     1.1                         public virtual CIMProvider
 61                 {
 62                 public:
 63                 
 64                     enum Status
 65                     {
 66                         UNKNOWN,
 67                         INITIALIZING,
 68                         INITIALIZED,
 69                         TERMINATING,
 70                         TERMINATED
 71                     };
 72                 
 73                 public:
 74                 
 75                 
 76                     class pm_service_op_lock {
 77                     private:
 78                        pm_service_op_lock(void);
 79                     public:
 80                        pm_service_op_lock(JMPIProvider *provider) : _provider(provider)
 81 schuur     1.1            { _provider->protect(); }
 82                        ~pm_service_op_lock(void)
 83                           { _provider->unprotect(); }
 84                        JMPIProvider * _provider;
 85                     };
 86                 
 87                  //  typedef JMPIProviderFacade Base;
 88                 
 89                     JMPIProvider(const String & name,
 90                         JMPIProviderModule *module,
 91                         ProviderVector *mv);
 92                     JMPIProvider(JMPIProvider*);
 93                 
 94                     virtual ~JMPIProvider(void);
 95                 
 96                     virtual void initialize(CIMOMHandle & cimom);
 97                 
 98                     virtual Boolean tryTerminate(void);
 99                     virtual void terminate(void);
100                     virtual void _terminate(void);
101                 
102 schuur     1.1      Status getStatus(void) const;
103                     String getName(void) const;
104                 
105                     JMPIProviderModule *getModule(void) const;
106                 
107                 //    virtual Boolean unload_ok(void);
108                 
109                 //   force provider manager to keep in memory
110                     virtual void protect(void);
111                 // allow provider manager to unload when idle
112                     virtual void unprotect(void);
113                 
114 carolann.graves 1.4      /**
115                              Increments the count of current subscriptions for this provider, and
116                              determines if there were no current subscriptions before the increment.
117                              If there were no current subscriptions before the increment, the first
118                              subscription has been created, and the provider's enableIndications
119                              method should be called.
120                      
121                              @return  True, if before the increment there were no current
122                                             subscriptions for this provider;
123                                       False, otherwise
124                           */
125                          Boolean testIfZeroAndIncrementSubscriptions ();
126                      
127                          /**
128                              Decrements the count of current subscriptions for this provider, and
129                              determines if there are no current subscriptions after the decrement.
130                              If there are no current subscriptions after the decrement, the last
131                              subscription has been deleted, and the provider's disableIndications
132                              method should be called.
133                      
134                              @return  True, if after the decrement there are no current subscriptions
135 carolann.graves 1.4                         for this provider;
136                                       False, otherwise
137                           */
138                          Boolean decrementSubscriptionsAndTestIfZero ();
139                      
140                          /**
141                              Determines if there are current subscriptions for this provider.
142                      
143                              @return  True, if there is at least one current subscription
144                                             for this provider;
145                                       False, otherwise
146                           */
147                          Boolean testSubscriptions ();
148                      
149                          /**
150                              Resets the count of current subscriptions for the indication provider.
151                           */
152                          void resetSubscriptions ();
153                      
154                          /**
155                              Sets the provider instance for the provider.
156 carolann.graves 1.4  
157                              Note: the provider instance is set only for an indication provider, and
158                              is set when a Create Subscription request is processed for the provider.
159                      
160                              @param  instance  the Provider CIMInstance for the provider
161                           */
162                          void setProviderInstance (const CIMInstance & instance);
163                      
164                          /**
165                              Gets the provider instance for the provider.
166                      
167                              Note: the provider instance is set only for an indication provider, and
168                              only if a Create Subscription request has been processed for the
169                              provider.
170                      
171                              @return  the Provider CIMInstance for the provider
172                           */
173                          CIMInstance getProviderInstance ();
174                      
175 schuur          1.1  protected:
176                          Status _status;
177                          JMPIProviderModule *_module;
178                          ProviderVector miVector;
179                          Boolean noUnload;
180                          CIMClass *cachedClass;
181                      
182                      private:
183                          friend class JMPILocalProviderManager;
184                          friend class JMPIProviderManager;
185 konrad.r        1.5      class OpProviderHolder;
186                          friend class OpProviderHolder;
187 mark.hamzy      1.8      mutable Mutex _cimomMutex;
188                          /* NOTE:  This is a C++ provider only handle which is currently
189                          **        used for calls to ->getClass ().  getClass returns
190                          **        immediately with data and is therefore safe to lock.
191                          */
192 schuur          1.1      CIMOMHandle *_cimom_handle;
193 mark.hamzy      1.8      /* NOTE:  This is the java provider's handle and is left
194                          **        untouched.
195                          */
196                          CIMOMHandle *_java_cimom_handle;
197 schuur          1.1      void *jProviderClass,*jProvider;
198                          String _name;
199                          AtomicInt _no_unload;
200                          Uint32 _quantum;
201                          AtomicInt _current_operations;
202 mark.hamzy      1.6      mutable Mutex _statusMutex;
203 carolann.graves 1.4  
204                          /**
205                              Count of current subscriptions for this provider.  Access to this
206                              data member is controlled by the _currentSubscriptionsLock.
207                           */
208                          Uint32 _currentSubscriptions;
209                      
210                          /**
211                              A mutex to control access to the _currentSubscriptions member variable.
212                              Before any access (test, increment, decrement or reset) of the
213                              _currentSubscriptions member variable, the _currentSubscriptionsMutex is
214                              first locked.
215                           */
216                          Mutex _currentSubscriptionsMutex;
217                      
218                          /**
219                              The Provider CIMInstance for the provider.
220                              The Provider CIMInstance is set only for indication providers, and only
221                              if a Create Subscription request has been processed for the provider.
222                              The Provider CIMInstance is needed in order to construct the
223                              EnableIndicationsResponseHandler to send to the indication provider
224 carolann.graves 1.4          when the provider's enableIndications() method is called.
225                              The Provider CIMInstance is needed in the
226                              EnableIndicationsResponseHandler in order to construct the Process
227                              Indication request when an indication is delivered by the provider.
228                              The Provider CIMInstance is needed in the Process Indication request
229                              to enable the Indication Service to determine if the provider that
230                              generated the indication accepted a matching subscription.
231                           */
232                          CIMInstance _providerInstance;
233 schuur          1.1  //};
234                      
235                      
236                      //
237                      // Used to encapsulate the incrementing/decrementing of the _current_operations
238                      // for a JMPIProvider so it won't be unloaded during operations.
239                      //
240                      
241                         class OpProviderHolder
242                         {
243                         private:
244                             JMPIProvider* _provider;
245                      
246                         public:
247                             OpProviderHolder(): _provider( NULL )
248                             {
249                             }
250                             OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
251                             {
252                                 SetProvider( p._provider );
253                             }
254 schuur          1.1         OpProviderHolder( JMPIProvider* p ): _provider( NULL )
255                             {
256                                 SetProvider( p );
257                             }
258                             ~OpProviderHolder()
259                             {
260                                 UnSetProvider();
261                             }
262                             JMPIProvider& GetProvider()
263                             {
264                                 return(*_provider);
265                             }
266                      
267                             OpProviderHolder& operator=( const OpProviderHolder& x )
268                             {
269                                 if(this == &x)
270                                     return(*this);
271                                 SetProvider( x._provider );
272                      
273                                 return(*this);
274                             }
275 schuur          1.1  
276                             void SetProvider( JMPIProvider* p )
277                             {
278                                 UnSetProvider();
279                                 if(p)
280                                 {
281                                     _provider = p;
282                                     _provider->_current_operations++;
283                                 }
284                             }
285                      
286                             void UnSetProvider()
287                             {
288                                 if(_provider)
289                                 {
290                                     _provider->_current_operations--;
291                                     _provider = NULL;
292                                 }
293                             }
294                         };
295                      };
296 schuur          1.1  
297                      PEGASUS_NAMESPACE_END
298                      
299                      #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2