Ejemplo n.º 1
0
bool SunJVMLauncher::setupVM(ResourceManager& resource, JVMBase* vm)
{
    //
    // create the properties array
    const vector<JavaProperty>& jprops = resource.getJavaProperties();
    for (int i=0; i<jprops.size(); i++)
    {
        vm->addProperty(jprops[i]);
    }

    if (resource.getProperty("maxheap") != "")
        vm->setMaxHeap( StringUtils::parseInt(resource.getProperty("maxheap") ));

    if (resource.getProperty("initialheap") != "")
        vm->setInitialHeap( StringUtils::parseInt(resource.getProperty("initialheap") ));

    if (resource.getProperty("vmparameter") != "")
        vm->setVmParameter( resource.getProperty("vmparameter") );

    if (resource.useEmbeddedJar())
    {
        std::string embj = resource.saveJarInTempFile();
        vm->addPathElement(embj);
    }

    std::string jnijar = resource.saveJnismoothInTempFile();
    if (jnijar != "")
        vm->addPathElement(jnijar);

    //
    // Define the classpath
    std::vector<std::string> classpath = resource.getNormalizedClassPathVector();
    for (int i=0; i<classpath.size(); i++)
    {
        vm->addPathElement(classpath[i]);
    }

    //
    // Defines the arguments passed to the java application
    //  vm->setArguments(resource.getProperty(ResourceManager::KEY_ARGUMENTS));
    std::vector<std::string> args = resource.getArguments();
    for (int i=0; i<args.size(); i++)
    {
        vm->addArgument(args[i]);
    }

    return true;
}