Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/rmic/newrmic/equivalence/ServerImpl.java
38867 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.*;24import java.rmi.*;25import java.rmi.server.UnicastRemoteObject;2627public class ServerImpl28extends UnicastRemoteObject29implements Server30{31private String name;32Callback cLocal;3334public ServerImpl(String s) throws java.rmi.RemoteException {35super();36name = s;37}3839public String sayHello(Callback c) throws RemoteException {40System.out.println("Calling Callback method from the ServerImpl");41cLocal = c;42new Thread(new Runnable() {43public void run() {44System.out.println(45"+ running a new thread in sayHello method!");46try {47cLocal.callback();48} catch(RemoteException e) {49System.out.println(50"ServerImpl.main: exception while calling callback " +51"method:");52e.printStackTrace();53}54}55}).start();56return "Hello Callback!";57}5859public static void main(String args[]) {60// Create and install the security manager61System.setSecurityManager(new RMISecurityManager());6263ServerImpl obj = null;6465try {66obj = new ServerImpl("ServerImpl");67Naming.rebind("/ServerImpl", obj);68System.out.println("ServerImpl created and bound in the registry" +69" to the name ServerImpl");70System.err.println("DTI_DoneInitializing");71} catch (Exception e) {72System.out.println("ServerImpl.main: an exception occurred:");73e.printStackTrace();74System.err.println("DTI_Error");75}7677}78}798081