Escolar Documentos
Profissional Documentos
Cultura Documentos
Commerceservices and
Commercefacades
6/3/2013
commerceservices
commerceservices extension
CartService (platformservices)
public ... addToCart(...){...}
summary
more concise product description (e.g. in search)
galleryImages
storing multiple images each resized to a number of
standard formats expected by the storefront
6/3/2013
commercefacades extension
commercefacades extension
Data Objects
6/3/2013
Converter
Populator
Interface for a populator that sets values in a target
instance based on values in the source instance
Type conversion is typically broken down into a pipeline of
Population steps
Configurable Populators
Interface for a Populator that uses a collection of options to
control what data is populated
facades
some Service
some
some
Storefront
facade
Controller
user
15. view
services
3. invoke
business service
2. invoke
business action
1. request
6. model(s)
5. model(s)
4. find
model(s)
some Data
Access Object
{model to
convert to
data object}
13. data
object
7.
convert
model
some Converter
9. invoke
business service
another Service
{more populators}
8. populate
data object
11.
model(s)
10. find
model(s)
some Populator
12. model(s)
another Data
Access Object
6/3/2013
Implementing classes
i
Converter
AbstractConverter
AbstractPopulatingConverter
0..*
populators
1..*
populators
Populator
i
ConfigurablePopulator
DefaultConfigurablePopulator
Converters
AbstractConverter:
Base implementation which can be used as a converter and a populator
Recommended to use Spring lookup-method for createTarget
10
yacceleratorfacadesspring.xml
<alias name="defaultDeliveryModeConverter"
alias="deliveryModeConverter"/>
id="defaultDeliveryModeConverter"
parent="abstractPopulatingConverter">
<lookupmethod name="createTarget" bean="deliveryModeData"/>
<property name="populators">
<list>
<ref bean="deliveryModePopulator"/>
</list>
</property>
</bean>
<bean
6/3/2013
11
How to hook properly into the type conversion to not rewrite the
basic code or overwrite existing converters?
modifyPopulatorList to modify existing populator lists
defined in commerceservicesspring.xml
Processed by BeanPostProcessor
foofacadesspring.xml
<bean parent="modifyPopulatorList">
<property name="list" ref="productConverter"/>
<property name="add" ref="fooProductPopulator"/>
</bean>
12
How to hook properly into the type conversion with extended types?
<itemtype code=FooProductextends=Product...
<attribute qualifier=bartype=java.lang.String...
Solution 1
Write custom converter by extending the base type converter
Decide at call level (Controller) which converter should be used
Solution 2
Merge new attributes in ProductData (base type DTO)
Add additional populator to modifyPopulatorList
Populator must do an instance check on source type
6/3/2013
13