Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/rmi/PortableRemoteObject/8146975/HelloServer.java
38853 views
/*1* Copyright (c) 2016, 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 javax.naming.InitialContext;24import javax.naming.Context;2526public class HelloServer {2728static final int MAX_RETRY = 10;29static final int ONE_SECOND = 1000;3031public static void main(String[] args) {32int retryCount = 0;33while (retryCount < MAX_RETRY) {34try {35//HelloServer.set("SETTING TEST ITL");36// Step 1: Instantiate the Hello servant37HelloImpl helloRef = new HelloImpl();3839// Step 2: Publish the reference in the Naming Service40// using JNDI API41Context initialNamingContext = new InitialContext();42initialNamingContext.rebind("HelloService", helloRef);4344System.out.println("Hello Server: Ready...");45break;46} catch (Exception e) {47System.out.println("Server initialization problem: " + e);48e.printStackTrace();49retryCount++;50try {51Thread.sleep(ONE_SECOND);52} catch (InterruptedException e1) {53e1.printStackTrace();54}55}56}57}58}596061