6
<title>App Launching</title>
7
<author email="bob@eng.werken.com">bob mcwhirter</author>
12
<section name="Introduction">
14
<subsection name="Purpose">
17
In order to reduce the number of classloading projects,
18
<code>classworlds</code> replaces <code>forehead</code>
19
for application launching.
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.
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.
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 \
51
<section name="Configuration">
53
<subsection name="Entry Definition">
56
The entry-point class and realm must be specified
57
using the <code>main is</code> directive before
58
specifying realm definitions.
62
main is com.werken.projectz.Server from app
67
<subsection name="Realm Definitions">
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
94
Within a realm definition, two directives are available:
95
<code>load</code> and <code>import</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>.
112
load ${app.home}/lib/myapp.jar
113
load ${app.home}/lib/xerces.jar
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>.
130
import com.werken.projectz.Foo from [app]
136
<subsection name="Entry point methods">
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.
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.
156
public static void main(String[] args,