public MappingDefinition getDefinition(Class<?> clazz) {
return getDefinition(clazz.getName());
}
private void loadCustomMappings() {
MetaDataScanner scanner = ScannerSingleton.getOrCreateInstance();
for (Class<?> cls : scanner.getTypesAnnotatedWith(CustomMapping.class)) {
if (!MappingDefinition.class.isAssignableFrom(cls)) {
throw new RuntimeException("@CustomMapping class: " + cls.getName() + " does not inherit " + MappingDefinition.class.getName());
}
try {
MappingDefinition definition = (MappingDefinition) cls.newInstance();
definition.setMarshallerInstance(new DefaultDefinitionMarshaller(definition));
addDefinition(definition);
exposedClasses.add(definition.getMappingClass().asClass());
if (log.isDebugEnabled())
log.debug("loaded custom mapping class: " + cls.getName() + " (for mapping: "
+ definition.getMappingClass().getFullyQualifiedName() + ")");
if (cls.isAnnotationPresent(InheritedMappings.class)) {
InheritedMappings inheritedMappings = cls.getAnnotation(InheritedMappings.class);
for (Class<?> c : inheritedMappings.value()) {
MappingDefinition aliasMappingDef = new MappingDefinition(c, definition.alreadyGenerated());
aliasMappingDef.setMarshallerInstance(new DefaultDefinitionMarshaller(aliasMappingDef));
addDefinition(aliasMappingDef);
exposedClasses.add(c);
if (log.isDebugEnabled())
log.debug("mapping inherited mapping " + c.getName() + " -> " + cls.getName());
}
}
}
catch (Throwable t) {
throw new RuntimeException("Failed to load definition", t);
}
}
for (MappingDefinition def : MAPPING_DEFINITIONS.values()) {
mergeDefinition(def);
}
Set<Class<?>> marshallers = scanner.getTypesAnnotatedWith(ClientMarshaller.class);
for (Class<?> marshallerCls : marshallers) {
if (Marshaller.class.isAssignableFrom(marshallerCls)) {
try {
Class<?> type = (Class<?>) Marshaller.class.getMethod("getTypeHandled").invoke(marshallerCls.newInstance());