KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > domain > LaunchHandlerDef


1 package org.sapia.magnet.domain;
2
3 // Import of Sapia's Corus classes
4
// --------------------------------
5
import org.sapia.magnet.render.AbstractRenderable;
6 import org.sapia.magnet.render.MagnetContext;
7 import org.sapia.magnet.render.RenderingException;
8
9
10 /**
11  *
12  *
13  * @author Jean-Cedric Desrochers
14  *
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public class LaunchHandlerDef extends AbstractRenderable {
22
23   /////////////////////////////////////////////////////////////////////////////////////////
24
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
25
/////////////////////////////////////////////////////////////////////////////////////////
26

27   /** The type of launch handler of this definition. */
28   private String JavaDoc _theType;
29
30   /** The classname of this definition. */
31   private String JavaDoc _theClassname;
32
33   /** The classpath of this definition. */
34   private String JavaDoc _theClasspath;
35
36   /////////////////////////////////////////////////////////////////////////////////////////
37
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
38
/////////////////////////////////////////////////////////////////////////////////////////
39

40   /**
41    * Creates a new LaunchHandlerDef instance.
42    */

43   public LaunchHandlerDef() {
44   }
45
46   /////////////////////////////////////////////////////////////////////////////////////////
47
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
48
/////////////////////////////////////////////////////////////////////////////////////////
49

50   public String JavaDoc getType() {
51     return _theType;
52   }
53
54   public String JavaDoc getClassname() {
55     return _theClassname;
56   }
57
58   public String JavaDoc getClasspath() {
59     return _theClasspath;
60   }
61
62   /////////////////////////////////////////////////////////////////////////////////////////
63
/////////////////////////////////// MUTATOR METHODS ///////////////////////////////////
64
/////////////////////////////////////////////////////////////////////////////////////////
65

66   public void setType(String JavaDoc aType) {
67     _theType = aType;
68   }
69
70   public void setClassname(String JavaDoc aClassname) {
71     _theClassname = aClassname;
72   }
73
74   public void setClasspath(String JavaDoc aClasspath) {
75     _theClasspath = aClasspath;
76   }
77   /////////////////////////////////////////////////////////////////////////////////////////
78
////////////////////////////////// OVERRIDEN METHODS //////////////////////////////////
79
/////////////////////////////////////////////////////////////////////////////////////////
80

81   /**
82    * Renders this objects to the magnet context passed in.
83    *
84    * @param aContext The magnet context to use.
85    * @exception RenderingException If an error occurs while rendering this object.
86    */

87   public void render(MagnetContext aContext) throws RenderingException {
88     // Resolve the attributes
89
try {
90       _theType = resolveValue(aContext, _theType);
91       _theClassname = resolveValue(aContext, _theClassname);
92       _theClasspath = resolveValue(aContext, _theClasspath);
93   
94       HandlerFactory.getInstance().addLaunchHandler(_theType, _theClassname);
95     } catch (RenderingException re) {
96       StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc();
97       aBuffer.append("Unable to resolve an attribute of the launch handler def ").
98               append(_theType);
99         
100       throw new RenderingException(aBuffer.toString(), re);
101     }
102   }
103
104   /**
105    * Returns a string representation of this script.
106    *
107    * @return A string representation of this script.
108    */

109   public String JavaDoc toString() {
110     StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc(super.toString());
111     aBuffer.append("[type=").append(_theType).
112             append(" classname=").append(_theClassname).
113             append(" classpath=").append(_theClasspath).
114             append("]");
115
116     return aBuffer.toString();
117   }
118 }
119
Popular Tags