S2Remoting
スペックリーダーらしいので少しは仕事を.
まずはクライアントサイドで利用するインターセプタに関して抽象クラスを用意しましょうということで,こんな感じでいかがでしょうか?
まずはリモート呼び出しを行うインターセプタの抽象基底クラス.
package org.seasar.remoting.interceptors; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import org.aopalliance.intercept.MethodInvocation; import org.seasar.framework.aop.interceptors.AbstractInterceptor; public abstract class AbstractRemoteInterceptor extends AbstractInterceptor { public Object invoke(final MethodInvocation invocation) throws Throwable { final Method method = invocation.getMethod(); if (Modifier.isAbstract(method.getModifiers())) { return invokeRemoteMethod(invocation); } else { return invocation.proceed(); } } protected abstract Object invokeRemoteMethod(MethodInvocation invocation) throws Throwable; }
その派生クラスで,URL を指定できるもの.
package org.seasar.remoting.interceptors; import java.net.MalformedURLException; import java.net.URL; public abstract class URLBasedRemoteInterceptor extends AbstractRemoteInterceptor { private URL url; public URL getURL() { return url; } public void setURL(final URL url) { this.url = url; } public void setURL(final String url) throws MalformedURLException { setURL(new URL(url)); } }
getURL()
よりも getUrl()
の方がいいですかねぇ? Spring は getUrl()
.でも Java 的には getURL()
の方をよく見かける気がします.
ちなみに getURL
だと dicon に書くときは
<property name="URL">〜</property>
というようにプロパティ名が大文字の URL
になっちゃうんですよね.どっちがいいかご意見よろしくです〜.
それから,setURL(String)
も定義してみたら,セッター・インジェクションでプロパティに設定できなくなっちゃいました.一つのプロパティに setter が複数あるのはイレギュラーという気もしますが,できれば一番マッチする型の setter が呼び出されるとうれしいんですけどねぇ.無理?>ひがさん
無理だったらせめて例外を飛ばすか警告メッセージでも出して欲しいかも.今はプロパティに設定されないだけで何も通知されないみたいなので.
toString
とかは、Interceptor
で気の利いた文字列を作ってあげたほうがいいのかなぁ。
なーんと,toString() なんかには Aspect を適用できないことが判明.ポイントカットに .*
を指定しても適用されないし,toString
って指定すると NoSuchMethodException
が飛んできました.hashCode()
なんかも同じ.そういうものだったのか...
ってことは,toString()
なんかがリモート呼び出しされるとか心配する必要はなかったわけですね... 心より恥じる.
ともあれ (JW),上のようなクラス二つですが,これを S2Remoting としてリリースします? それともこれだけだったら S2 本体 (Extension) に入れてもらうのもありのような.
あと,S2Remoting というのは RMI のサポートを含むんでしょうか? それともそれは S2RMI とか別物とする?
「S2Remoting」をちゃんと分かってないダメダメなスペックリーダーです... 無念だ.