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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2