用意したインターセプトのバインドは、難しくない。
先日のFtpInterceptorコンストラクタに対象Class変数を渡す方法はあまりよくないかも知れないが、
とりあえず、以下のとおり。
import com.google.inject.AbstractModule;
import com.google.inject.matcher.Matchers;
public class SampletModule extends AbstractModule{
/*
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure(){
// インターセプトされる対象クラスのバインド定義も書いた上で。。。
binder().bindInterceptor(Matchers.any()
,FtpInterceptMatcher.annotatedWith(FtpMethod.class)
,new FtpInterceptor(対象の.class));
}
}
=================
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface FtpMethod{
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface FtpUser{
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface FTPClientDefine{
}