You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by bu...@apache.org on 2012/04/23 15:42:53 UTC

svn commit: r814074 - in /websites/staging/river/trunk/content: ./ helloworld.html

Author: buildbot
Date: Mon Apr 23 13:42:53 2012
New Revision: 814074

Log:
Staging update by buildbot for river

Modified:
    websites/staging/river/trunk/content/   (props changed)
    websites/staging/river/trunk/content/helloworld.html

Propchange: websites/staging/river/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon Apr 23 13:42:53 2012
@@ -1 +1 @@
-1327987
+1329233

Modified: websites/staging/river/trunk/content/helloworld.html
==============================================================================
--- websites/staging/river/trunk/content/helloworld.html (original)
+++ websites/staging/river/trunk/content/helloworld.html Mon Apr 23 13:42:53 2012
@@ -71,7 +71,7 @@
 Warning!  The following describes how to use code which is currently only contained in a branch of River and has not been formally released yet.</p>
 <h2 id="introduction">Introduction</h2>
 <p>It can be argued that part of the barrier to entry of getting working River services is the complexity and difficulty with configuring services.  The are many things that users, new and old, must remember when trying to set up new environments and tweak the configurations of their services.</p>
-<p>The configurations themselves can be tempermental and difficult for new comers to get to grips with.  Largely, they are text files with a Java-esque content which is parsed by the <font face="Courier">ServiceStarter</font>.  The following describes how to use the "extra" bits of River to get around these issues.</p>
+<p>The configurations themselves can be temperamental and difficult for new comers to get to grips with.  Largely, they are text files with a Java-esque content which is parsed by the <code>ServiceStarter</code>.  The other problem with the config files is ensuring that you can share configuration for certain services across the djinn.  Encapsulating configuration in Java code, which can be more easily humanly read, verified and shared is possibly a better idea than having many slightly different copies of configuration files which must then be kept in step.  The following describes how to use the "extra" bits of River to get around these issues.</p>
 <h2 id="extra-river">Extra River</h2>
 <p>The classes required in this documentation live outside of the main River distribution, in fact they are not part of the core of the library neither are they part of the Jini and JavaSpaces specifications. In a standard River install, they are therefore completely optional.</p>
 <h2 id="getting-started">Getting Started</h2>
@@ -81,26 +81,26 @@ Warning!  The following describes how to
 <li>Apache Commons Collections 3.2</li>
 <li>Apache Commons Lang 2.6</li>
 </ul>
-<p>From now on, this document will refer to these two exact file system locatino of these JARs as;</p>
+<p>From now on, this document will refer to these two exact file system location of these JARs as;</p>
 <ul>
-<li><pre>${COMMONS_COLLECTIONS_JAR}</pre></li>
-<li><pre>${COMMONS_LANG_JAR}</pre></li>
+<li><code>${COMMONS_COLLECTIONS_JAR}</code></li>
+<li><code>${COMMONS_LANG_JAR}</code></li>
 </ul>
 <h3 id="getting-the-code-and-building-river">Getting the Code and Building River</h3>
 <p>You must first get the River source.  Since this code is still experimental, that means checking out the code from a trunk.  Ideally, this code will make the next release and so will come packaged as part of the River (source) distribution.</p>
-<pre>
+<pre><code>
 $  cd ~/projects/river
 $  svn co http://svn.apache.org/repos/asf/river/jtsk/skunk/easystart helloworld
 $  cd helloworld
 $  ant # This will build the River distribution, including the lib/extra.jar
-</pre>
+</code></pre>
 
 <p>Optionally, you can also;
-<pre>
+<pre><code>
 $  cd ../src-extra-examples
 $  ant # This will build the lib/extra-examples.jar
-</pre></p>
-<p>From this point on, we shall refer to the installation of River as <code>${RIVER_HOME}</code>.  In this example, it would refer to directory ~/projects/river/helloworld.</p>
+</code></pre></p>
+<p>From this point on, we shall refer to the installation of River as <code>${RIVER_HOME}</code>.  In this example, it would refer to directory <code>~/projects/river/helloworld</code>.</p>
 <h3 id="starting-the-http-server">Starting the HTTP Server</h3>
 <p>Jini/River services of course require a HTTP server.  This is easily started in such a way as it will serve all the JAR files from the ${RIVER_HOME}/lib directory.</p>
 <p>Open your IDE of choice, fix any build/setup errors and then setup a run configuration for the HTTP server - I use Eclipse, hence the terminology.</p>
@@ -113,6 +113,15 @@ $  ant # This will build the lib/extra-e
 <p>Execute this run configuration and leave it running.  You can verify that it's working correctly by using your browser or <code>wget</code> to download a sample JAR, e.g.</p>
 <p><code>$  wget http://localhost:8080/reggie.jar</code></p>
 <p>The rest of this document describes code that can be found in the <code>src-extra</code> and <code>src-extra-examples</code> source directories.</p>
