protected void initDatatypes(List<Element> datatypeElements) { loadDatatypesFromClasspathResource(); for (Element datatypeEl : datatypeElements) { String id = datatypeEl.attributeValue("id"); String className = datatypeEl.attributeValue("class"); if (Strings.isNullOrEmpty(className)) throw new IllegalStateException("Missing required 'class' attribute for datatype " + id + ". Check your metadata.xml file."); if (Strings.isNullOrEmpty(id)) throw new IllegalStateException("Missing required 'id' attribute for datatype " + className + ". Check your metadata.xml file."); try { Datatype datatype; Class<Datatype> datatypeClass = ReflectionHelper.getClass(className); try { Constructor<Datatype> constructor = datatypeClass.getConstructor(Element.class); datatype = constructor.newInstance(datatypeEl); } catch (Throwable e) { datatype = datatypeClass.newInstance(); } datatypeRegistry.register(datatype, id, Boolean.valueOf(datatypeEl.attributeValue("default"))); } catch (Throwable e) { log.error("Fail to load datatype '{}'", className, e); } } }
if (Strings.isNullOrEmpty(id)) id = guessDatatypeId(datatype); datatypeRegistry.register(datatype, id, true); } catch (Throwable e) { log.error(String.format("Fail to load datatype '%s'", datatypeClassName), e);