作成した修飾子を持つ複数のクラスがあります。
@ServiceComponent(restPath = "/trucks")
public class TruckService {
}
@ServiceComponent(restPath = "/cars")
public class CarService {
}
これが修飾子です(質問には重要ではありません)
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE, FIELD})
public @interface ServiceComponent {
public boolean exposeAsRest() default true;
@Nonbinding public String restPath() default "";
@Nonbinding public String restGetPrefix() default "get,find,all";
@Nonbinding public String restPostPrefix() default "create,new,post";
}
別のクラスでは、javax.enterprise.inject.Instance<> を使用してこれらのインスタンスを注入します
class SomeConfigurationClasss {
@Inject
@ServiceComponent()
Instance<Object> _restComponents;
@Override
public void iterate() throws Exception {
//iterate
for(Object obj : _restComponents){
somefuncion(obj);
}
//List.of(_restComponents)
//.flatMap(obj -> somefuncion(obj));
}
}
「通常の」反復を実行すると (...)、オブジェクト (TruckService または CarService) がパラメーターとして somefunction() に渡されます。
しかし、javaslang のList.of(...) を使用すると、インスタンス自体が取得されます。これは予想される動作だと思います
1 つまたは複数の Bean を含むことができるインスタンスで List.of を使用する可能性はありますか (インジェクション バインディングによって異なります)。(私はすでにインスタンスで iterator()、select() を呼び出そうとしています)