/*
 * Copyright 2012 The Clustermeister Team.
 *
 * 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.
 */
package com.github.nethad.clustermeister.provisioning.jppf;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 *
 * @author thomas
 */
public class JPPFNodeConfiguration {
    
    Properties properties = new Properties();

    public JPPFNodeConfiguration() {
        properties.setProperty("jppf.management.enabled", "true");
        properties.setProperty("jppf.discovery.enabled", "false");
        properties.setProperty("reconnect.max.time", "60");
        
        properties.setProperty("jppf.jvm.options", "-Xmx128m -Djava.util.logging.config.file=config/logging-driver.properties");
        properties.setProperty("jppf.classloader.delegation", "parent");
    }
    
    public JPPFNodeConfiguration setProperty(String key, String value) {
        properties.setProperty(key, value);
        return this;
    }
    
    public InputStream getPropertyStream() throws IOException {
//        System.out.println("READING CUSTOM CONFIGURATION, inputstream");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        properties.store(baos, "");
        return new ByteArrayInputStream(baos.toByteArray());
    }

	public String getProperty(String key) {
		return properties.getProperty(key);
	}
    
}

@@ -978,16 +978,23 @@
 tion() %7B
+       
 %0A       
@@ -1248,12 +1248,20 @@
 %22-Xm
-x
+s64m -Xmx5
 12
-8
 m -D
@@ -1395,24 +1395,106 @@
  %22parent%22);%0A
+        %0A//        properties.setProperty(%22jppf.classloader.cache.size%22, %221000%22);%0A
     %7D%0A    %0A 

change jvm memory options in node config class