-改めてSAO
S2SaoInterceptorの中核コード
public Object invoke(MethodInvocation invocation) throws Throwable { if(invocation == null) { throw new IllegalArgumentException(); } if(_scriptEngine == null) { throw new IllegalStateException(); } Method method = invocation.getMethod(); Class<?> sao = method.getDeclaringClass(); Object script = _scriptCache.get(sao); if(script == null) { script = _scriptEngine.compile(sao); _scriptCache.put(sio, script); } if(script != null && _scriptEngine.hasFunction(script, method)) { Object[] args = invocation.getArguments(); Class<?> expectedClass = method.getReturnType(); return _scriptEngine.invoke(script, method, args, expectedClass); } return invocation.proceed(); }
ScriptEngineインターフェイス
public interface ScriptEngine extends Serializable { Object compile(Class<?> sio) throws Exception; boolean hasFunction(Object script, Method method); Object invoke(Object script, Method method, Object[] args, Class<?> expectedClass) throws Exception; }
あとは、RhinoScriptEngineを実装する。まあ、私の脳内では出来た。
追記
戻りの型変換を忘れてたので、invokeの引数に戻り型を渡すようにしました。あとWrapFactoryとS2Containerのラッパーと。。。意外と作るものあったな。まあ、Mayaaから持ってきてちょっと直せばいいものが多いけど。
ListとMapがヤバイのでMayaaでの手当てをそのままコピペ。。。ほっほっほ。こういうのがノウハウというのだな。まあ、乱暴にもコピペなのだが。
再追記
では、これから接待飲みにでかけます。飲みすぎなければ今晩、飲みすぎてもやる気が出れば明日、そうでなければそれなりにリリースできるでしょう。見積もりであと0.5栗日です。