1 package org.sapia.magnet.domain.java; 2 3 import java.util.Iterator ; 6 7 import org.sapia.magnet.domain.Path; 10 import org.sapia.magnet.domain.Resource; 11 import org.sapia.magnet.render.MagnetContext; 12 import org.sapia.magnet.render.RenderingException; 13 14 15 26 public class Codebase extends Classpath { 27 28 32 33 private String _theProfileName; 34 35 39 42 public Codebase() { 43 } 44 45 49 54 public String getProfile() { 55 return _theProfileName; 56 } 57 58 62 67 public void setProfile(String aProfileName) { 68 _theProfileName = aProfileName; 69 } 70 71 75 81 public void render(MagnetContext aContext) throws RenderingException { 82 if (_theProfileName == null || 83 (aContext.getProfile() != null && _theProfileName.equals(aContext.getProfile()))) { 84 try { 85 super.render(aContext); 86 87 StringBuffer aBuffer = new StringBuffer (); 88 if (System.getProperty("java.rmi.server.codebase") != null) { 89 aBuffer.append(System.getProperty("java.rmi.server.codebase")).append(" "); 90 } 91 92 for (Iterator somePaths = getPaths().iterator(); somePaths.hasNext(); ) { 93 Path aPath = (Path) somePaths.next(); 94 for (Iterator it = aPath.getSelectedResources().iterator(); it.hasNext(); ) { 95 Resource aResource = (Resource) it.next(); 96 aBuffer.append(aResource.getURL()).append(" "); 97 } 98 } 99 100 System.setProperty("java.rmi.server.codebase", aBuffer.toString()); 101 } catch (RenderingException re) { 102 StringBuffer aBuffer = new StringBuffer ("Unable to render the codebase of the"); 103 if (_theProfileName == null) { 104 aBuffer.append(" default profile"); 105 } else { 106 aBuffer.append(" profile ").append(_theProfileName); 107 } 108 109 throw new RenderingException(aBuffer.toString(), re); 110 } 111 } 112 } 113 114 119 public String toString() { 120 StringBuffer aBuffer = new StringBuffer (super.toString()); 121 aBuffer.append("[profile=").append(_theProfileName). 122 append("]"); 123 124 return aBuffer.toString(); 125 } 126 } 127 128 | Popular Tags |