test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2013, 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  */


  80 
  81             //      rmid.addArguments(new String[] {
  82             //          "-C-Djava.rmi.server.logCalls=true"});
  83 
  84             rmid.start();
  85 
  86             // Ensure that activation groups run with the correct
  87             // security manager.
  88             //
  89             Properties p = new Properties();
  90             p.put("java.security.policy",
  91                   TestParams.defaultGroupPolicy);
  92             p.put("java.security.manager",
  93                   "java.lang.SecurityManager");
  94 
  95             System.err.println("activation group will be created " +
  96                                "in a new VM");
  97             ActivationGroupDesc groupDesc =
  98                 new ActivationGroupDesc(p, null);
  99             ActivationSystem system = ActivationGroup.getSystem();
















 100             ActivationGroupID groupID = system.registerGroup(groupDesc);
 101 
 102             System.err.println("registering activatable");
 103             ActivationDesc desc = new ActivationDesc
 104                 (groupID, "ShutdownGracefully", null, null);
 105             registering = (RegisteringActivatable)
 106                 Activatable.register(desc);
 107 
 108             System.err.println("activate and deactivate object " +
 109                                "via method call");
 110             registering.shutdown();
 111 
 112             /*
 113              * the security manager rmid is running with will stop
 114              * rmid from writing to its log files; in 1.2.x this would
 115              * have caused rmid to have thrown a runtime exception and
 116              * continue running in an unstable state.  With the fix
 117              * for 4183169, rmid should shutdown gracefully instead.
 118              */
 119 


   1 /*
   2  * Copyright (c) 1999, 2014, 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  */


  80 
  81             //      rmid.addArguments(new String[] {
  82             //          "-C-Djava.rmi.server.logCalls=true"});
  83 
  84             rmid.start();
  85 
  86             // Ensure that activation groups run with the correct
  87             // security manager.
  88             //
  89             Properties p = new Properties();
  90             p.put("java.security.policy",
  91                   TestParams.defaultGroupPolicy);
  92             p.put("java.security.manager",
  93                   "java.lang.SecurityManager");
  94 
  95             System.err.println("activation group will be created " +
  96                                "in a new VM");
  97             ActivationGroupDesc groupDesc =
  98                 new ActivationGroupDesc(p, null);
  99             ActivationSystem system = ActivationGroup.getSystem();
 100             if(system == null) {
 101                 //Set a 5 seconds timeout
 102                 long stopTime = System.currentTimeMillis() + 5000;
 103                 do {
 104                     try {
 105                         Thread.sleep(200);
 106                     } catch (InterruptedException ignore) {
 107                     }
 108                     if((system = ActivationGroup.getSystem()) != null) {
 109                         break;
 110                     }
 111                 } while (System.currentTimeMillis() < stopTime);
 112                 if (system == null) {
 113                     TestLibrary.bomb("\nfailure: Can't acquire ActivationSystem");
 114                 }
 115             }
 116             ActivationGroupID groupID = system.registerGroup(groupDesc);
 117 
 118             System.err.println("registering activatable");
 119             ActivationDesc desc = new ActivationDesc
 120                 (groupID, "ShutdownGracefully", null, null);
 121             registering = (RegisteringActivatable)
 122                 Activatable.register(desc);
 123 
 124             System.err.println("activate and deactivate object " +
 125                                "via method call");
 126             registering.shutdown();
 127 
 128             /*
 129              * the security manager rmid is running with will stop
 130              * rmid from writing to its log files; in 1.2.x this would
 131              * have caused rmid to have thrown a runtime exception and
 132              * continue running in an unstable state.  With the fix
 133              * for 4183169, rmid should shutdown gracefully instead.
 134              */
 135