test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  51 
  52             Thread.sleep(500);
  53             System.err.println("(ShutDownImpl.shutdown) FEE");
  54             Thread.sleep(500);
  55             System.err.println("(ShutDownImpl.shutdown) FIE");
  56             Thread.sleep(500);
  57             System.err.println("(ShutDownImpl.shutdown) FOE");
  58             Thread.sleep(500);
  59             System.err.println("(ShutDownImpl.shutdown) FOO");
  60 
  61             monitor.declareStillAlive();
  62             System.err.println("(ShutDownImpl.shutdown) still alive!");
  63         } catch (Exception e) {
  64             throw new RuntimeException(
  65                 "unexpected exception occurred in shutdown method", e);
  66         }
  67     }
  68 
  69     public static void main(String[] args) {
  70         try {

  71             Registry registry =
  72                 LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT);
  73             ShutdownMonitor monitor = (ShutdownMonitor)
  74                 registry.lookup(KeepAliveDuringCall.BINDING);
  75             System.err.println("(ShutdownImpl) retrieved shutdown monitor");
  76 
  77             impl = new ShutdownImpl(monitor);
  78             Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl);
  79             System.err.println("(ShutdownImpl) exported shutdown object");
  80 
  81             monitor.submitShutdown(stub);
  82             System.err.println("(ShutdownImpl) submitted shutdown object");
  83 
  84         } catch (Exception e) {
  85             System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:");
  86             e.printStackTrace();
  87         }
  88     }
  89 }
   1 /*
   2  * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  51 
  52             Thread.sleep(500);
  53             System.err.println("(ShutDownImpl.shutdown) FEE");
  54             Thread.sleep(500);
  55             System.err.println("(ShutDownImpl.shutdown) FIE");
  56             Thread.sleep(500);
  57             System.err.println("(ShutDownImpl.shutdown) FOE");
  58             Thread.sleep(500);
  59             System.err.println("(ShutDownImpl.shutdown) FOO");
  60 
  61             monitor.declareStillAlive();
  62             System.err.println("(ShutDownImpl.shutdown) still alive!");
  63         } catch (Exception e) {
  64             throw new RuntimeException(
  65                 "unexpected exception occurred in shutdown method", e);
  66         }
  67     }
  68 
  69     public static void main(String[] args) {
  70         try {
  71             int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port"));
  72             Registry registry =
  73                 LocateRegistry.getRegistry("", registryPort);
  74             ShutdownMonitor monitor = (ShutdownMonitor)
  75                 registry.lookup(KeepAliveDuringCall.BINDING);
  76             System.err.println("(ShutdownImpl) retrieved shutdown monitor");
  77 
  78             impl = new ShutdownImpl(monitor);
  79             Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl);
  80             System.err.println("(ShutdownImpl) exported shutdown object");
  81 
  82             monitor.submitShutdown(stub);
  83             System.err.println("(ShutdownImpl) submitted shutdown object");
  84 
  85         } catch (Exception e) {
  86             System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:");
  87             e.printStackTrace();
  88         }
  89     }
  90 }