test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java

Print this page


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


 143             ActivationDesc desc =
 144                 new ActivationDesc("CheckActivateRef", null, null);
 145             System.err.println("Registering descriptor");
 146             obj = (ActivateMe) Activatable.register(desc);
 147 
 148             System.err.println("proxy = " + obj);
 149 
 150             if (useDynamicProxies && !Proxy.isProxyClass(obj.getClass()))
 151             {
 152                 throw new RuntimeException("proxy is not dynamic proxy");
 153             }
 154 
 155             /*
 156              * Loop a bunch of times to force activator to
 157              * spawn VMs (groups)
 158              */
 159             try {
 160                 for (; i < 7; i++) {
 161 
 162                     System.err.println("Activate object via method call");
 163 
 164                     /*
 165                      * Fix for 4277196: if we got an inactive group
 166                      * exception, it is likely that we accidentally
 167                      * invoked a method on an old activation
 168                      * group. Give some time for the group to go away
 169                      * and then retry the activation.
 170                      */
 171                     try {
 172                         obj.ping();
 173                     } catch (RemoteException e) {
 174                         Exception detail = (Exception) e.detail;
 175                         if ((detail != null) &&
 176                             (detail instanceof ActivationException) &&
 177                             (detail.getMessage().equals("group is inactive")))
 178                         {
 179                             try {
 180                                 Thread.sleep(5000);
 181                             } catch (InterruptedException ex) {
 182                             }
 183                             obj.ping();
 184 
 185                         } else {
 186                             throw e;
 187                         }
 188                     }
 189 
 190                     System.err.println("proxy = " + obj);
 191 
 192                     /*
 193                      * Now that object is activated, check to make sure that
 194                      * the RemoteRef inside the stub's ActivatableRef
 195                      * is *not* an ActivatableRef.
 196                      */
 197                     ActivatableRef aref;
 198                     if (obj instanceof RemoteStub) {
 199                         aref = (ActivatableRef) ((RemoteObject) obj).getRef();
 200                     } else if (Proxy.isProxyClass(obj.getClass())) {
 201                         RemoteObjectInvocationHandler handler =
 202                             (RemoteObjectInvocationHandler)
 203                             Proxy.getInvocationHandler(obj);
 204                         aref = (ActivatableRef) handler.getRef();
 205                     } else {
 206                         throw new RuntimeException("unknown proxy type");
 207                     }
 208 
 209                     final ActivatableRef ref = aref;


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


 143             ActivationDesc desc =
 144                 new ActivationDesc("CheckActivateRef", null, null);
 145             System.err.println("Registering descriptor");
 146             obj = (ActivateMe) Activatable.register(desc);
 147 
 148             System.err.println("proxy = " + obj);
 149 
 150             if (useDynamicProxies && !Proxy.isProxyClass(obj.getClass()))
 151             {
 152                 throw new RuntimeException("proxy is not dynamic proxy");
 153             }
 154 
 155             /*
 156              * Loop a bunch of times to force activator to
 157              * spawn VMs (groups)
 158              */
 159             try {
 160                 for (; i < 7; i++) {
 161 
 162                     System.err.println("Activate object via method call");




















 163                     obj.ping();






 164                     System.err.println("proxy = " + obj);
 165 
 166                     /*
 167                      * Now that object is activated, check to make sure that
 168                      * the RemoteRef inside the stub's ActivatableRef
 169                      * is *not* an ActivatableRef.
 170                      */
 171                     ActivatableRef aref;
 172                     if (obj instanceof RemoteStub) {
 173                         aref = (ActivatableRef) ((RemoteObject) obj).getRef();
 174                     } else if (Proxy.isProxyClass(obj.getClass())) {
 175                         RemoteObjectInvocationHandler handler =
 176                             (RemoteObjectInvocationHandler)
 177                             Proxy.getInvocationHandler(obj);
 178                         aref = (ActivatableRef) handler.getRef();
 179                     } else {
 180                         throw new RuntimeException("unknown proxy type");
 181                     }
 182 
 183                     final ActivatableRef ref = aref;