Run modes
Insight may run in several modes (standalone, rmi server, rmi client), so it
should support being configured in several ways :
-
From a java program, like a test case
-
From a Cocoon configuration file
-
From an external configuration file
-
Not configured, using defaults
So the configuration system has been designed to be as flexible as possible.
It relies mainly on Avalon-Framework configuration system, but we added a few
things to support "exposed" services.
Configuration file anatomy
Here is the basic anatomy of a Insight configuration file :
<insight
xmlns:insight="http://shaman.paris5.fr/insight-conf"
rmi-server="localhost"
run-style="standalone"
>
<foo-service
role="fr.paris5.shaman.insight.service.unexposed.Foo"
class="fr.paris5.shaman.insight.logic.unexposed.FooImpl"
/>
<hello-service
role="fr.paris5.shaman.insight.service.exposed.HelloService"
class="fr.paris5.shaman.insight.logic.exposed.HelloServiceImpl"
exposed-as="Hello"
>
<hello-message>Hello, world</hello-message>
</hello-service>
</insight>
|
The exposed-as attribute makes that only
service known as
fr.paris5.shaman.insight.service.exposed.HelloService
will be seen from the RMI client side.
The rmi-server attribute gives the DNS name
of the RMI server.
The run-style attribute can be one of following :
-
standalone
-
rmi-client
-
rmi-server
The role and class attributes of each service
do keep their meaning as defined by Avalon-Excalibur Component Manager.
Compatibility with Excalibur
Insight maybe instantiated / configured from an Excalibur-compatible
file (like cocoon.xconf ).
Embedding
Here is a sample of an embedded Insight configuration file, with
Insight running in the same VM as the Exacalibur Component Manager.
Please note the role and style attributes
which appeared, telling the Excalibur Component Manager how to
instantiate the Insight Manager.
<my-excalibur-configuration-file>
<!-- some declarations here... -->
<insight
xmlns:insight="http://shaman.paris5.fr/insight-conf"
role="fr.paris5.shaman.insight.component.InsightManager"
class="fr.paris5.shaman.insight.component.InsightManager"
rmi-server="myhost"
run-style="standalone"
>
<foo-service
role="fr.paris5.shaman.insight.service.unexposed.Foo"
class="fr.paris5.shaman.insight.logic.unexposed.FooImpl"
/>
<hello-service
role="fr.paris5.shaman.insight.service.exposed.HelloService"
class="fr.paris5.shaman.insight.logic.exposed.HelloServiceImpl"
exposed-as="Hello"
>
<hello-message>Hello, world</hello-message>
</hello-service>
</insight>
<!-- some declarations here... -->
</my-excalibur-configuration-file>
|
If the configuration should describe a rmi-client behavior, it
would look like :
<my-excalibur-configuration-file>
<!-- some declarations here... -->
<insight
xmlns:insight="http://shaman.paris5.fr/insight-conf"
role="fr.paris5.shaman.insight.component.InsightManager"
class="fr.paris5.shaman.insight.component.InsightManager"
run-style="rmi-client"
rmi-server="myhost"
>
<hello-service
role="fr.paris5.shaman.insight.service.exposed.HelloService"
exposed-as="Hello"
>
</hello-service>
</insight>
<!-- some declarations here... -->
</my-excalibur-configuration-file>
|
Note that unnecessary options have been removed (they could still
appear, but would be ignored) :
-
foo-service is not exposed, so it won't exist in a
RMI client run style
-
hello-message is a parameter supposed to be used
by server only
Referencing
Since Cocoon configuration files aleready tend to be huge, it may
be preferable to not embed configuration. For achieving this,
an Insight Manager declaration in an Excalibur configuration can
declare a reference to a configuration using an URL :
<my-excalibur-configuration-file>
<!-- some declarations here... -->
<insight
xmlns:insight="http://shaman.paris5.fr/insight-conf"
role="fr.paris5.shaman.insight.component.InsightManager"
class="fr.paris5.shaman.insight.component.InsightManager"
configuration-url="./insight.xconf"
run-style="rmi-client"
rmi-server="myhost"
/>
<!-- some declarations here... -->
</my-excalibur-configuration-file>
|
The configuration-url defines a reference to the file to
use. The run-style and rmi-server will
override the values (if any) in the given ./insight.xconf .
Since defaults for services will be used most often, it's possible to
let the Insight Manager use its own bundled resource for configuring
itself. In this case, the declaration in the Excalibur configuration
file will look as follow (rmi-server attribute may be
forgotten, defaulting to localhost ) :
<my-excalibur-configuration-file>
<!-- some declarations here... -->
<insight
xmlns:insight="http://shaman.paris5.fr/insight-conf"
role="fr.paris5.shaman.insight.component.InsightManager"
class="fr.paris5.shaman.insight.component.InsightManager"
run-style="rmi-client"
/>
<!-- some declarations here... -->
</my-excalibur-configuration-file>
|
|
When referencing (e.g. declaring a configuration-url
attribute, it's not allowed to declare nested elements.
|
Using Avalon's Contexts
Avalon's Contexts are supported, for allowing a Java program to define
some context values without defining a Configuration object.
Configuration item
|
Type
|
Key
|
Configuration URL
|
java.lang.String
|
CONFIGURATIONURL_KEY
|
RMI server name
|
java.lang.String
|
RMISERVERNAME_KEY
|
Run type
|
fr.paris5.shaman.insight.InsightContext.RunStyle
|
RUNSTYLE_KEY
|
|
All Key objects are defined in
fr.paris5.shaman.insight.InsightContext .
|
Order of preseance : summary
Paragraphs above pointed out there are several ways to configure
the Insight Manager. Configuration items are taken in the order
of preseance defined below :
Configuration url
-
Excalibur element
-
Context
-
The class-bundled configuration is used
RMI server
-
Excalibur element
-
Configuration file
-
Context
-
"localhost" used as default
Run style
-
Excalibur element
-
Configuration file
-
Context
-
"standalone" used as default
|