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

  1 karl  1.4 //%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.4 // 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 mark.hamzy 1.7 //
 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                // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26                // 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:
 33                //      Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
 34                //		Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 35                //     Mike Day, IBM (mdday@us.ibm.com)
 36                //     Adrian Schuur, IBM (schuur@de.ibm.com)
 37 joyce.j    1.5 //     Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for PEP#101
 38 schuur     1.1 //
 39                //%/////////////////////////////////////////////////////////////////////////////
 40                
 41                #include "JMPIProviderModule.h"
 42                
 43                #include <Pegasus/Common/FileSystem.h>
 44                #include <Pegasus/Common/MessageLoader.h> //l10n
 45                #include <Pegasus/Config/ConfigManager.h>
 46                #include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>
 47                #include <Pegasus/ProviderManager2/JMPI/JMPIProviderManager.h>
 48                
 49                PEGASUS_NAMESPACE_BEGIN
 50                
 51                JMPIProviderModule::JMPIProviderModule(const String & fileName,
 52                                                       const String & interfaceName)
 53                    : _fileName(fileName),
 54                    _interfaceName(interfaceName),
 55                    _ref_count(0),
 56                    _library(0)
 57                {
 58                   Uint32 i=fileName.find(".jar:");
 59 schuur     1.1    if (i==PEG_NOT_FOUND) {
 60                      String msg="Invalid Location format for Java providers: "+fileName;
 61                      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,msg);
 62                   }
 63                   String jar=fileName.subString(0,i+4);
 64                   _className=fileName.subString(i+5);
 65                
 66                   if (jar[0]!='/')
 67                      _fileName=JMPIProviderManager::resolveFileName(jar);
 68                   else _fileName=jar;
 69                }
 70                
 71                JMPIProviderModule::~JMPIProviderModule(void)
 72                {
 73                }
 74                
 75                ProviderVector JMPIProviderModule::load(const String & providerName)
 76                {
 77 mark.hamzy 1.7     ProviderVector  pv;
 78                    JvmVector      *jv  = NULL;
 79                    JNIEnv         *env = JMPIjvm::attachThread(&jv);
 80 schuur     1.1 
 81 mark.hamzy 1.7     if (env)
 82                    {
 83                       pv.jProvider = JMPIjvm::getProvider (env,
 84                                                            _fileName,
 85                                                            _className,
 86                                                            providerName.getCString(),
 87                                                            &pv.jProviderClass);
 88                       JMPIjvm::detachThread ();
 89                    }
 90 schuur     1.1 
 91 mark.hamzy 1.7     if (pv.jProvider == 0)
 92                    {
 93 schuur     1.1         String s0 = "ProviderLoadFailure";
 94                        throw Exception(MessageLoaderParms("ProviderManager.JMPIProviderModule.CANNOT_LOAD_LIBRARY",
 95                            "$0 ($1:$2):Cannot load library",
 96                            s0,
 97                            _fileName,
 98                            providerName));
 99                    }
100                
101                    _ref_count++;
102                
103                    return pv;
104                }
105                
106                void JMPIProviderModule::unloadModule(void)
107                {
108 mike       1.6     if (_ref_count.decAndTestIfZero())
109 schuur     1.1     {
110 david.dillard 1.3         if(_library != 0)
111                           {
112                               System::unloadDynamicLibrary(_library);
113                               _library = 0;
114                           }
115 schuur        1.1     }
116                   }
117                   
118                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2