Upload
neoworks
View
222
Download
4
Embed Size (px)
Citation preview
Omni Commerce: From Buzzword to Technology Jürgen Albertsen Enterprise Architect hybris
Commerce is Everywhere
TV
Console
Web
POS
Mobile
Call Center
Social
Digital Ads Marketplace
Mobile Native
A Few Examples
TV Mobile + + = Live stream, shop as you
watch
Mobile
+ = Want this, alert me when near shop
Product
Product
Checkout
Location
POS + = Not available in store,
deliver to home Product Checkout
We call it Multi Channel
No, Omni Channel
No, Omni Commerce
Nice word but: How to do it?
The solution: Web Services of course
The Problem: hybris is pretty old mature
Core Services
Core / Jalo
Over the Years We Stacked up Quite a Stack
Commerce Services
Commerce Façades
Accelerator (Web Storefront) OCC (Web Services)
Let’s Zoom In
Controller
Converter
Service
Façade
DTO
Model
Populator
A DTO
public class CartData implements Serializable { ! private String code; private boolean net; private PriceData totalPrice; //... public String getCode() { return code; } public void setCode(String code) { this.code = code; } ! //... }
A Descriptor for DTOs
<bean class="de.hybris.platform.commercefacades.order.CartData"> <property name="code" type="String"/> <property name="net" type="boolean"/> <property name="totalPrice" type="de.hybris.platform.commercefacades.product.PriceData"/> <!-- ... --> </bean>
A Façade
public interface CartFacade { ! CartData getSessionCart(); ! CartData getMiniCart(); ! CartModificationData addToCart(String code, long quantity) throws CommerceCartModificationException; ! // ... !}
A Controller for the Storefront
@Controller public class AddToCartController extends AbstractController { @Resource(name = "cartFacade") private CartFacade cartFacade; ! @RequestMapping(value = "/cart/add", method = RequestMethod.POST) public String addToCart(@RequestParam("productCodePost") String code, Model model, @Valid AddToCartForm form, BindingResult bindingErrors) { // ... CartModificationData cartModification = cartFacade.addToCart(code, qty); if (cartModification.getQuantityAdded() == 0L) { model.addAttribute(ERROR_MSG_TYPE, "basket.information.quantity.noItemsAdded." + cartModification.getStatusCode()); } else if (cartModification.getQuantityAdded() < qty) { model.addAttribute(ERROR_MSG_TYPE, "basket.information.quantity.reducedNumberOfItemsAdded." + cartModification.getStatusCode()); } // .. } }
Spring MVC doesn’t care if it’s HTML, XML, JSON, or whatever
Another Controller — this Time for a Web Service
@Controller public class CartController extends BaseController { @Resource(name = "cartFacade") private CartFacade cartFacade; ! @RequestMapping(value = "/entry", method = RequestMethod.POST) @ResponseBody public CartModificationData addToCart(@RequestParam(required = true) String code, @RequestParam(required = false, defaultValue = "1") long qty) throws CommerceCartModificationException { return cartFacade.addToCart(code, qty); } !}
Marshal Response DTOs to XML/JSON
<!-- from springmvc-servlet.xml --> !<mvc:annotation-driven> <mvc:message-converters register-defaults="false"> <bean parent="resolverXStreamJSONConverter"/> <bean parent="resolverXStreamXmlConverter"/> </mvc:message-converters> </mvc:annotation-driven>
We expose commerce logic and data model 1:1
What Else?
REST-like
ETag
OAuth 2.0 & HTTPS
Template
Shipped as source
Questions? Beer?