• R/O
  • SSH
  • HTTPS

repserv: Commit


Commit MetaInfo

Revisão185 (tree)
Hora2016-03-02 22:07:33
Autornkoseki

Mensagem de Log

(mensagem de log vazia)

Mudança Sumário

Diff

--- trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/RepServScriptContext.java (nonexistent)
+++ trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/RepServScriptContext.java (revision 185)
@@ -0,0 +1,96 @@
1+package org.dyndns.nuda.repserv.scripting;
2+
3+import java.io.Reader;
4+import java.io.Writer;
5+import java.util.List;
6+
7+import javax.script.Bindings;
8+import javax.script.ScriptContext;
9+
10+public class RepServScriptContext implements ScriptContext {
11+
12+ @Override
13+ public void setBindings(Bindings bindings, int scope) {
14+ // TODO 自動生成されたメソッド・スタブ
15+
16+ }
17+
18+ @Override
19+ public Bindings getBindings(int scope) {
20+ // TODO 自動生成されたメソッド・スタブ
21+ return null;
22+ }
23+
24+ @Override
25+ public void setAttribute(String name, Object value, int scope) {
26+ // TODO 自動生成されたメソッド・スタブ
27+
28+ }
29+
30+ @Override
31+ public Object getAttribute(String name, int scope) {
32+ // TODO 自動生成されたメソッド・スタブ
33+ return null;
34+ }
35+
36+ @Override
37+ public Object removeAttribute(String name, int scope) {
38+ // TODO 自動生成されたメソッド・スタブ
39+ return null;
40+ }
41+
42+ @Override
43+ public Object getAttribute(String name) {
44+ // TODO 自動生成されたメソッド・スタブ
45+ return null;
46+ }
47+
48+ @Override
49+ public int getAttributesScope(String name) {
50+ // TODO 自動生成されたメソッド・スタブ
51+ return 0;
52+ }
53+
54+ @Override
55+ public Writer getWriter() {
56+ // TODO 自動生成されたメソッド・スタブ
57+ return null;
58+ }
59+
60+ @Override
61+ public Writer getErrorWriter() {
62+ // TODO 自動生成されたメソッド・スタブ
63+ return null;
64+ }
65+
66+ @Override
67+ public void setWriter(Writer writer) {
68+ // TODO 自動生成されたメソッド・スタブ
69+
70+ }
71+
72+ @Override
73+ public void setErrorWriter(Writer writer) {
74+ // TODO 自動生成されたメソッド・スタブ
75+
76+ }
77+
78+ @Override
79+ public Reader getReader() {
80+ // TODO 自動生成されたメソッド・スタブ
81+ return null;
82+ }
83+
84+ @Override
85+ public void setReader(Reader reader) {
86+ // TODO 自動生成されたメソッド・スタブ
87+
88+ }
89+
90+ @Override
91+ public List<Integer> getScopes() {
92+ // TODO 自動生成されたメソッド・スタブ
93+ return null;
94+ }
95+
96+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/EngineFactoryBuilder.java (nonexistent)
+++ trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/EngineFactoryBuilder.java (revision 185)
@@ -0,0 +1,16 @@
1+package org.dyndns.nuda.repserv.scripting;
2+
3+import javax.script.ScriptEngineFactory;
4+
5+public class EngineFactoryBuilder {
6+ private static ScriptEngineFactory FACTORY = null;
7+
8+ private EngineFactoryBuilder(){}
9+
10+ public static ScriptEngineFactory getInstance() {
11+ if(FACTORY == null) {
12+ FACTORY = new EngineFactory();
13+ }
14+ return FACTORY;
15+ }
16+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/Engine.java (revision 184)
+++ trunc/RepServ-Core-V2-20150902/scripting/org/dyndns/nuda/repserv/scripting/Engine.java (revision 185)
@@ -1,6 +1,8 @@
11 package org.dyndns.nuda.repserv.scripting;
22
33 import java.io.Reader;
4+import java.util.HashMap;
5+import java.util.Map;
46
57 import javax.script.Bindings;
68 import javax.script.ScriptContext;
@@ -7,6 +9,7 @@
79 import javax.script.ScriptEngine;
810 import javax.script.ScriptEngineFactory;
911 import javax.script.ScriptException;
12+import javax.script.SimpleBindings;
1013
1114 /**
1215 * RepServDSL用スクリプティングエンジンです
@@ -15,6 +18,12 @@
1518 */
1619 public class Engine implements ScriptEngine {
1720
21+ private ScriptContext ctx = null;
22+
23+ private Map<Integer, Bindings> bindingMap = new HashMap<Integer, Bindings>();
24+
25+ private Map<String, Object> bindingContextMap = new HashMap<String, Object>();
26+
1827 @Override
1928 public Object eval(String script, ScriptContext context)
2029 throws ScriptException {
@@ -55,50 +64,75 @@
5564
5665 @Override
5766 public void put(String key, Object value) {
58- // TODO 自動生成されたメソッド・スタブ
67+ if(key == null) {
68+ throw new NullPointerException("Parameter of [key] is null");
69+ }
70+ if(key.isEmpty()) {
71+ throw new IllegalArgumentException("Parameter of [key] is empty");
72+ }
5973
74+ this.bindingContextMap.put(key, value);
6075 }
6176
6277 @Override
6378 public Object get(String key) {
64- // TODO 自動生成されたメソッド・スタブ
65- return null;
79+ if(key == null) {
80+ throw new NullPointerException("Parameter of [key] is null");
81+ }
82+ if(key.isEmpty()) {
83+ throw new IllegalArgumentException("Parameter of [key] is empty");
84+ }
85+ return this.bindingContextMap.get(key);
6686 }
6787
6888 @Override
6989 public Bindings getBindings(int scope) {
70- // TODO 自動生成されたメソッド・スタブ
71- return null;
90+ if(!checkScope(scope)) {
91+ throw new IllegalArgumentException("Parameter of [scope] is invalid");
92+ }
93+ return this.bindingMap.get(scope);
7294 }
7395
7496 @Override
7597 public void setBindings(Bindings bindings, int scope) {
76- // TODO 自動生成されたメソッド・スタブ
77-
98+ if(bindings == null) {
99+ throw new NullPointerException("Parameter of [bindings] is null");
100+ }
101+ if(!checkScope(scope)) {
102+ throw new IllegalArgumentException("Parameter of [scope] is invalid");
103+ }
104+ this.bindingMap.put(scope, bindings);
78105 }
79106
80107 @Override
81108 public Bindings createBindings() {
82- // TODO 自動生成されたメソッド・スタブ
83- return null;
109+ return new SimpleBindings();
84110 }
85111
86112 @Override
87113 public ScriptContext getContext() {
88- // TODO 自動生成されたメソッド・スタブ
89- return null;
114+ return this.ctx;
90115 }
91116
92117 @Override
93118 public void setContext(ScriptContext context) {
94- // TODO 自動生成されたメソッド・スタブ
95-
119+ if(context == null) {
120+ throw new NullPointerException("Parameter of [context] is null");
121+ }
122+ this.ctx = context;
96123 }
97124
98125 @Override
99126 public ScriptEngineFactory getFactory() {
100- // TODO 自動生成されたメソッド・スタブ
101- return null;
127+ return EngineFactoryBuilder.getInstance();
102128 }
103129
130+ private boolean checkScope(int scope) {
131+ if(ScriptContext.ENGINE_SCOPE == scope) {
132+ return true;
133+ } else if(ScriptContext.GLOBAL_SCOPE == scope) {
134+ return true;
135+ }
136+ return false;
137+ }
104138 }
Show on old repository browser