Return-Path:
In HiveMind, a service is an implementation of a Java interface. Unlike
other SOAs (Service Oriented Architectures, such as a SOAP, or EJBs),
1.5 +301 -113 jakarta-hivemind/src/documentation/content/xdocs/bootstrap.xml
Index: bootstrap.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/bootstrap.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- bootstrap.xml 26 May 2004 21:28:49 -0000 1.4
+++ bootstrap.xml 2 Jun 2004 19:45:31 -0000 1.5
@@ -16,36 +16,45 @@
limitations under the License.
-->
- %common-links;
- ]>
+ "./dtd/document-v12.dtd" [
+
+ %common-links;
+ ]>
Before you can access the configuration points and services defined in
- your many module deployment descriptors, you need a registry; here we'll
- describe how to construct the registry. The key class here is &api.RegistryBuilder;, which contains code for
- locating and parsing the module deployment descriptors and constructing a
- registry from the combined data. Let's examine how all this comes together. The layout of the project is
- shown below. The first step is to define the service interface: Finally, we need the HiveMind module deployment descriptor,
- hivemodule.sdl
. This file is in Simple Data
- Language format (though equivalent XML is supported if the file
- is named hivemodule.xml
).
+The Calculator implementation will require some wiring; it expects that each of the other four +services (Adder, Substracter, Multiplier and Divider) will be plugged into it: +
+ +Finally, we need the HiveMind module deployment descriptor,
+ hivemodule.sdl
. This file is in Simple Data
+ Language format (though equivalent XML is supported if the file
+ is named hivemodule.xml
).
+ The module descriptor creates each of the services in terms of + an interface, and an implementation. In addition, each service gets its + own logging interceptor. +
+Here we've chosen to have the module id, hivemind.examples
- , match the package name but that is not an absolute requirement.
Before your code can access any services (or configuration points), it - must construct the registry.
-hivemind.examples
,
+ match the package name but that is not an absolute requirement.
+
+ + The interesting part is the use of the &hivemind.BuilderFactory; to construct + the Calculator service and connect it to the other four services. +
+Before your code can access any services (or configuration points), it + must construct the &api.Registry;. The Registry is the applications gateway into the services + and configurations managed by HiveMind.
+Building the registry requires four steps:
-processModules()
to find and parse all HiveMind
- module deployment descriptors visible on the classpath (as
- META-INF/hivemodule.sdl
or META-INF/hivemodule.xml
- ). Here, this will be the master HiveMind module descriptor (for the
- hivemind
module), and the descriptor for this example
- module. You could invoke processModule()
to parse
- additional deployment descriptors stored in unusual locations.constructRegistry()
to integrate and validate
- all the information in all of the HiveMind module deployment
- descriptors and produce a &api.Registry; from it.Alternately, the static method - constructDefaultRegistry() can be invoked. It's just those same - four lines of code.
-Now that we have the registry, we can use the full id of the Adder
- service, hivemind.examples.Adder
, to get the service
- implementation. We pass in the class that we'll be casting the service
- to ... this allows HiveMind to produce a more meaningful error than a
- ClassCastException.
Using the reference to the Adder service, we can finally invoke the
- add()
method.
Building and running the example using Ant is a snap; all the details
- are in the build.xml
:
&api.RegistryBuilder; contains a static method for constructing a Registry, which + is suitable for most situations.
+Now that we have the registry, we can use the fully qualified id of the Calculator
+ service, hivemind.examples.Calculator
, to get the service
+ implementation. We pass in the class that we'll be casting the service
+ to ... this allows HiveMind to produce a more meaningful error than a
+ ClassCastException.
Using the reference to the Calculator service, we can finally invoke the
+ add()
, subtract()
, multiply()
+ and divide()
methods.
Building and running the example using Ant is a snap; all the details
+ are in the build.xml
:
The important part is to package both the classes and the HiveMind - module deployment descriptor into the JAR. The latter is accomplished - using the <metainf> element.
-The only other oddity was to add src/conf
to the runtime
- classpath; this is to include the log4j.properties
- configuration file; otherwise Log4J will write console errors about
- missing configuration.
The important part is to package both the classes and the HiveMind + module deployment descriptor into the JAR.
+The only other oddity was to add src/conf
to the runtime
+ classpath; this is to include the log4j.properties
+ configuration file; otherwise Log4J will write console errors about
+ missing configuration.