xref: /trunk/main/jvmfwk/source/framework.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #if !defined INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
28 #define INCLUDED_JVMFWK_LOCAL_FRAMEWORK_HXX
29 #include "rtl/ustring.hxx"
30 #include "rtl/byteseq.hxx"
31 #include "jvmfwk/framework.h"
32 #include "jvmfwk/vendorplugin.h"
33 
34 /** typedefs for functions from vendorplugin.h
35  */
36 typedef javaPluginError (*jfw_plugin_getAllJavaInfos_ptr)(
37 	rtl_uString * sVendor,
38     rtl_uString * sMinVersion,
39     rtl_uString * sMaxVersion,
40     rtl_uString * * arExcludeList,
41     sal_Int32  nLenList,
42     JavaInfo*** parJavaInfo,
43     sal_Int32 *nLenInfoList);
44 
45 typedef javaPluginError (*jfw_plugin_getJavaInfoByPath_ptr)(
46     rtl_uString * sPath,
47     rtl_uString * sVendor,
48     rtl_uString * sMinVersion,
49     rtl_uString * sMaxVersion,
50     rtl_uString * * arExcludeList,
51     sal_Int32  nLenList,
52     JavaInfo** ppInfo);
53 
54 /** starts a Java Virtual Machine.
55     <p>
56     The function shall ensure, that the VM does not abort the process
57     during instantiation.
58     </p>
59  */
60 typedef javaPluginError (*jfw_plugin_startJavaVirtualMachine_ptr)(
61     const JavaInfo *info,
62     const JavaVMOption* options,
63     sal_Int32 cOptions,
64     JavaVM ** ppVM,
65     JNIEnv ** ppEnv);
66 
67 typedef javaPluginError (*jfw_plugin_existJRE_ptr)(
68     const JavaInfo *info,
69     sal_Bool *exist);
70 
71 
72 namespace jfw
73 {
74 
75 class CJavaInfo
76 {
77     static JavaInfo * copyJavaInfo(const JavaInfo * pInfo);
78 
79     enum _transfer_ownership {TRANSFER};
80     /*Attaching the pointer to this class. The argument pInfo must not
81     be freed afterwards.
82     */
83     CJavaInfo(::JavaInfo * info, _transfer_ownership);
84 
85 public:
86     ::JavaInfo * pInfo;
87 
88 
89 
90     CJavaInfo();
91     CJavaInfo(const CJavaInfo &);
92     ~CJavaInfo();
93     CJavaInfo& operator =(const ::JavaInfo* info);
94     CJavaInfo & operator = (const CJavaInfo& info);
95 
96     /* The returned class takes ownership of the argument info. info
97     must not been freed afterwards.
98     */
99     static CJavaInfo createWrapper(::JavaInfo* info);
100     /*Attaching the pointer to this class. The argument pInfo must not
101     be freed afterwards.
102     */
103     void attach(::JavaInfo* pInfo);
104     ::JavaInfo * detach();
105     const ::JavaInfo* operator ->() const;
106 //    ::JavaInfo** operator & ();
107     operator ::JavaInfo* ();
108     operator ::JavaInfo const * () const;
109     ::JavaInfo* cloneJavaInfo() const;
110 
111     rtl::OUString getVendor() const;
112     rtl::OUString getLocation() const;
113     sal_uInt64 getFeatures() const;
114 };
115 
116 class FrameworkException
117 {
118 public:
119 
120     FrameworkException(javaFrameworkError err, const rtl::OString& msg):
121         errorCode(err), message(msg)
122         {
123         }
124     javaFrameworkError errorCode;
125     rtl::OString message;
126 };
127 }
128 #endif
129