~ubuntu-branches/ubuntu/trusty/classworlds/trusty

« back to all changes in this revision

Viewing changes to xdocs/launchusage.xml

  • Committer: Bazaar Package Importer
  • Author(s): Marcus Crafter
  • Date: 2004-09-01 20:46:11 UTC
  • Revision ID: james.westby@ubuntu.com-20040901204611-e6rdq2qf5me6v83d
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0"?>
 
2
 
 
3
<document>
 
4
 
 
5
  <properties>
 
6
    <title>App Launching</title>
 
7
    <author email="bob@eng.werken.com">bob mcwhirter</author>
 
8
  </properties>
 
9
 
 
10
  <body>
 
11
 
 
12
  <section name="Introduction">
 
13
 
 
14
    <subsection name="Purpose"> 
 
15
 
 
16
      <p>
 
17
      In order to reduce the number of classloading projects,
 
18
      <code>classworlds</code> replaces <code>forehead</code>
 
19
      for application launching.  
 
20
      </p>
 
21
 
 
22
      <p>
 
23
      The main problems to solve in application launching include
 
24
      locating all of application's JARs, configuring the initial
 
25
      classloaders, and invoking the <code>main</code> entry method.
 
26
      </p>
 
27
 
 
28
      <p>
 
29
      The launcher facilities of <code>classworlds</code> simplify
 
30
      the process of locating application jars.  A common idiom is
 
31
      to have a script which starts the JVM with only the 
 
32
      <code>classworlds.jar</code> in the classpath and a system
 
33
      property to specify the location of a launcher configuration.
 
34
      Additionally, typically a property specifying the installation
 
35
      location is passed on the command-line.
 
36
      </p>
 
37
 
 
38
<source><![CDATA[
 
39
$JAVA_HOME/bin/java \
 
40
    -classpath $APP_HOME/lib/classworlds-1.0.jar \
 
41
    -Dclassworlds.conf=$APP_HOME/etc/classworlds.conf \
 
42
    -Dapp.home=$APP_HOME \
 
43
    org.codehaus.classworlds.Launcher \
 
44
    $*
 
45
]]></source>
 
46
 
 
47
    </subsection>
 
48
 
 
49
  </section>
 
50
 
 
51
  <section name="Configuration">
 
52
 
 
53
    <subsection name="Entry Definition">
 
54
 
 
55
      <p>
 
56
      The entry-point class and realm must be specified
 
57
      using the <code>main is</code> directive before
 
58
      specifying realm definitions. 
 
59
      </p>
 
60
 
 
61
<source><![CDATA[
 
62
main is com.werken.projectz.Server from app
 
63
]]></source>
 
64
 
 
65
    </subsection>
 
66
 
 
67
    <subsection name="Realm Definitions">
 
68
 
 
69
      <p>
 
70
      At least one <code>classworlds</code> realm must be defined
 
71
      within the configuration file.  The syntax for starting a
 
72
      realm definition is <code>[realm.name]</code>.  All lines
 
73
      following the realm header are considered directives for 
 
74
      that realm.  The realm definition continues either until
 
75
      another realm is defined or until the end of the file is
 
76
      reached.  
 
77
      </p>
 
78
 
 
79
<source><![CDATA[
 
80
[realm.one]
 
81
    ...
 
82
    ...
 
83
 
 
84
[realm.two]
 
85
    ...
 
86
    ...
 
87
 
 
88
[realm.three]
 
89
    ...
 
90
    ...
 
91
]]></source>
 
92
 
 
93
      <p>
 
94
      Within a realm definition, two directives are available:
 
95
      <code>load</code> and <code>import</code>.  
 
96
      </p>
 
97
 
 
98
      <p>
 
99
      The <code>load</code>
 
100
      directive specifies a class source to be used for loading
 
101
      classes in the realm.  Any loaded source that ends with
 
102
      the <code>/</code> character is considered a directory
 
103
      hierarchy of classes and resources and all others are
 
104
      considered to be JAR files.  System properties may be
 
105
      referred to using <code>${propname}</code> notation.
 
106
      The <code>load</code> directive is equivelent to the
 
107
      <code>addConstituent(..)</code> method of <code>ClassRealm</code>.
 
108
      </p>
 
109
 
 
110
<source><![CDATA[
 
111
[app]
 
112
    load ${app.home}/lib/myapp.jar
 
113
    load ${app.home}/lib/xerces.jar
 
114
    load ${tools.jar}
 
115
]]></source>
 
116
 
 
117
      <p>
 
118
      The <code>import</code> directive specifies that certain
 
119
      packages should be imported and loaded by way of another
 
120
      realm.  The <code>import</code> directive is equivelent
 
121
      to the <code>importFrom(..)</code> method of
 
122
      <code>ClassRealm</code>.
 
123
      </p>
 
124
 
 
125
<source><![CDATA[
 
126
[app]
 
127
    ...
 
128
  
 
129
[subcomponent]
 
130
    import com.werken.projectz.Foo from [app]
 
131
    ...
 
132
]]></source>
 
133
 
 
134
    </subsection>
 
135
 
 
136
    <subsection name="Entry point methods">
 
137
 
 
138
      <p>
 
139
      <code>classworlds</code> can be used to invoke any existing
 
140
      application's <code>main()</code> method.  Using the standard
 
141
      entry point does not allow for gaining access to the 
 
142
      <code>ClassWorld</code> of the application, but not all 
 
143
      applications will need it at run-time.
 
144
      </p>
 
145
 
 
146
      <p>
 
147
      For those applications that do require the <code>ClassWorld</code>
 
148
      instance, an alternative entry-point method signature can be
 
149
      provide.  Simply add a <code>ClassWorld</code> parameter to 
 
150
      the standard <code>main</code> parameter list.
 
151
      </p>
 
152
 
 
153
<source><![CDATA[
 
154
public class MyApp
 
155
{
 
156
    public static void main(String[] args,
 
157
                            ClassWorld world)
 
158
    {
 
159
        ...     
 
160
    }
 
161
}
 
162
]]></source>
 
163
 
 
164
    </subsection>
 
165
 
 
166
  </section>
 
167
 
 
168
  </body>
 
169
 
 
170
</document>