+<h3 id="running-services">Running Services</h3>
+<p>When running River services you will also require the following VM arguments.</p>
+<pre><code>
+-Djava.security.policy=<em>${RIVER_HOME}</em>/src-extra/policy.all 
+-Djava.rmi.server.RMIClassLoaderSpi=net.jini.loader.pref.PreferredClassProvider
+-DRIVER_HOME=<em>${RIVER_HOME}</em>
+</code></pre>
+
+<p><b>Important</b>: The policy file specified above is a "grant all" policy file.  You could consider it a "disable security" security policy.  As such it is unsuitable for real-world use.</p>
 <h3 id="common-service-configuration-options">Common Service Configuration Options</h3>
 <p>We are going to use a <code>ApplicationOptions</code> to describe certain service configuration options that will be common to all the services we're going to start.  From, <code>org.apache.river.extra.examples.easystart.StartServices</code>;</p>
 <p><code>
@@ -128,28 +137,30 @@ options.setPackageName(ExampleService.PA
 <p><code>
 ApplicationConfigurationFactory configFac = new ApplicationConfigurationFactory(options);
 </code></p>
-<p>This class extends a non-example River Extra class, <code>org.apache.river.extra.easystart.config.ConfigurationFactory</code>.  This base class knows how to create configuration objects for the standard River services using the djinn specific options as we have described above, the extending class also knows how to create configuration objects for our additional custom services.</p>
+<p>This class extends a River Extra class, <code>org.apache.river.extra.easystart.config.ConfigurationFactory</code>.  This base class knows how to create configuration objects for the standard River services using the djinn specific options as we have described above, the extending class also knows how to create configuration objects for our additional custom services.</p>
 <h3 id="starting-the-lookup-service">Starting the Lookup Service</h3>
 <p>Staying with the same <code>StartServices</code> class from above.</p>
-<p>First we need to config the lookup service and then we can start it.  This is easily done;</p>
-<p><code>
-LookupServiceConfiguration lusConfig = configFac.lookupServiceConfig();<br/>
-lusConfig.addMemberGroup("extra").addMemberGroup("extra");<br/>
-ServiceStarter.main(lusConfig.riverConfig());<br/>
-</code></p>
+<p>First we need to configure the lookup service and then we can start it.  This is easily done;</p>
+<pre><code>
+LookupServiceConfiguration lusConfig = configFac.lookupServiceConfig();
+lusConfig.addMemberGroup("extra").addMemberGroup("example");
+ServiceStarter.main(lusConfig.riverConfig());
+</code></pre>
+
 <p>Notice that we have set the lookup service's configuration's member groups to be the same as the lookup groups as defined in the <code>ApplicationOptions</code> instance above.</p>
-<p>We now have a started lookup service.</p>
+<p>We now have a started lookup service; (but check your console for errors!)</p>
 <h3 id="starting-the-example-service">Starting the Example Service</h3>
 <p>Next we need a configuration for our example service.</p>
 <p>The configuration is described in our extended <code>ApplicationConfigurationFactory</code>, thus;</p>
-<p><code>
-public AbstractEasyConfiguration exampleService(Name name) {<br/>
-&nbsp;&nbsp;&nbsp;&nbsp;ApplicationOptions exampleOptions = getDefaultOptions();<br/>
-&nbsp;&nbsp;&nbsp;&nbsp;exampleOptions.setImplementationClass(ExampleServiceImpl.class);<br/>
-&nbsp;&nbsp;&nbsp;&nbsp;exampleOptions.addInitialLookupAttribute(name);<br/>
-&nbsp;&nbsp;&nbsp;&nbsp;return new AbstractEasyConfiguration(exampleOptions) {};<br/>
+<pre><code>
+public AbstractEasyConfiguration exampleService(Name name) {
+&nbsp;&nbsp;&nbsp;&nbsp;ApplicationOptions exampleOptions = getDefaultOptions();
+&nbsp;&nbsp;&nbsp;&nbsp;exampleOptions.setImplementationClass(ExampleServiceImpl.class);
+&nbsp;&nbsp;&nbsp;&nbsp;exampleOptions.addInitialLookupAttribute(name);
+&nbsp;&nbsp;&nbsp;&nbsp;return new AbstractEasyConfiguration(exampleOptions) {};
 }
-</code></p>
+</code></pre>
+
 <p>Now we know how the configuration was done.  You should also be able to see how easy it will be to extend this concept of ConfigurationFactory to handle all of your own custom services that make up your own applications.</p>
 <p>We can start the example service in exactly the same way as we did the lookup service previously.</p>
 <p><code>
@@ -158,6 +169,7 @@ ServiceStarter.main(config.riverConfig()
 </code></p>
 <p>Now we have successfully configured and started our example service, and in all of this we did not have to bother ourselves with any configuration file.</p>
 <p>It should be pointed out that the services we have started are using the default policy file which is unsuitable for a live environment, since it is a "grant all" policy file that can be found in <code>${RIVER_HOME}/src-extra/policy.all</code></p>
+<p>So by defining and sharing our own implementation of the configuration factory we can be sure that all services started with configurations from that factory will be configured accordingly.  What's more, we no longer have to maintain series of configuration files which potential contain many duplicate data items.</p>
 <h2 id="additional-configuration">Additional Configuration</h2>
 <p>You can specify additional configuration data by creating custom <code>org.apache.river.extra.easystart.config.settings.Setting</code> objects and adding them to the <code>org.apache.river.extra.easystart.config.ApplicationOptions</code> instance before creating your configuration factory.  In the same package, there are additional extending classes of <code>Setting</code> that can be used as templates for your own configuration options.</p>
           </div>