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

  1 karl  1.2 //%2004////////////////////////////////////////////////////////////////////////
  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 schuur 1.1 //
 10            // Permission is hereby granted, free of charge, to any person obtaining a copy
 11            // of this software and associated documentation files (the "Software"), to
 12            // deal in the Software without restriction, including without limitation the
 13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14            // sell copies of the Software, and to permit persons to whom the Software is
 15            // furnished to do so, subject to the following conditions:
 16 karl   1.2 // 
 17 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25            //
 26            //==============================================================================
 27            //
 28            // Author: Chip Vincent (cvincent@us.ibm.com)
 29            //
 30            // Modified By:
 31            //      Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
 32            //		Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 33            //     Mike Day, IBM (mdday@us.ibm.com)
 34            //     Adrian Schuur, IBM (schuur@de.ibm.com)
 35            //
 36            //%/////////////////////////////////////////////////////////////////////////////
 37            
 38 schuur 1.1 #include "JMPIProviderModule.h"
 39            
 40            #include <Pegasus/Common/Destroyer.h>
 41            #include <Pegasus/Common/FileSystem.h>
 42            #include <Pegasus/Common/MessageLoader.h> //l10n
 43            #include <Pegasus/Config/ConfigManager.h>
 44            #include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>
 45            #include <Pegasus/ProviderManager2/JMPI/JMPIProviderManager.h>
 46            
 47            PEGASUS_NAMESPACE_BEGIN
 48            
 49            JMPIProviderModule::JMPIProviderModule(const String & fileName,
 50                                                   const String & interfaceName)
 51                : _fileName(fileName),
 52                _interfaceName(interfaceName),
 53                _ref_count(0),
 54                _library(0)
 55            {
 56               Uint32 i=fileName.find(".jar:");
 57               if (i==PEG_NOT_FOUND) {
 58                  String msg="Invalid Location format for Java providers: "+fileName;
 59 schuur 1.1       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,msg);
 60               }
 61               String jar=fileName.subString(0,i+4);
 62               _className=fileName.subString(i+5);
 63            
 64               if (jar[0]!='/')
 65                  _fileName=JMPIProviderManager::resolveFileName(jar);
 66               else _fileName=jar;
 67            }
 68            
 69            JMPIProviderModule::~JMPIProviderModule(void)
 70            {
 71            }
 72            
 73            ProviderVector JMPIProviderModule::load(const String & providerName)
 74            {
 75               ProviderVector pv;
 76               JvmVector *jv;
 77            
 78               JNIEnv *env=JMPIjvm::attachThread(&jv);
 79               pv.jProvider=JMPIjvm::getProvider(env,_fileName,_className,
 80 schuur 1.1         providerName.getCString(),&pv.jProviderClass);
 81               JMPIjvm::detachThread();
 82            
 83                if (pv.jProvider == 0) {
 84                    String s0 = "ProviderLoadFailure";
 85                    throw Exception(MessageLoaderParms("ProviderManager.JMPIProviderModule.CANNOT_LOAD_LIBRARY",
 86                        "$0 ($1:$2):Cannot load library",
 87                        s0,
 88                        _fileName,
 89                        providerName));
 90                }
 91            
 92                _ref_count++;
 93            
 94                return pv;
 95            }
 96            
 97            void JMPIProviderModule::unloadModule(void)
 98            {
 99 david.dillard 1.3     if (_ref_count.DecAndTestIfZero())
100 schuur        1.1     {
101 david.dillard 1.3         if(_library != 0)
102                           {
103                               System::unloadDynamicLibrary(_library);
104                               _library = 0;
105                           }
106 schuur        1.1     }
107                   }
108                   
109                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2