diff options
Diffstat (limited to 'java')
30 files changed, 1886 insertions, 77 deletions
diff --git a/java/build.xml b/java/build.xml index f34f7de3f4b..0fd78a7febc 100644 --- a/java/build.xml +++ b/java/build.xml @@ -221,7 +221,8 @@ <target name="icegridadmin-plain-jar" depends="icegridadmin-compile" if="build-icegridadmin-plain-jar"> <manifest file="${lib.dir}/icegridgui.mf"> - <attribute name="Class-Path" value="Ice.jar ../resources/"/> + <attribute name="Main-Class" value="IceGridGUI.Main"/> + <attribute name="Class-Path" value="Ice.jar ${jgoodies.forms} ${jgoodies.looks} ../resources/ "/> </manifest> <jar jarfile="${lib.dir}/IceGridGUI.jar" manifest="${lib.dir}/icegridgui.mf" basedir="${lib.dir}"> <include name="IceGridGUI/**"/> diff --git a/java/demo/Ice/README b/java/demo/Ice/README index ed7506e7146..6a9eceee376 100644 --- a/java/demo/Ice/README +++ b/java/demo/Ice/README @@ -1,9 +1,14 @@ Demos in this directory: +- applet + + An unsigned applet that demonstrates how to use Asynchronous Method + Invocation (AMI) in a graphical client. + - async - This demo illustrates the use of Asynchronous Message Invocation - (AMI) and Asynchronous Message Dispatch (AMD). + This demo illustrates the use of Asynchronous Method Invocation + (AMI) and Asynchronous Method Dispatch (AMD). - bidir diff --git a/java/demo/Ice/applet/Hello.ice b/java/demo/Ice/applet/Hello.ice new file mode 100644 index 00000000000..0ab2de4f3e6 --- /dev/null +++ b/java/demo/Ice/applet/Hello.ice @@ -0,0 +1,24 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef HELLO_ICE +#define HELLO_ICE + +module Demo +{ + +interface Hello +{ + ["ami"] idempotent void sayHello(int delay); + ["ami"] void shutdown(); +}; + +}; + +#endif diff --git a/java/demo/Ice/applet/HelloApplet.java b/java/demo/Ice/applet/HelloApplet.java new file mode 100644 index 00000000000..751ef21ea51 --- /dev/null +++ b/java/demo/Ice/applet/HelloApplet.java @@ -0,0 +1,597 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; + +public class HelloApplet extends JApplet +{ + public void init() + { + // + // Make sure we create the GUI from the Swing event dispatch thread. + // + try + { + SwingUtilities.invokeAndWait(new Runnable() + { + public void run() + { + initUI(); + } + }); + } + catch(Throwable ex) + { + ex.printStackTrace(); + return; + } + + // + // Initialize an Ice communicator. + // + try + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(); + initData.properties.setProperty("Ice.ACM.Client", "10"); + _communicator = Ice.Util.initialize(initData); + } + catch(Throwable ex) + { + handleException(ex); + } + } + + public void start() + { + // Nothing to do. + } + + public void stop() + { + // Nothing to do. + } + + public void destroy() + { + // + // Destroy the Ice run time. + // + if(_communicator != null) + { + try + { + _communicator.destroy(); + } + catch(Throwable ex) + { + ex.printStackTrace(); + } + _communicator = null; + } + } + + private void initUI() + { + Container cp = getContentPane(); + + JLabel l1 = new JLabel("Hostname"); + _hostname = new JTextField(); + JLabel l2 = new JLabel("Mode"); + _mode = new JComboBox(); + JLabel l3 = new JLabel("Timeout"); + _timeoutSlider = new JSlider(0, MAX_TIME); + _timeoutLabel = new JLabel("0.0"); + JLabel l4 = new JLabel("Delay"); + _delaySlider = new JSlider(0, MAX_TIME); + _delayLabel = new JLabel("0.0"); + JPanel buttonPanel = new JPanel(); + _hello = new JButton("Hello World!"); + _shutdown = new JButton("Shutdown"); + _flush = new JButton("Flush"); + _flush.setEnabled(false); + JPanel statusPanel = new JPanel(); + JSeparator statusPanelSeparator = new JSeparator(); + _status = new JLabel(); + _status.setText("Ready"); + + // + // Default to the host from which the applet was downloaded. + // + _hostname.setText(getCodeBase().getHost()); + + final String[] modes = new String[] + { + "Twoway", "Twoway Secure", "Oneway", "Oneway Batch", "Oneway Secure", "Oneway Secure Batch", "Datagram", + "Datagram Batch" + }; + _mode.setModel(new DefaultComboBoxModel(modes)); + + _hello.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sayHello(); + } + }); + _shutdown.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + shutdown(); + } + }); + _flush.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + flush(); + } + }); + _mode.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + changeDeliveryMode(_mode.getSelectedIndex()); + } + }); + changeDeliveryMode(_mode.getSelectedIndex()); + + _timeoutSlider.addChangeListener(new SliderListener(_timeoutSlider, _timeoutLabel)); + _timeoutSlider.setValue(0); + _delaySlider.addChangeListener(new SliderListener(_delaySlider, _delayLabel)); + _delaySlider.setValue(0); + + GridBagConstraints gridBagConstraints; + + cp.setMaximumSize(null); + cp.setPreferredSize(null); + cp.setLayout(new GridBagLayout()); + + l1.setText("Hostname"); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); + cp.add(l1, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(5, 0, 5, 5); + cp.add(_hostname, gridBagConstraints); + + l2.setText("Mode"); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(0, 5, 5, 0); + cp.add(l2, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(0, 0, 5, 5); + cp.add(_mode, gridBagConstraints); + + l3.setText("Timeout"); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(0, 5, 5, 0); + cp.add(l3, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = GridBagConstraints.WEST; + cp.add(_timeoutSlider, gridBagConstraints); + + _timeoutLabel.setMinimumSize(new Dimension(20, 17)); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(0, 5, 5, 5); + cp.add(_timeoutLabel, gridBagConstraints); + + l4.setText("Delay"); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(0, 5, 5, 0); + cp.add(l4, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = GridBagConstraints.WEST; + cp.add(_delaySlider, gridBagConstraints); + + _delayLabel.setMinimumSize(new Dimension(20, 17)); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 3; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(0, 5, 5, 5); + cp.add(_delayLabel, gridBagConstraints); + + _hello.setText("Hello World!"); + buttonPanel.add(_hello); + + _shutdown.setText("Shutdown"); + buttonPanel.add(_shutdown); + + _flush.setText("Flush"); + buttonPanel.add(_flush); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.ipady = 5; + cp.add(buttonPanel, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 5; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(0, 5, 5, 5); + cp.add(statusPanelSeparator, gridBagConstraints); + + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 6; + gridBagConstraints.gridwidth = 3; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(0, 5, 5, 5); + cp.add(_status, gridBagConstraints); + } + + private enum DeliveryMode + { + TWOWAY, + TWOWAY_SECURE, + ONEWAY, + ONEWAY_BATCH, + ONEWAY_SECURE, + ONEWAY_SECURE_BATCH, + DATAGRAM, + DATAGRAM_BATCH; + + Ice.ObjectPrx apply(Ice.ObjectPrx prx) + { + switch (this) + { + case TWOWAY: + prx = prx.ice_twoway(); + break; + case TWOWAY_SECURE: + prx = prx.ice_twoway().ice_secure(true); + break; + case ONEWAY: + prx = prx.ice_oneway(); + break; + case ONEWAY_BATCH: + prx = prx.ice_batchOneway(); + break; + case ONEWAY_SECURE: + prx = prx.ice_oneway().ice_secure(true); + break; + case ONEWAY_SECURE_BATCH: + prx = prx.ice_batchOneway().ice_secure(true); + break; + case DATAGRAM: + prx = prx.ice_datagram(); + break; + case DATAGRAM_BATCH: + prx = prx.ice_batchDatagram(); + break; + } + return prx; + } + + public boolean isBatch() + { + return this == ONEWAY_BATCH || this == DATAGRAM_BATCH || this == ONEWAY_SECURE_BATCH; + } + } + + private Demo.HelloPrx createProxy() + { + String host = _hostname.getText().toString().trim(); + if(host.length() == 0) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _status.setText("No hostname"); + } + }); + return null; + } + + String s = "hello:tcp -h " + host + " -p 10000:ssl -h " + host + " -p 10001:udp -h " + host + " -p 10000"; + Ice.ObjectPrx prx = _communicator.stringToProxy(s); + prx = _deliveryMode.apply(prx); + int timeout = _timeoutSlider.getValue(); + if(timeout != 0) + { + prx = prx.ice_timeout(timeout); + } + return Demo.HelloPrxHelper.uncheckedCast(prx); + } + + class SayHelloI extends Demo.AMI_Hello_sayHello implements Ice.AMISentCallback + { + private boolean _response = false; + + synchronized public void ice_exception(final Ice.LocalException ex) + { + assert (!_response); + _response = true; + + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleException(ex); + } + }); + } + + synchronized public void ice_sent() + { + if(_response) + { + return; + } + + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) + { + _status.setText("Waiting for response"); + } + else + { + _status.setText("Ready"); + } + } + }); + } + + synchronized public void ice_response() + { + assert (!_response); + _response = true; + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _status.setText("Ready"); + } + }); + } + } + + private void sayHello() + { + Demo.HelloPrx hello = createProxy(); + if(hello == null) + { + return; + } + + int delay = _delaySlider.getValue(); + try + { + if(!_deliveryMode.isBatch()) + { + if(hello.sayHello_async(new SayHelloI(), delay)) + { + if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) + { + _status.setText("Waiting for response"); + } + } + else + { + _status.setText("Sending request"); + } + } + else + { + _flush.setEnabled(true); + hello.sayHello(delay); + _status.setText("Queued sayHello request"); + } + } + catch(Ice.LocalException ex) + { + handleException(ex); + } + } + + private void shutdown() + { + Demo.HelloPrx hello = createProxy(); + if(hello == null) + { + return; + } + + try + { + if(!_deliveryMode.isBatch()) + { + hello.shutdown_async(new Demo.AMI_Hello_shutdown() + { + public void ice_exception(final Ice.LocalException ex) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleException(ex); + } + }); + } + + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _status.setText("Ready"); + } + }); + } + }); + if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) + { + _status.setText("Waiting for response"); + } + } + else + { + _flush.setEnabled(true); + hello.shutdown(); + _status.setText("Queued shutdown request"); + } + } + catch(Ice.LocalException ex) + { + handleException(ex); + } + } + + private void flush() + { + new Thread(new Runnable() + { + public void run() + { + try + { + _communicator.flushBatchRequests(); + } + catch(final Ice.LocalException ex) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleException(ex); + } + }); + } + } + }).start(); + + _flush.setEnabled(false); + _status.setText("Flushed batch requests"); + } + + private void changeDeliveryMode(long id) + { + switch ((int)id) + { + case 0: + _deliveryMode = DeliveryMode.TWOWAY; + break; + case 1: + _deliveryMode = DeliveryMode.TWOWAY_SECURE; + break; + case 2: + _deliveryMode = DeliveryMode.ONEWAY; + break; + case 3: + _deliveryMode = DeliveryMode.ONEWAY_BATCH; + break; + case 4: + _deliveryMode = DeliveryMode.ONEWAY_SECURE; + break; + case 5: + _deliveryMode = DeliveryMode.ONEWAY_SECURE_BATCH; + break; + case 6: + _deliveryMode = DeliveryMode.DATAGRAM; + break; + case 7: + _deliveryMode = DeliveryMode.DATAGRAM_BATCH; + break; + } + } + + private void handleException(final Throwable ex) + { + ex.printStackTrace(); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _status.setText(ex.getClass().getName()); + } + } + ); + } + + private static class SliderListener implements ChangeListener + { + SliderListener(JSlider slider, JLabel label) + { + _slider = slider; + _label = label; + } + + public void stateChanged(ChangeEvent ce) + { + float value = (float)(_slider.getValue() / 1000.0); + _label.setText(String.format("%.1f", value)); + } + + private JSlider _slider; + private JLabel _label; + } + + private static final int MAX_TIME = 5000; // 5 seconds + + private JTextField _hostname; + private JComboBox _mode; + private JSlider _timeoutSlider; + private JLabel _timeoutLabel; + private JSlider _delaySlider; + private JLabel _delayLabel; + private JButton _hello; + private JButton _shutdown; + private JButton _flush; + private JLabel _status; + + private Ice.Communicator _communicator; + private DeliveryMode _deliveryMode; +} diff --git a/java/demo/Ice/applet/README b/java/demo/Ice/applet/README new file mode 100644 index 00000000000..83e3cfc5e84 --- /dev/null +++ b/java/demo/Ice/applet/README @@ -0,0 +1,44 @@ +This demo presents an unsigned applet that shows how to make +asynchronous Ice invocations in a graphical application. + +The demo includes a start page (hello.html) that you will need to +publish on a web server. This page assumes that the demo applet is +stored in a fully self-contained archive named Hello.jar. In order to +create a fully self-contained JAR file, you must build the applet +with ProGuard in your CLASSPATH. After a successful build, copy +Hello.jar from this subdirectory to the same directory as hello.html +on your web server. + +If you did not build the applet with ProGuard in your CLASSPATH, the +Hello.jar archive contains only the applet classes. In this case you +must modify the start page to add Ice.jar to the applet's ARCHIVE +parameter. Alternatively, you can add ProGuard to your CLASSPATH and +rebuild the applet with the following commands: + + ant clean + ant + +To run the demo, you must start a "hello" server on the web server +host. You can use the hello server from the ../hello directory or +a hello server from any other Ice language mapping. Note that you may +need to temporarily relax the firewall restrictions on your web server +host to allow the applet to establish connections to the hello server. +Next, start a web browser and open the hello.html page on your web +server. + +Once the applet has started, verify that the name of your web server +host is correct in the "Hostname" field and press the "Hello World!" +button. You will notice that the server prints a "Hello World!" +message to the console for each invocation. To make other types of Ice +invocations, select a different mode from the combobox. + +The two sliders allow you to experiment with various timeout settings. +The "Timeout" slider determines how long the Ice run time will wait +for an invocation to complete, while the "Delay" slider forces the +server to delay its response. The value of each slider is shown in +seconds. To force a timeout, select a non-zero timeout and set the +delay to be larger than the timeout. The server prints two "Hello +World!" messages in this case because the Slice operation sayHello is +marked as idempotent, meaning that Ice does not need to follow the +at-most-once retry semantics. See the manual for more information +about retry behavior. diff --git a/java/demo/Ice/applet/applet.pro b/java/demo/Ice/applet/applet.pro new file mode 100644 index 00000000000..dae1ea08906 --- /dev/null +++ b/java/demo/Ice/applet/applet.pro @@ -0,0 +1,53 @@ +# ProGuard configuration options + +-keep class HelloApplet + +# Preserve all annotations. +-keepattributes *Annotation* + +# Preserve all native method names and the names of their classes. +-keepclasseswithmembernames class * { + native <methods>; +} + +# Preserve a method that is required in all enumeration classes. +-keepclassmembers class * extends java.lang.Enum { + public **[] values(); +} + +-dontskipnonpubliclibraryclasses +-dontusemixedcaseclassnames +-dontwarn + +# We could reduce the size of the JAR file significantly if we +# enable obfuscation but it would make things like stack traces +# much harder to read. +-dontobfuscate + +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# This class is loaded dynamically. +-keep public class IceSSL.PluginFactory { + public *; +} + +# More keeps to suppress Notes + +-keep interface Ice.Communicator +-keep class IceInternal.SelectorHandler + +-keep public class Ice.DispatchStatus { + int __value; + Ice.DispatchStatus[] __values; + int value(); +} + +-keep public class java.net.DatagramSocketImpl { + java.io.FileDescriptor fd; +} diff --git a/java/demo/Ice/applet/build.xml b/java/demo/Ice/applet/build.xml new file mode 100644 index 00000000000..ad9be449216 --- /dev/null +++ b/java/demo/Ice/applet/build.xml @@ -0,0 +1,94 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. + + This copy of Ice is licensed to you under the terms described in the + ICE_LICENSE file included in this distribution. + + ********************************************************************** +--> + +<project name="demo_Ice_applet" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <condition property="proguard-found"> + <available classname="proguard.ant.ProGuardTask" classpath="${env.CLASSPATH}" /> + </condition> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <meta value="${java2metadata}"/> + <includepath> + <pathelement path="${slice.dir}"/> + </includepath> + <fileset dir="." includes="Hello.ice"/> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + debug="${debug}"> + <classpath refid="ice.classpath"/> + <compilerarg value="${javac.lint}"/> + </javac> + <javac srcdir="." destdir="${class.dir}" + excludes="generated/**" debug="${debug}"> + <classpath refid="ice.classpath"/> + <compilerarg value="${javac.lint}"/> + </javac> + </target> + + <target name="jar" depends="compile" unless="proguard-found"> + <jar jarfile="Hello.jar" basedir="${class.dir}"> + <include name="Demo/**"/> + <include name="HelloApplet*"/> + </jar> + </target> + + <target name="proguard-jar" depends="jar" if="proguard-found"> + <condition property="library.jarfiles" value="classes.jar,jsse.jar"> + <os family="mac"/> + </condition> + <condition property="library.jarfiles" value="rt.jar,jsse.jar"> + <!-- Library jar files for Sun JDK --> + <available file="${java.home}/lib/rt.jar"/> + </condition> + <condition property="library.jarfiles" value="vm.jar,core.jar,graphics.jar,security.jar"> + <!-- Library jar files for IBM J9 (from Linux SuSE) --> + <available file="${java.home}/lib/vm.jar"/> + </condition> + <condition property="library.jarpath" value="${java.home}/../Classes" else="${java.home}/lib"> + <os family="mac"/> + </condition> + <pathconvert property="library.jars"> + <filelist dir="${library.jarpath}" files="${library.jarfiles}"/> + </pathconvert> + + <taskdef resource="proguard/ant/task.properties"/> + + <proguard configuration="applet.pro"> + <injar path="${class.dir}"/> + <injar refid="ice.classpath" filter="!META-INF/**"/> + <outjar path="Hello.jar"/> + <libraryjar path="${library.jars}"/> + </proguard> + </target> + + <target name="all" depends="proguard-jar"/> + + <target name="clean"> + <delete file="Hello.jar"/> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> diff --git a/java/demo/Ice/applet/hello.html b/java/demo/Ice/applet/hello.html new file mode 100644 index 00000000000..c0a48d8f38f --- /dev/null +++ b/java/demo/Ice/applet/hello.html @@ -0,0 +1,35 @@ +<html> +<head> +<title>Ice Hello Applet</title> +</head> + +<body> +<object + classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" + codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=1,5,0,0" + WIDTH = 300 HEIGHT = 175 > + <PARAM NAME = CODE VALUE = "HelloApplet" > + <param name = "type" value = "application/x-java-applet;version=1.5"> + <param name = "scriptable" value = "false"> + <param name = "archive" value = "Hello.jar"> + + <comment> + <embed + type = "application/x-java-applet;version=1.5" \ + CODE = "HelloApplet" \ + ARCHIVE = "Hello.jar" \ + WIDTH = 300 \ + HEIGHT = 175 + scriptable = false + pluginspage = "http://java.sun.com/products/plugin/index.html#download"> + <noembed> + alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." + Your browser is completely ignoring the <APPLET> tag! + </noembed> + </embed> + + </comment> +</object> + +</body> +</html> diff --git a/java/demo/Ice/build.xml b/java/demo/Ice/build.xml index f3f00642dbd..36f4d8d9547 100644 --- a/java/demo/Ice/build.xml +++ b/java/demo/Ice/build.xml @@ -12,33 +12,35 @@ <project name="demo_Ice" default="all" basedir="."> <target name="all"> + <ant dir="applet"/> + <ant dir="async"/> <ant dir="bidir"/> <ant dir="callback"/> <ant dir="hello"/> <ant dir="invoke"/> <ant dir="latency"/> <ant dir="minimal"/> + <ant dir="multicast"/> <ant dir="nested"/> + <ant dir="session"/> <ant dir="throughput"/> <ant dir="value"/> - <ant dir="session"/> - <ant dir="async"/> - <ant dir="multicast"/> </target> <target name="clean"> + <ant dir="applet" target="clean"/> + <ant dir="async" target="clean"/> <ant dir="bidir" target="clean"/> <ant dir="callback" target="clean"/> <ant dir="hello" target="clean"/> <ant dir="invoke" target="clean"/> <ant dir="latency" target="clean"/> <ant dir="minimal" target="clean"/> + <ant dir="multicast" target="clean"/> <ant dir="nested" target="clean"/> + <ant dir="session" target="clean"/> <ant dir="throughput" target="clean"/> <ant dir="value" target="clean"/> - <ant dir="session" target="clean"/> - <ant dir="async" target="clean"/> - <ant dir="multicast" target="clean"/> </target> </project> diff --git a/java/demo/RMI/README b/java/demo/RMI/README new file mode 100644 index 00000000000..50bf06f8b2f --- /dev/null +++ b/java/demo/RMI/README @@ -0,0 +1,12 @@ +Demos in this directory: + +- latency + + A simple latency test that measures the basic call dispatch delay of RMI. + +- throughput + + A simple RMI throughput demo that allows you to send sequences of + various types between client and server and to measure the maximum + bandwidth that can be achieved using serialized synchronous + requests. diff --git a/java/demo/RMI/build.xml b/java/demo/RMI/build.xml new file mode 100644 index 00000000000..3892e2818c7 --- /dev/null +++ b/java/demo/RMI/build.xml @@ -0,0 +1,24 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. + + This copy of Ice is licensed to you under the terms described in the + ICE_LICENSE file included in this distribution. + + ********************************************************************** +--> + +<project name="demo" default="all" basedir="."> + + <target name="all"> + <ant dir="latency"/> + <ant dir="throughput"/> + </target> + + <target name="clean"> + <ant dir="latency" target="clean"/> + <ant dir="throughput" target="clean"/> + </target> + +</project> diff --git a/java/demo/RMI/throughput/Client.java b/java/demo/RMI/throughput/Client.java new file mode 100755 index 00000000000..a815d6c64dc --- /dev/null +++ b/java/demo/RMI/throughput/Client.java @@ -0,0 +1,421 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class Client +{ + private static void + menu() + { + System.out.println( + "usage:\n" + + "\n" + + "toggle type of data to send:\n" + + "1: sequence of bytes (default)\n" + + "2: sequence of strings (\"hello\")\n" + + "3: sequence of structs with a string (\"hello\") and a double\n" + + "4: sequence of structs with two ints and a double\n" + + "\n" + + "select test to run:\n" + + "t: Send sequence\n" + + "r: Receive sequence\n" + + "e: Echo (send and receive) sequence\n" + + "\n" + + "other commands:\n" + + "s: shutdown server\n" + + "x: exit\n" + + "?: help\n"); + } + + public int + run(String args[]) throws java.lang.Exception + { + String registryHost; + if(args.length == 0) + { + registryHost = "127.0.0.1"; + } + else if(args.length == 1) + { + registryHost = args[0]; + } + else + { + System.err.println("usage: java Client [registryHost]"); + return 1; + } + + + if(System.getSecurityManager() == null) + { + System.setSecurityManager(new SecurityManager()); + } + Registry registry = LocateRegistry.getRegistry(registryHost); + Throughput throughput = (Throughput)registry.lookup("throughput"); + + byte[] byteSeq = new byte[Throughput.ByteSeqSize]; + + String[] stringSeq = new String[Throughput.StringSeqSize]; + for(int i = 0; i < Throughput.StringSeqSize; ++i) + { + stringSeq[i] = new String("hello"); + } + + Throughput.StringDouble[] structSeq = new Throughput.StringDouble[Throughput.StringDoubleSeqSize]; + for(int i = 0; i < Throughput.StringDoubleSeqSize; ++i) + { + structSeq[i] = new Throughput.StringDouble(); + structSeq[i].s = new String("Hello"); + structSeq[i].d = 3.14; + } + + Throughput.Fixed[] fixedSeq = new Throughput.Fixed[Throughput.FixedSeqSize]; + for(int i = 0; i < Throughput.FixedSeqSize; ++i) + { + fixedSeq[i] = new Throughput.Fixed(); + fixedSeq[i].i = 0; + fixedSeq[i].j = 0; + fixedSeq[i].d = 0; + } + + { + byte[] emptyBytes= new byte[1]; + String[] emptyStrings = new String[1]; + Throughput.StringDouble[] emptyStructs = new Throughput.StringDouble[1]; + emptyStructs[0] = new Throughput.StringDouble(); + Throughput.Fixed[] emptyFixed = new Throughput.Fixed[1]; + emptyFixed[0] = new Throughput.Fixed(); + + System.out.print("warming up..."); + System.out.flush(); + for(int i = 0; i < 100; i++) + { + throughput.sendByteSeq(emptyBytes); + throughput.recvByteSeq(); + throughput.echoByteSeq(emptyBytes); + + throughput.sendStringSeq(emptyStrings); + throughput.recvStringSeq(); + throughput.echoFixedSeq(emptyFixed); + + throughput.sendStructSeq(emptyStructs); + throughput.recvStructSeq(); + throughput.echoStructSeq(emptyStructs); + + throughput.sendFixedSeq(emptyFixed); + throughput.recvFixedSeq(); + throughput.echoStringSeq(emptyStrings); + } + System.out.println(); + } + + menu(); + + java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); + + char currentType = '1'; + int seqSize = Throughput.ByteSeqSize; + + String line = null; + do + { + try + { + System.out.print("==> "); + System.out.flush(); + line = in.readLine(); + if(line == null) + { + break; + } + + long tmsec = System.currentTimeMillis(); + final int repetitions = 100; + + if(line.equals("1") || line.equals("2") || line.equals("3") || line.equals("4")) + { + currentType = line.charAt(0); + + switch(currentType) + { + case '1': + { + System.out.println("using byte sequences"); + seqSize = Throughput.ByteSeqSize; + break; + } + + case '2': + { + System.out.println("using string sequences"); + seqSize = Throughput.StringSeqSize; + break; + } + + case '3': + { + System.out.println("using variable-length struct sequences"); + seqSize = Throughput.StringDoubleSeqSize; + break; + } + + case '4': + { + System.out.println("using fixed-length struct sequences"); + seqSize = Throughput.FixedSeqSize; + break; + } + } + } + else if(line.equals("t") || line.equals("o") || line.equals("r") || line.equals("e")) + { + char c = line.charAt(0); + + switch(c) + { + case 't': + { + System.out.print("sending"); + break; + } + + case 'r': + { + System.out.print("receiving"); + break; + } + + case 'e': + { + System.out.print("sending and receiving"); + break; + } + } + + System.out.print(" " + repetitions); + switch(currentType) + { + case '1': + { + System.out.print(" byte"); + break; + } + + case '2': + { + System.out.print(" string"); + break; + } + + case '3': + { + System.out.print(" variable-length struct"); + break; + } + + case '4': + { + System.out.print(" fixed-length struct"); + break; + } + } + + System.out.print(" sequences of size " + seqSize + "..."); + + + for(int i = 0; i < repetitions; ++i) + { + switch(currentType) + { + case '1': + { + switch(c) + { + case 't': + { + throughput.sendByteSeq(byteSeq); + break; + } + + case 'r': + { + throughput.recvByteSeq(); + break; + } + + case 'e': + { + throughput.echoByteSeq(byteSeq); + break; + } + } + break; + } + + case '2': + { + switch(c) + { + case 't': + { + throughput.sendStringSeq(stringSeq); + break; + } + + case 'r': + { + throughput.recvStringSeq(); + break; + } + + case 'e': + { + throughput.echoStringSeq(stringSeq); + break; + } + } + break; + } + + case '3': + { + switch(c) + { + case 't': + { + throughput.sendStructSeq(structSeq); + break; + } + + case 'r': + { + throughput.recvStructSeq(); + break; + } + + case 'e': + { + throughput.echoStructSeq(structSeq); + break; + } + } + break; + } + + case '4': + { + switch(c) + { + case 't': + { + throughput.sendFixedSeq(fixedSeq); + break; + } + + case 'r': + { + throughput.recvFixedSeq(); + break; + } + + case 'e': + { + throughput.echoFixedSeq(fixedSeq); + break; + } + } + break; + } + } + } + + double dmsec = System.currentTimeMillis() - tmsec; + System.out.println("time for " + repetitions + " sequences: " + dmsec + "ms"); + System.out.println("time per sequence: " + dmsec / repetitions + "ms"); + int size = 0; + switch(currentType) + { + case '1': + { + size = 1; + break; + } + + case '2': + { + size = stringSeq[0].length(); + break; + } + + case '3': + { + size = structSeq[0].s.length() + 8; + break; + } + + case '4': + { + size = 16; // Two ints and a double. + break; + } + } + double mbit = repetitions * seqSize * size * 8.0 / dmsec / 1000.0; + if(c == 'e') + { + mbit *= 2; + } + System.out.println("throughput: " + new java.text.DecimalFormat("#.##").format(mbit) + "Mbps"); + } + else if(line.equals("s")) + { + throughput.shutdown(); + } + else if(line.equals("x")) + { + // Nothing to do + } + else if(line.equals("?")) + { + menu(); + } + else + { + System.out.println("unknown command `" + line + "'"); + menu(); + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + while(!line.equals("x")); + + return 0; + } + + public static void + main(String[] args) + { + Client app = new Client(); + int status; + try + { + status = app.run(args); + } + catch(Exception e) + { + System.err.println(e); + status = 1; + } + System.exit(status); + } +} diff --git a/java/demo/RMI/throughput/README b/java/demo/RMI/throughput/README new file mode 100755 index 00000000000..82fa2178612 --- /dev/null +++ b/java/demo/RMI/throughput/README @@ -0,0 +1,26 @@ +A simple RMI throughput demo that allows you to send sequences of various +types between client and server and to measure the maximum bandwidth +that can be achieved using serialized synchronous requests. + +To run the demo, start the RMI registry: + +$ rmiregistry + +In a separate window, start the server: + +$ java -Djava.rmi.server.hostname=127.0.0.1 -Djava.rmi.server.codebase=file:/c:/path/to/ice/java/demo/RMI/throughput/classes/ -Djava.security.policy=policy Server + +You need to edit the path on the command line to specify this directory. +Under Vista, you must run the server as administrator. + +In a separate window, start the client: + +$ client.exe --Djava.security.policy=policy Client + +If you want to run client and server on different machines, you +can specify the hsot on which you started the registry on +the client's command line, for example: + +$ client.exe --Djava.security.policy=policy Client 192.168.4.2 + +This directs the client to connect to the registry at the specified IP address. diff --git a/java/demo/RMI/throughput/Server.java b/java/demo/RMI/throughput/Server.java new file mode 100755 index 00000000000..b1a2cff19de --- /dev/null +++ b/java/demo/RMI/throughput/Server.java @@ -0,0 +1,145 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + +public class Server implements Throughput +{ + + public + Server() + { + _byteSeq = new byte[ByteSeqSize]; + + _stringSeq = new String[StringSeqSize]; + for(int i = 0; i < StringSeqSize; ++i) + { + _stringSeq[i] = new String("hello"); + } + + _structSeq = new StringDouble[StringDoubleSeqSize]; + for(int i = 0; i < StringDoubleSeqSize; ++i) + { + _structSeq[i] = new StringDouble(); + _structSeq[i].s = new String("hello"); + _structSeq[i].d = 3.14; + } + + _fixedSeq = new Fixed[FixedSeqSize]; + for(int i = 0; i < FixedSeqSize; ++i) + { + _fixedSeq[i] = new Fixed(); + _fixedSeq[i].i = 0; + _fixedSeq[i].j = 0; + _fixedSeq[i].d = 0; + } + } + + public void + sendByteSeq(byte[] seq) + { + } + + public byte[] + recvByteSeq() + { + return _byteSeq; + } + + public byte[] + echoByteSeq(byte[] seq) + { + return seq; + } + + public void + sendStringSeq(String[] seq) + { + } + + public String[] + recvStringSeq() + { + return _stringSeq; + } + + public String[] + echoStringSeq(String[] seq) + { + return seq; + } + + public void + sendStructSeq(StringDouble[] seq) + { + } + + public StringDouble[] + recvStructSeq() + { + return _structSeq; + } + + public StringDouble[] + echoStructSeq(StringDouble[] seq) + { + return seq; + } + + public void + sendFixedSeq(Fixed[] seq) + { + } + + public Fixed[] + recvFixedSeq() + { + return _fixedSeq; + } + + public Fixed[] + echoFixedSeq(Fixed[] seq) + { + return seq; + } + + public void + shutdown() + { + System.exit(0); + } + + private byte[] _byteSeq; + private String[] _stringSeq; + private StringDouble[] _structSeq; + private Fixed[] _fixedSeq; + + public static void main(String[] args) + { + if(System.getSecurityManager() == null) + { + System.setSecurityManager(new SecurityManager()); + } + try + { + Throughput servant = new Server(); + Throughput stub = (Throughput)UnicastRemoteObject.exportObject(servant, 0); + Registry registry = LocateRegistry.getRegistry(); + registry.rebind("throughput", stub); + System.out.println("ready"); + } + catch(Exception e) + { + System.err.println(e); + } + } +} diff --git a/java/demo/RMI/throughput/Throughput.java b/java/demo/RMI/throughput/Throughput.java new file mode 100755 index 00000000000..7afac1564d1 --- /dev/null +++ b/java/demo/RMI/throughput/Throughput.java @@ -0,0 +1,51 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface Throughput extends Remote +{ + int ByteSeqSize = 500000; + + int StringSeqSize = 50000; + + class StringDouble implements java.io.Serializable + { + public String s; + public double d; + }; + int StringDoubleSeqSize = 50000; + + class Fixed implements java.io.Serializable + { + int i; + int j; + double d; + }; + int FixedSeqSize = 50000; + + void sendByteSeq(byte[] seq) throws RemoteException; + byte[] recvByteSeq() throws RemoteException; + byte[] echoByteSeq(byte[] seq) throws RemoteException; + + void sendStringSeq(String[] seq) throws RemoteException; + String[] recvStringSeq() throws RemoteException; + String[] echoStringSeq(String[] seq) throws RemoteException; + + void sendStructSeq(StringDouble[] seq) throws RemoteException; + StringDouble[] recvStructSeq() throws RemoteException; + StringDouble[] echoStructSeq(StringDouble[] seq) throws RemoteException; + + void sendFixedSeq(Fixed[] seq) throws RemoteException; + Fixed[] recvFixedSeq() throws RemoteException; + Fixed[] echoFixedSeq(Fixed[] seq) throws RemoteException; + + void shutdown() throws RemoteException; +} diff --git a/java/demo/RMI/throughput/build.xml b/java/demo/RMI/throughput/build.xml new file mode 100755 index 00000000000..cc5b90d8e88 --- /dev/null +++ b/java/demo/RMI/throughput/build.xml @@ -0,0 +1,35 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. + + This copy of Ice is licensed to you under the terms described in the + ICE_LICENSE file included in this distribution. + + ********************************************************************** +--> + +<project name="rmi_throughput" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <target name="compile"> + <mkdir dir="${class.dir}"/> + <javac srcdir="." destdir="${class.dir}" + debug="${debug}"> + <compilerarg value="${javac.lint}"/> + </javac> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> diff --git a/java/demo/RMI/throughput/policy b/java/demo/RMI/throughput/policy new file mode 100755 index 00000000000..1b73fb10b9c --- /dev/null +++ b/java/demo/RMI/throughput/policy @@ -0,0 +1,3 @@ +grant { + permission java.net.SocketPermission "*:*", "connect,accept,resolve,listen"; +}; diff --git a/java/src/Freeze/TransactionI.java b/java/src/Freeze/TransactionI.java index b1d0a807048..e05eab4c663 100644 --- a/java/src/Freeze/TransactionI.java +++ b/java/src/Freeze/TransactionI.java @@ -222,7 +222,14 @@ class TransactionI implements Transaction { if(_postCompletionCallback != null) { - _postCompletionCallback.postCompletion(committed, deadlock); + try + { + _postCompletionCallback.postCompletion(committed, deadlock); + } + finally + { + _postCompletionCallback = null; + } } } diff --git a/java/src/Freeze/TransactionalEvictorI.java b/java/src/Freeze/TransactionalEvictorI.java index 6d44f055ea3..26623346c53 100644 --- a/java/src/Freeze/TransactionalEvictorI.java +++ b/java/src/Freeze/TransactionalEvictorI.java @@ -252,6 +252,16 @@ class TransactionalEvictorI extends EvictorI implements TransactionalEvictor { if(_deactivateController.deactivate()) { + synchronized(this) + { + // + // Set the evictor size to zero, meaning that we will evict + // everything possible. + // + _evictorSize = 0; + evict(); + } + try { closeDbEnv(); diff --git a/java/src/Ice/LoggerI.java b/java/src/Ice/LoggerI.java index aa9fa251e1f..33983a38cce 100644 --- a/java/src/Ice/LoggerI.java +++ b/java/src/Ice/LoggerI.java @@ -19,7 +19,7 @@ public class LoggerI implements Logger _prefix = prefix + ": "; } - _lineSeparator = System.getProperties().getProperty("line.separator"); + _lineSeparator = System.getProperty("line.separator"); _date = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT); _time = new java.text.SimpleDateFormat(" HH:mm:ss:SSS"); } diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java index 30f711f884e..c562715b457 100644 --- a/java/src/Ice/PropertiesI.java +++ b/java/src/Ice/PropertiesI.java @@ -36,7 +36,14 @@ public final class PropertiesI implements Properties PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key, ""); + try + { + result = System.getProperty(key, ""); + } + catch(java.lang.SecurityException ex) + { + result = ""; + } } else { @@ -53,7 +60,14 @@ public final class PropertiesI implements Properties PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key, value); + try + { + result = System.getProperty(key, value); + } + catch(java.lang.SecurityException ex) + { + result = value; + } } else { @@ -76,7 +90,13 @@ public final class PropertiesI implements Properties PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key); + try + { + result = System.getProperty(key); + } + catch(java.lang.SecurityException ex) + { + } } else { @@ -118,7 +138,13 @@ public final class PropertiesI implements Properties PropertyValue pv = _properties.get(key); if(pv == null) { - result = System.getProperty(key); + try + { + result = System.getProperty(key); + } + catch(java.lang.SecurityException ex) + { + } if(result == null) { return value; @@ -621,9 +647,8 @@ public final class PropertiesI implements Properties value = ""; } } - catch(SecurityException ex) + catch(java.lang.SecurityException ex) { - Ice.Util.getProcessLogger().warning("unable to access ICE_CONFIG environment variable"); value = ""; } } diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index 3a128ca91c1..245b52a36f2 100644 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -1396,7 +1396,7 @@ public class Coordinator { JOptionPane.showMessageDialog( parent, - "This version of IceGrid Admin requires an IceGrid Registry version 3.2 or higher", + "This version of IceGrid Admin requires an IceGrid Registry version 3.3", "Version Mismatch", JOptionPane.ERROR_MESSAGE); return null; @@ -1627,6 +1627,11 @@ public class Coordinator return _sessionKeeper.addCallback(servant, name, facet); } + public Ice.ObjectPrx retrieveCallback(String name, String facet) + { + return _sessionKeeper.retrieveCallback(name, facet); + } + public Ice.Object removeCallback(String name, String facet) { return _sessionKeeper.removeCallback(name, facet); diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index a9ac2d67c1e..4767c04a8c2 100644 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -711,6 +711,21 @@ class Server extends ListArrayTreeNode } } + void updateServices() + { + for(Service service: _services) + { + if(_startedServices.contains(service.getId())) + { + service.started(); + } + else + { + service.stopped(); + } + } + } + void rebuild(Server server) { _resolver = server._resolver; @@ -722,6 +737,10 @@ class Server extends ListArrayTreeNode _dbEnvs = server._dbEnvs; _services = server._services; + _childrenArray[0] = _adapters; + _childrenArray[1] = _dbEnvs; + _childrenArray[2] = _services; + // // Need to re-parent all the children // @@ -740,9 +759,7 @@ class Server extends ListArrayTreeNode service.reparent(this); } - _childrenArray[0] = _adapters; - _childrenArray[1] = _dbEnvs; - _childrenArray[2] = _services; + updateServices(); getRoot().getTreeModel().nodeStructureChanged(this); } @@ -777,6 +794,7 @@ class Server extends ListArrayTreeNode _services.clear(); _servicePropertySets.clear(); createServices(); + updateServices(); getRoot().getTreeModel().nodeStructureChanged(this); } @@ -785,6 +803,8 @@ class Server extends ListArrayTreeNode _services.clear(); _servicePropertySets.clear(); createServices(); + updateServices(); + getRoot().getTreeModel().nodeStructureChanged(this); } } @@ -813,63 +833,77 @@ class Server extends ListArrayTreeNode { if(_serviceObserver == null) { - IceBox.ServiceObserver servant = new IceBox._ServiceObserverDisp() - { - public void servicesStarted(final String[] services, Ice.Current current) + _serviceObserver = IceBox.ServiceObserverPrxHelper.uncheckedCast( + getCoordinator().retrieveCallback(_id, "IceBox.ServiceManager")); + + if(_serviceObserver == null) + { + IceBox.ServiceObserver servant = new IceBox._ServiceObserverDisp() { - final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); - - SwingUtilities.invokeLater(new Runnable() - { - public void run() + public void servicesStarted(final String[] services, Ice.Current current) + { + final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); + + SwingUtilities.invokeLater(new Runnable() { - for(Service service: _services) + public void run() { - if(serviceSet.contains(service.getId())) + for(Service service: _services) { - service.started(); + if(serviceSet.contains(service.getId())) + { + service.started(); + } } + _startedServices.addAll(serviceSet); + getCoordinator().getLiveDeploymentPane().refresh(); } - getCoordinator().getLiveDeploymentPane().refresh(); - } - }); - } - - public void servicesStopped(final String[] services, Ice.Current current) - { - final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); + }); + } - SwingUtilities.invokeLater(new Runnable() - { - public void run() + public void servicesStopped(final String[] services, Ice.Current current) + { + final java.util.Set<String> serviceSet = new java.util.HashSet<String>(java.util.Arrays.asList(services)); + + SwingUtilities.invokeLater(new Runnable() { - for(Service service: _services) + public void run() { - if(serviceSet.contains(service.getId())) + for(Service service: _services) { - service.stopped(); + if(serviceSet.contains(service.getId())) + { + service.stopped(); + } } + _startedServices.removeAll(serviceSet); + getCoordinator().getLiveDeploymentPane().refresh(); } - getCoordinator().getLiveDeploymentPane().refresh(); - } - }); - } - - }; + }); + } + + }; - _serviceObserver = IceBox.ServiceObserverPrxHelper.uncheckedCast( - getCoordinator().addCallback(servant, _id, "IceBox.ServiceManager")); + _serviceObserver = IceBox.ServiceObserverPrxHelper.uncheckedCast( + getCoordinator().addCallback(servant, _id, "IceBox.ServiceManager")); - if(_serviceObserver == null) - { - // TODO: log/report condition (observer not available, e.g. adapter not configured) + if(_serviceObserver == null) + { + JOptionPane.showMessageDialog( + getCoordinator().getMainFrame(), + "Could not create servant for service-manager observer", + "Observer creation error", + JOptionPane.ERROR_MESSAGE); + } } + } - + if(_serviceObserver != null) { // // Add observer to service manager using AMI call + // Note that duplicate registrations are ignored // IceBox.AMI_ServiceManager_addObserver cb = new IceBox.AMI_ServiceManager_addObserver() @@ -881,7 +915,11 @@ class Server extends ListArrayTreeNode public void ice_exception(Ice.LocalException e) { - // TODO: log/report exception + JOptionPane.showMessageDialog( + getCoordinator().getMainFrame(), + "Failed to register service-manager observer: " + e.toString(), + "Observer registration error", + JOptionPane.ERROR_MESSAGE); } }; @@ -897,20 +935,24 @@ class Server extends ListArrayTreeNode } catch(Ice.LocalException ex) { - // TODO: log/report exception + JOptionPane.showMessageDialog( + getCoordinator().getMainFrame(), + "Failed to contact service-manager: " + ex.toString(), + "Observer communication error", + JOptionPane.ERROR_MESSAGE); } } } } - else if(_state == null || _state == ServerState.Inactive) + } + else if(_state == null || _state == ServerState.Inactive) + { + for(Service service: _services) { - for(Service service: _services) - { - service.stopped(); - } + service.stopped(); } } - + if(fireEvent) { getRoot().getTreeModel().nodeChanged(this); @@ -1157,6 +1199,8 @@ class Server extends ListArrayTreeNode private java.util.List<DbEnv> _dbEnvs = new java.util.LinkedList<DbEnv>(); private java.util.List<Service> _services = new java.util.LinkedList<Service>(); + private java.util.Set<String> _startedServices = new java.util.HashSet<String>(); + private ServerState _state; private boolean _enabled; private int _stateIconIndex; diff --git a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java index 6b81a98c045..5b0f9577ce8 100644 --- a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java @@ -95,6 +95,9 @@ class ServerEditor extends CommunicatorEditor void show(Server server) { + + Server previousServer = _target; + _target = server; ServerState state = server.getState(); @@ -108,6 +111,7 @@ class ServerEditor extends CommunicatorEditor _currentPid.setText(""); _buildId.setText("Unknown"); _properties.clear(); + _propertiesRetrieved = false; _refreshButton.setEnabled(false); } else @@ -128,19 +132,29 @@ class ServerEditor extends CommunicatorEditor int iceIntVersion = server.getIceVersion(); if(state == ServerState.Active && (iceIntVersion == 0 || iceIntVersion >= 30300)) { - _buildId.setText("Retrieving..."); - _properties.clear(); + if(!_propertiesRetrieved || previousServer != server) + { + _buildId.setText("Retrieving..."); + _properties.clear(); + // + // Retrieve all properties in background + // + _target.showRuntimeProperties(); + _propertiesRetrieved = true; // set to true immediately to avoid 'spinning' + } + // - // Retrieve all properties in background + // Otherwise, use current value // - _target.showRuntimeProperties(); _refreshButton.setEnabled(true); + } else { _buildId.setText(""); _properties.clear(); + _propertiesRetrieved = false; _refreshButton.setEnabled(false); } } @@ -215,7 +229,8 @@ class ServerEditor extends CommunicatorEditor if(server == _target) { _properties.setSortedMap(map); - + _propertiesRetrieved = true; + String buildString = (String)map.get("BuildId"); if(buildString == null) { @@ -370,6 +385,7 @@ class ServerEditor extends CommunicatorEditor private JTextField _buildId = new JTextField(20); private JButton _refreshButton; private TableField _properties = new TableField("Name", "Value"); + private boolean _propertiesRetrieved = false; private JTextField _application = new JTextField(20); private JButton _gotoApplication; diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java index 128ce1a7b80..5130b133c6d 100644 --- a/java/src/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/SessionKeeper.java @@ -99,6 +99,17 @@ class SessionKeeper _serverAdminCategory = _admin.getServerAdminCategory(); } + catch(Ice.OperationNotExistException e) + { + logout(true); + JOptionPane.showMessageDialog( + parent, + "This version of IceGrid Admin requires an IceGrid Registry version 3.3", + "Login failed: Version Mismatch", + JOptionPane.ERROR_MESSAGE); + throw e; + + } catch(Ice.LocalException e) { logout(true); @@ -189,6 +200,27 @@ class SessionKeeper } } + Ice.ObjectPrx retrieveCallback(String name, String facet) + { + if(_adminCallbackCategory == null) + { + return null; + } + else + { + Ice.Identity ident = new Ice.Identity(name, _adminCallbackCategory); + if(_adapter.findFacet(ident, facet) == null) + { + return null; + } + else + { + return _adapter.createProxy(ident).ice_facet(facet); + } + } + } + + Ice.Object removeCallback(String name, String facet) { if(_adminCallbackCategory == null) @@ -1388,6 +1420,12 @@ class SessionKeeper { return _session == null ? null : _session.addCallback(servant, name, facet); } + + Ice.ObjectPrx retrieveCallback(String name, String facet) + { + return _session == null ? null : _session.retrieveCallback(name, facet); + } + Ice.Object removeCallback(String name, String facet) { diff --git a/java/src/IceGridGUI/XMLWriter.java b/java/src/IceGridGUI/XMLWriter.java index 30bb46ffba5..a0c6e225f87 100644 --- a/java/src/IceGridGUI/XMLWriter.java +++ b/java/src/IceGridGUI/XMLWriter.java @@ -93,7 +93,7 @@ public class XMLWriter while(p.hasNext()) { String[] pair = (String[])p.next(); - _writer.write(" " + pair[0] + "=\"" + pair[1] + "\""); + _writer.write(" " + pair[0] + "=\"" + escape(pair[1]) + "\""); } } } diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index e1de5ed1960..915883e05d3 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -317,6 +317,13 @@ public final class Network se.initCause(ex); throw se; } + catch(java.lang.SecurityException ex) + { + closeSocketNoThrow(fd); + Ice.SocketException se = new Ice.SocketException(); + se.initCause(ex); + throw se; + } if(System.getProperty("os.name").equals("Linux")) { @@ -827,6 +834,13 @@ public final class Network { Ice.DNSException e = new Ice.DNSException(); e.host = host; + e.initCause(ex); + throw e; + } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); throw e; } @@ -875,6 +889,12 @@ public final class Network se.initCause(e); throw se; } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); + throw e; + } return result; } @@ -917,6 +937,12 @@ public final class Network catch(java.net.UnknownHostException ex) { } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); + throw e; + } } java.util.ArrayList<String> hosts = new java.util.ArrayList<String>(); @@ -1158,6 +1184,13 @@ public final class Network { Ice.DNSException e = new Ice.DNSException(); e.host = host; + e.initCause(ex); + throw e; + } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); throw e; } @@ -1191,6 +1224,12 @@ public final class Network assert(false); return null; } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); + throw e; + } } private static java.net.InetAddress[] @@ -1215,5 +1254,11 @@ public final class Network assert(false); return null; } + catch(java.lang.SecurityException ex) + { + Ice.SocketException e = new Ice.SocketException(); + e.initCause(ex); + throw e; + } } } diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 439d3a099cc..91a1371bdb3 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -7,6 +7,9 @@ // // ********************************************************************** +// +// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Dec 23 19:01:32 2008 + // IMPORTANT: Do not edit this file -- any edits made here will be lost! package IceInternal; @@ -264,7 +267,15 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.CryptPasswords", false, null), new Property("IceGrid\\.Registry\\.Data", false, null), new Property("IceGrid\\.Registry\\.DefaultTemplates", false, null), + new Property("IceGrid\\.Registry\\.Discard\\.Interval", false, null), new Property("IceGrid\\.Registry\\.DynamicRegistration", false, null), + new Property("IceGrid\\.Registry\\.Election\\.ElectionTimeout", false, null), + new Property("IceGrid\\.Registry\\.Election\\.MasterTimeout", false, null), + new Property("IceGrid\\.Registry\\.Election\\.ResponseTimeout", false, null), + new Property("IceGrid\\.Registry\\.Flush\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.IceStormAdmin\\.TopicManager\\.Default", false, null), + new Property("IceGrid\\.Registry\\.IceStormAdmin\\.TopicManager\\.[^\\s]+", false, null), + new Property("IceGrid\\.Registry\\.InstanceName", false, null), new Property("IceGrid\\.Registry\\.Internal\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator", false, null), @@ -278,6 +289,9 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Internal\\.ThreadPool\\.SizeWarn", false, null), new Property("IceGrid\\.Registry\\.Internal\\.ThreadPool\\.StackSize", false, null), new Property("IceGrid\\.Registry\\.Internal\\.ThreadPool\\.Serialize", false, null), + new Property("IceGrid\\.Registry\\.Node\\.[^\\s]+", false, null), + new Property("IceGrid\\.Registry\\.NodeId", false, null), + new Property("IceGrid\\.Registry\\.Nodes\\.id", false, null), new Property("IceGrid\\.Registry\\.NodeSessionTimeout", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.EndpointSelection", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.ConnectionCached", false, null), @@ -288,8 +302,12 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.CollocationOptimization", true, "IceGrid.Registry.PermissionsVerifier.CollocationOptimized"), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier", false, null), + new Property("IceGrid\\.Registry\\.Publish\\.[^\\s]+", false, null), new Property("IceGrid\\.Registry\\.ReplicaName", false, null), new Property("IceGrid\\.Registry\\.ReplicaSessionTimeout", false, null), + new Property("IceGrid\\.Registry\\.ReplicatedPublishEndpoints", false, null), + new Property("IceGrid\\.Registry\\.ReplicatedTopicManagerEndpoints", false, null), + new Property("IceGrid\\.Registry\\.Send\\.Timeout", false, null), new Property("IceGrid\\.Registry\\.Server\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Server\\.Endpoints", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator", false, null), @@ -327,15 +345,22 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.CollocationOptimization", true, "IceGrid.Registry.SSLPermissionsVerifier.CollocationOptimized"), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier", false, null), + new Property("IceGrid\\.Registry\\.TopicManager\\.[^\\s]+", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Application", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Adapter", false, null), + new Property("IceGrid\\.Registry\\.Trace\\.Election", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Node", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Object", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Patch", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Replica", false, null), + new Property("IceGrid\\.Registry\\.Trace\\.Replication", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Server", false, null), new Property("IceGrid\\.Registry\\.Trace\\.Session", false, null), + new Property("IceGrid\\.Registry\\.Trace\\.Subscriber", false, null), + new Property("IceGrid\\.Registry\\.Trace\\.Topic", false, null), + new Property("IceGrid\\.Registry\\.Trace\\.TopicManager", false, null), + new Property("IceGrid\\.Registry\\.Transient", false, null), new Property("IceGrid\\.Registry\\.UserAccounts", false, null), null }; diff --git a/java/src/IceInternal/ValueWriter.java b/java/src/IceInternal/ValueWriter.java index 63efa63640a..2c4ed5d3bd8 100644 --- a/java/src/IceInternal/ValueWriter.java +++ b/java/src/IceInternal/ValueWriter.java @@ -190,9 +190,28 @@ public final class ValueWriter writeFields(name, obj, c.getSuperclass(), objectTable, out); // - // Write the declared fields of the given class. + // Write the declared fields of the given class. We prefer to use the declared + // fields because it includes protected fields that may have been defined using + // the Slice "protected" metadata. However, if a security manager prevents us + // from obtaining the declared fields, we will fall back to using the public ones. // - java.lang.reflect.Field[] fields = c.getDeclaredFields(); + java.lang.reflect.Field[] fields = null; + try + { + fields = c.getDeclaredFields(); + } + catch(java.lang.SecurityException ex) + { + try + { + fields = c.getFields(); + } + catch(java.lang.SecurityException e) + { + return; // Nothing else we can do. + } + } + assert(fields != null); for(int i = 0; i < fields.length; i++) { // diff --git a/java/test/Freeze/evictor/AccountI.java b/java/test/Freeze/evictor/AccountI.java index 8df7057eeaa..949d77c3b42 100644 --- a/java/test/Freeze/evictor/AccountI.java +++ b/java/test/Freeze/evictor/AccountI.java @@ -81,7 +81,6 @@ public class AccountI extends Test.Account notify(); } - public synchronized void run() { if(_response == false && _exception == null) @@ -129,8 +128,7 @@ public class AccountI extends Test.Account ResponseThread thread = new ResponseThread(); thread.setDaemon(true); - thread.start(); - + test(_evictor.getCurrentTransaction() != null); try @@ -140,6 +138,9 @@ public class AccountI extends Test.Account } catch(Ice.UserException e) { + thread.start(); + Thread.yield(); + // // Need to rollback here -- "rollback on user exception" does not work // when the dispatch commits before it gets any response! @@ -150,6 +151,8 @@ public class AccountI extends Test.Account return; } + thread.start(); + Thread.yield(); thread.response(); } |