1 package org.sapia.magnet; 2 3 import java.util.Iterator ; 6 import java.util.List ; 7 8 import org.apache.log4j.Logger; 11 12 import org.sapia.magnet.domain.Magnet; 15 import org.sapia.magnet.render.MagnetContext; 16 import org.sapia.magnet.render.RenderingException; 17 18 19 29 public class MagnetRenderer { 30 31 35 36 private static final Logger _theLogger = Logger.getLogger(MagnetRenderer.class); 37 38 42 45 public MagnetRenderer() { 46 } 47 48 52 61 public MagnetContext render(List someMagnets, String aProfile) throws MagnetException { 62 Magnet aMagnet = null; 63 MagnetContext aContext = null; 64 65 try { 66 for (Iterator it = someMagnets.iterator(); it.hasNext(); ) { 67 if (aContext == null) { 68 aContext = new MagnetContext(aProfile); 69 } else { 70 aContext = new MagnetContext(aContext); 71 } 72 aMagnet = (Magnet) it.next(); 73 aMagnet.render(aContext); 74 } 75 76 return aContext; 77 } catch (RenderingException re) { 78 String aMessage = "Unable to render the profile " + aProfile + " of the magnet " + aMagnet.getName(); 79 _theLogger.error(aMessage, re); 80 throw new MagnetException(aMessage, re); 81 82 } catch (RuntimeException re) { 83 String aMessage = "System error rendering the profile " + aProfile + " of the magnet " + aMagnet.getName(); 84 _theLogger.error(aMessage, re); 85 throw new MagnetException(aMessage, re); 86 } 87 } 88 } 89 | Popular Tags |