You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by ni...@apache.org on 2008/12/10 06:23:13 UTC
svn commit: r724994 [4/10] - in
/incubator/river/jtsk/skunk/niclas1/examples: ./ browser/ browser/src/
browser/src/main/ browser/src/main/java/ browser/src/main/java/com/
browser/src/main/java/com/sun/ browser/src/main/java/com/sun/jini/
browser/src/ma...
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/build.xml?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/build.xml (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/build.xml Tue Dec 9 21:23:07 2008
@@ -0,0 +1,225 @@
+<!--
+ ! 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.
+ !-->
+
+<project name="browser" basedir="." default="all">
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## ENVIRONMENT SETTINGS -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <property name="top" location="../../../../../.."/>
+
+ <property name="pkg-path" value="com/sun/jini/example/${ant.project.name}"/>
+
+ <!-- ## -->
+ <!-- ## Set java-source for use with the javac task: -->
+ <!-- ## -->
+
+ <property name="java-source" value="${pkg-path}/**/*.java"/>
+
+ <import file="${top}/build_common.xml"/>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: all -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="all"
+ description=""
+ depends="compile">
+
+ </target>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: clean -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="clean"
+ description="Removes all files and dirs created by the build."
+ depends="clean.jre.ext">
+
+ <delete dir="${build.classes}/${pkg-path}" quiet="true"/>
+
+ </target>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: this.jars -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="this.jars"
+ depends="browser.jar,
+ browser-dl.jar">
+
+ </target>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: browser.jar -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="browser.jar"
+ depends="tools">
+
+ <property name="browser.deps" location="${build.deps}/browser.deps"/>
+
+ <!-- ## -->
+ <!-- ## Run ClassDep. -->
+ <!-- ## -->
+
+ <java classname="com.sun.jini.tool.ClassDep"
+ failonerror="true"
+ output="${browser.deps}">
+
+ <classpath refid="path.classdep"/>
+ <arg value="-cp"/>
+ <arg path="${build.classes}"/>
+ <arg value="-files"/>
+ <arg line="${jskprivate.include}"/>
+
+ <arg line="-in com.sun.jini.example.browser"/>
+
+ <arg value="com.sun.jini.example.browser.Browser"/>
+ <arg value="com.sun.jini.example.browser.Browser$$Listener_Stub"/>
+ <arg value="com.sun.jini.example.browser.ServiceEditor$$NotifyReceiver_Stub"/>
+
+ </java>
+
+ <!-- ## -->
+ <!-- ## Generate the jar file. -->
+ <!-- ## -->
+
+ <delete file="${build.lib}/browser.jar" quiet="true"/>
+
+ <jar destfile="${build.lib}/browser.jar"
+ index="false"
+ manifest="${src.jini.manifest}/browser.mf">
+
+ <fileset dir="${build.classes}" includesfile="${browser.deps}"/>
+
+ </jar>
+
+ </target>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: browser-dl.jar -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="browser-dl.jar"
+ depends="tools">
+
+ <property name="browser-dl.deps" location="${build.deps}/browser-dl.deps"/>
+
+ <!-- ## -->
+ <!-- ## Run ClassDep. -->
+ <!-- ## -->
+
+ <java classname="com.sun.jini.tool.ClassDep"
+ failonerror="true"
+ output="${browser-dl.deps}">
+
+ <classpath refid="path.classdep"/>
+ <arg value="-cp"/>
+ <arg path="${build.classes}"/>
+ <arg value="-files"/>
+ <arg line="${jskprivate.include}"/>
+
+ <arg line="-in com.sun.jini.example.browser"/>
+
+ <arg value="com.sun.jini.example.browser.Browser$$Listener_Stub"/>
+ <arg value="com.sun.jini.example.browser.ServiceEditor$$NotifyReceiver_Stub"/>
+ <arg value="com.sun.jini.proxy.BasicProxyTrustVerifier"/>
+
+ </java>
+
+ <!-- ## -->
+ <!-- ## Generate the jar file. -->
+ <!-- ## -->
+
+ <delete file="${build.lib-dl}/browser-dl.jar" quiet="true"/>
+
+ <jar destfile="${build.lib-dl}/browser-dl.jar"
+ index="false">
+
+ <fileset dir="${build.classes}" includesfile="${browser-dl.deps}"/>
+
+ </jar>
+
+ <!-- ## -->
+ <!-- ## Generate the Preferred List -->
+ <!-- ## -->
+
+ <preferredlistgen>
+
+ <plg-elements>
+
+ <arg line="-cp"/>
+ <arg path="${build.lib}/jsk-platform.jar"/>
+
+ <arg line="-jar"/>
+ <arg path="${build.lib-dl}/browser-dl.jar"/>
+
+ <arg line="-jar"/>
+ <arg path="${build.lib-dl}/jsk-dl.jar"/>
+
+ <arg line="-proxy com.sun.jini.example.browser.ServiceEditor$$NotifyReceiver_Stub"/>
+
+ </plg-elements>
+
+ </preferredlistgen>
+
+ </target>
+
+
+ <!-- ################################################################ -->
+ <!-- ## -->
+ <!-- ## TARGET: this.stubs -->
+ <!-- ## -->
+ <!-- ################################################################ -->
+
+ <target name="this.stubs"
+ description="Builds the RMI stubs for ${ant.project.name}."
+ depends="compile">
+
+ <rmic base="${build.classes}" stubversion="1.2">
+
+ <classpath refid="path.jini"/>
+
+ <include name="com/sun/jini/example/browser/Browser$$Listener.class"/>
+ <include name="com/sun/jini/example/browser/ServiceEditor$$NotifyReceiver.class"/>
+
+ </rmic>
+
+ </target>
+
+</project>
+
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser1.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser1.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser1.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser2.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser2.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser2.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser3.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser3.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser3.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser4.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser4.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser4.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser5.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser5.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser5.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser6.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser6.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser6.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser7.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser7.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser7.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser8.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser8.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser8.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser9.gif
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser9.gif?rev=724994&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/doc-files/browser9.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/package.html
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/package.html?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/package.html (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/java/com/sun/jini/example/browser/package.html Tue Dec 9 21:23:07 2008
@@ -0,0 +1,934 @@
+<!--
+ ! 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.
+ !-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
+ "http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd">
+<html>
+<head>
+ <title>Service Browser</title>
+</head>
+<body text="#000000" bgcolor="#ffffff" link="#9b37cc"
+ vlink="#cc1877" alink="#ffffff">
+A visualization tool for exploring Jini Network Technology
+communities (<i>djinns</i>). The Service Browser
+lets you discover lookup services and inspect the various
+services registered within those lookup services. This tool
+is provided as an example program within the Apache River release
+but many who use it think
+of it more as a utility than an example.
+<p>
+ This document provides the following information about the Service Browser:
+<ul>
+ <li><a href="#running">Running the Service Browser</a>
+ <li><a href="#discovering">Discovering and Selecting a Lookup Service</a>
+ <li><a href="#inspecting">Inspecting Services</a>
+ <li><a href="#filtering">Filtering Services</a>
+ <li><a href="#miscops">Other Operations</a>
+ <li><a href="#configuring">Configuring the Service Browser</a>
+ <li><a href="#logging">Loggers and Logging Levels</a>
+ <li><a href="#examples">Examples for Running the Service Browser</a>
+</ul>
+
+<a name="running"></a>
+
+<h2>Running the Service Browser</h2>
+The Service Browser is started with the following command line
+structure:
+<blockquote><pre>
+% java <var><b>java_options</b></var>
+ -jar <var><b>install_dir</b></var>/lib/browser.jar
+ <var><b>config_options</b></var>
+</pre>
+</blockquote>
+where <var><b>java_options</b></var> includes such things as the security
+policy file and the RMI codebase annotation, <var><b>install_dir</b></var>
+is the directory where the Apache River release is installed, and
+<var><b>config_options</b></var> includes any
+{@link net.jini.config.Configuration} provider options. The
+Service Browser can be run with no <var><b>config_options</b></var>.
+For the RMI codebase annotation,
+the system property <code>java.rmi.server.codebase</code> should be set to
+two URLs that provide HTTP-based access to the Service Browser's download
+JAR files,
+<code><var><b>install_dir</b></var>/lib-dl/browser-dl.jar</code> and
+<code><var><b>install_dir</b></var>/lib-dl/jsk-dl.jar</code>, in that order.
+<p>
+ The Service Browser also can be run as a nonactivatable entity under the
+ {@linkplain com.sun.jini.start Service Starter}, using
+ <code>com.sun.jini.example.browser.Browser</code> for the implementation
+ class, <code><var><b>install_dir</b></var>/lib/browser.jar</code> for the
+ implementation class path, and a codebase containing URLs for
+ <code><var><b>install_dir</b></var>/lib-dl/browser-dl.jar</code> and
+ <code><var><b>install_dir</b></var>/lib-dl/jsk-dl.jar</code> (in that order).
+
+ <a name="discovering"></a>
+
+<h2>Discovering and Selecting a Lookup Service</h2>
+The lookup services that will be discovered are initially controlled
+by configuration entries, with the default being to perform multicast
+discovery for all lookup services. If you specify one or more groups or
+addresses in a configuration file (as described in
+<a href="#configuring">Configuring the Service Browser</a>),
+the browser only discovers lookup services that are members of those groups
+or that are at those addresses.
+<p>
+ The Service Browser presents a single window when it is started. The
+ window has the menu items <b>File</b>, <b>Registrar</b>, <b>Options</b>,
+ <b>Services</b>, and <b>Attributes</b>. The upper text area changes to
+ show which groups and/or addresses are being used for discovery and
+ how many lookup services have been discovered.
+ The picture below shows a typical Service Browser main window, in which
+ nine lookup services have been discovered, but none have yet been selected.
+
+<p>
+ <img src="doc-files/browser1.gif"
+ Alt="Picture of the lookup browser as it looks when it first starts.">
+
+<p>
+ As lookup services are discovered,
+ they appear under the <b>Registrar</b> menu, listed by unicast address.
+ A specific lookup service can then be selected from this menu for browsing.
+ When a lookup service is selected, the upper text area will be revised to
+ show the number of services registered in that lookup service, and the lower
+ folder area will show the registered services. Administrable services
+ are shown with a blue icon, and non-administrable services are shown with
+ a gray icon. As new services register or existing services unregister,
+ the contents of the window will change automatically to reflect them.
+
+<p>
+ After initial start up, different lookup services can be discovered
+ using several items available from the <b>File</b> menu:
+<ul>
+ <li><b>Find All</b> will perform multicast discovery for all lookup
+ services. This is the default behavior of the
+ browser when it first starts.
+ </li>
+ <li><b>Find Public</b> will perform multicast discovery for all lookup
+ services that are members of the <code>public</code> group.
+ </li>
+ <li><b>Find By Group...</b> will present a dialog box allowing you to
+ specify one or more group names (separated by commas or whitespace).
+ Multicast discovery will then be performed to find all lookup
+ services that are members of those groups.
+ </li>
+ <li><b>Find By Address...</b> will present a dialog box allowing you to
+ specify one or more unicast addresses (separated by commas or
+ whitespace). Unicast discovery will then be performed to find the
+ lookup services at those adddresses.
+ </li>
+</ul>
+<p>
+ For example, the picture below shows the dialog box presented when the
+ <b>Find By Group...</b> menu item is selected.
+
+<p>
+ <img src="doc-files/browser2.gif"
+ Alt="Picture of the lookup browser with File menu pulled down.">
+
+<p>
+ In this next picture, the group name <code>examples.jini.sun.com</code>
+ will be entered.
+
+<p>
+ <img src="doc-files/browser3.gif"
+ Alt="Picture of the lookup browser with group dialog box visible.">
+
+<p>
+ After the group <code>examples.jini.sun.com</code> has been entered, a list of
+ discovered lookup services will appear in the <b>Registrar</b> menu.
+ In this example, only the host
+ <code>kahlua</code> has a lookup service running that is a member of
+ <code>examples.jini.sun.com</code>, so <code>kahlua</code> is the only
+ address in the drop-down list from the <b>Registrar</b> menu.
+
+<p>
+ <img src="doc-files/browser4.gif"
+ Alt="Picture of the lookup browser with drop-down registrar list visible.">
+
+<p>
+ When <code>kahlua</code> is selected from the <b>Registrar</b>
+ menu, the window contents change as shown in the next picture.
+ In this example, six services are registered:
+
+<p>
+ <img src="doc-files/browser5.gif"
+ Alt="Picture of the lookup browser with six services visible.">
+
+ <a name="inspecting"></a>
+
+<h2>Inspecting Services</h2>
+Double clicking on a service listed in the lower area of the main window
+will open a new window, which can be used to inspect and optionally edit
+attributes of the selected service. The window is titled <b>ServiceItem
+ Editor</b> if the service's administrative proxy implements any of the
+administrative interfaces supported by the Service Browser, otherwise it is
+titled <b>ServiceItem Browser</b>. In our running example,
+double clicking on the <b>net.jini.core.lookup.ServiceRegistrar</b>
+item opens this window:
+<p>
+ <img src="doc-files/browser6.gif"
+ Alt="Picture of the ServiceItem editor when first opened.">
+
+<p>
+ The window shows all of the attribute sets
+ that can be inspected and, in some cases, altered. Attribute sets and
+ attributes with blue icons can be edited, those with gray icons cannot.
+ An attribute set can be edited if it is not
+ {@link net.jini.lookup.entry.ServiceControlled} and the service's
+ administrative proxy implements the {@link net.jini.admin.JoinAdmin} interface.
+ Within an editable attribute set, an attribute can be edited if it is of
+ type <code>String</code> or one of the primitive wrapper classes.
+ The two attribute sets shown in the example above are <b>ServiceInfo</b>
+ and <b>BasicServiceType</b>.
+ Each of these entries can be expanded by double-clicking on them
+ as illustrated in the next two pictures.
+
+<p>
+ Expanding the <b>BasicServiceType</b> entry:
+
+<p>
+ <img src="doc-files/browser7.gif"
+ Alt="Picture of the ServiceItem editor with BasicServiceType expanded.">
+
+<p>
+ Expanding the <b>ServiceInfo</b> entry:
+
+<p>
+ <img src="doc-files/browser8.gif"
+ Alt="Picture of the ServiceItem editor with all items expanded.">
+
+<p>
+ Double clicking again on an entry collapses the view. In an expanded entry,
+ double clicking on an editable attribute brings up a dialog box that
+ allows you to input a new value for the attribute. You can also use
+ the <b>Edit</b> menu in the <b>ServiceItem Editor</b> window to
+ add and remove attribute sets, if the service's administrative proxy
+ implements the {@link net.jini.admin.JoinAdmin} interface.
+ Select <b>Add attribute...</b> from the <b>Edit</b> menu to add an
+ attribute set. (Note that for this to work, you will have to run the
+ Service Browser in such a way that the desired attribute set classes
+ are in both its class path and its codebase.)
+ Click on an attribute set and then select <b>Remove attribute</b> from
+ the <b>Edit</b> menu to delete an attribute set.
+
+ <a name="filtering"></a>
+
+<h2>Filtering Services</h2>
+Back in the main window, the <b>Services</b> menu shows various types that
+the registered services are instances of. You can select one or more of
+these types to add them your current template to refine the set of
+services displayed in the lower area of the window. When you select a
+type, it appears in the upper text area to show you what your new
+template contains, the revised number of matching services is shown,
+and only the services that are instances of all of the selected types are
+displayed in the lower area.
+<p>
+ Similarly, the <b>Attributes</b> menu shows attribute set classes (with
+ package prefixes removed) that can be added to your current template to
+ refine the set of services.
+ When you select a class, it appears in the upper text area to
+ show you what your new template contains, the revised number of
+ matching services is shown, and only the services with such an attribute
+ set are displayed in the lower area. In addition, the selected menu item
+ changes to a pull-aside menu.
+ You can go back to the <b>Attributes</b> menu to select
+ additional attribute set classes, or traverse a pull-aside menu to
+ see the names of attributes, each of which is itself a pull-aside
+ menu. You can traverse these to see the possible values for the
+ attributes, and select one to further refine your search. You
+ can deselect existing attribute choices, and you can deselect
+ the <code>(match)</code> menu item to deselect an entire class.
+
+<p>
+ By default, the <b>Services</b> menu only shows service interface types. You
+ can select <b>Service classes</b> from the <b>Options</b> menu to see service
+ implementation classes instead. By default, only the most-derived interfaces
+ or classes are shown, but you can select <b>Service supertypes</b> from the
+ <b>Options</b> menu to see supertypes as well. Similarly, by default only the
+ most-derived attribute set classes are shown in the <b>Attributes</b>
+ menu, but you can select <b>Attribute supertypes</b> from the
+ <b>Options</b> menu to see superclasses as well.
+
+<p>
+ Select <b>Reset</b> from the <b>File</b> menu of the main window
+ to reset the template to the initial (empty) state.
+
+ <a name="miscops"></a>
+
+<h2>Other Operations</h2>
+In the lower area of the main window, you can right click on a service
+to obtain a popup menu. Select <b>Show Info</b> from this menu to see
+details about service ID and service types. If the service's administrative
+proxy implements any of the administrative interfaces supported by the Service
+Browser, selecting <b>Admin Service</b> from this menu brings up the
+<b>ServiceItem Editor</b> window. Selecting <b>Browse Service</b> from
+this menu brings up the <b>ServiceItem Browser</b> window. If the service
+is a JavaSpaces service and either its proxy implements the
+{@link net.jini.space.JavaSpace05} interface or its administrative proxy
+implements the {@link com.sun.jini.outrigger.JavaSpaceAdmin}
+interface, selecting <b>Browse Entries</b> from this menu brings up a
+window that displays all of the current entries.
+<p>
+ In a <b>ServiceItem Editor</b> window, the <b>Admin</b> menu allows
+ various administrative operations to be performed on the service.
+ If the service's administrative proxy implements the
+ {@link net.jini.admin.JoinAdmin} interface,
+ you can use the <b>Joining groups...</b> and <b>Joining locators...</b>
+ menu items to control which lookup groups and lookup locators the
+ service uses for lookup discovery and join.
+ If the service is itself a lookup service and its administrative proxy
+ implements the {@link net.jini.lookup.DiscoveryAdmin} interface, you can use
+ the <b>Member groups...</b> menu item to control
+ which groups the lookup service is a member of, and you can
+ use the <b>Unicast port...</b> menu item to control
+ which unicast port the lookup service uses for its lookup locator.
+ If the service's administrative proxy implements the
+ {@link com.sun.jini.admin.DestroyAdmin}
+ interface, you can use the <b>Destroy</b> menu item to destroy the
+ service. This last menu selection is illustrated in the picture below.
+
+<p>
+ <img src="doc-files/browser9.gif"
+ Alt="Picture of the ServiceItem editor with Destroy selected from the Admin menu.">
+
+ <a name="configuring"></a>
+
+<h2>Configuring the Service Browser</h2>
+
+The Service Browser obtains its configuration by calling
+{@link net.jini.config.ConfigurationProvider#getInstance(String[],ClassLoader)
+ConfigurationProvider.getInstance} with the <var><b>config_options</b></var>
+specified on the command line and the class loader for the main
+implementation class.
+<p>
+ The Service Browser supports the following configuration
+ entries, with component <code>com.sun.jini.example.browser</code>:
+
+<p>
+
+ <a name="adminPreparer"></a>
+<table summary="Describes the adminPreparer configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ adminPreparer</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.security.ProxyPreparer}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>
+ new {@link net.jini.security.BasicProxyPreparer}()
+ </code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Prepares administrative proxies obtained by calling
+ the {@link net.jini.admin.Administrable#getAdmin Administrable.getAdmin}
+ method on service proxies. The value should not be <code>null</code>.
+ The Service Browser only calls methods on an administrative proxy if
+ administrative operations are performed using menu items. Methods of
+ the {@link net.jini.admin.JoinAdmin},
+ {@link net.jini.lookup.DiscoveryAdmin},
+ {@link com.sun.jini.admin.DestroyAdmin}, and
+ {@link com.sun.jini.outrigger.JavaSpaceAdmin} interfaces can be invoked.
+</table>
+
+<a name="discoveryManager"></a>
+<table summary="Describes the discoveryManager configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ discoveryManager</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.discovery.DiscoveryManagement}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td>
+<pre>
+new {@link net.jini.discovery.LookupDiscoveryManager}(
+ {@link net.jini.discovery.DiscoveryGroupManagement#NO_GROUPS},
+ null, // locators
+ null, // listener
+ this) // config
+</pre>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Supplies the object used to discover lookup services.
+ The value should not be <code>null</code>. The object returned must
+ also implement {@link net.jini.discovery.DiscoveryGroupManagement} and
+ {@link net.jini.discovery.DiscoveryLocatorManagement}, and should be
+ configured initially to discover no groups and no specific lookup
+ services.
+</table>
+
+<a name="exitActionListener"></a>
+<table summary="Describes the exitActionListener configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ exitActionListener</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link java.awt.event.ActionListener}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td> see the {@link com.sun.jini.example.browser.Browser}
+ constructors for details
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> The action listener for the <b>Exit</b> item of
+ the <b>File</b> menu.
+</table>
+
+<a name="folderView"></a>
+<table summary="Describes the folderView configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ folderView</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td><code>boolean</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>true</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Controls the format of the main window.
+ If <code>true</code>, the main window is split into two areas
+ as described in the rest of this documentation. If <code>false</code>,
+ the main window a single text area, and many of the browsing and
+ administrative operations are not available; the <b>Show Matches</b>
+ item of the <b>File</b> menu must be used to display services
+ registered in the selected lookup service.
+</table>
+
+<a name="initialLookupGroups"></a>
+<table summary="Describes the initialLookupGroups configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ initialLookupGroups</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td><code>String[]</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>null</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> The names of the lookup groups that the Service
+ Browser should initially discover. An empty array specifies that no groups
+ should be discovered. A <code>null</code> value specifies that all
+ lookup services should be discovered. Otherwise, the value specifies the
+ names of the groups to discover. The array must not contain
+ <code>null</code> elements. This entry used when the Service Browser is
+ first started; after initial startup, lookup service discovery is
+ controlled through the <b>File</b> menu.
+</table>
+
+<a name="initialLookupLocators"></a>
+<table summary="Describes the initialLookupLocators configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ initialLookupLocators</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td><code>{@link net.jini.core.discovery.LookupLocator}[]</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>null</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> The locators for specific lookup services that
+ the Service Browser should initially discover. An empty array or
+ <code>null</code> specifies that no specific lookup services
+ should be discovered. The array must not contain <code>null</code>
+ elements. This entry is used when the Service Browser is first started;
+ after initial startup, lookup service discovery is controlled through
+ the <b>File</b> menu.
+ <p>
+ Note that the constraints specified in the <code>locatorConstraints</code>
+ configuration entry will not be used for these initial locators; any
+ desired constraints should be attached directly to the initial locators.
+</table>
+
+<a name="leaseManager"></a>
+<table summary="Describes the leaseManager configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ leaseManager</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.lease.LeaseRenewalManager}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>new LeaseRenewalManager(this /* config */)</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Supplies the lease renewal manager used to
+ renew leases for remote event registrations and when obtaining the
+ entries of a JavaSpaces service. The value should not be
+ <code>null</code>.
+</table>
+
+<a name="leasePreparer"></a>
+<table summary="Describes the leasePreparer configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ leasePreparer</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.security.ProxyPreparer}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>
+ new {@link net.jini.security.BasicProxyPreparer}()
+ </code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Prepares leases obtained from registering
+ for event notifications with lookup services and from requesting
+ the entries of a JavaSpaces service. The value should not be
+ <code>null</code>.
+ <p>
+ The Service Browser calls the {@link net.jini.core.lease.Lease#renew
+ renew} and {@link net.jini.core.lease.Lease#cancel cancel} methods on
+ leases, and the {@link net.jini.core.lease.LeaseMap#renewAll renewAll}
+ method on lease maps created (via the {@link
+ net.jini.lease.LeaseRenewalManager}) from leases.
+</table>
+
+<a name="listenerExporter"></a>
+<table summary="Describes the listenerExporter configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ listenerExporter</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.export.Exporter}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td>
+<pre>
+new {@link net.jini.jeri.BasicJeriExporter}(
+ {@link net.jini.jeri.tcp.TcpServerEndpoint#getInstance TcpServerEndpoint.getInstance}(0),
+ new {@link net.jini.jeri.BasicILFactory}(), false, false)
+</pre>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> The object to use for exporting all
+ {@link net.jini.core.event.RemoteEventListener} instances used
+ by the Service Browser when registering for event notifications from
+ lookup services. The value should not be <code>null</code>.
+</table>
+
+<a name="locatorConstraints"></a>
+<table summary="Describes the locatorConstraints configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ locatorConstraints</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.core.constraint.MethodConstraints}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>null</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Constraints to attach to any
+ {@link net.jini.core.discovery.LookupLocator} instances constructed
+ from the addresses entered using the <b>Find By Address...</b> menu item.
+ <p>
+ These constraints are not attached to the locators obtained from the
+ <code>initialLookupLocators</code> configuration entry.
+</table>
+
+<a name="loginContext"></a>
+<table summary="Describes the loginContext configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ loginContext</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link javax.security.auth.login.LoginContext}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>null</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Specifies the JAAS login context to use for
+ performing a JAAS login and supplying the
+ {@link javax.security.auth.Subject} to use when running the
+ Service Browser. If <code>null</code>, no JAAS login is performed
+ and no subject is used.
+</table>
+
+<a name="servicePreparer"></a>
+<table summary="Describes the servicePreparer configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ servicePreparer</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td> {@link net.jini.security.ProxyPreparer}
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td><code>
+ new {@link net.jini.security.BasicProxyPreparer}()
+ </code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Prepares service proxies obtained from lookup servics.
+ The value should not be <code>null</code>. The Service Browser
+ calls the {@link net.jini.admin.Administrable#getAdmin
+ Administrable.getAdmin} method on a service proxy for most
+ administrative operations, and calls the
+ {@link net.jini.space.JavaSpace05#contents JavaSpace05.contents}
+ method on a JavaSpaces service proxy to browse entries.
+</table>
+
+<a name="uninterestingInterfaces"></a>
+<table summary="Describes the uninterestingInterfaces configuration entry"
+ border="0" cellpadding="2">
+ <tr valign="top">
+ <th scope="col" summary="layout"><font size="+1">•</font>
+ <th scope="col" align="left" colspan="2"><font size="+1"><code>
+ uninterestingInterfaces</code></font>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Type:
+ <td><code>String[]</code>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Default:
+ <td>
+<pre>
+new String[]{
+ "java.io.Serializable",
+ "java.rmi.Remote",
+ "net.jini.admin.Administrable",
+ "net.jini.core.constraint.RemoteMethodControl",
+ "net.jini.id.ReferentUuid"}
+</pre>
+ <tr valign="top">
+ <td>  
+ <th scope="row" align="right">
+ Description:
+ <td> Supplies the set of interface names that are not
+ interesting to choose when displaying service instances the lower
+ area of the main window. If the service proxy implements exactly
+ one interface that is not in this list, the name of that interface
+ is used to name the service, otherwise the concrete class of the
+ service proxy is used appended with all the names of the 'interesting'
+ interfaces implemented by that proxy. The value should not be
+ <code>null</code>.
+</table>
+<p>
+ Note that additional entries can also be specified to configure the
+ {@link net.jini.lease.LeaseRenewalManager},
+ {@link net.jini.discovery.LookupDiscovery}, and
+ {@link net.jini.discovery.LookupLocatorDiscovery} components. For
+ example, the Service Browser assumes you have configured the discovery
+ manager (obtained from the <code>discoveryManager</code> configuration
+ entry) to enforce any desired constraints for multicast discovery
+ and to perform any desired proxy preparation for all discovered lookup
+ services.
+
+<p>
+ The most commonly used configuration entries are likely to be:
+<ul>
+ <li><a href="#initialLookupGroups"><code>initialLookupGroups</code></a>
+ <li><a href="#initialLookupLocators"><code>initialLookupLocators</code></a>
+</ul>
+<p>
+ Secure deployments typically will provide values for most of the following
+ configuration entries:
+<ul>
+ <li><a href="#loginContext"><code>loginContext</code></a>
+ <li><a href="#leasePreparer"><code>leasePreparer</code></a>
+ <li><a href="#servicePreparer"><code>servicePreparer</code></a>
+ <li><a href="#adminPreparer"><code>adminPreparer</code></a>
+ <li><a href="#listenerExporter"><code>listenerExporter</code></a>
+ <li><a href="#locatorConstraints"><code>locatorConstraints</code></a>
+</ul>
+plus the following configuration entries for <code>LookupDiscovery</code>
+(if groups are used for discovery):
+<ul>
+ <li><code>registrarPreparer</code></li>
+ <li><code>discoveryConstraints</code></li>
+</ul>
+and the following configuration entry for <code>LookupLocatorDiscovery</code>
+(if locators are used for discovery):
+<ul>
+ <li><code>registrarPreparer</code></li>
+</ul>
+
+<a name="logging"></a>
+
+<h2>Loggers and Logging Levels</h2>
+
+The Service Browser uses the {@link java.util.logging.Logger} named
+<code>com.sun.jini.example.browser</code> to log
+information at the following logging levels:
+<p>
+<table border="1" cellpadding="5"
+ summary="Describes logging performed by Service Browser at different
+ logging levels">
+
+ <caption halign="center" valign="top"><b><code>
+ com.sun.jini.example.browser</code></b></caption>
+
+ <tr>
+ <th scope="col"> Level
+ <th scope="col"> Description
+
+ <tr>
+ <td> {@link java.util.logging.Level#SEVERE SEVERE}
+ <td>
+ Problems that prevent Service Browser startup
+
+ <tr>
+ <td> {@link java.util.logging.Level#INFO INFO}
+ <td> Potentially
+ interesting exceptions that occur when performing operations
+
+ <tr>
+ <td> {@link com.sun.jini.logging.Levels#HANDLED HANDLED}
+ <td>
+ Less interesting exceptions that occur when performing operations
+
+</table>
+<p>
+ See the {@link com.sun.jini.logging.LogManager} class for one way to use the
+ <code>HANDLED</code> logging level in standard logging configuration files.
+
+ <a name="examples"></a>
+
+<h2>Examples for Running the Service Browser</h2>
+
+An example command line for starting the Service Browser is:
+<blockquote><pre>
+% java -Djava.security.policy=<a href="#policy">browser.policy</a>
+ -Djava.rmi.server.codebase="http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/browser-dl.jar http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/jsk-dl.jar"
+ -Djava.protocol.handler.pkgs=net.jini.url
+ -jar <var><b>install_dir</b></var>/lib/browser.jar
+</pre>
+</blockquote>
+In this example, the local host is assumed to have the name
+<var><b>your_host</b></var>, running an HTTP server on port
+<var><b>http_port</b></var>, serving files in the <code>lib</code>
+subdirectory of <var><b>install_dir</b></var>, the directory where the
+Apache River release is installed.
+When the Service Browser is run this way, without a configuration file, it
+will perform multicast discovery to find all available lookup
+services, and will use Jini extensible remote invocation (Jini ERI)
+over TCP/IP for its remote event listeners.
+<p>
+ An example command line for starting the Service Browser with a
+ configuration file is:
+<blockquote><pre>
+% java -Djava.security.policy=<a href="#policy">browser.policy</a>
+ -Djava.rmi.server.codebase="http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/browser-dl.jar http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/jsk-dl.jar"
+ -Djava.protocol.handler.pkgs=net.jini.url
+ -jar <var><b>install_dir</b></var>/lib/browser.jar
+ <a href="#public">public.config</a>
+</pre>
+</blockquote>
+The example configuration file <code>public.config</code> only discovers
+lookup services in the public group:
+<a name="public"></a>
+<blockquote><pre>
+com.sun.jini.example.browser {
+ initialLookupGroups = new String[]{""};
+}
+</pre>
+</blockquote>
+<p>
+ The following example configuration file initially discovers no
+ lookup services and uses JRMP for its remote event listeners:
+<blockquote><pre>
+com.sun.jini.example.browser {
+ initialLookupGroups = new String[]{};
+ listenerExporter = new net.jini.jrmp.JrmpExporter();
+}
+</pre>
+</blockquote>
+<p>
+ In all the above command lines, the policy file <code>browser.policy</code>
+ was specified for the <code>java.security.policy</code> system property.
+ An example policy file is:
+ <a name="policy"></a>
+<blockquote><pre>
+grant codebase "file:<var><b>install_dir</b></var>/lib/browser.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codebase "file:<var><b>install_dir</b></var>/lib/jsk-platform.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codebase "file:<var><b>install_dir</b></var>/lib/jsk-lib.jar" {
+ permission java.security.AllPermission;
+};
+
+grant {
+ permission java.net.SocketPermission "*:1024-", "connect";
+};
+</pre>
+</blockquote>
+<p>
+ <b>Note:</b> Of course, a more restrictive policy file could be used;
+ the one shown here is for illustrative purposes only.
+
+<p>
+ An example of running under the Service Starter is:
+<blockquote><pre>
+% java -Djava.security.policy=<a href="#start_policy">start.policy</a>
+ -Djava.protocol.handler.pkgs=net.jini.url
+ -jar <var><b>install_dir</b></var>/lib/start.jar
+ <a href="#start_config">start.config</a>
+</pre>
+</blockquote>
+<p>
+ where <code>start.config</code> is the following configuration file:
+ <a name="start_config"></a>
+<blockquote><pre>
+import com.sun.jini.start.NonActivatableServiceDescriptor;
+import com.sun.jini.start.ServiceDescriptor;
+
+com.sun.jini.start {
+
+ serviceDescriptors = new ServiceDescriptor[]{
+ new NonActivatableServiceDescriptor(
+ "http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/browser-dl.jar http://<var><b>your_host</b></var>:<var><b>http_port</b></var>/jsk-dl.jar",
+ "<a href="#policy">browser.policy</a>",
+ "<var><b>install_dir</b></var>/lib/browser.jar",
+ "com.sun.jini.example.browser.Browser",
+ new String[]{"<a href="#public">public.config</a>"})
+ };
+}
+</pre>
+</blockquote>
+An example policy file for <code>start.policy</code> is:
+<a name="start_policy"></a>
+<blockquote><pre>
+grant codebase "file:<var><b>install_dir</b></var>/lib/start.jar" {
+ permission java.security.AllPermission;
+};
+
+grant codebase "file:<var><b>install_dir</b></var>/lib/jsk-platform.jar" {
+ permission java.security.AllPermission;
+};
+</pre>
+</blockquote>
+</body>
+</html>
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/browser.mf
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/browser.mf?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/browser.mf (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/browser.mf Tue Dec 9 21:23:07 2008
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.sun.jini.example.browser.Browser
+Class-Path: jsk-platform.jar jsk-lib.jar
Added: incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/configentry/browser
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/configentry/browser?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/configentry/browser (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/browser/src/main/resources/configentry/browser Tue Dec 9 21:23:07 2008
@@ -0,0 +1,32 @@
+#/*
+# 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.
+#*/
+
+# browser configuration entries
+com.sun.jini.example.browser.adminPreparer: net.jini.security.ProxyPreparer
+com.sun.jini.example.browser.discoveryManager: net.jini.discovery.DiscoveryManagement
+com.sun.jini.example.browser.exitActionListener: java.awt.event.ActionListener
+com.sun.jini.example.browser.folderView: boolean
+com.sun.jini.example.browser.initialLookupGroups: String[]
+com.sun.jini.example.browser.initialLookupLocators: net.jini.core.discovery.LookupLocator[]
+com.sun.jini.example.browser.leaseManager: net.jini.lease.LeaseRenewalManager
+com.sun.jini.example.browser.leasePreparer: net.jini.security.ProxyPreparer
+com.sun.jini.example.browser.listenerExporter: net.jini.export.Exporter
+com.sun.jini.example.browser.loginContext: javax.security.auth.login.LoginContext
+com.sun.jini.example.browser.locatorConstraints: net.jini.core.constraint.MethodConstraints
+com.sun.jini.example.browser.servicePreparer: net.jini.security.ProxyPreparer
+com.sun.jini.example.browser.uninterestingInterfaces: String[]
Added: incubator/river/jtsk/skunk/niclas1/examples/hello/pom.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/hello/pom.xml?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/hello/pom.xml (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/hello/pom.xml Tue Dec 9 21:23:07 2008
@@ -0,0 +1,58 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.river.example</groupId>
+ <artifactId>master-examples</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.river.example</groupId>
+ <artifactId>river-example-hello</artifactId>
+ <name>Apache River - Example - Hello World</name>
+ <packaging>jar</packaging>
+ <version>10.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-url</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-config</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-discovery</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-export</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-id</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-jeri</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-loader</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.river.api</groupId>
+ <artifactId>river-lookup</artifactId>
+ <version>10.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Added: incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ActivatableServer.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ActivatableServer.java?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ActivatableServer.java (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ActivatableServer.java Tue Dec 9 21:23:07 2008
@@ -0,0 +1,282 @@
+/*
+ * 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 com.sun.jini.example.hello;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationGroup;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupDesc.CommandEnvironment;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationSystem;
+import java.security.PrivilegedExceptionAction;
+import java.util.Properties;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationException;
+import net.jini.config.ConfigurationProvider;
+import net.jini.core.lookup.ServiceID;
+import net.jini.export.Exporter;
+import net.jini.security.BasicProxyPreparer;
+import net.jini.security.ProxyPreparer;
+
+/**
+ * Defines an activatable application server that provides an implementation of
+ * the Hello interface.
+ *
+ * The application uses the following arguments:
+ *
+ * [all] - All arguments are used as options when getting the configuration
+ *
+ * The application uses the following configuration entries, with component
+ * com.sun.jini.example.hello.Server:
+ *
+ * activationIdPreparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the service proxy's activation ID
+ *
+ * activationSystemPreparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the activation system proxy
+ *
+ * configOptions
+ * type: String[]
+ * default: none
+ * The options for the configuration used to configure the server
+ *
+ * discoveryManager
+ * type: DiscoveryManagement
+ * default: new LookupDiscovery(new String[] { "" }, config)
+ * Object used to discover lookup services to join.
+ *
+ * exporter
+ * type: Exporter
+ * default: none
+ * The object to use for exporting the server
+ *
+ * loginContext
+ * type: LoginContext
+ * default: null
+ * If non-null, specifies the JAAS login context to use for performing a JAAS
+ * login and supplying the Subject to use when starting the service. If null,
+ * no JAAS login is performed.
+ *
+ * javaOptions
+ * type: String[]
+ * default: new String[0]
+ * Command line options for the activation group executable
+ *
+ * javaProgram
+ * type: String
+ * default: null
+ * The executable for the activation group, or the default executable if null
+ *
+ * javaProperties
+ * type: String[]
+ * default: new String[0]
+ * System properties for the activation group executable, specified as pairs
+ * of keys and values
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class ActivatableServer extends Server
+{
+
+ /**
+ * The activation ID for this server
+ */
+ private ActivationID aid;
+
+ /**
+ * The service ID for this server
+ */
+ private final ServiceID serviceID;
+
+ /**
+ * Starts and registers an activatable server that implements the Hello
+ * interface.
+ */
+ public static void main( String[] args ) throws Exception
+ {
+ final Configuration config = ConfigurationProvider.getInstance( args );
+ LoginContext loginContext = (LoginContext) config.getEntry(
+ "com.sun.jini.example.hello.Server", "loginContext",
+ LoginContext.class, null );
+ if( loginContext == null )
+ {
+ mainAsSubject( config );
+ }
+ else
+ {
+ loginContext.login();
+ Subject.doAsPrivileged(
+ loginContext.getSubject(),
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ mainAsSubject( config );
+ return null;
+ }
+ },
+ null );
+ }
+ }
+
+ /**
+ * Starts the server with the subject already set.
+ */
+ static void mainAsSubject( Configuration config ) throws Exception
+ {
+ /* Get Java program */
+ String program = (String) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaProgram",
+ String.class, null );
+
+ /* Get options for Java program */
+ String[] options = (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaOptions", String[].class,
+ new String[0] );
+
+ /* Create command environment */
+ CommandEnvironment cmd = new CommandEnvironment( program, options );
+
+ /* Get system properties for Java program */
+ String[] propValues = (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "javaProperties",
+ String[].class, new String[0] );
+ Properties props = new Properties();
+ for( int i = 0; i < propValues.length; i += 2 )
+ {
+ props.setProperty( propValues[ i ], propValues[ i + 1 ] );
+ }
+
+ /* Create group description */
+ ActivationGroupDesc groupDesc = new ActivationGroupDesc( props, cmd );
+
+ /* Create the activation data -- configuration source and service ID */
+ MarshalledObject data = new MarshalledObject(
+ new ActivationData(
+ (String[]) config.getEntry(
+ "com.sun.jini.example.hello.Server", "configOptions",
+ String[].class ),
+ createServiceID() ) );
+
+ /* Get the activation system */
+ ProxyPreparer actSysPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationSystemPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer() );
+ ActivationSystem actSys =
+ (ActivationSystem) actSysPreparer.prepareProxy(
+ ActivationGroup.getSystem() );
+
+ /* Create the activation group */
+ ActivationGroupID gid = actSys.registerGroup( groupDesc );
+
+ /* Create the activation descriptor */
+ ActivationDesc actDesc =
+ new ActivationDesc(
+ gid, ActivatableServer.class.getName(),
+ null /* location */, data, true /* restart */ );
+
+ /* Register the activation descriptor */
+ ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationIdPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer() );
+ ActivationID aid = (ActivationID) actIdPreparer.prepareProxy(
+ actSys.registerObject( actDesc ) );
+
+ /* Activate the server */
+ aid.activate( true );
+
+ System.out.println( "Activated server" );
+ }
+
+ /**
+ * Creates the server
+ *
+ * @param aid the activation ID for the server
+ * @param data the data for the activatable server, which should be the
+ * options to use when getting the Configuration
+ * @throws Exception if a problem occurs
+ */
+ public ActivatableServer( ActivationID aid, MarshalledObject data )
+ throws Exception
+ {
+ super( ( (ActivationData) data.get() ).configOptions );
+ this.aid = aid;
+ serviceID = ( (ActivationData) data.get() ).serviceID;
+ init();
+ }
+
+ /**
+ * Stores the configuration options and service ID for the activatable
+ * server.
+ */
+ static class ActivationData implements Serializable
+ {
+ private static final long serialVersionUID = 2L;
+ final String[] configOptions;
+ final ServiceID serviceID;
+
+ ActivationData( String[] configOptions, ServiceID serviceID )
+ {
+ this.configOptions = configOptions;
+ this.serviceID = serviceID;
+ }
+ }
+
+ /**
+ * Returns the exporter for exporting the server. Prepares the activation
+ * ID and makes it available to the exporter through the getActivationID
+ * method.
+ *
+ * @throws ConfigurationException if a problem occurs getting the exporter
+ * from the configuration
+ * @throws RemoteException if a remote communication problem occurs
+ */
+ protected Exporter getExporter()
+ throws ConfigurationException, RemoteException
+ {
+ /* Prepare the activation ID */
+ ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Server", "activationIdPreparer",
+ ProxyPreparer.class, new BasicProxyPreparer() );
+ aid = (ActivationID) actIdPreparer.prepareProxy( aid );
+
+ /* Provide the activation ID to the exporter */
+ return (Exporter) config.getEntry(
+ "com.sun.jini.example.hello.Server", "exporter", Exporter.class,
+ Configuration.NO_DEFAULT, aid );
+ }
+
+ /**
+ * Returns the service ID for this server.
+ */
+ protected ServiceID getServiceID()
+ {
+ return serviceID;
+ }
+}
Added: incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/Client.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/Client.java?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/Client.java (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/Client.java Tue Dec 9 21:23:07 2008
@@ -0,0 +1,182 @@
+/*
+ * 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 com.sun.jini.example.hello;
+
+import java.rmi.RemoteException;
+import java.security.PrivilegedExceptionAction;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import net.jini.config.Configuration;
+import net.jini.config.ConfigurationProvider;
+import net.jini.config.NoSuchEntryException;
+import net.jini.core.lookup.ServiceItem;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.discovery.LookupDiscovery;
+import net.jini.lookup.ServiceDiscoveryManager;
+import net.jini.lookup.ServiceItemFilter;
+import net.jini.security.BasicProxyPreparer;
+import net.jini.security.ProxyPreparer;
+
+/**
+ * Defines an application that makes calls to a remote Hello server.
+ *
+ * The application uses the following arguments:
+ *
+ * [all] - All arguments are used as options when getting the configuration
+ *
+ * The application uses the following configuration entries, with component
+ * com.sun.jini.example.hello.Client:
+ *
+ * loginContext
+ * type: LoginContext
+ * default: null
+ * If non-null, specifies the JAAS login context to use for performing a JAAS
+ * login and supplying the Subject to use when running the client. If null,
+ * no JAAS login is performed.
+ *
+ * preparer
+ * type: ProxyPreparer
+ * default: new BasicProxyPreparer()
+ * Proxy preparer for the server proxy
+ *
+ * serviceDiscovery
+ * type: ServiceDiscoveryManager
+ * default: new ServiceDiscoveryManager(
+ * new LookupDiscovery(new String[] { "" }, config),
+ * null, config)
+ * Object used for discovering a server that implement Hello.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class Client
+{
+
+ /**
+ * Starts an application that makes calls to a remote Hello implementation.
+ */
+ public static void main( String[] args ) throws Exception
+ {
+ /*
+ * The configuration contains information about constraints to apply to
+ * the server proxy.
+ */
+ final Configuration config = ConfigurationProvider.getInstance( args );
+ LoginContext loginContext = (LoginContext) config.getEntry(
+ "com.sun.jini.example.hello.Client", "loginContext",
+ LoginContext.class, null );
+ if( loginContext == null )
+ {
+ mainAsSubject( config );
+ }
+ else
+ {
+ loginContext.login();
+ Subject.doAsPrivileged(
+ loginContext.getSubject(),
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ mainAsSubject( config );
+ return null;
+ }
+ },
+ null );
+ }
+ }
+
+ /**
+ * Performs the main operations of the application with the specified
+ * configuration and assuming that the appropriate subject is in effect.
+ */
+ static void mainAsSubject( Configuration config ) throws Exception
+ {
+
+ /* Get the service discovery manager, for discovering other services */
+ ServiceDiscoveryManager serviceDiscovery;
+ try
+ {
+ serviceDiscovery = (ServiceDiscoveryManager) config.getEntry(
+ "com.sun.jini.example.hello.Client", "serviceDiscovery",
+ ServiceDiscoveryManager.class );
+ }
+ catch( NoSuchEntryException e )
+ {
+ /* Default to search in the public group */
+ serviceDiscovery = new ServiceDiscoveryManager(
+ new LookupDiscovery( new String[]{ "" }, config ),
+ null, config );
+ }
+
+ /* Retrieve the server proxy preparer from the configuration */
+ ProxyPreparer preparer = (ProxyPreparer) config.getEntry(
+ "com.sun.jini.example.hello.Client",
+ "preparer", ProxyPreparer.class, new BasicProxyPreparer() );
+
+ /* Create the filter to pass to the SDM for proxy preparation */
+ ServiceItemFilter filter = new ProxyPreparerFilter( preparer );
+
+ /* Look up the remote server (SDM performs proxy preparation) */
+ ServiceItem serviceItem = serviceDiscovery.lookup(
+ new ServiceTemplate( null, new Class[]{ Hello.class }, null ),
+ filter, Long.MAX_VALUE );
+ Hello server = (Hello) serviceItem.service;
+
+ /* Use the server */
+ System.out.println( "Server says: " + server.sayHello() );
+
+ /* Exit to close any thread created by the callback handler's GUI */
+ System.exit( 0 );
+ }
+
+ /**
+ * Performs proxy preparation on discovered services. For more information
+ * see the javadoc for the net.jini.lookup.ServiceItemFilter interface.
+ */
+ private static class ProxyPreparerFilter implements ServiceItemFilter
+ {
+ private ProxyPreparer preparer;
+
+ ProxyPreparerFilter( ProxyPreparer preparer )
+ {
+ this.preparer = preparer;
+ }
+
+ /**
+ * See the javadoc for the ServiceItemFilter.check method.
+ */
+ public boolean check( ServiceItem item )
+ {
+ try
+ {
+ item.service = preparer.prepareProxy( item.service );
+ return true; //pass
+ }
+ catch( SecurityException e )
+ {//definite exception
+ return false; //fail: don't try again
+ }
+ catch( RemoteException e )
+ {//indefinite exception
+ item.service = null;
+ return true; //null & true == indefinite: will retry later
+ }
+ }
+ }
+}
Added: incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ConfirmingILFactory.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ConfirmingILFactory.java?rev=724994&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ConfirmingILFactory.java (added)
+++ incubator/river/jtsk/skunk/niclas1/examples/hello/src/main/java/com/sun/jini/example/hello/ConfirmingILFactory.java Tue Dec 9 21:23:07 2008
@@ -0,0 +1,158 @@
+/*
+ * 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 com.sun.jini.example.hello;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.server.ExportException;
+import java.rmi.server.ServerNotActiveException;
+import java.util.Collection;
+import javax.swing.JOptionPane;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.export.ServerContext;
+import net.jini.io.context.ClientHost;
+import net.jini.jeri.BasicILFactory;
+import net.jini.jeri.BasicInvocationDispatcher;
+import net.jini.jeri.InvocationDispatcher;
+import net.jini.jeri.ObjectEndpoint;
+import net.jini.jeri.ServerCapabilities;
+
+/**
+ * Defines an <code>InvocationLayerFactory</code> that uses pop-up dialog
+ * windows to confirm calls.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class ConfirmingILFactory extends BasicILFactory
+{
+
+ /**
+ * Creates a <code>InvocationLayerFactory</code> that confirms calls, with
+ * no server constraints and no permission class.
+ */
+ public ConfirmingILFactory()
+ {
+ }
+
+ /**
+ * Creates a <code>InvocationLayerFactory</code> that confirms calls, and
+ * uses the specified server constraints and permission class.
+ */
+ public ConfirmingILFactory( MethodConstraints serverConstraints,
+ Class permissionClass )
+ {
+ super( serverConstraints, permissionClass );
+ }
+
+ /**
+ * Returns a confirming invocation handler for the object endpoint and
+ * interfaces.
+ *
+ * @param interfaces the interfaces
+ * @param impl the remote object
+ * @param oe the object endpoint
+ * @return a confirming invocation handler for the object endpoint and
+ * interfaces
+ */
+ protected InvocationHandler createInvocationHandler( Class[] interfaces,
+ Remote impl,
+ ObjectEndpoint oe )
+ {
+ return new ConfirmingInvocationHandler( oe, getServerConstraints() );
+ }
+
+
+ /**
+ * Returns a confirming invocation dispatcher for the remote object.
+ *
+ * @return a confirming invocation dispatcher for the remote object
+ * @param methods a collection of {@link Method} instances for the
+ * remote methods
+ * @param impl a remote object that the dispatcher is being created for
+ * @param capabilities the transport capabilities of the server
+ */
+ protected InvocationDispatcher createInvocationDispatcher(
+ Collection methods, Remote impl, ServerCapabilities capabilities )
+ throws ExportException
+ {
+ if( impl == null )
+ {
+ throw new NullPointerException( "impl is null" );
+ }
+ return new Dispatch( methods, capabilities, getServerConstraints(),
+ getPermissionClass() );
+ }
+
+ /**
+ * Defines a subclass of BasicInvocationDispatcher that confirms calls.
+ */
+ private static class Dispatch extends BasicInvocationDispatcher
+ {
+
+ Dispatch( Collection methods,
+ ServerCapabilities capabilities,
+ MethodConstraints serverConstraints,
+ Class permissionClass )
+ throws ExportException
+ {
+ super( methods, capabilities,
+ serverConstraints, permissionClass, null );
+ }
+
+ /**
+ * Reads the call identifier and asks whether the call should be
+ * permitted before unmarshalling the arguments.
+ */
+ protected Object[] unmarshalArguments( Remote obj,
+ Method method,
+ ObjectInputStream in,
+ Collection context )
+ throws IOException, ClassNotFoundException
+ {
+ long callId = in.readLong();
+ ClientHost client = null;
+ try
+ {
+ client = (ClientHost)
+ ServerContext.getServerContextElement( ClientHost.class );
+ }
+ catch( ServerNotActiveException e )
+ {
+ }
+ int result = JOptionPane.showConfirmDialog(
+ null,
+ "Permit incoming remote call?" +
+ "\n Client: " + ( client != null
+ ? client.toString() : "not active" ) +
+ "\n Object: " + obj +
+ "\n Method: " + method.getName() +
+ "\n Call id: " + callId,
+ "Permit incoming remote call?",
+ JOptionPane.OK_CANCEL_OPTION );
+ if( result != JOptionPane.OK_OPTION )
+ {
+ throw new SecurityException( "Server denied call" );
+ }
+ return super.unmarshalArguments( obj, method, in, context );
+ }
+ }
+}