✨
This commit is contained in:
58
Assignment-3/buyer-compare.ol
Normal file
58
Assignment-3/buyer-compare.ol
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
from SellerShipperServiceInterfaceModule import SellerInterface
|
||||||
|
from BuyerServiceInterfaceModule import BuyerShipperInterface, BuyerSellerInterface
|
||||||
|
|
||||||
|
include "console.iol"
|
||||||
|
|
||||||
|
service BuyerService {
|
||||||
|
execution { single }
|
||||||
|
|
||||||
|
outputPort Seller1 {
|
||||||
|
location: "socket://localhost:9005"
|
||||||
|
protocol: http { format = "json" }
|
||||||
|
interfaces: SellerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
outputPort Seller2 {
|
||||||
|
location: "socket://localhost:9007"
|
||||||
|
protocol: http { format = "json" }
|
||||||
|
interfaces: SellerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
inputPort ShipperBuyer {
|
||||||
|
location: "socket://localhost:9003"
|
||||||
|
protocol: http { format = "json" }
|
||||||
|
interfaces: BuyerShipperInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
inputPort SellerBuyer {
|
||||||
|
location: "socket://localhost:9004"
|
||||||
|
protocol: http { format = "json" }
|
||||||
|
interfaces: BuyerSellerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
main {
|
||||||
|
ask@Seller1("chips")
|
||||||
|
[quote(price1)]
|
||||||
|
ask@Seller2("chips")
|
||||||
|
[quote(price2)]
|
||||||
|
if (price1 < 20 && price1 < price2) {
|
||||||
|
println@Console( "price 1 lower than 20 and price 2")()
|
||||||
|
accept@Seller1("Ok to buy chips for " + price1)
|
||||||
|
reject@Seller2("Not ok to buy chips for " + price2)
|
||||||
|
[details(invoice)]
|
||||||
|
println@Console( "Received '"+invoice+"' from Shipper!")()
|
||||||
|
} else if (price2 < 20 && price2 < price1) {
|
||||||
|
println@Console( "price 2 lower than 20 and price 1")()
|
||||||
|
reject@Seller1("Not ok to buy chips for " + price1)
|
||||||
|
accept@Seller2("Ok to buy chips for " + price2)
|
||||||
|
[details(invoice)]
|
||||||
|
println@Console( "Received '"+invoice+"' from Shipper!")()
|
||||||
|
} else {
|
||||||
|
println@Console( "Both prices too high")()
|
||||||
|
reject@Seller1("Not ok to buy chips for " + price)
|
||||||
|
reject@Seller2("Not ok to buy chips for " + price)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ service BuyerService {
|
|||||||
execution { single }
|
execution { single }
|
||||||
|
|
||||||
outputPort Seller {
|
outputPort Seller {
|
||||||
location: "socket://localhost:9005"
|
location: "socket://localhost:9007"
|
||||||
protocol: http { format = "json" }
|
protocol: http { format = "json" }
|
||||||
interfaces: SellerInterface
|
interfaces: SellerInterface
|
||||||
}
|
}
|
||||||
|
41
Assignment-3/seller2.ol
Normal file
41
Assignment-3/seller2.ol
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from BuyerServiceInterfaceModule import BuyerSellerInterface
|
||||||
|
from SellerShipperServiceInterfaceModule import SellerInterface, ShipperInterface
|
||||||
|
|
||||||
|
include "console.iol"
|
||||||
|
|
||||||
|
service SellerService {
|
||||||
|
execution { concurrent }
|
||||||
|
|
||||||
|
outputPort Buyer {
|
||||||
|
Location: "socket://localhost:9004"
|
||||||
|
Protocol: http { format = "json" }
|
||||||
|
Interfaces: BuyerSellerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
outputPort Shipper {
|
||||||
|
Location: "socket://localhost:9006"
|
||||||
|
Protocol: http { format = "json" }
|
||||||
|
Interfaces: ShipperInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
inputPort BuyerSeller {
|
||||||
|
location: "socket://localhost:9007"
|
||||||
|
protocol: http { format = "json" }
|
||||||
|
interfaces: SellerInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
[ask(product)] {
|
||||||
|
println@Console( "Price requested" )()
|
||||||
|
quote@Buyer(20)
|
||||||
|
}
|
||||||
|
[accept(order)] {
|
||||||
|
println@Console( "Accepted" )()
|
||||||
|
order@Shipper(order)
|
||||||
|
}
|
||||||
|
[reject(order)] {
|
||||||
|
println@Console( "Rejected" )()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user