我是 Tapestry5 用户,想知道如何使用一些参数 @Inject 服务类。据我了解,使用@Inject 注入服务类与使用 new MyClass(); 实例化一个类非常相似。我似乎遇到的问题是我不确定如何将参数传递到服务中。
例子
使用 Tapestry 服务
public class Main {
@Inject
private MyService myService;
public Main() {
//Where would I pass in my arguements?
this.myService();
//I can't seem to do this by passing the arg's in through
//this.myService(arg1, arg2) unless I may be missing something.
}
}
传统用法
public class Main {
public Main() {
//In this example I can pass my arg's into the constructor.
MyService myService = new MyService(arg1, arg2);
}
}