本文整理汇总了Java中reactor.core.publisher.Flux.fromIterable方法的典型用法代码示例。如果您正苦于以下问题:Java Flux.fromIterable方法的具体用法?Java Flux.fromIterable怎么用?Java Flux.fromIterable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.publisher.Flux
的用法示例。
在下文中一共展示了Flux.fromIterable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEmployeesByDescAge
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> readEmployeesByDescAge() {
Scheduler subWorker = Schedulers.newSingle("sub-thread");
Scheduler pubWorker = Schedulers.newSingle("pub-thread");
Supplier<Flux<Employee>> deferredTask = ()->{
System.out.println("flux:defer task executor: "+ Thread.currentThread().getName());
System.out.println("flux:defer task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
return Flux.fromIterable(employeeDaoImpl.getEmployees());
};
Comparator<Employee> descAge = (e1, e2) -> {
System.out.println("flux:sort task executor: " + Thread.currentThread().getName());
System.out.println("flux:sort task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
if(e1.getAge().compareTo(e2.getAge()) == 0){
return 0;
} else if(e1.getAge().compareTo(e2.getAge()) > 0){
return -1;
} else return 1;
};
Flux<Employee> deferred = Flux.defer(deferredTask).sort(descAge).subscribeOn(subWorker).publishOn(pubWorker);
return deferred;
}
示例2: readEmployeesFlux
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> readEmployeesFlux(int age) {
Scheduler subWorker = Schedulers.newSingle("sub-thread");
Scheduler pubWorker = Schedulers.newSingle("pub-thread");
Predicate<Employee> validAge = (e) -> {
System.out.println("flux:filter task executor: " + Thread.currentThread().getName());
System.out.println("flux:filter task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
return e.getAge() > age;
};
Supplier<Flux<Employee>> deferredTask = ()->{
System.out.println("flux:defer task executor: " + Thread.currentThread().getName());
System.out.println("flux:defer task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
return Flux.fromIterable(employeeDaoImpl.getEmployees());
};
Flux<Employee> deferred = Flux.defer(deferredTask).filter(validAge).subscribeOn(subWorker).publishOn(pubWorker);
return deferred;
}
示例3: createPubAndMain
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> createPubAndMain() {
Scheduler pubWorker = Schedulers.newSingle("pub-thread");
Predicate<Employee> validAge = (e) -> {
System.out.println("filter thread " +Thread.currentThread().getName());
return e.getAge() > 25;
};
Supplier<Flux<Employee>> deferredTask = ()->{
System.out.println("defer thread "+Thread.currentThread().getName());
return Flux.fromIterable(employeeDaoImpl.getEmployees());
};
Flux<Employee> deferred = Flux.defer(deferredTask).publishOn(pubWorker).filter(validAge);
return deferred;
}
示例4: createPublisherThread
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> createPublisherThread() {
Scheduler pubWorker = Schedulers.newSingle("pub-thread");
Predicate<Employee> validAge = (e) -> {
System.out.println("filter thread " +Thread.currentThread().getName());
return e.getAge() > 25;
};
Supplier<Flux<Employee>> deferredTask = ()->{
System.out.println("defer thread "+Thread.currentThread().getName());
return Flux.fromIterable(employeeDaoImpl.getEmployees());
};
Flux<Employee> deferred = Flux.defer(deferredTask).filter(validAge).publishOn(pubWorker);
return deferred;
}
示例5: fooBarFluxFromValues
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<String> fooBarFluxFromValues() {
return Flux.fromIterable(Arrays.asList("foo", "bar"));
}
示例6: findAll
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<Post> findAll() {
return Flux.fromIterable(data.values());
}
示例7: selectReactDepts
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping("/selectReactDepts")
public Flux<Department> selectReactDepts() {
return Flux.fromIterable(departmentServiceImpl.findAllDepts());
}
示例8: exposeJpaUsers
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping("/fluxJpaUsers")
public Flux<UserDetails> exposeJpaUsers() {
return Flux.fromIterable(userdetailsServiceImpl.findAllUserdetails());
}
示例9: findAll
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<Post> findAll() {
return Flux.fromIterable(DATA);
}
示例10: loginDetailsList
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> loginDetailsList(ServerRequest req) {
Flux<LoginDetails> flux = Flux.fromIterable(logindetailsServiceImpl.findAllLogindetails());
return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, LoginDetails.class);
}
示例11: empList
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> empList(ServerRequest req) {
Flux<Employee> flux = Flux.fromIterable(employeeServiceImpl.findAllEmps());
return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, Employee.class);
}
示例12: deptList
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> deptList(ServerRequest req) {
Flux<Department> flux = Flux.fromIterable(departmentServiceImpl.findAllDepts());
return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, Department.class);
}
示例13: userDetailsList
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> userDetailsList(ServerRequest req) {
Flux<UserDetails> flux = Flux.fromIterable(userdetailsServiceImpl.findAllUserdetails());
return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, UserDetails.class);
}
示例14: chooseUserByLastName
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> chooseUserByLastName(ServerRequest req) {
Flux<UserDetails> flux = Flux.fromIterable(userdetailsServiceImpl.findUserByLastname(req.pathVariable("lname")));
return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, UserDetails.class)
.switchIfEmpty(ServerResponse.notFound().build());
}