src/share/classes/sun/rmi/server/ActivationGroupImpl.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 191      * Creates a new instance of an activatable remote object. The
 192      * <code>Activator</code> calls this method to create an activatable
 193      * object in this group. This method should be idempotent; a call to
 194      * activate an already active object should return the previously
 195      * activated object.
 196      *
 197      * Note: this method assumes that the Activator will only invoke
 198      * newInstance for the same object in a serial fashion (i.e.,
 199      * the activator will not allow the group to see concurrent requests
 200      * to activate the same object.
 201      *
 202      * @param id the object's activation identifier
 203      * @param desc the object's activation descriptor
 204      * @return a marshalled object containing the activated object's stub
 205      */
 206     public MarshalledObject<? extends Remote>
 207                                       newInstance(final ActivationID id,
 208                                                   final ActivationDesc desc)
 209         throws ActivationException, RemoteException
 210     {
 211         RegistryImpl.checkAccess("ActivationInstantiator.newInstance");
 212 
 213         if (!groupID.equals(desc.getGroupID()))
 214             throw new ActivationException("newInstance in wrong group");
 215 
 216         try {
 217             acquireLock(id);
 218             synchronized (this) {
 219                 if (groupInactive == true)
 220                     throw new InactiveGroupException("group is inactive");
 221             }
 222 
 223             ActiveEntry entry = active.get(id);
 224             if (entry != null)
 225                 return entry.mobj;
 226 
 227             String className = desc.getClassName();
 228 
 229             final Class<? extends Remote> cl =
 230                 RMIClassLoader.loadClass(desc.getLocation(), className)
 231                 .asSubclass(Remote.class);


   1 /*
   2  * Copyright (c) 1997, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 191      * Creates a new instance of an activatable remote object. The
 192      * <code>Activator</code> calls this method to create an activatable
 193      * object in this group. This method should be idempotent; a call to
 194      * activate an already active object should return the previously
 195      * activated object.
 196      *
 197      * Note: this method assumes that the Activator will only invoke
 198      * newInstance for the same object in a serial fashion (i.e.,
 199      * the activator will not allow the group to see concurrent requests
 200      * to activate the same object.
 201      *
 202      * @param id the object's activation identifier
 203      * @param desc the object's activation descriptor
 204      * @return a marshalled object containing the activated object's stub
 205      */
 206     public MarshalledObject<? extends Remote>
 207                                       newInstance(final ActivationID id,
 208                                                   final ActivationDesc desc)
 209         throws ActivationException, RemoteException
 210     {
 211         Activation.checkAccess("ActivationInstantiator.newInstance");
 212 
 213         if (!groupID.equals(desc.getGroupID()))
 214             throw new ActivationException("newInstance in wrong group");
 215 
 216         try {
 217             acquireLock(id);
 218             synchronized (this) {
 219                 if (groupInactive == true)
 220                     throw new InactiveGroupException("group is inactive");
 221             }
 222 
 223             ActiveEntry entry = active.get(id);
 224             if (entry != null)
 225                 return entry.mobj;
 226 
 227             String className = desc.getClassName();
 228 
 229             final Class<? extends Remote> cl =
 230                 RMIClassLoader.loadClass(desc.getLocation(), className)
 231                 .asSubclass(Remote.class);