221N/A/*
553N/A * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
221N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
221N/A *
221N/A * This code is free software; you can redistribute it and/or modify it
221N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation.
221N/A *
553N/A * This code is distributed in the hope that it will be useful, but WITHOUT
221N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
221N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
221N/A * version 2 for more details (a copy is included in the LICENSE file that
221N/A * accompanied this code).
221N/A *
221N/A * You should have received a copy of the GNU General Public License version
221N/A * 2 along with this work; if not, write to the Free Software Foundation,
221N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
221N/A *
221N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
553N/A */
553N/A
221N/Aimport java.rmi.RemoteException;
221N/Aimport java.rmi.server.UnicastRemoteObject;
221N/Aimport java.util.logging.Logger;
221N/Aimport java.util.logging.Level;
221N/A
221N/A/**
221N/A * The OrangeEchoImpl class implements the behavior of the remote "orange
221N/A * echo" objects exported by the server. The purpose of these objects
221N/A * is simply to recursively call back to their caller.
221N/A */
221N/Apublic class OrangeEchoImpl extends UnicastRemoteObject implements OrangeEcho {
221N/A
221N/A private static final Logger logger =
221N/A Logger.getLogger("reliability.orangeecho");
221N/A private final String name;
221N/A
221N/A public OrangeEchoImpl(String name) throws RemoteException {
221N/A this.name = name;
221N/A }
221N/A
221N/A /**
221N/A * Call back on supplied "orange" object (presumably the caller)
221N/A * with the same message data and a decremented recursion level.
221N/A */
221N/A public int[] recurse(Orange orange, int[] message, int level)
221N/A throws RemoteException
221N/A {
221N/A String threadName = Thread.currentThread().getName();
221N/A
221N/A logger.log(Level.FINEST,
221N/A threadName + ": " + toString() + ".recurse(message["
221N/A + message.length + "], " + level + "): BEGIN");
221N/A
221N/A int[] response = orange.recurse(this, message, level - 1);
221N/A
221N/A logger.log(Level.FINEST,
221N/A threadName + ": " + toString() + ".recurse(message["
221N/A + message.length + "], " + level + "): END");
221N/A
221N/A return response;
221N/A }
221N/A
221N/A public String toString() {
221N/A return name;
221N/A }
221N/A}
221N/A