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