// Path: osgi.enroute.examples.plugin.application/src/osgi/enroute/examples/plugin/api/Product.java
// public class Product extends DTO {
// 	public String	supplier;
// 	public String	id;
// 	public String	name;
// 	public String	description;
// 	public long		price;
// 	public int		inStock;
// 	public int		deliveryTimeInDays;
// }
// 
// Path: osgi.enroute.examples.plugin.application/src/osgi/enroute/examples/plugin/api/SupplierPlugin.java
// public interface SupplierPlugin {
//     Set<Product> findProducts( String query );
//     boolean buy( String id);
//     String getSupplierId();
// }


import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.configurer.api.RequireConfigurerExtender;
import osgi.enroute.examples.plugin.api.Product;
import osgi.enroute.examples.plugin.api.SupplierPlugin;
import osgi.enroute.google.angular.capabilities.RequireAngularWebResource;
import osgi.enroute.rest.api.REST;
import osgi.enroute.twitter.bootstrap.capabilities.RequireBootstrapWebResource;
import osgi.enroute.webserver.capabilities.RequireWebServerExtender;
package osgi.enroute.examples.plugin.application;




@RequireAngularWebResource(resource = { "angular.js", "angular-resource.js", "angular-route.js" }, priority = 1000)
@RequireBootstrapWebResource(resource = "css/bootstrap.css")
@RequireWebServerExtender
@RequireConfigurerExtender
@Component(name = "osgi.enroute.examples.plugin")
public class OrderApplication implements REST {

	@Reference
	volatile List<SupplierPlugin> suppliers;

	public List<Product> getFind(String query) {
		return suppliers.stream().flatMap(supplier -> supplier.findProducts(query).stream())
// Path: osgi.enroute.examples.plugin.application/src/osgi/enroute/examples/plugin/api/Product.java
// public class Product extends DTO {
// 	public String	supplier;
// 	public String	id;
// 	public String	name;
// 	public String	description;
// 	public long		price;
// 	public int		inStock;
// 	public int		deliveryTimeInDays;
// }
// 
// Path: osgi.enroute.examples.plugin.application/src/osgi/enroute/examples/plugin/api/SupplierPlugin.java
// public interface SupplierPlugin {
//     Set<Product> findProducts( String query );
//     boolean buy( String id);
//     String getSupplierId();
// }


// Path: osgi.enroute.examples.plugin.application/src/osgi/enroute/examples/plugin/application/OrderApplication.java
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import osgi.enroute.configurer.api.RequireConfigurerExtender;
import osgi.enroute.examples.plugin.api.Product;
import osgi.enroute.examples.plugin.api.SupplierPlugin;
import osgi.enroute.google.angular.capabilities.RequireAngularWebResource;
import osgi.enroute.rest.api.REST;
import osgi.enroute.twitter.bootstrap.capabilities.RequireBootstrapWebResource;
import osgi.enroute.webserver.capabilities.RequireWebServerExtender;

package osgi.enroute.examples.plugin.application;




@RequireAngularWebResource(resource = { "angular.js", "angular-resource.js", "angular-route.js" }, priority = 1000)
@RequireBootstrapWebResource(resource = "css/bootstrap.css")
@RequireWebServerExtender
@RequireConfigurerExtender
@Component(name = "osgi.enroute.examples.plugin")
public class OrderApplication implements REST {

	@Reference
	volatile List<SupplierPlugin> suppliers;

	public List<Product> getFind(String query) {
		return suppliers.stream().flatMap(supplier -> supplier.findProducts(query).stream())
				.sorted((a, b) -> Long.compare(a.price, b.price)).collect(Collectors.toList());