//(1) Read the base mappings from the Yard
this.baseMapper = CacheUtils.loadBaseMappings(yard,nsPrefixService);
//(2) Init the additional mappings based on the configuration
Object mappings = context.getProperties().get(Cache.ADDITIONAL_MAPPINGS);
FieldMapper configuredMappings = null;
if (mappings instanceof String[] && ((String[]) mappings).length > 0) {
configuredMappings = new DefaultFieldMapperImpl(ValueConverterFactory.getDefaultInstance());
for (String mappingString : (String[]) mappings) {
FieldMapping fieldMapping = FieldMappingUtils.parseFieldMapping(mappingString, nsPrefixService);
if (fieldMapping != null) {
configuredMappings.addMapping(fieldMapping);
}
}
//check if there are valid mappings
if (configuredMappings.getMappings().isEmpty()) {
configuredMappings = null; //if no mappings where found set to null
}
}
FieldMapper yardAdditionalMappings = CacheUtils.loadAdditionalMappings(yard,nsPrefixService);
if (yardAdditionalMappings == null) {
if (configuredMappings != null) {
setAdditionalMappings(yard, configuredMappings);
}
} else if (!yardAdditionalMappings.equals(configuredMappings)) {
//this may also set the additional mappings to null!
log.info("Replace Additional Mappings for Cache " + yardId + "with Mappings configured by OSGI");
setAdditionalMappings(yard, configuredMappings);
} //else current config equals configured one -> nothing to do!
initWithYard = true;