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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2