I'm extending the Broadleaf API Wrappers for REST 'CRUD' calls. For this I need to implement several 'unwrap' methods. (First use-case is a Product import feature, that creates a Product entity based on the incoming ProductWrapper on a POST/PUT REST call.)
The problem I have is, how to properly extend the base Wrappers. I have implemented a new Bean that extends the base wrapper, but due to JAXB processing the Child fields always refer to the original implementation.
For example:
Code: Select all
@XmlRootElement(name = "product")
@XmlAccessorType(value = XmlAccessType.FIELD)
public class ProductWrapper extends BaseWrapper implements APIWrapper<Product> {
@XmlElement
protected ProductSummaryWrapper productSummary;
....
}
In this particular case there is no way to override ProductSummaryWrapper for a custom wrapper that can use this field to 'unwrap'. This wouldn't be such a problem, when the the field access wasn't 'protected'. Now I don't see a solution to implement a proper 'unwrap'.
Ofcourse I can't cast this productSummary to a custom Wrapper class. (ClassCastException), but I do need the internals to properly construct a Product.
The only solution I see now is to change the Broadleaf Core so the field access is from protected -> public to access the internals. (Id, description, etc).
Maybe I'm missing something I can do to properly extend the Wrappers, without modifying the Broadleaf core?
Thanks in advance,
Sander