Updated RulesManager

This commit is contained in:
Andrea Cavalli 2018-03-22 15:54:06 +01:00
parent 4a53bb68b4
commit e49bb8ff62
3 changed files with 12 additions and 10 deletions

View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -1,5 +1,7 @@
package org.warp.picalculator.math.rules;
import java.io.Serializable;
import org.warp.picalculator.math.Function;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@ -10,7 +12,7 @@ import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
* @author Andrea Cavalli
*
*/
public interface Rule {
public interface Rule extends Serializable {
/**
* Get rule name
* @return

View File

@ -109,21 +109,21 @@ public class RulesManager {
}
}
if (!loadedFromCache) {
Rule r;
Rule r = null;
try {
r = compileJavaRule(scriptFile);
RulesManager.addRule(r);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Path p = Paths.get(compiledFile.replace("/", "_")).toAbsolutePath();
System.out.println(p);
p.toFile().createNewFile();
OutputStream fout = Files.newOutputStream(p, StandardOpenOption.CREATE);
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(script);
oos.writeObject(r);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}