1
私はMethod Replacerに遭遇し、Method Replacer for Finalメソッドを使用できるかどうかを知りたいと思っています。ここ最終メソッドのSpringメソッドの置き換え
コードである:ここ
public class FriendlyImpl implements Friendly {
public void sayHello(String name) {
System.out.println("Hello "+ name);
}
}
はメソッド代替のためのコードである:ここ
import java.lang.reflect.Method;
import org.springframework.beans.factory.support.MethodReplacer;
public class FriendlyReplacer implements MethodReplacer {
public Object reimplement(Object o, Method m, Object[] a)
throws Throwable {
System.out.println("Hola "+a[0]);
return null;
}
}
は
<beans>
<bean id="friendly"
class="com.habuma.wiring.FriendlyImpl">
<replaced-method name="sayHello" replacer="friendlyReplacer">
<arg-type>String</arg-type>
</replaced-method>
</bean>
<bean id="friendlyReplacer"
class="com.habuma.wiring.FriendlyReplacer"/>
</beans>
春は、メソッドを見つけるためにリフレクションを使用します(プライベートメソッドも)。また、それらの最終的なメソッドにアクセスできる必要があります。まだ回答を求めている人 –
誰でもコメントできますか? –