summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process/module/ModuleScript.java
blob: f16f3909c54a57bd2998aa09d1506f1e047c7a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.c2kernel.process.module;

import com.c2kernel.entity.proxy.AgentProxy;
import com.c2kernel.scripting.Script;
import com.c2kernel.scripting.ScriptingEngineException;

public class ModuleScript {


	public String target;
	public String event;
	public String lang;
	public String script;
	public ModuleScript() {
	}
	
	public ModuleScript(String target, String event, String lang, String script) {
		super();
		this.target = target;
		this.event = event;
		this.lang = lang;
		this.script = script;
	}
	
	public Script getScript(String ns, AgentProxy user) throws ScriptingEngineException {
        return new Script(lang, ns+" "+target+" "+event, script, user);
	}

	public boolean shouldRun(String event, boolean isServer) {
		return ((this.target == null || this.target.length() == 0 || isServer == target.equals("server")) && 
				(this.event == null || this.event.length() == 0 || event.equals(this.event)));
	}
}