source: trunk/projects/jar2lib/src/main/resources/project-files/jtools/include/javaTools.h @ 7731

Revision 7731, 4.7 KB checked in by hinerm, 9 years ago (diff)

Fixes for ticket #298 and #654

Ticket #298 fixes:

  • search for a /jar subdirectory in working directory or provided classpath
  • all files in /jar are added to the classpath of the instantiated JVM

Ticket #654 fixes:

  • copying of project headers
  • copying of proxy headers
  • copying of jar dependencies to /jar
  • removal of loci_tool dependency
  • packaging improvements to remove full path references
Line 
1//
2// javaTools.h
3//
4
5/*
6OME Bio-Formats ITK plugin for calling Bio-Formats from the Insight Toolkit.
7Copyright (c) 2008-@year@, UW-Madison LOCI.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12    * Redistributions of source code must retain the above copyright
13      notice, this list of conditions and the following disclaimer.
14    * Redistributions in binary form must reproduce the above copyright
15      notice, this list of conditions and the following disclaimer in the
16      documentation and/or other materials provided with the distribution.
17    * Neither the name of the UW-Madison LOCI nor the
18      names of its contributors may be used to endorse or promote products
19      derived from this software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY UW-MADISON LOCI ''AS IS'' AND ANY
22EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24DISCLAIMED. IN NO EVENT SHALL UW-MADISON LOCI BE LIABLE FOR ANY
25DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32
33/*
34IMPORTANT NOTE: Although this software is distributed according to a
35"BSD-style" license, it requires the OME Bio-Formats Java library to do
36anything useful, which is licensed under the GPL v2 or later.
37As such, if you wish to distribute this software with Bio-Formats itself,
38your combined work must be distributed under the terms of the GPL.
39*/
40
41#include <string>
42#include <dirent.h>
43#include <iostream>
44#include "jace.h"
45#include "jace/JNIHelper.h"
46#include "jace/StaticVmLoader.h"
47#include "jace/JNIException.h"
48#include "jace/OptionList.h"
49
50using namespace std;
51
52/**
53 * JavaTools provides static helper methods used in more than one
54 * of the various BFITK plugin implementations.
55 */
56class JavaTools
57{
58  public:
59    typedef JavaTools      Self;
60
61    /**
62     * This method is used to instantiate a JVM with the following defaults:
63     * class path: working directory
64     * extra jars: none
65     * memory: 256MB
66     * headless: true
67     */
68    static void createJVM();
69
70    /**
71     * This method is used to instantiate a JVM with a custom class path.
72     */
73    static void createJVM(string jarlist);
74
75    /**
76     * This method is used to instantiate a JVM with custom memory specifications.
77     */
78    static void createJVM(int memory);
79
80    /**
81     * This method is used to instantiate a JVM with specified headless mode.
82     */
83    static void createJVM(bool headless);
84
85    /**
86     * This method is used to instantiate a JVM with a custom class path and
87     * memory specifications..
88     */
89    static void createJVM(string classdir, int memory);
90
91    /**
92     * This method is used to instantiate a JVM with a custom class path and
93     * specified headless mode.
94     */
95    static void createJVM(string classdir, bool headless);
96
97    /**
98     * This method is used to instantiate a JVM with extra jars and
99     * memory specifications..
100     */
101    static void createJVM(int memory, string jarlist);
102
103    /**
104     * This method is used to instantiate a JVM with extra jars and
105     * specified headless mode.
106     */
107    static void createJVM(bool headless, string jarlist);
108
109    /**
110     * This method is used to instantiate a JVM with a custom class path and
111     * additional jars.
112     */
113    static void createJVM(string classdir, string jarlist);
114
115    /**
116     * This method is used to instantiate a JVM with a custom class path,
117     * extra jars and custom memory specifications.
118     */
119    static void createJVM(string classdir, string jarlist, int memory);
120
121    /**
122     * This method is used to instantiate a JVM with a custom class path,
123     * extra jars and specified headless mode.
124     */
125    static void createJVM(string classdir, string jarlist, bool headless);
126
127    /**
128     * This method is the fundamental JVM creation method.
129     * classdir - specifies location of the core jar files, and extra jars (if present)
130     * jarlist - a ; separated list of additional jars to include in the JVM classpath.
131     *           jace-runtime.jar, loci_tools.jar and bio-formats.jar are always included.
132     * headless - whether to run headless or not
133     * memory - how much memory to instantiate the JVM with
134     */
135    static void createJVM(string classdir, string jarlist, bool headless, int memory);
136};
Note: See TracBrowser for help on using the repository browser.