1 25 26 package org.objectweb.speedo.generation.serializer; 27 28 import java.util.Iterator ; 29 30 import org.objectweb.speedo.api.SpeedoException; 31 import org.objectweb.speedo.api.SpeedoProperties; 32 import org.objectweb.speedo.generation.lib.AbstractGeneratorComponent; 33 import org.objectweb.speedo.mapper.lib.Object2StringSerializer; 34 import org.objectweb.speedo.metadata.SpeedoXMLDescriptor; 35 36 39 public class MISerializer extends AbstractGeneratorComponent { 40 41 public final static String LOGGER_NAME 42 = SpeedoProperties.LOGGER_NAME + ".generation.jorm"; 43 44 public boolean init() throws SpeedoException { 45 if (scp.getXmldescriptor().isEmpty()) { 46 return false; 47 } 48 logger = scp.loggerFactory.getLogger(LOGGER_NAME); 49 return true; 50 } 51 52 55 public void process() throws SpeedoException { 56 if (scp.getXmldescriptor().isEmpty()) { 57 return; 58 } 59 try { 60 for (Iterator itDesc = scp.getXmldescriptor().values().iterator(); itDesc.hasNext();) { 61 SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next(); 62 serialize(desc); 63 } 64 } catch (SpeedoException e) { 65 throw new SpeedoException("Error during serialization of meta information", e); 66 } 67 } 68 69 private void serialize(SpeedoXMLDescriptor desc) throws SpeedoException { 70 try { 72 Object2StringSerializer.serialize(scp.output, desc.xmlFile, desc.mos, logger); 73 } catch (Exception io) { 74 throw new SpeedoException("IO Exception, impossible to write the " + 75 "meta information for the jdo file " + desc.xmlFile, io); 76 } 77 } 78 79 80 } 81 | Popular Tags |