xref: /trunk/main/jvmfwk/source/framework.hxx (revision 5ac42e1f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #if !defined INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
24 #define INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
25 #include "rtl/ustring.hxx"
26 #include "rtl/byteseq.hxx"
27 #include "jvmfwk/framework.h"
28 #include "jvmfwk/vendorplugin.h"
29 
30 /** typedefs for functions from vendorplugin.h
31  */
32 typedef javaPluginError (*jfw_plugin_getAllJavaInfos_ptr)(
33 	rtl_uString * sVendor,
34     rtl_uString * sMinVersion,
35     rtl_uString * sMaxVersion,
36     rtl_uString * * arExcludeList,
37     sal_Int32  nLenList,
38     JavaInfo*** parJavaInfo,
39     sal_Int32 *nLenInfoList);
40 
41 typedef javaPluginError (*jfw_plugin_getJavaInfoByPath_ptr)(
42     rtl_uString * sPath,
43     rtl_uString * sVendor,
44     rtl_uString * sMinVersion,
45     rtl_uString * sMaxVersion,
46     rtl_uString * * arExcludeList,
47     sal_Int32  nLenList,
48     JavaInfo** ppInfo);
49 
50 /** starts a Java Virtual Machine.
51     <p>
52     The function shall ensure, that the VM does not abort the process
53     during instantiation.
54     </p>
55  */
56 typedef javaPluginError (*jfw_plugin_startJavaVirtualMachine_ptr)(
57     const JavaInfo *info,
58     const JavaVMOption* options,
59     sal_Int32 cOptions,
60     JavaVM ** ppVM,
61     JNIEnv ** ppEnv);
62 
63 typedef javaPluginError (*jfw_plugin_existJRE_ptr)(
64     const JavaInfo *info,
65     sal_Bool *exist);
66 
67 
68 namespace jfw
69 {
70 
71 class CJavaInfo
72 {
73     static JavaInfo * copyJavaInfo(const JavaInfo * pInfo);
74 
75     enum _transfer_ownership {TRANSFER};
76     /*Attaching the pointer to this class. The argument pInfo must not
77     be freed afterwards.
78     */
79     CJavaInfo(::JavaInfo * info, _transfer_ownership);
80 
81 public:
82     ::JavaInfo * pInfo;
83 
84 
85 
86     CJavaInfo();
87     CJavaInfo(const CJavaInfo &);
88     ~CJavaInfo();
89     CJavaInfo& operator =(const ::JavaInfo* info);
90     CJavaInfo & operator = (const CJavaInfo& info);
91 
92     /* The returned class takes ownership of the argument info. info
93     must not been freed afterwards.
94     */
95     static CJavaInfo createWrapper(::JavaInfo* info);
96     /*Attaching the pointer to this class. The argument pInfo must not
97     be freed afterwards.
98     */
99     void attach(::JavaInfo* pInfo);
100     ::JavaInfo * detach();
101     const ::JavaInfo* operator ->() const;
102 //    ::JavaInfo** operator & ();
103     operator ::JavaInfo* ();
104     operator ::JavaInfo const * () const;
105     ::JavaInfo* cloneJavaInfo() const;
106 
107     rtl::OUString getVendor() const;
108     rtl::OUString getLocation() const;
109     sal_uInt64 getFeatures() const;
110 };
111 
112 class FrameworkException
113 {
114 public:
115 
FrameworkException(javaFrameworkError err,const rtl::OString & msg)116     FrameworkException(javaFrameworkError err, const rtl::OString& msg):
117         errorCode(err), message(msg)
118         {
119         }
120     javaFrameworkError errorCode;
121     rtl::OString message;
122 };
123 }
124 #endif
125