Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
DataBinder, based on the DD4T 2 Java pattern, to get other types of pages from SDL
public interface CustomDataBinder {
<T extends Sitemap> T buildSitemap(String source, final Class<T> aClass) throws SerializationException;
public class CustomDataBinderImpl implements CustomDataBinder {
private static final Logger LOG = LoggerFactory.getLogger(CustomDataBinderImpl.class);
private static final ObjectMapper GENERIC_MAPPER = new ObjectMapper();
static {
GENERIC_MAPPER.registerModule(new JodaModule());
GENERIC_MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
private static final CustomDataBinderImpl INSTANCE = new CustomDataBinderImpl();
private CustomDataBinderImpl () {"CustomDataBinderImpl init.");
public static CustomDataBinderImpl getInstance () {
if (null == INSTANCE) {
LOG.error("DataBinderImpl not properly instantiated!");
return INSTANCE;
public <T extends Sitemap> T buildSitemap(String source, final Class<T> aClass) throws SerializationException {
try {
return GENERIC_MAPPER.readValue(source, aClass);
} catch (IOException e) {
throw new SerializationException(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.