(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                // Author: Chip Vincent (cvincent@us.ibm.com)
 33                //
 34                // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 35                //              Mike Day, IBM (mdday@us.ibm.com)
 36                //              Adrian Schuur, schuur@de.ibm.com
 37                //
 38                //%/////////////////////////////////////////////////////////////////////////////
 39                
 40                #ifndef Pegasus_JMPIProvider_h
 41                #define Pegasus_JMPIProvider_h
 42                
 43                #include "JMPIImpl.h"
 44                #include <Pegasus/Common/Config.h>
 45                #include <Pegasus/Provider/CIMOMHandle.h>
 46                #include <Pegasus/Provider/CIMInstanceProvider.h>
 47                #include <Pegasus/Provider/CIMAssociationProvider.h>
 48                #include <Pegasus/Provider/CIMMethodProvider.h>
 49 schuur     1.1 
 50                //#include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
 51                
 52                #include <Pegasus/Server/Linkage.h>
 53                
 54                PEGASUS_NAMESPACE_BEGIN
 55                
 56                class JMPIProviderModule;
 57                class CMPIResolverModule;
 58                
 59                struct ProviderVector {
 60                   jclass jProviderClass;
 61                   jobject jProvider;
 62                };
 63                
 64                // The JMPIProvider class represents the logical provider extracted from a
 65                // provider module. It is wrapped in a facade to stabalize the interface
 66                // and is directly tied to a module.
 67                
 68                class PEGASUS_SERVER_LINKAGE JMPIProvider :
 69                                       public virtual CIMProvider
 70 schuur     1.1 {
 71                public:
 72                
 73                    enum Status
 74                    {
 75                        UNKNOWN,
 76                        INITIALIZING,
 77                        INITIALIZED,
 78                        TERMINATING,
 79                        TERMINATED
 80                    };
 81                
 82                public:
 83                
 84                
 85                    class pm_service_op_lock {
 86                    private:
 87                       pm_service_op_lock(void);
 88                    public:
 89                       pm_service_op_lock(JMPIProvider *provider) : _provider(provider)
 90                          { _provider->protect(); }
 91 schuur     1.1        ~pm_service_op_lock(void)
 92                          { _provider->unprotect(); }
 93                       JMPIProvider * _provider;
 94                    };
 95                
 96                 //  typedef JMPIProviderFacade Base;
 97                
 98                    JMPIProvider(const String & name,
 99                        JMPIProviderModule *module,
100                        ProviderVector *mv);
101                    JMPIProvider(JMPIProvider*);
102                
103                    virtual ~JMPIProvider(void);
104                
105                    virtual void initialize(CIMOMHandle & cimom);
106                
107                    virtual Boolean tryTerminate(void);
108                    virtual void terminate(void);
109                    virtual void _terminate(void);
110                
111                    Status getStatus(void) const;
112 schuur     1.1     String getName(void) const;
113                    void setResolver(CMPIResolverModule *rm) { _rm=rm; }
114                
115                    JMPIProviderModule *getModule(void) const;
116                
117                //    virtual void get_idle_timer(struct timeval *);
118                //    virtual void update_idle_timer(void);
119                //    virtual Boolean pending_operation(void);
120                //    virtual Boolean unload_ok(void);
121                
122                //   force provider manager to keep in memory
123                    virtual void protect(void);
124                // allow provider manager to unload when idle
125                    virtual void unprotect(void);
126                
127 carolann.graves 1.4     /**
128                             Increments the count of current subscriptions for this provider, and
129                             determines if there were no current subscriptions before the increment.
130                             If there were no current subscriptions before the increment, the first
131                             subscription has been created, and the provider's enableIndications
132                             method should be called.
133                     
134                             @return  True, if before the increment there were no current
135                                            subscriptions for this provider;
136                                      False, otherwise
137                          */
138                         Boolean testIfZeroAndIncrementSubscriptions ();
139                     
140                         /**
141                             Decrements the count of current subscriptions for this provider, and
142                             determines if there are no current subscriptions after the decrement.
143                             If there are no current subscriptions after the decrement, the last
144                             subscription has been deleted, and the provider's disableIndications
145                             method should be called.
146                     
147                             @return  True, if after the decrement there are no current subscriptions
148 carolann.graves 1.4                        for this provider;
149                                      False, otherwise
150                          */
151                         Boolean decrementSubscriptionsAndTestIfZero ();
152                     
153                         /**
154                             Determines if there are current subscriptions for this provider.
155                     
156                             @return  True, if there is at least one current subscription
157                                            for this provider;
158                                      False, otherwise
159                          */
160                         Boolean testSubscriptions ();
161                     
162                         /**
163                             Resets the count of current subscriptions for the indication provider.
164                          */
165                         void resetSubscriptions ();
166                     
167                         /**
168                             Sets the provider instance for the provider.
169 carolann.graves 1.4 
170                             Note: the provider instance is set only for an indication provider, and
171                             is set when a Create Subscription request is processed for the provider.
172                     
173                             @param  instance  the Provider CIMInstance for the provider
174                          */
175                         void setProviderInstance (const CIMInstance & instance);
176                     
177                         /**
178                             Gets the provider instance for the provider.
179                     
180                             Note: the provider instance is set only for an indication provider, and
181                             only if a Create Subscription request has been processed for the
182                             provider.
183                     
184                             @return  the Provider CIMInstance for the provider
185                          */
186                         CIMInstance getProviderInstance ();
187                     
188 schuur          1.1 protected:
189                         Status _status;
190                         JMPIProviderModule *_module;
191                         ProviderVector miVector;
192                         Boolean noUnload;
193                         CIMClass *cachedClass;
194                     
195                     private:
196                         friend class JMPILocalProviderManager;
197                         friend class JMPIProviderManager;
198                         friend class ProviderManagerService;
199 konrad.r        1.5     class OpProviderHolder;
200                         friend class OpProviderHolder;
201 mark.hamzy      1.8     mutable Mutex _cimomMutex;
202                         /* NOTE:  This is a C++ provider only handle which is currently
203                         **        used for calls to ->getClass ().  getClass returns
204                         **        immediately with data and is therefore safe to lock.
205                         */
206 schuur          1.1     CIMOMHandle *_cimom_handle;
207 mark.hamzy      1.8     /* NOTE:  This is the java provider's handle and is left
208                         **        untouched.
209                         */
210                         CIMOMHandle *_java_cimom_handle;
211 schuur          1.1     void *jProviderClass,*jProvider;
212                         String _name;
213                         AtomicInt _no_unload;
214                         CMPIResolverModule *_rm;
215                         Uint32 _quantum;
216                         AtomicInt _current_operations;
217 mark.hamzy      1.6     mutable Mutex _statusMutex;
218 carolann.graves 1.4 
219                         /**
220                             Count of current subscriptions for this provider.  Access to this
221                             data member is controlled by the _currentSubscriptionsLock.
222                          */
223                         Uint32 _currentSubscriptions;
224                     
225                         /**
226                             A mutex to control access to the _currentSubscriptions member variable.
227                             Before any access (test, increment, decrement or reset) of the
228                             _currentSubscriptions member variable, the _currentSubscriptionsMutex is
229                             first locked.
230                          */
231                         Mutex _currentSubscriptionsMutex;
232                     
233                         /**
234                             The Provider CIMInstance for the provider.
235                             The Provider CIMInstance is set only for indication providers, and only
236                             if a Create Subscription request has been processed for the provider.
237                             The Provider CIMInstance is needed in order to construct the
238                             EnableIndicationsResponseHandler to send to the indication provider
239 carolann.graves 1.4         when the provider's enableIndications() method is called.
240                             The Provider CIMInstance is needed in the
241                             EnableIndicationsResponseHandler in order to construct the Process
242                             Indication request when an indication is delivered by the provider.
243                             The Provider CIMInstance is needed in the Process Indication request
244                             to enable the Indication Service to determine if the provider that
245                             generated the indication accepted a matching subscription.
246                          */
247                         CIMInstance _providerInstance;
248 schuur          1.1 //};
249                     
250                     
251                     //
252                     // Used to encapsulate the incrementing/decrementing of the _current_operations
253                     // for a JMPIProvider so it won't be unloaded during operations.
254                     //
255                     
256                        class OpProviderHolder
257                        {
258                        private:
259                            JMPIProvider* _provider;
260                     
261                        public:
262                            OpProviderHolder(): _provider( NULL )
263                            {
264                            }
265                            OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
266                            {
267                                SetProvider( p._provider );
268                            }
269 schuur          1.1        OpProviderHolder( JMPIProvider* p ): _provider( NULL )
270                            {
271                                SetProvider( p );
272                            }
273                            ~OpProviderHolder()
274                            {
275                                UnSetProvider();
276                            }
277                            JMPIProvider& GetProvider()
278                            {
279                                return(*_provider);
280                            }
281                     
282                            OpProviderHolder& operator=( const OpProviderHolder& x )
283                            {
284                                if(this == &x)
285                                    return(*this);
286                                SetProvider( x._provider );
287                     
288                                return(*this);
289                            }
290 schuur          1.1 
291                            void SetProvider( JMPIProvider* p )
292                            {
293                                UnSetProvider();
294                                if(p)
295                                {
296                                    _provider = p;
297                                    _provider->_current_operations++;
298                                }
299                            }
300                     
301                            void UnSetProvider()
302                            {
303                                if(_provider)
304                                {
305                                    _provider->_current_operations--;
306                                    _provider = NULL;
307                                }
308                            }
309                        };
310                     };
311 schuur          1.1 
312                     PEGASUS_NAMESPACE_END
313                     
314                     #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2