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

  1 karl  1.3 //%2005////////////////////////////////////////////////////////////////////////
  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 schuur 1.1 //
 12            // Permission is hereby granted, free of charge, to any person obtaining a copy
 13            // of this software and associated documentation files (the "Software"), to
 14            // deal in the Software without restriction, including without limitation the
 15            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16            // sell copies of the Software, and to permit persons to whom the Software is
 17            // furnished to do so, subject to the following conditions:
 18 karl   1.2 // 
 19 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25 karl   1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26 schuur 1.1 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27            //
 28            //==============================================================================
 29            //
 30            // Author: Chip Vincent (cvincent@us.ibm.com)
 31            //
 32            // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 33            //              Mike Day, IBM (mdday@us.ibm.com)
 34            //              Adrian Schuur, schuur@de.ibm.com
 35            //
 36            //%/////////////////////////////////////////////////////////////////////////////
 37            
 38            #ifndef Pegasus_JMPIProvider_h
 39            #define Pegasus_JMPIProvider_h
 40            
 41            #include "JMPIImpl.h"
 42            #include <Pegasus/Common/Config.h>
 43            #include <Pegasus/Common/IPC.h>
 44            #include <Pegasus/Provider/CIMOMHandle.h>
 45            #include <Pegasus/Provider/CIMInstanceProvider.h>
 46            #include <Pegasus/Provider/CIMAssociationProvider.h>
 47 schuur 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
 48            
 49            //#include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
 50            
 51            #include <Pegasus/Server/Linkage.h>
 52            
 53            PEGASUS_NAMESPACE_BEGIN
 54            
 55            class JMPIProviderModule;
 56            class CMPIResolverModule;
 57            
 58            struct ProviderVector {
 59               jclass jProviderClass;
 60               jobject jProvider;
 61            };
 62            
 63            // The JMPIProvider class represents the logical provider extracted from a
 64            // provider module. It is wrapped in a facade to stabalize the interface
 65            // and is directly tied to a module.
 66            
 67            class PEGASUS_SERVER_LINKAGE JMPIProvider :
 68 schuur 1.1                        public virtual CIMProvider
 69            {
 70            public:
 71            
 72                enum Status
 73                {
 74                    UNKNOWN,
 75                    INITIALIZING,
 76                    INITIALIZED,
 77                    TERMINATING,
 78                    TERMINATED
 79                };
 80            
 81            public:
 82            
 83            
 84                class pm_service_op_lock {
 85                private:
 86                   pm_service_op_lock(void);
 87                public:
 88                   pm_service_op_lock(JMPIProvider *provider) : _provider(provider)
 89 schuur 1.1           { _provider->protect(); }
 90                   ~pm_service_op_lock(void)
 91                      { _provider->unprotect(); }
 92                   JMPIProvider * _provider;
 93                };
 94            
 95             //  typedef JMPIProviderFacade Base;
 96            
 97                JMPIProvider(const String & name,
 98                    JMPIProviderModule *module,
 99                    ProviderVector *mv);
100                JMPIProvider(JMPIProvider*);
101            
102                virtual ~JMPIProvider(void);
103            
104                virtual void initialize(CIMOMHandle & cimom);
105            
106                virtual Boolean tryTerminate(void);
107                virtual void terminate(void);
108                virtual void _terminate(void);
109            
110 schuur 1.1     Status getStatus(void) const;
111                String getName(void) const;
112                void setResolver(CMPIResolverModule *rm) { _rm=rm; }
113            
114                JMPIProviderModule *getModule(void) const;
115            
116                // << Mon Oct 14 15:42:24 2002 mdd >> for use with DQueue template
117                // to allow conversion from using Array<>
118                Boolean operator == (const void *key) const;
119                Boolean operator == (const JMPIProvider & prov) const;
120            
121            //    virtual void get_idle_timer(struct timeval *);
122            //    virtual void update_idle_timer(void);
123            //    virtual Boolean pending_operation(void);
124            //    virtual Boolean unload_ok(void);
125            
126            //   force provider manager to keep in memory
127                virtual void protect(void);
128            // allow provider manager to unload when idle
129                virtual void unprotect(void);
130            
131 schuur 1.1 protected:
132                Status _status;
133                JMPIProviderModule *_module;
134                ProviderVector miVector;
135                Boolean noUnload;
136                CIMClass *cachedClass;
137            
138            private:
139                friend class JMPILocalProviderManager;
140                friend class JMPIProviderManager;
141                friend class ProviderManagerService;
142            //    friend class OpProviderHolder;
143                CIMOMHandle *_cimom_handle;
144                void *jProviderClass,*jProvider;
145                String _name;
146                AtomicInt _no_unload;
147                CMPIResolverModule *_rm;
148                Uint32 _quantum;
149                AtomicInt _current_operations;
150            //};
151            
152 schuur 1.1 
153            //
154            // Used to encapsulate the incrementing/decrementing of the _current_operations
155            // for a JMPIProvider so it won't be unloaded during operations.
156            //
157            
158               class OpProviderHolder
159               {
160               private:
161                   JMPIProvider* _provider;
162            
163               public:
164                   OpProviderHolder(): _provider( NULL )
165                   {
166                   }
167                   OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
168                   {
169                       SetProvider( p._provider );
170                   }
171                   OpProviderHolder( JMPIProvider* p ): _provider( NULL )
172                   {
173 schuur 1.1            SetProvider( p );
174                   }
175                   ~OpProviderHolder()
176                   {
177                       UnSetProvider();
178                   }
179                   JMPIProvider& GetProvider()
180                   {
181                       return(*_provider);
182                   }
183            
184                   OpProviderHolder& operator=( const OpProviderHolder& x )
185                   {
186                       if(this == &x)
187                           return(*this);
188                       SetProvider( x._provider );
189            
190                       return(*this);
191                   }
192            
193                   void SetProvider( JMPIProvider* p )
194 schuur 1.1        {
195                       UnSetProvider();
196                       if(p)
197                       {
198                           _provider = p;
199                           _provider->_current_operations++;
200                       }
201                   }
202            
203                   void UnSetProvider()
204                   {
205                       if(_provider)
206                       {
207                           _provider->_current_operations--;
208                           _provider = NULL;
209                       }
210                   }
211               };
212            };
213            
214            PEGASUS_NAMESPACE_END
215 schuur 1.1 
216            #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2