use of com.sun.jdo.api.persistence.mapping.ejb.AbstractNameMapper in project Payara by payara.
the class MappingGenerator method writeSunCmpMappingFile.
/**
* Writes to sun-cmp-mappings.xml from mappings classes
* @param mappingClasses a set of mapping classes
* @param cmpMappingFile corresponds to sun-cmp-mappings.xml
* @throws IOException
* @throws ConversionException
* @throws Schema2BeansException
*/
private void writeSunCmpMappingFile(Set mappingClasses, File cmpMappingFile) throws IOException, ConversionException, Schema2BeansException {
// Construct the input to MappingFile.fromMappingClasses(): a Map
// object containing ejbName and MappingClassElement. Use the
// elements of iteration and NameMapper to create the input for
// MappingFile.
Map mappingMap = new HashMap();
AbstractNameMapper nameMapper = getNameMapper();
Iterator iter = mappingClasses.iterator();
while (iter.hasNext()) {
MappingClassElement mappingClass = (MappingClassElement) iter.next();
String ejbName = nameMapper.getEjbNameForPersistenceClass(mappingClass.getName());
mappingMap.put(ejbName, mappingClass);
}
MappingFile mf = new MappingFile();
OutputStream sunCmpMapping = null;
try {
sunCmpMapping = new FileOutputStream(cmpMappingFile);
mf.fromMappingClasses(sunCmpMapping, mappingMap, getConversionHelper());
} catch (IOException ex) {
throw ex;
} finally {
try {
if (sunCmpMapping != null) {
sunCmpMapping.close();
}
} catch (IOException ex) {
if (logger.isLoggable(Logger.FINE))
logger.fine(ex.toString());
}
}
}
Aggregations