1 package org.sapia.magnet.domain; 2 3 import org.sapia.util.xml.confix.ObjectWrapperIF; 6 7 import org.sapia.magnet.render.AbstractRenderable; 10 import org.sapia.magnet.render.MagnetContext; 11 import org.sapia.magnet.render.RenderingException; 12 13 14 25 public class Launcher extends AbstractRenderable implements ObjectWrapperIF { 26 27 31 32 private String _theType; 33 34 35 private LaunchHandlerIF _theLaunchHandler; 36 37 41 44 public Launcher() { 45 } 46 47 51 56 public String getType() { 57 return _theType; 58 } 59 60 65 public LaunchHandlerIF getLaunchHandler() { 66 if (_theLaunchHandler == null) { 67 throw new IllegalStateException ("The laucher type is not define"); 68 } 69 70 return _theLaunchHandler; 71 } 72 73 77 84 public void setType(String aType) { 85 try { 86 _theType = aType; 87 _theLaunchHandler = HandlerFactory.getInstance().createLaunchHandler(aType); 88 _theLaunchHandler.setType(aType); 89 } catch (ObjectCreationException oce) { 90 throw new IllegalArgumentException ("Unable to assign the launcher type - " + oce.getMessage()); 91 } 92 } 93 94 98 103 public void execute(String aProfile) { 104 _theLaunchHandler.execute(aProfile); 105 } 106 107 111 117 public void render(MagnetContext aContext) throws RenderingException { 118 if (_theLaunchHandler == null) { 119 throw new RenderingException("Unable to render the laucher - the laucher type is not define"); 120 } 121 122 _theLaunchHandler.render(aContext); 123 } 124 125 130 public String toString() { 131 StringBuffer aBuffer = new StringBuffer (super.toString()); 132 aBuffer.append("[type=").append(_theType). 133 append(" launchHandler=").append(_theLaunchHandler). 134 append("]"); 135 136 return aBuffer.toString(); 137 } 138 139 143 148 public Object getWrappedObject(){ 149 if (_theLaunchHandler == null) { 150 return this; 151 } else { 152 return _theLaunchHandler; 153 } 154 } 155 } 156 | Popular Tags |