Chris Hillery has proposed merging lp:~zorba-coders/zorba/bug-1210677-util-jvm into lp:zorba.
Commit message: Replace auto_ptr with unique_ptr Requested reviews: Zorba Coders (zorba-coders) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug-1210677-util-jvm/+merge/184923 -- https://code.launchpad.net/~zorba-coders/zorba/bug-1210677-util-jvm/+merge/184923 Your team Zorba Coders is requested to review the proposed merge of lp:~zorba-coders/zorba/bug-1210677-util-jvm into lp:zorba.
=== added file 'CMakeLists.txt' --- CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ CMakeLists.txt 2013-09-11 04:36:06 +0000 @@ -0,0 +1,66 @@ +# Copyright 2006-2010 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +PROJECT (zorba_util-jvm_module) + +IF (ZORBA_SUPPRESS_JAVA) + MESSAGE (STATUS "ZORBA_SUPPRESS_JAVA is true - not searching for Java") +ELSE (ZORBA_SUPPRESS_JAVA) + INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/config/UtilJavaUse.cmake) + + MESSAGE(STATUS "") + MESSAGE(STATUS "--- Module: util-jvm ---") + + FIND_PACKAGE (Zorba REQUIRED HINTS "${ZORBA_BUILD_DIR}") + INCLUDE ("${Zorba_USE_FILE}") + + SET_CMAKE_MODULE_PATH() + + MESSAGE (STATUS "Looking for JNI") + ZORBA_FIND_JNI() + + MESSAGE (STATUS "Looking for Java") + FIND_PACKAGE(Java) + + IF (JNI_FOUND) + SET (UTIL_JVM_VERSION 1.0) + + # Export this include directory by setting ZORBA_PROJECT_INCLUDE_DIRS + SET (ZORBA_PROJECT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include") + INCLUDE_DIRECTORIES ("${ZORBA_PROJECT_INCLUDE_DIRS}") + INSTALL (FILES include/JavaVMSingleton.h DESTINATION include) + + # Set up a "use file" for other modules to import + SET (ZORBA_PROJECT_USE_FILE + "${CMAKE_CURRENT_SOURCE_DIR}/config/UtilJavaUse.cmake") + ADD_SUBDIRECTORY ("src") + + # Set up configuration for install + ADD_SUBDIRECTORY ("config") + + DONE_DECLARING_ZORBA_URIS () + + ELSE (JNI_FOUND) + MESSAGE(STATUS "Building Zorba without util-jvm module.") + ENDIF (JNI_FOUND) + MESSAGE(STATUS "---") + MESSAGE(STATUS "") +ENDIF(ZORBA_SUPPRESS_JAVA) + +# Cache these variables for ease of packages depending on us +SET (JAVA_FOUND "${JAVA_FOUND}" CACHE BOOL "Whether Java was found" FORCE) +SET (JNI_FOUND "${JNI_FOUND}" CACHE BOOL "Whether JNI was found" FORCE) + === renamed file 'CMakeLists.txt' => 'CMakeLists.txt.moved' === added directory 'cmake_modules' === renamed directory 'cmake_modules' => 'cmake_modules.moved' === added file 'cmake_modules/FindJNI.cmake' --- cmake_modules/FindJNI.cmake 1970-01-01 00:00:00 +0000 +++ cmake_modules/FindJNI.cmake 2013-09-11 04:36:06 +0000 @@ -0,0 +1,304 @@ +# - Find JNI java libraries. +# This module finds if Java is installed and determines where the +# include files and libraries are. It also determines what the name of +# the library is. This code sets the following variables: +# +# JNI_INCLUDE_DIRS = the include dirs to use +# JNI_LIBRARIES = the libraries to use +# JNI_FOUND = TRUE if JNI headers and libraries were found. +# JAVA_AWT_LIBRARY = the path to the jawt library +# JAVA_JVM_LIBRARY = the path to the jvm library +# JAVA_INCLUDE_PATH = the include path to jni.h +# JAVA_INCLUDE_PATH2 = the include path to jni_md.h +# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h +# + +#============================================================================= +# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the names of Kitware, Inc., the Insight Software Consortium, nor +# the names of their contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var} +MACRO(java_append_library_directories _var) + # Determine java arch-specific library subdir + # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk + # 1.6.0_18 + icedtea patches. However, it would be much better to base the + # guess on the first part of the GNU config.guess platform triplet. + IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "amd64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + SET(_java_libarch "i386") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") + SET(_java_libarch "alpha") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + # Subdir is "arm" for both big-endian (arm) and little-endian (armel). + SET(_java_libarch "arm") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") + # mips* machines are bi-endian mostly so processor does not tell + # endianess of the underlying system. + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") + SET(_java_libarch "ppc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") + SET(_java_libarch "ppc") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") + # Both flavours can run on the same processor + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)") + SET(_java_libarch "parisc" "parisc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390") + # s390 binaries can run on s390x machines + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh") + SET(_java_libarch "sh") + ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") + ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + + # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or + # system is non-Linux (where the code above has not been well tested) + IF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux") + LIST(APPEND _java_libarch "i386" "amd64" "ppc") + ENDIF(NOT _java_libarch OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux") + + # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer + # current value to a hardcoded list. Remove possible duplicates. + LIST(REMOVE_DUPLICATES _java_libarch) + + FOREACH(_path ${ARGN}) + IF(_path MATCHES "{libarch}") + FOREACH(_libarch ${_java_libarch}) + STRING(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}") + LIST(APPEND ${_var} "${_newpath}") + ENDFOREACH(_libarch) + ELSE(_path MATCHES "{libarch}") + LIST(APPEND ${_var} "${_path}") + ENDIF(_path MATCHES "{libarch}") + ENDFOREACH(_path) +ENDMACRO(java_append_library_directories) + +GET_FILENAME_COMPONENT(java_install_version + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) + +SET(JAVA_AWT_LIBRARY_DIRECTORIES + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" + ) + +FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) + +JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES + ${_JAVA_HOME}/jre/lib/{libarch} + ${_JAVA_HOME}/jre/lib + ${_JAVA_HOME}/lib + ${_JAVA_HOME} + /usr/lib/jvm/java-6-openjdk/jre/lib + /usr/lib/jvm/java-6-openjdk-i386/jre/lib + /usr/lib/jvm/java-6-openjdk-amd64/jre/lib + /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch} + /usr/lib/jvm/java-6-openjdk-i386/jre/lib/{libarch} + /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/{libarch} + /usr/lib + /usr/local/lib + /usr/lib/jvm/java/lib + /usr/lib/java/jre/lib/{libarch} + /usr/local/lib/java/jre/lib/{libarch} + /usr/local/share/java/jre/lib/{libarch} + /usr/lib/j2sdk1.4-sun/jre/lib/{libarch} + /usr/lib/j2sdk1.5-sun/jre/lib/{libarch} + /opt/sun-jdk-1.5.0.04/jre/lib/{libarch} + /usr/lib/jvm/java-6-sun/jre/lib/{libarch} + /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch} + /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex + /usr/lib/jvm/java-openjdk/jre/lib/{libarch} + # Debian specific paths for default JVM + /usr/lib/jvm/default-java/jre/lib/{libarch} + /usr/lib/jvm/default-java/jre/lib + /usr/lib/jvm/default-java/lib + ) + +SET(JAVA_JVM_LIBRARY_DIRECTORIES) +FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) + SET(JAVA_JVM_LIBRARY_DIRECTORIES + ${JAVA_JVM_LIBRARY_DIRECTORIES} + "${dir}" + "${dir}/client" + "${dir}/server" + ) +ENDFOREACH(dir) + + +SET(JAVA_AWT_INCLUDE_DIRECTORIES + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" + ${_JAVA_HOME}/include + /usr/lib/jvm/java-6-openjdk/include + /usr/lib/jvm/java-6-openjdk-amd64/include + /usr/lib/jvm/java-6-openjdk-i386/include + /usr/include + /usr/local/include + /usr/lib/java/include + /usr/local/lib/java/include + /usr/lib/jvm/java/include + /usr/lib/jvm/java-6-sun/include + /usr/lib/jvm/java-1.5.0-sun/include + /usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex + /usr/lib/jvm/java-6-openjdk/include + /usr/local/share/java/include + /usr/lib/j2sdk1.4-sun/include + /usr/lib/j2sdk1.5-sun/include + /opt/sun-jdk-1.5.0.04/include + # Debian specific path for default JVM + /usr/lib/jvm/default-java/include + ) + +FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") + GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH) + FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include) + IF(EXISTS ${jpath}/${JAVA_INC_PATH}) + SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}") + ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH}) + ENDFOREACH(JAVA_INC_PATH) + FOREACH(JAVA_LIB_PATH + ../lib ../jre/lib ../jre/lib/i386 + ../java/lib ../java/jre/lib ../java/jre/lib/i386 + ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386) + IF(EXISTS ${jpath}/${JAVA_LIB_PATH}) + SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}") + ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH}) + ENDFOREACH(JAVA_LIB_PATH) +ENDFOREACH(JAVA_PROG) + +IF(APPLE) + IF(EXISTS ~/Library/Frameworks/JavaVM.framework) + SET(JAVA_HAVE_FRAMEWORK 1) + ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework) + IF(EXISTS /Library/Frameworks/JavaVM.framework) + SET(JAVA_HAVE_FRAMEWORK 1) + ENDIF(EXISTS /Library/Frameworks/JavaVM.framework) + IF(EXISTS /System/Library/Frameworks/JavaVM.framework) + SET(JAVA_HAVE_FRAMEWORK 1) + ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework) + + IF(JAVA_HAVE_FRAMEWORK) + IF(NOT JAVA_AWT_LIBRARY) + SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) + ENDIF(NOT JAVA_AWT_LIBRARY) + + IF(NOT JAVA_JVM_LIBRARY) + SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE) + ENDIF(NOT JAVA_JVM_LIBRARY) + + IF(NOT JAVA_AWT_INCLUDE_PATH) + IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h) + SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE) + ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h) + ENDIF(NOT JAVA_AWT_INCLUDE_PATH) + + # If using "-framework JavaVM", prefer its headers *before* the others in + # JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here) + # + SET(JAVA_AWT_INCLUDE_DIRECTORIES + ~/Library/Frameworks/JavaVM.framework/Headers + /Library/Frameworks/JavaVM.framework/Headers + /System/Library/Frameworks/JavaVM.framework/Headers + ${JAVA_AWT_INCLUDE_DIRECTORIES} + ) + ENDIF(JAVA_HAVE_FRAMEWORK) +ELSE(APPLE) + FIND_LIBRARY(JAVA_AWT_LIBRARY jawt + PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES} + ) + FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM java + PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES} + ) +ENDIF(APPLE) + +# add in the include path +FIND_PATH(JAVA_INCLUDE_PATH jni.h + ${JAVA_AWT_INCLUDE_DIRECTORIES} +) + +FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH}/win32 + ${JAVA_INCLUDE_PATH}/linux + ${JAVA_INCLUDE_PATH}/freebsd + ${JAVA_INCLUDE_PATH}/solaris +) + +FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h + ${JAVA_INCLUDE_PATH} +) + + +IF (APPLE) + # On Mac, the java headers files are broken symlinks if the Apple Developer Tools for Java are not installed + EXECUTE_PROCESS(COMMAND cat ${JAVA_INCLUDE_PATH}/jni.h + OUTPUT_QUIET + ERROR_QUIET + RESULT_VARIABLE SYMLINK_CHECK_RESULT_VARIABLE) + IF (SYMLINK_CHECK_RESULT_VARIABLE GREATER 0) + SET (JAVA_INCLUDE_PATH "JAVA_INCLUDE_PATH-NOTFOUND") + SET (JAVA_INCLUDE_PATH2 "JAVA_INCLUDE_PATH2-NOTFOUND") + SET (JAVA_AWT_INCLUDE_PATH "JAVA_AWT_INCLUDE_PATH-NOTFOUND") + ENDIF() +ENDIF (APPLE) + + +#INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +#FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY +# JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) + +MARK_AS_ADVANCED( + JAVA_AWT_LIBRARY + JAVA_JVM_LIBRARY + JAVA_AWT_INCLUDE_PATH + JAVA_INCLUDE_PATH + JAVA_INCLUDE_PATH2 +) + +IF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) + SET(JNI_FOUND 1) + SET(JNI_LIBRARIES + ${JAVA_AWT_LIBRARY} + ${JAVA_JVM_LIBRARY} + ) + SET(JNI_INCLUDE_DIRS + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2} + ${JAVA_AWT_INCLUDE_PATH} + ) +ELSE (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) + SET(JNI_FOUND 0) + SET(JNI_LIBRARIES "") + SET(JNI_INCLUDE_DIRS "") +ENDIF (JAVA_AWT_LIBRARY AND JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2 AND JAVA_AWT_INCLUDE_PATH) === added directory 'cmake_modules/Windows' === added file 'cmake_modules/Windows/FindJNI.cmake' --- cmake_modules/Windows/FindJNI.cmake 1970-01-01 00:00:00 +0000 +++ cmake_modules/Windows/FindJNI.cmake 2013-09-11 04:36:06 +0000 @@ -0,0 +1,37 @@ +# Copyright 2010 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# - Try to find the JNI libraries on Windows +# +# See the FindJNI.cmake module shipped with Zorba for more information. + +FIND_PACKAGE_WIN32_NO_PROXY (JNI JNI_FOUND) + +IF (JNI_FOUND) + + STRING (REPLACE "/jvm.lib" "" JAVA_JVM_LIBRARY_PATH "${JAVA_JVM_LIBRARY}") + + IF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") + SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") + # find the needed DLL's + FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm" SKIP_INSTALL) + ELSEIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server") + SET (FOUND_LOCATION "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/server") + # find the needed DLL's + FIND_PACKAGE_DLL_WIN32 (${FOUND_LOCATION} "jvm" SKIP_INSTALL) + ELSE (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") + MESSAGE (WARNING "Could not find the jvm.dll for the JVM library: ${JAVA_JVM_LIBRARY}. Please extend this module to find the jvm.dll somewhere in your JVM directory or make sure that jvm.dll is in the PATH.") + ENDIF (EXISTS "${JAVA_JVM_LIBRARY_PATH}/../jre/bin/client") + +ENDIF (JNI_FOUND) === added directory 'config' === renamed directory 'config' => 'config.moved' === added file 'config/CMakeLists.txt' --- config/CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ config/CMakeLists.txt 2013-09-11 04:36:06 +0000 @@ -0,0 +1,37 @@ +# Copyright 2006-2012 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# We need to be able to install util-jvm and then build module projects +# against that. The "auto-config" approach Zorba provides does not +# support this, so we roll our own here. This should probably be +# re-thought in the future. + +SET (UTILJVM_CMAKE_DIR "share/cmake/zorba_util-jvm_module") + +# First, install the Use file. Doesn't need to be configured since it +# just contains a macro. +INSTALL (FILES UtilJavaUse.cmake DESTINATION "${UTILJVM_CMAKE_DIR}") + +# Anyway, we set all the same variables to what they should be in the +# install image, and re-config Zorba's ExternalModuleConfig.cmake.in. +SET (ZORBA_PROJECT_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") +SET (ZORBA_PROJECT_USE_FILE "${CMAKE_INSTALL_PREFIX}/${UTILJVM_CMAKE_DIR}/UtilJavaUse.cmake") +GET_TARGET_PROPERTY(_libpath util-jvm LOCATION) +GET_FILENAME_COMPONENT(_libname "${_libpath}" NAME) +SET (ZORBA_PROJECT_LIBRARIES "${CMAKE_INSTALL_PREFIX}/lib/${_libname}") + +CONFIGURE_FILE("${Zorba_EXTERNALMODULECONFIG_FILE}" + "${PROJECT_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake" @ONLY) +INSTALL(FILES "${PROJECT_BINARY_DIR}/install/${PROJECT_NAME}Config.cmake" + DESTINATION "${UTILJVM_CMAKE_DIR}") === added file 'config/UtilJavaUse.cmake' --- config/UtilJavaUse.cmake 1970-01-01 00:00:00 +0000 +++ config/UtilJavaUse.cmake 2013-09-11 04:36:06 +0000 @@ -0,0 +1,129 @@ +# Copyright 2006-2010 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Macro to find a Jar file whose filename possibly includes a version +# number. Some Apache distributions, such as FOP, include dependent jars +# with version numbers, and CMake's FIND_FILE() doesn't support glob +# patterns for the filename. This macro will find .jar files with optional +# patterns like "-1.0" in the basename. +# +# This macro operates the similarly to FIND_FILE(), except it only supports +# NAMES, PATHS, PATH_SUFFIXES, DOC, and NO_CMAKE_PATH. Other differences: +# 1. NAMES is required, and it should be passed the basename of the +# jarfiles without the version number or ".jar" extension. +# 2. The only search directories will be those on CMAKE_PREFIX_PATH and +# those specified by PATHS. +# +# For example: +# ZORBA_FIND_JAR (FOP_JAR NAMES fop PATHS ${XSL_FOP_HOME} PATH_SUFFIXES build) +# +# will find fop.jar, fop-1.0.jar, or fop-23453.1234.jar, in any directory +# on CMAKE_PREFIX_PATH or in XSL_FOP_HOME, or in any subdirectory named +# "build" of any of those directories. +# +# For the moment this macro does not check the version number or enforce +# a particular/minimum version. +MACRO (ZORBA_FIND_JAR JARVARNAME) + IF (NOT COMMAND PARSE_ARGUMENTS) + MESSAGE (FATAL_ERROR + "Please INCLUDE(\${Zorba_USE_FILE}) file " + "prior to calling ZORBA_FIND_JAR().") + ENDIF (NOT COMMAND PARSE_ARGUMENTS) + + PARSE_ARGUMENTS (ZFINDJAR "PATHS;NAMES;PATH_SUFFIXES" "DOC" + "NO_CMAKE_PATH" ${ARGN}) + + IF (NOT ZFINDJAR_NAMES) + MESSAGE (FATAL_ERROR "'NAMES' argument is required for ZORBA_FIND_JAR") + ENDIF (NOT ZFINDJAR_NAMES) + + # If the value is already cached, don't do anything + IF (NOT ${JARVARNAME}) + + # Form up the set of directories to search in. + SET (_paths) + IF (NOT ZFINDJAR_NO_CMAKE_PATH) + SET (_paths ${CMAKE_PREFIX_PATH}) + ENDIF (NOT ZFINDJAR_NO_CMAKE_PATH) + IF (ZFINDJAR_PATHS) + LIST (APPEND _paths ${ZFINDJAR_PATHS}) + ENDIF (ZFINDJAR_PATHS) + IF (NOT _paths) + MESSAGE (WARNING "No place to search for ${ZFINDJAR_NAMES} jars! " + "Set either CMAKE_PREFIX_PATH or pass PATHS") + ENDIF (NOT _paths) + + # Iterate through each directory looking for each filename + SET (_jarpath "${JARVARNAME}-NOTFOUND") + FOREACH (_path ${_paths}) + IF (_jarpath) + BREAK () + ENDIF (_jarpath) + + # Iterate through each potential jarname + FOREACH (_name ${ZFINDJAR_NAMES}) + IF (_jarpath) + BREAK () + ENDIF (_jarpath) + + # Iterate through current directory and each suffix + FOREACH (_dir "" ${ZFINDJAR_PATH_SUFFIXES}) + # Form up the final full path + IF (_dir) + SET (_path2 "${_path}/${_dir}") + ELSE (_dir) + SET (_path2 "${_path}") + ENDIF (_dir) + + # First see if the exact filename exists + IF (EXISTS "${_path2}/${_name}.jar") + SET (_jarpath "${_path2}/${_name}.jar") + BREAK () + ENDIF (EXISTS "${_path2}/${_name}.jar") + + # Finally, glob for version variants + FILE (GLOB _jarfiles "${_path2}/${_name}-*.jar") + IF (_jarfiles) + LIST (GET _jarfiles 0 _jarpath) + BREAK () + ENDIF (_jarfiles) + + ENDFOREACH (_dir) + ENDFOREACH (_name) + ENDFOREACH (_path) + + # Cache the results + SET (${JARVARNAME} "${_jarpath}" CACHE PATH "${ZFINDJAR_DOC}" FORCE) + + ENDIF (NOT ${JARVARNAME}) + +ENDMACRO (ZORBA_FIND_JAR) + +MACRO (ZORBA_FIND_JNI) + IF (UNIX AND NOT APPLE) + # setting JAVA_HOME to bypass issues in FindJNI.cmake + FIND_FILE(_JAVA_BIN_LOC NAMES java PATHS ENV PATH) + IF (_JAVA_BIN_LOC) + GET_FILENAME_COMPONENT(_JAVA_BIN_LOC "${_JAVA_BIN_LOC}" REALPATH) + GET_FILENAME_COMPONENT(_JAVA_BIN_DIR ${_JAVA_BIN_LOC} PATH) + GET_FILENAME_COMPONENT(_JAVA_HOME "${_JAVA_BIN_DIR}/../.." ABSOLUTE) + MESSAGE( + STATUS "Generated JAVA_HOME to support FindJNI.cmake: " + ${_JAVA_HOME}) + SET(ENV{JAVA_HOME} ${_JAVA_HOME}) + ENDIF() + ENDIF() + + FIND_PACKAGE(JNI) +ENDMACRO (ZORBA_FIND_JNI) === added directory 'include' === renamed directory 'include' => 'include.moved' === added file 'include/JavaVMSingleton.h' --- include/JavaVMSingleton.h 1970-01-01 00:00:00 +0000 +++ include/JavaVMSingleton.h 2013-09-11 04:36:06 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright 2006-2008 The FLWOR Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JAVA_VM_SINGLETON +#define JAVA_VM_SINGLETON + +#include <jni.h> +#include <zorba/static_context.h> + +# if defined WIN32 || defined CYGWIN +# ifdef util_jvm_EXPORTS +# ifdef __GNUC__ +# define UTIL_JVM_DLL_PUBLIC __attribute__((dllexport)) +# else +# define UTIL_JVM_DLL_PUBLIC __declspec(dllexport) +# endif /* __GNUC__ */ +# else /* util_jvm_EXPORTS */ +# ifdef __GNUC__ +# define UTIL_JVM_DLL_PUBLIC __attribute__((dllimport)) +# else +# define UTIL_JVM_DLL_PUBLIC __declspec(dllimport) +# endif /* __GNUC__ */ +# endif /* util_jvm_EXPORTS */ +# else +# if __GNUC__ >= 4 +# define UTIL_JVM_DLL_PUBLIC __attribute__ ((visibility("default"))) +# else +# define UTIL_JVM_DLL_PUBLIC +# endif +# endif + +namespace zorba { namespace jvm { + +#define NO_OF_JVM_OPTIONS 3 + + +class VMOpenException {}; + +class UTIL_JVM_DLL_PUBLIC JavaVMSingleton +{ +public: + //static JavaVMSingleton* getInstance(const char* classPath); + static JavaVMSingleton* getInstance(const char* classPath, const char* javaLibPath); + static JavaVMSingleton* getInstance(const zorba::StaticContext* aStaticContext); + + virtual ~JavaVMSingleton(); + JavaVM* getVM(); + JNIEnv* getEnv(); + +protected: + JavaVMSingleton(const char* classPath, const char* javaLibPath); + JavaVMSingleton(JavaVM *jvm, JNIEnv *env) : m_vm(jvm), m_env(env) {} + static String computeClassPath(const zorba::StaticContext* aStaticContext); + static String computeLibPath(const zorba::StaticContext* aStaticContext); + + static JavaVMSingleton* instance; + JavaVM* m_vm; + JNIEnv* m_env; + JavaVMInitArgs args; + JavaVMOption options[NO_OF_JVM_OPTIONS]; + + char* classPathOption; + char* awtOption; + char* jlpOption; +}; + + +}} //namespace zorba, jvm + +#endif // JAVA_VM_SINGLETON + + + + === added directory 'src' === renamed directory 'src' => 'src.moved' === added file 'src/CMakeLists.txt' --- src/CMakeLists.txt 1970-01-01 00:00:00 +0000 +++ src/CMakeLists.txt 2013-09-11 04:36:06 +0000 @@ -0,0 +1,56 @@ +# Copyright 2006-2010 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +INCLUDE (CMakeJavaInformation ) +MESSAGE(STATUS "Using Java API") +EXECUTE_PROCESS ( + COMMAND ${JAVA_RUNTIME} -version + RESULT_VARIABLE JAVA_VERSION + OUTPUT_QUIET + ERROR_QUIET) + +MESSAGE (STATUS "JNI found at :${JAVA_INCLUDE_PATH}") +MESSAGE (STATUS "Java Library at :${JAVA_JVM_LIBRARY}") + +INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) +INCLUDE_DIRECTORIES (${JAVA_INCLUDE_PATH}) + +# For now, we still have a module, but it actually does nothing at all. +DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/util-jvm" + VERSION 1.0 FILE "util-jvm.xq") + +# The important stuff is the library, which we install in Zorba's +# default lib directory. +ADD_LIBRARY(util-jvm SHARED util-jvm.cpp JavaVMSingleton.cpp) +TARGET_LINK_LIBRARIES(util-jvm "${JAVA_JVM_LIBRARY}" zorba_${ZORBA_STORE_NAME}) +INSTALL(TARGETS util-jvm + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib) + +#SET RPATH +IF (ZORBA_ADD_DEBIAN_JRE_RPATHS) + SET (INSTALL_RPATH_PATHS "/usr/lib/jvm/default-java/jre/lib/amd64/server;/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server;/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server;/usr/lib/jvm/java-7-openjdk/jre/lib/amd64/server;/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server;/usr/lib/jvm/default-java/jre/lib/i386/server;/usr/lib/jvm/java-6-openjdk/jre/lib/i386/server;/usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386/server;/usr/lib/jvm/java-7-openjdk/jre/lib/i386/server;/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server") + SET_TARGET_PROPERTIES(util-jvm PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH "${INSTALL_RPATH_PATHS}") +ELSE (ZORBA_ADD_DEBIAN_JRE_RPATHS) + # MAC OS X only property + # this is required to make sure that the library has the correct install name after + # installation such that dependent modules always find it + SET_TARGET_PROPERTIES(util-jvm PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +ENDIF (ZORBA_ADD_DEBIAN_JRE_RPATHS) + + +# Set this in the parent scope so it will be put into our Config.cmake file. +# As with many other things, this doesn't work when the module is installed. +SET(ZORBA_PROJECT_LIBRARIES util-jvm PARENT_SCOPE) === added file 'src/JavaVMSingleton.cpp' --- src/JavaVMSingleton.cpp 1970-01-01 00:00:00 +0000 +++ src/JavaVMSingleton.cpp 2013-09-11 04:36:06 +0000 @@ -0,0 +1,256 @@ +/* + * Copyright 2006-2008 The FLWOR Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "JavaVMSingleton.h" + +#include <fstream> +#include <iostream> +#include <istream> +#include <string> +#include <cstdlib> +#include <cstring> +#include <sstream> + +#include <zorba/zorba.h> +#include <zorba/util/fs_util.h> + +namespace zorba { +namespace jvm { + +JavaVMSingleton* JavaVMSingleton::instance = NULL; + +JavaVMSingleton::JavaVMSingleton(const char* classPath, const char* javaLibPath) +{ + memset(&args, 0, sizeof(args)); + jint r; + jint nOptions = NO_OF_JVM_OPTIONS; + + std::string classpathOption; + std::ostringstream os; + os << "-Djava.class.path=" << classPath; + classpathOption = os.str(); + classPathOption = new char[classpathOption.size() + 1]; + memset(classPathOption, 0, sizeof(char) * (classpathOption.size() + 1)); + memcpy(classPathOption, classpathOption.c_str(), classpathOption.size() * sizeof(char)); + + std::string lAwtArgStr = "-Djava.awt.headless=true"; + awtOption = new char[lAwtArgStr.size() + 1]; + memset(awtOption, 0, sizeof(char) * (lAwtArgStr.size() + 1)); + memcpy(awtOption, lAwtArgStr.c_str(), sizeof(char) * lAwtArgStr.size()); + awtOption[lAwtArgStr.size()] = 0; + + // javaLibPath are only base pathes, the full path will be computed at runtime in the Java class + std::string jlpStr = "-Djava.library.path=" + std::string(javaLibPath); + jlpOption = new char[jlpStr.size() + 1]; + memset(jlpOption, 0, sizeof(char) * (jlpStr.size() + 1)); + memcpy(jlpOption, jlpStr.c_str(), sizeof(char) * jlpStr.size()); + jlpOption[jlpStr.size()] = 0; + + options[0].optionString = classPathOption; + options[0].extraInfo = NULL; + options[1].optionString = awtOption; + options[1].extraInfo = NULL; + options[2].optionString = jlpOption; + options[2].extraInfo = NULL; + + memset(&args, 0, sizeof(args)); + args.version = JNI_VERSION_1_2; + args.nOptions = nOptions; + args.options = options; + args.ignoreUnrecognized = JNI_FALSE; + + r = JNI_CreateJavaVM(&m_vm, (void **)&m_env, &args); + if (r != JNI_OK) { + throw VMOpenException(); + } +} + +JavaVMSingleton::~JavaVMSingleton() +{ + if (instance) { + delete instance; + instance = NULL; + } + m_vm->DestroyJavaVM(); + if (awtOption) + delete[] awtOption; + if (classPathOption) + delete[] classPathOption; +} + +/*JavaVMSingleton* JavaVMSingleton::getInstance(const char* classPath) +{ + return getInstance(classPath, ""); +}*/ + +JavaVMSingleton* JavaVMSingleton::getInstance(const char* classPath, const char* javaLibPath) +{ +//#ifdef WIN32 +// // If pointer to instance of JavaVMSingleton exists (true) then return instance pointer else look for +// // instance pointer in memory mapped pointer. If the instance pointer does not exist in +// // memory mapped pointer, return a newly created pointer to an instance of Abc. + +// return instance ? +// instance : (instance = (JavaVMSingleton*) MemoryMappedPointers::getPointer("JavaVMSingleton")) ? +// instance : (instance = (JavaVMSingleton*) MemoryMappedPointers::createEntry("JavaVMSingleton",(void*)new JavaVMSingleton(classPath))); +//#else + + + // If pointer to instance of JavaVMSingleton exists (true) then return instance pointer + // else return a newly created pointer to an instance of JavaVMSingleton. + if (instance == NULL) + { + JavaVM *jvms; + jsize nVMs; + if ( JNI_GetCreatedJavaVMs(&jvms, 1, &nVMs)==0 ) + { + //std::cout << "Got JVMs " << nVMs << "\n"; std::cout.flush(); + if (nVMs == 1) + { + JavaVM *jvm = jvms; + JNIEnv *env; + if( jvm->AttachCurrentThread((void **)&env, NULL) ==0 ) + { + // if there is a jvm opened already by a diffrent dynamic lib + // make a singleton for this lib with that jvm + instance = new JavaVMSingleton(jvm, env); + } + } + } + + if (instance == NULL) + { + instance = new JavaVMSingleton(classPath, javaLibPath); + } + } + + return instance; +} + + + +JavaVMSingleton* JavaVMSingleton::getInstance(const zorba::StaticContext* aStaticContext) +{ + if (instance == NULL) + { + String cp = computeClassPath(aStaticContext); + String lp = computeLibPath(aStaticContext); + return getInstance(cp.c_str(), lp.c_str()); + } + + return instance; +} + +JavaVM* JavaVMSingleton::getVM() +{ + return m_vm; +} + +JNIEnv* JavaVMSingleton::getEnv() +{ + return m_env; +} + + +String JavaVMSingleton::computeClassPath(const zorba::StaticContext* aStaticContext) +{ + String cp; + + // get classpath from global Properties + PropertiesGlobal * properties = Zorba::getInstance(NULL)->getPropertiesGlobal(); + std::string globalClassPath; + properties->getJVMClassPath(globalClassPath); + cp += globalClassPath; + + std::vector<String> lCPV; + aStaticContext->getFullLibPath(lCPV); + + for (std::vector<String>::iterator lIter = lCPV.begin(); + lIter != lCPV.end(); ++lIter) + { + // verify it contains a jars dir + String jarsDir( *lIter ); + fs::append( jarsDir, "jars" ); + + if ( fs::get_type( jarsDir ) == fs::directory ) + { + fs::iterator itemIter( jarsDir ); + + while ( itemIter.next() ) + { + String itemFile( jarsDir ); + fs::append( itemFile, itemIter->name ); + if ( fs::get_type( itemFile ) == fs::file ) + { + std::string suffix = "-classpath.txt"; + size_t found; + found = itemFile.rfind(suffix); + if (found!=std::string::npos && + found + suffix.length() == itemFile.length() ) + { + std::unique_ptr<std::istream> pathFile; + pathFile.reset(new std::ifstream (itemFile.c_str ())); + if (!pathFile->good() || pathFile->eof() ) + { + std::cerr << "file {" << itemFile << "} not found or not readable." << std::endl; + throw itemFile; + } + + // read file + char line[1024]; + while( !pathFile->eof() && !pathFile->bad() && !pathFile->fail()) + { + pathFile->getline(line, sizeof(line)); + std::string lineStr(line); + + if ( lineStr.size() > 0 ) { + cp += fs::path_separator; + cp += fs::normalize_path( lineStr, jarsDir ); + } + } + } + } + } + } + } + + properties->setJVMClassPath(cp.str()); + + return cp; +} + + +String JavaVMSingleton::computeLibPath(const zorba::StaticContext* aStaticContext) +{ + String lp; + std::vector<String> lCPV; + + aStaticContext->getFullLibPath(lCPV); + for (std::vector<String>::iterator lIter = lCPV.begin(); + lIter != lCPV.end(); ++lIter) + { + String p( *lIter ); + lp += fs::path_separator; + lp += p; + } + + return lp; +} + + +} // namespace jvm +} // namespace zorba +/* vim:set et sw=2 ts=2: */ === added file 'src/util-jvm.cpp' --- src/util-jvm.cpp 1970-01-01 00:00:00 +0000 +++ src/util-jvm.cpp 2013-09-11 04:36:06 +0000 @@ -0,0 +1,87 @@ +/* + * Copyright 2006-2008 The FLWOR Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <zorba/diagnostic_list.h> +#include <zorba/empty_sequence.h> +#include <zorba/external_module.h> +#include <zorba/function.h> +#include <zorba/item_factory.h> +#include <zorba/serializer.h> +#include <zorba/singleton_item_sequence.h> +#include <zorba/user_exception.h> +#include <zorba/util/base64_util.h> +#include <zorba/vector_item_sequence.h> +#include <zorba/zorba.h> + +#include "JavaVMSingleton.h" + +#define UTILJVM_MODULE_NAMESPACE "http://www.zorba-xquery.com/modules/util-jvm" +#define UTILJVM_OPTIONS_NAMESPACE "http://www.zorba-xquery.com/modules/util-jvm/util-jvm-options" + +class JavaException { +}; + +#define CHECK_EXCEPTION(env) if ((lException = env->ExceptionOccurred())) throw JavaException() + +namespace zorba +{ + namespace utiljvm + { + + class UtilJvmModule; + + class UtilJvmModule : public ExternalModule { + private: + + public: + UtilJvmModule() {} + + virtual ~UtilJvmModule() + {} + + virtual String getURI() const + { + return UTILJVM_MODULE_NAMESPACE; + } + + virtual ExternalFunction* + getExternalFunction(const String& localName); + + virtual void destroy() + { + delete this; + } + }; + + + ExternalFunction* + UtilJvmModule::getExternalFunction(const String& localName) + { + return 0; + } + + }}; // namespace zorba, utiljvm + +#ifdef WIN32 +# define DLL_EXPORT __declspec(dllexport) +#else +# define DLL_EXPORT __attribute__ ((visibility("default"))) +#endif + +extern "C" DLL_EXPORT zorba::ExternalModule* createModule() +{ + return new zorba::utiljvm::UtilJvmModule(); +} === added file 'src/util-jvm.xq' --- src/util-jvm.xq 1970-01-01 00:00:00 +0000 +++ src/util-jvm.xq 2013-09-11 04:36:06 +0000 @@ -0,0 +1,40 @@ +xquery version "1.0"; + +(: + : Copyright 2006-2009 The FLWOR Foundation. + : + : Licensed under the Apache License, Version 2.0 (the "License"); + : you may not use this file except in compliance with the License. + : You may obtain a copy of the License at + : + : http://www.apache.org/licenses/LICENSE-2.0 + : + : Unless required by applicable law or agreed to in writing, software + : distributed under the License is distributed on an "AS IS" BASIS, + : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + : See the License for the specific language governing permissions and + : limitations under the License. + :) + +(:~ + : This module provides common functionality for modules that use java + : implementations. + : <br/> + : <br/> + : Modules using java implementations must import this module + : to specify the dependency. + : <br /> + : <br /> + : <b>Note:</b> Since this module has a Java library dependency a JVM is required + : to be installed on the system. For Windows: jvm.dll is required on the system + : path (usually located in "C:\Program Files\Java\jre\bin\client"). + : + : @author Cezar Andrei + : @library <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK - Java Development Kit</a> + : @project Zorba/JVM Utility + :) +module namespace util-jvm = "http://www.zorba-xquery.com/modules/util-jvm"; + +declare namespace ver = "http://zorba.io/options/versioning"; +declare option ver:module-version "1.0"; +
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp