Author: gtrasuk
Date: Fri Jan 9 21:23:59 2015
New Revision: 1650673
URL: http://svn.apache.org/r1650673
Log:
Examples no longer use the newer river-rt-tools project. Examples are complete
up to getting the infrastructure services running. Work is started on the
hello-service example.
Added:
river/river-examples/river-examples/trunk/hello-api/
river/river-examples/river-examples/trunk/hello-api/pom.xml
river/river-examples/river-examples/trunk/hello-api/src/
river/river-examples/river-examples/trunk/hello-api/src/main/
river/river-examples/river-examples/trunk/hello-api/src/main/java/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java
river/river-examples/river-examples/trunk/hello-api/src/test/
river/river-examples/river-examples/trunk/hello-api/src/test/java/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/apache/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/apache/river/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/apache/river/examples/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/apache/river/examples/hello/
river/river-examples/river-examples/trunk/hello-api/src/test/java/org/apache/river/examples/hello/api/
river/river-examples/river-examples/trunk/hello-api/target/
river/river-examples/river-examples/trunk/hello-api/target/classes/
river/river-examples/river-examples/trunk/hello-api/target/classes/.netbeans_automatic_build
river/river-examples/river-examples/trunk/hello-api/target/classes/org/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/api/
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/api/Greeter.class
(with props)
river/river-examples/river-examples/trunk/hello-api/target/hello-api-1.0-SNAPSHOT.jar
(with props)
river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/
river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/pom.properties
river/river-examples/river-examples/trunk/hello-api/target/maven-status/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/testCompile/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
river/river-examples/river-examples/trunk/hello-api/target/test-classes/
river/river-examples/river-examples/trunk/hello-api/target/test-classes/.netbeans_automatic_build
river/river-examples/river-examples/trunk/home/src/main/home/start-class-server.config
river/river-examples/river-examples/trunk/home/src/main/home/start-infra.config
river/river-examples/river-examples/trunk/src/site/markdown/browser/
river/river-examples/river-examples/trunk/src/site/markdown/browser/browser.md
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/
river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/infrastructure.md
river/river-examples/river-examples/trunk/src/site/resources/browser/
river/river-examples/river-examples/trunk/src/site/resources/browser/browser-start.png
(with props)
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-show-registrar.png
(with props)
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-with-registrar.png
(with props)
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/select-registrar.png
(with props)
Added: river/river-examples/river-examples/trunk/hello-api/pom.xml
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/pom.xml?rev=1650673&view=auto
==============================================================================
--- river/river-examples/river-examples/trunk/hello-api/pom.xml (added)
+++ river/river-examples/river-examples/trunk/hello-api/pom.xml Fri Jan 9
21:23:59 2015
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.river.examples</groupId>
+ <artifactId>river-examples</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.river.examples</groupId>
+ <artifactId>hello-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>hello-api</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java
(added)
+++
river/river-examples/river-examples/trunk/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.examples.hello.api;
+
+import java.io.IOException;
+import java.rmi.Remote;
+
+/**
+ * This is the interface for a greeter service.
+ * Note that it extends java.rmi.Remote. This isn't strictly necessary -
+ * we could have had a plain interface and then created a proxy that
implements that
+ * interface while extending Remote. But in this case, we know it's going to
be implemented
+ * as a remote service, so it simplifies things if we just extend Remote.
+ */
+public interface Greeter extends Remote {
+ /**
+ * Say 'Hello' to the client with the name provided.
+ * @param name The name of the client.
+ * @return a greeting message.
+ * @throws IOException
+ */
+ public String sayHello(String name) throws IOException;
+}
Added:
river/river-examples/river-examples/trunk/hello-api/target/classes/.netbeans_automatic_build
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/classes/.netbeans_automatic_build?rev=1650673&view=auto
==============================================================================
(empty)
Added:
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/api/Greeter.class
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/api/Greeter.class?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/hello-api/target/classes/org/apache/river/examples/hello/api/Greeter.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
river/river-examples/river-examples/trunk/hello-api/target/hello-api-1.0-SNAPSHOT.jar
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/hello-api-1.0-SNAPSHOT.jar?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/hello-api/target/hello-api-1.0-SNAPSHOT.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/pom.properties
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/pom.properties?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/pom.properties
(added)
+++
river/river-examples/river-examples/trunk/hello-api/target/maven-archiver/pom.properties
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Fri Jan 09 15:36:25 EST 2015
+version=1.0-SNAPSHOT
+groupId=org.apache.river.examples
+artifactId=hello-api
Added:
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
(added)
+++
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,2 @@
+.netbeans_automatic_build
+org/apache/river/examples/hello/api/Greeter.class
Added:
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
(added)
+++
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
Fri Jan 9 21:23:59 2015
@@ -0,0 +1 @@
+/Users/trasukg/NetBeansProjects/river-examples/hello-api/src/main/java/org/apache/river/examples/hello/api/Greeter.java
Added:
river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst?rev=1650673&view=auto
==============================================================================
(empty)
Added:
river/river-examples/river-examples/trunk/hello-api/target/test-classes/.netbeans_automatic_build
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/hello-api/target/test-classes/.netbeans_automatic_build?rev=1650673&view=auto
==============================================================================
(empty)
Added:
river/river-examples/river-examples/trunk/home/src/main/home/start-class-server.config
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/home/src/main/home/start-class-server.config?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/home/src/main/home/start-class-server.config
(added)
+++
river/river-examples/river-examples/trunk/home/src/main/home/start-class-server.config
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import com.sun.jini.start.NonActivatableServiceDescriptor;
+import com.sun.jini.start.ServiceDescriptor;
+import com.sun.jini.config.ConfigUtil;
+
+start {
+ port="8085";
+ discoveryGroup="example-group";
+}
+
+com.sun.jini.start {
+ private static policy = "server.policy";
+ private static host = ConfigUtil.getHostAddress();
+ private static port = start.port;
+ private static jskdl = " http://" + host + ":" + port + "/jsk-dl.jar";
+ private static pathSep=File.pathSeparator;
+
+ serviceDescriptors = new ServiceDescriptor[]{
+ new NonActivatableServiceDescriptor(
+ "",
+ policy,
+ "lib/tools.jar",
+ "com.sun.jini.tool.ClassServer",
+ new String[]{"-port", port, "-dir",
+ "lib-dl",
+ "-verbose"}),
+
+
+ };
+
+}
Added:
river/river-examples/river-examples/trunk/home/src/main/home/start-infra.config
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/home/src/main/home/start-infra.config?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/home/src/main/home/start-infra.config
(added)
+++
river/river-examples/river-examples/trunk/home/src/main/home/start-infra.config
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import com.sun.jini.start.NonActivatableServiceDescriptor;
+import com.sun.jini.start.ServiceDescriptor;
+import com.sun.jini.config.ConfigUtil;
+
+start {
+ port="8085";
+ discoveryGroup="example-group";
+}
+
+com.sun.jini.start {
+ private static policy = "server.policy";
+ private static host = ConfigUtil.getHostAddress();
+ private static port = start.port;
+ private static jskdl = " http://" + host + ":" + port + "/jsk-dl.jar";
+ private static pathSep=File.pathSeparator;
+
+ serviceDescriptors = new ServiceDescriptor[]{
+ new NonActivatableServiceDescriptor(
+ "",
+ policy,
+ "lib/tools.jar",
+ "com.sun.jini.tool.ClassServer",
+ new String[]{"-port", port, "-dir",
+ "lib-dl",
+ "-verbose"}),
+
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/reggie-dl.jar" + jskdl,
+ policy,
+ "lib/reggie.jar",
+ "com.sun.jini.reggie.TransientRegistrarImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""})
+
+ };
+
+ unusedServiceDescriptors = new ServiceDescriptor[]{
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/browser-dl.jar" + jskdl,
+ policy,
+ "lib/browser.jar",
+ "com.sun.jini.example.browser.Browser",
+ new String[] { "browserNonsecure.config" }),
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/mahalo-dl.jar" + jskdl,
+ policy,
+ "lib/mahalo.jar",
+ "com.sun.jini.mahalo.TransientMahaloImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""}),
+
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/mercury-dl.jar" + jskdl,
+ policy,
+ "lib/mercury.jar",
+ "com.sun.jini.mercury.TransientMercuryImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""}),
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/fiddler-dl.jar" + jskdl,
+ policy,
+ "lib/fiddler.jar",
+ "com.sun.jini.fiddler.TransientFiddlerImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""}),
+
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/norm-dl.jar" + jskdl,
+ policy,
+ "lib/norm.jar",
+ "com.sun.jini.norm.TransientNormServerImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""}),
+
+ new NonActivatableServiceDescriptor(
+ "http://" + host + ":" + port + "/outrigger-dl.jar" + jskdl,
+ policy,
+ "lib/outrigger.jar",
+ "com.sun.jini.outrigger.TransientOutriggerImpl",
+ new String[] { "start-infra.config",
+ "start.discoveryGroup=\"" + start.discoveryGroup + "\""}),
+
+
+ };
+}
+
+com.sun.jini.fiddler {
+ initialLookupGroups = new String[] { start.discoveryGroup };
+}
+
+com.sun.jini.mahalo {
+ initialLookupGroups = new String[] { start.discoveryGroup };
+}
+
+com.sun.jini.mercury {
+ initialLookupGroups = new String[] { start.discoveryGroup };
+}
+
+com.sun.jini.norm {
+ initialLookupGroups = new String[] { start.discoveryGroup };
+}
+
+com.sun.jini.outrigger {
+ initialLookupGroups = new String[] { start.discoveryGroup };
+}
+
+com.sun.jini.reggie {
+
+ initialLookupGroups = new String[] {start.discoveryGroup};
+ initialMemberGroups = new String[] {start.discoveryGroup};
+
+ serverExporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
+ new BasicILFactory());
+
+}
Added:
river/river-examples/river-examples/trunk/src/site/markdown/browser/browser.md
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/markdown/browser/browser.md?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/src/site/markdown/browser/browser.md
(added)
+++
river/river-examples/river-examples/trunk/src/site/markdown/browser/browser.md
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,260 @@
+# Service Browser Example
+
+This is a utility that allows you to browse the services that are
+operating in your workgroup, or 'djinn'. Although it's presented as an
example,
+you'll find it to be a useful utility, as well.
+
+The example illustrates a basic use of the ServiceStarter utility class to
+setup the environment for the browser to run in, including the installation of
+a DynamicPolicyProvider and custom classloader.
+
+## Building the Service Browser
+
+The project uses Apache Maven to manage the dependencies and build the
examples.
+There is no need to download and build the main River distribution or tools;
+the River artifacts are deployed to Maven Central, so Maven will automatically
+download the binary artifacts as needed for the examples build.
+
+The examples project is a multi-module project. 'browser' is one of the
modules.
+It produces the 'jar' artifact 'browser-${version}.jar'.
+
+However, as we'll see, there's a lot more to running a River application than
just the
+jar files. The code of the browser is in the browser project, but the
configuration
+files and other jars in the classpath are assembled in the 'home' module under
+the parent 'river-examples' project.
+
+So, to be completely safe, we should run 'mvn install' on the parent project
when we
+make a change to any code. Doing so will cause Maven to build all the modules
in the
+order derived from their dependencies. 'home' declares a dependency on
'browser'
+ (among others), so
+the 'browser' module gets built, and then the 'home' module
+gets built. As part of its build, 'home' will gather the jar files from its
dependency
+modules into the 'lib' directory of its target build.
+
+## Running the Service Browser
+
+First navigate to the directory that's built by the 'home' module:
+
+ cd ${river-examples-home}/home/target/home-${version}-bin
+
+This location follows the Maven conventions of putting all build output into
the
+'target' folder under a module's home directory.
+
+Services and clients in a Jini/River context generally don't run in a
stand-alone
+fashion. They need an environment setup for them.
+
+* The security environment needs
+particular attention, because Jini/River uses a 'mobile-code' approach to
distributed
+systems. Since we're going to load proxies that are transferred over the
network, we
+need to have a security policy in place. And then, the client code will want
to
+dynamically change the permissions that are granted to that remotely-loaded
code, so that
+we can check out the authenticity of the proxy before we let it loose. The
standard
+security policy in the JRE doesn't allow for dynamic permission grants, so we
have to use
+a special security policy implementation
(net.jini.security.policy.DynamicPolicyProvider),
+which has to be configured into the JVM.
+
+* If we're providing proxies that will be downloaded by someone else (this
covers most
+services and a surprising number of clients), then we're going to need to
+attach a codebase annotation to the
+class loader. This annotation (not to be confused with a "Java 5 Annotation"
that
+uses the '@' symbol in source code) ensures that the serialized version of an
object
+will include the location of an http server that can supply the bytecode for
that
+object.
+
+* Speaking of the codebase annotation, the bytecode for a proxy has to be
downloadable
+from somewhere. This could certainly be a standard web server like Tomcat,
but it
+does need to be setup. And the codebase annotation has to point to it.
+
+It is (barely) possible to configure a JRE and setup the policy files using
command-line
+options to the JDK, but there's an easier way: The ServiceStarter container.
+
+So the way that we "run" the service browser is to run the ServiceStarter
container with
+a setup file that instructs it how to run the browser program that we're
really interested in.
+
+ java -Djava.security.manager -Djava.security.policy=server.policy -jar
lib/start.jar start-browser.config
+
+If all is well, you should see the Service Browser start up, with a window
that looks like this:
+
+
+
+If all isn't well, feel free to ask about it on
+[[email protected]](mailto:[email protected]).
+
+Right now, there's probably nothing to browse (No registrars to select).
+We'll fix that in another example.
+
+For now, let's take a look at how we're actually running this client. First,
the command line
+turns on Java security ('-Djava.security.manager') and calls out a policy file
+('-Djava.security.policy=server.policy'). Together, these command line
options enable the security
+manager and set the permissions for code the 'ServiceStarter' code. As we'll
see shortly,
+the actual browser code runs under a different set of security policies, and
any proxies that
+we download run under yet a different policy.
+
+The 'server.policy' file looks like:
+
+ /* Security policy for non-secure server */
+
+ /* Grant all permissions to our classes */
+ grant codeBase "file:lib${/}*" {
+ permission java.security.AllPermission;
+ };
+
+ grant codebase "file:lib${/}*" {
+ permission java.security.AllPermission;
+ };
+
+It simply grants full permissions to any code that is contained in a jar file
in the
+'lib' folder. Note - this policy is fairly safe, since we are in control of
all the code
+that's in the 'lib' folder. You certainly could lock it down further if you
had any
+doubts, but we'll typically be OK.
+
+Note also that we're not granting any permissions to code that is not in our
'lib'
+folder. So if the running program downloads a proxy from a remote source,
that proxy
+has no permissions to do anything. It's permissions will be granted to it
dynamically
+as part of the 'proxy preparation' process. We'll explore that a little when
we
+[create a client](../hello-client/hello-client.html) later on
+
+After that, the command line identifies the jar file to run ('-jar
lib/start.jar).
+This jar file is not a product of the river-examples project - it was
downloaded from
+Maven Central, since the browser module declares it as a dependency. The file
is created in the
+process of building the Jini Technology Starter Kit (you don't need to
download or build the
+JTSK sources for these examples - the artifacts are in Maven Central).
+
+If you examine the contents of the start.jar file, you'll find that it
contains the
+following manifest:
+
+ Manifest-Version: 1.0
+ Ant-Version: Apache Ant 1.9.2
+ Created-By: 1.7.0_45-b18 (Oracle Corporation)
+ Main-Class: com.sun.jini.start.ServiceStarter
+ Class-Path: jsk-platform.jar
+
+This manifest follows the guidelines to be an 'executable jar file'. It lists
a
+main class, and also the classpath that is needed to execute the file. In
this case, it
+calls out 'jsk-platform.jar'. This artifact is
+built in the River JTSK project, and is published to Maven Central. It's
mentioned as
+a dependency by the 'home' module's 'pom.xml', so it is downloaded by Maven
automatically.
+Additionally, for this class path to work, then the 'start.jar' file needs to
be deployed into a folder
+that also contains the 'jsk-*' jars. That's handled by the assembly
specification that's
+contained in the 'home' module.
+
+The last parameter 'start-browser.config', is the name of the configuration
file
+for the service starter. Let's have a look at it:
+
+ /* Configuration file for starting non-secure Browser */
+
+ import com.sun.jini.config.ConfigUtil;
+ import com.sun.jini.start.NonActivatableServiceDescriptor;
+ import com.sun.jini.start.ServiceDescriptor;
+
+ com.sun.jini.start {
+
+ private static policy = "server.policy";
+ private static classpath = "lib${/}browser.jar";
+ private static config = "browser.config";
+ private static codebase = "";
+
+ static serviceDescriptors = new ServiceDescriptor[] {
+ new NonActivatableServiceDescriptor(
+ codebase, policy, classpath,
+ "org.apache.river.examples.browser.Browser",
+ new String[] { config })
+ };
+
+ }//com.sun.jini.start
+
+The syntax kind of looks like Java, but it isn't. This is really a
specification of
+all the objects that the service browser might need, in a form that can be
+relatively easily edited. To understand the configuration, it helps to look
at a
+small amount of the service starter startup code:
+
+ public static void main(String[] args) {
+ ensureSecurityManager();
+ try {
+ logger.entering(ServiceStarter.class.getName(),
+ MessageNames.MAIN, (Object[])args);
+ Configuration config = ConfigurationProvider.getInstance(args);
+ processServiceDescriptors(config);
+ } catch (ConfigurationException cex) {
+ logger.log(Level.SEVERE, MessageNames.SERVICE_CONFIG_EXCEPTION, cex);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, MessageNames.SERVICE_CREATION_EXCEPTION,
e);
+ }
+ logger.exiting(ServiceStarter.class.getName(),
+ MessageNames.MAIN);
+ }
+
+ private static void processServiceDescriptors( Configuration config )
throws Exception
+ {
+ ServiceDescriptor[] descs = (ServiceDescriptor[])
+ config.getEntry(START_PACKAGE, "serviceDescriptors",
+ ServiceDescriptor[].class, null);
+ if (descs == null || descs.length == 0) {
+ logger.warning("service.config.empty");
+ return;
+ }
+
+Looking at the code above, you can see that the 'main(...)' method uses
something called
+'ConfigurationProvider' to create a configuration object based on the command
line
+parameters, and then the 'processServiceDescriptors(...)' method calls
'config.getEntry(...)' to
+retrieve objects from the configuration.
+
+So, the configuration file uses a Java-like syntax to specify how to create
the
+objects that are needed to run the service browser. It isn't really that much
+different from Spring bean configuration files, if you're familiar with those.
+We'll end up using similar
+configuration files to configure the infrastructure services and also our
service and client
+examples.
+
+The configuration file that we referenced on the command line is there to
configure
+the service starter. It basically lets the service starter obtain a list of
services that
+it should start, by supplying a 'variable' that looks a lot like a plain old
Java
+variable initializer:
+
+ static serviceDescriptors = new ServiceDescriptor[] {
+ new NonActivatableServiceDescriptor(
+ codebase, policy, classpath,
+ "org.apache.river.examples.browser.Browser",
+ new String[] { config })
+ };
+
+When the service starter asks its Configuration for a property called
'serviceDescriptors',
+the configuration will return an array containing a single instance of
+the 'NonActivatableServiceDescriptor' class, constructed using the parameters
'codebase',
+'policy', 'classpath', etc. Where these parameters look like variables, the
configuration
+uses the initializer that's found elsewhere in the configuration file. For
instance, the 'policy'
+entry is declared to be the literal string "server.policy".
+
+That browser configuration file is perhaps more interesting. It contains the
following:
+
+ org.apache.river.examples.browser {
+
+ serverExporter = new
BasicJeriExporter(TcpServerEndpoint.getInstance(0),
+ new BasicILFactory());
+
+ serviceInvocationConstraints=InvocationConstraints.EMPTY;
+
+ proxyPermissions = new Permission[] {
+ new RuntimePermission("accessClassInPackage.com.sun.proxy"),
+ new java.lang.reflect.ReflectPermission("newProxyInPackage.*")
+ };
+
+ servicePreparer =
+ new BasicProxyPreparer(false, new
BasicMethodConstraints(serviceInvocationConstraints),
+ proxyPermissions );
+
+ leasePreparer =
+ new BasicProxyPreparer(false, new
BasicMethodConstraints(serviceInvocationConstraints),
+ proxyPermissions );
+ }
+
+We'll actually explore these files more when we talk about writing services
and clients.
+The browser example is a little out of scope.
+
+The net result of the service starter configuration is to construct an
instance of
+'org.apache.river.examples.browser.Browser' using the arguments
'browser.config', and run
+it in a classloader that has the appropriate codebase annotation set on it.
+
+OK, now we need to get some services running, so we can see them in the
browser.
+That's described in
+[Infrastructure Services...](../infrastructure/infrastructure.html).
Added:
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
(added)
+++
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,16 @@
+A Hello Service Example
+=================
+
+OK, let's look at a service!
+
+Actually, before we create a service, we need to create the Application
+Programming Interface (API) for a service. We do that in a separate Maven
module,
+so that the api will be contained in its own artifact. Then later on, we can
+refer to that artifact in both the service implementation and the client
implementation.
+
+That way, the service and client both have a dependency on the API, but the
client does
+not have any dependency on the service implementation.
+
+So, if you have a look at the 'hello-api' module of the examples project,
you'll see the
+following interface defined:
+
Added:
river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/infrastructure.md
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/infrastructure.md?rev=1650673&view=auto
==============================================================================
---
river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/infrastructure.md
(added)
+++
river/river-examples/river-examples/trunk/src/site/markdown/infrastructure/infrastructure.md
Fri Jan 9 21:23:59 2015
@@ -0,0 +1,44 @@
+Infrastructure Services
+=======================
+
+A set of services and clients that are interoperating using Jini is called a
+'workgroup' or sometimes a 'djinn'.
+
+These services and clients need some basic infrastructure available to them.
There needs
+to be a service registrar in order for clients to find services. Clients may
want to
+use a transaction manager. They may want to use messaging intermediaries, and
so on.
+
+All these supporting functions are implemented by River's infrastructure
services.
+Because services are run by the service starter, we need run the service
starter with the
+list of infrastructure services that we want to run.
+
+In some cases, we only want one instance of an infrastructure service to
running in a
+workgroup. For example, if we have a shared JavaSpaces implementation, we
usually
+only want that running on one machine.
+
+In other cases, we might want more than one instance. The service registrar,
for example,
+should probably run on at least two machines in the work group, so that we
don't have a
+single point of failure.
+
+In any case, in order to show a simple client and service, we'll need a
service registrar.
+There's another configuration provided in the examples 'home' module, which we
can run as below:
+
+ java -Djava.security.manager -Djava.security.policy=server.policy -jar
lib/start.jar start-infra.config
+
+If you run this command line, and you still have your service browser open
from the
+previous section, you should see a registrar appear in the browser, like so:
+
+
+
+Click on the _Registrar_ menu and select the registrar that's shown.
+
+
+
+Now the service browser should show you all the services that are registered
with
+that registrar. You should now see one service, which is the registrar itself.
+
+
+
+Congratulations! You now have a working infrastructure for Jini/Reggie!
+
+Next, let's [build a service](../hello-service/hello-service.html) that
executes within this workgroup.
Added:
river/river-examples/river-examples/trunk/src/site/resources/browser/browser-start.png
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/resources/browser/browser-start.png?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/src/site/resources/browser/browser-start.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-show-registrar.png
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-show-registrar.png?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-show-registrar.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-with-registrar.png
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-with-registrar.png?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/browser-with-registrar.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/select-registrar.png
URL:
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/resources/infrastructure/select-registrar.png?rev=1650673&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
river/river-examples/river-examples/trunk/src/site/resources/infrastructure/select-registrar.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream