Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/rmic/newrmic/equivalence/DayTimeServerImpl.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*/2223// RMI Activation Functional Test2425import java.rmi.*;26import java.rmi.activation.*;27import java.util.*;2829// DayTimeServerImpl3031public class DayTimeServerImpl32extends Activatable33implements DayTimeInterface {3435private static final String PROG_NAME = "DayTimeServerImpl";36private static final String SERVER_OBJECT = "DayTimeServer";37private static final String CLASS_NAME = "activation.DayTimeServerImpl";3839private static final String POLICY_FILE = "policy_file";4041private static final String USER_DIR =42System.getProperty("user.dir").replace('\\', '/');4344private static final String CODE_LOCATION = "file:"+USER_DIR+"/";4546private static final MarshalledObject DATA = null;47private static ActivationDesc ACTIVATION_DESC = null;4849private TestInterface ref;5051public void ping() throws RemoteException {}5253public ActivationID getActivationID() throws RemoteException {54return super.getID();55}5657public DayTimeServerImpl(ActivationID id, MarshalledObject data)58throws RemoteException {59super(id, 0);60if (data != null) {61try {62ref = (TestInterface)data.get();63ref.ping(SERVER_OBJECT);64}65catch (Exception e) {66System.err.println("Exception: " + e);67}68}69}7071public Date getDayTime() throws RemoteException {72return new Date();73}7475public void exit() throws RemoteException {76System.exit(0);77}7879public void inactive()80throws RemoteException, ActivationException, UnknownObjectException {8182//ShutDown s = new ShutDown(super.getID(),this,ShutDown.NORMAL_SHUTDOWN);83}8485public void unregister()86throws RemoteException, ActivationException, UnknownObjectException {87unregister(super.getID());88}8990public void register()91throws RemoteException, ActivationException, UnknownObjectException {92register(ACTIVATION_DESC);93}9495public ActivationGroupID getCurrentGroupID() throws RemoteException {96return ActivationGroup.currentGroupID();97}9899private static void setup() {100101try {102103DayTimeInterface rsi; // Remote server interface104105System.setSecurityManager(new RMISecurityManager());106107rsi = (DayTimeInterface)Activatable.register(ACTIVATION_DESC);108System.out.println("Got stub for "+SERVER_OBJECT+" implementation");109110Naming.rebind(SERVER_OBJECT, rsi);111System.out.println("Exported "+SERVER_OBJECT+" implementation");112113} catch (Exception e) {114System.err.println("Exception: " + e);115e.printStackTrace();116}117}118119public static void main(String[] args) {120121try {122Properties props = new Properties();123props.setProperty("java.security.policy", POLICY_FILE);124125ActivationGroupDesc agd = new ActivationGroupDesc(props, null);126127ActivationGroupID agid = ActivationGroup.getSystem().registerGroup(agd);128129ACTIVATION_DESC = new ActivationDesc(agid,130CLASS_NAME, CODE_LOCATION, DATA, false);131}132catch (Exception e) {133System.err.println("Exception: " + e);134e.printStackTrace();135}136137setup();138}139}140141142