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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2