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.
|
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:
|
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 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 schuur 1.1 #include "JMPIProviderModule.h"
41
42 #include <Pegasus/Common/Destroyer.h>
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 if (i==PEG_NOT_FOUND) {
60 String msg="Invalid Location format for Java providers: "+fileName;
61 schuur 1.1 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 ProviderVector pv;
78 JvmVector *jv;
79
80 JNIEnv *env=JMPIjvm::attachThread(&jv);
81 pv.jProvider=JMPIjvm::getProvider(env,_fileName,_className,
82 schuur 1.1 providerName.getCString(),&pv.jProviderClass);
83 JMPIjvm::detachThread();
84
85 if (pv.jProvider == 0) {
86 String s0 = "ProviderLoadFailure";
87 throw Exception(MessageLoaderParms("ProviderManager.JMPIProviderModule.CANNOT_LOAD_LIBRARY",
88 "$0 ($1:$2):Cannot load library",
89 s0,
90 _fileName,
91 providerName));
92 }
93
94 _ref_count++;
95
96 return pv;
97 }
98
99 void JMPIProviderModule::unloadModule(void)
100 {
|