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 mark.hamzy 1.9 //
|
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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include "JMPIProviderModule.h"
35
36 #include <Pegasus/Common/FileSystem.h>
|
37 kumpf 1.11 #include <Pegasus/Common/MessageLoader.h>
|
38 schuur 1.1 #include <Pegasus/Config/ConfigManager.h>
39 #include <Pegasus/ProviderManager2/JMPI/JMPIProvider.h>
40 #include <Pegasus/ProviderManager2/JMPI/JMPIProviderManager.h>
41
42 PEGASUS_NAMESPACE_BEGIN
43
|
44 mark.hamzy 1.9 JMPIProviderModule::JMPIProviderModule (const String & fileName,
45 const String & interfaceName)
46 : _fileName (fileName),
|
47 kumpf 1.10 _interfaceName (interfaceName)
|
48 schuur 1.1 {
|
49 mark.hamzy 1.9 Uint32 i = fileName.find (".jar:");
50
51 if (i == PEG_NOT_FOUND)
52 {
53 String msg = "Invalid Location format for Java providers: " + fileName;
54
55 throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED, msg);
|
56 schuur 1.1 }
57
|
58 mark.hamzy 1.9 String jar = fileName.subString (0, i + 4);
59
60 _className = fileName.subString (i + 5);
61
62 if (jar[0] != '/')
63 _fileName = JMPIProviderManager::resolveFileName (jar);
64 else
65 _fileName = jar;
|
66 schuur 1.1 }
67
|
68 mark.hamzy 1.9 JMPIProviderModule::~JMPIProviderModule (void)
|
69 schuur 1.1 {
70 }
71
|
72 mark.hamzy 1.9 ProviderVector JMPIProviderModule::load (const String & providerName)
|
73 schuur 1.1 {
|
74 mark.hamzy 1.9 ProviderVector pv = { 0, 0 };
75 JvmVector *jv = NULL;
76 JNIEnv *env = JMPIjvm::attachThread (&jv);
77
78 if (env)
79 {
80 pv.jProvider = JMPIjvm::getProvider (env,
81 _fileName,
82 _className,
83 providerName.getCString (),
84 &pv.jProviderClass);
85 JMPIjvm::detachThread ();
86 }
87 else
88 {
|
89 marek 1.12 throw PEGASUS_CIM_EXCEPTION_L(
90 CIM_ERR_FAILED,
91 MessageLoaderParms(
92 "ProviderManager.JMPI.INIT_JVM_FAILED",
93 "Could not initialize the JVM (Java Virtual Machine) "
94 "runtime environment."));
|
95 mark.hamzy 1.9 }
96
97 if (pv.jProvider == 0)
98 {
99 String s0 = "ProviderLoadFailure";
100
|
101 kumpf 1.11 throw Exception(MessageLoaderParms(
102 "ProviderManager.JMPI.JMPIProviderModule.CANNOT_LOAD_LIBRARY",
103 "$0 ($1:$2): Cannot load library.",
104 s0,
105 _fileName,
106 providerName));
|
107 mark.hamzy 1.9 }
|
108 schuur 1.1
|
109 mark.hamzy 1.9 return pv;
|
110 schuur 1.1 }
111
|
112 mark.hamzy 1.9 void JMPIProviderModule::unloadModule (void)
|
113 schuur 1.1 {
114 }
115
116 PEGASUS_NAMESPACE_END
|