src/share/classes/java/rmi/activation/ActivationGroup.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2005, 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
  23  * questions.
  24  */
  25 
  26 package java.rmi.activation;
  27 
  28 import java.lang.reflect.Constructor;
  29 import java.lang.reflect.InvocationTargetException;
  30 import java.rmi.MarshalledObject;
  31 import java.rmi.Naming;
  32 import java.rmi.Remote;
  33 import java.rmi.RemoteException;
  34 import java.rmi.activation.UnknownGroupException;
  35 import java.rmi.activation.UnknownObjectException;
  36 import java.rmi.server.RMIClassLoader;
  37 import java.rmi.server.UnicastRemoteObject;
  38 import java.security.AccessController;
  39 import sun.security.action.GetIntegerAction;

  40 
  41 /**
  42  * An <code>ActivationGroup</code> is responsible for creating new
  43  * instances of "activatable" objects in its group, informing its
  44  * <code>ActivationMonitor</code> when either: its object's become
  45  * active or inactive, or the group as a whole becomes inactive. <p>
  46  *
  47  * An <code>ActivationGroup</code> is <i>initially</i> created in one
  48  * of several ways: <ul>
  49  * <li>as a side-effect of creating an <code>ActivationDesc</code>
  50  *     without an explicit <code>ActivationGroupID</code> for the
  51  *     first activatable object in the group, or
  52  * <li>via the <code>ActivationGroup.createGroup</code> method
  53  * <li>as a side-effect of activating the first object in a group
  54  *     whose <code>ActivationGroupDesc</code> was only registered.</ul><p>
  55  *
  56  * Only the activator can <i>recreate</i> an
  57  * <code>ActivationGroup</code>.  The activator spawns, as needed, a
  58  * separate VM (as a child process, for example) for each registered
  59  * activation group and directs activation requests to the appropriate


 419      * obtain a reference to the <code>ActivationSystem</code> by
 420      * looking up the name "java.rmi.activation.ActivationSystem" in
 421      * the Activator's registry. By default, the port number used to
 422      * look up the activation system is defined by
 423      * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
 424      * overridden by setting the property
 425      * <code>java.rmi.activation.port</code>.
 426      *
 427      * @return the activation system for the VM/group
 428      * @exception ActivationException if activation system cannot be
 429      *  obtained or is not bound
 430      * (means that it is not running)
 431      * @see #setSystem
 432      * @since 1.2
 433      */
 434     public static synchronized ActivationSystem getSystem()
 435         throws ActivationException
 436     {
 437         if (currSystem == null) {
 438             try {



 439                 int port = AccessController.doPrivileged(
 440                     new GetIntegerAction("java.rmi.activation.port",
 441                                          ActivationSystem.SYSTEM_PORT));
 442                 currSystem = (ActivationSystem)
 443                     Naming.lookup("//:" + port +
 444                                   "/java.rmi.activation.ActivationSystem");
 445             } catch (Exception e) {
 446                 throw new ActivationException(
 447                     "unable to obtain ActivationSystem", e);
 448             }
 449         }
 450         return currSystem;
 451     }
 452 
 453     /**
 454      * This protected method is necessary for subclasses to
 455      * make the <code>activeObject</code> callback to the group's
 456      * monitor. The call is simply forwarded to the group's
 457      * <code>ActivationMonitor</code>.
 458      *
 459      * @param id the object's identifier
 460      * @param mobj a marshalled object containing the remote object's stub
 461      * @exception UnknownObjectException if object is not registered
 462      * @exception RemoteException if call informing monitor fails
 463      * @exception ActivationException if an activation error occurs


   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
  23  * questions.
  24  */
  25 
  26 package java.rmi.activation;
  27 
  28 import java.lang.reflect.Constructor;
  29 import java.lang.reflect.InvocationTargetException;
  30 import java.rmi.MarshalledObject;
  31 import java.rmi.Naming;
  32 import java.rmi.Remote;
  33 import java.rmi.RemoteException;
  34 import java.rmi.activation.UnknownGroupException;
  35 import java.rmi.activation.UnknownObjectException;
  36 import java.rmi.server.RMIClassLoader;
  37 import java.rmi.server.UnicastRemoteObject;
  38 import java.security.AccessController;
  39 import sun.security.action.GetIntegerAction;
  40 import sun.security.action.GetPropertyAction;
  41 
  42 /**
  43  * An <code>ActivationGroup</code> is responsible for creating new
  44  * instances of "activatable" objects in its group, informing its
  45  * <code>ActivationMonitor</code> when either: its object's become
  46  * active or inactive, or the group as a whole becomes inactive. <p>
  47  *
  48  * An <code>ActivationGroup</code> is <i>initially</i> created in one
  49  * of several ways: <ul>
  50  * <li>as a side-effect of creating an <code>ActivationDesc</code>
  51  *     without an explicit <code>ActivationGroupID</code> for the
  52  *     first activatable object in the group, or
  53  * <li>via the <code>ActivationGroup.createGroup</code> method
  54  * <li>as a side-effect of activating the first object in a group
  55  *     whose <code>ActivationGroupDesc</code> was only registered.</ul><p>
  56  *
  57  * Only the activator can <i>recreate</i> an
  58  * <code>ActivationGroup</code>.  The activator spawns, as needed, a
  59  * separate VM (as a child process, for example) for each registered
  60  * activation group and directs activation requests to the appropriate


 420      * obtain a reference to the <code>ActivationSystem</code> by
 421      * looking up the name "java.rmi.activation.ActivationSystem" in
 422      * the Activator's registry. By default, the port number used to
 423      * look up the activation system is defined by
 424      * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
 425      * overridden by setting the property
 426      * <code>java.rmi.activation.port</code>.
 427      *
 428      * @return the activation system for the VM/group
 429      * @exception ActivationException if activation system cannot be
 430      *  obtained or is not bound
 431      * (means that it is not running)
 432      * @see #setSystem
 433      * @since 1.2
 434      */
 435     public static synchronized ActivationSystem getSystem()
 436         throws ActivationException
 437     {
 438         if (currSystem == null) {
 439             try {
 440                 String host = AccessController.doPrivileged(
 441                     new GetPropertyAction("sun.rmi.activation.host",
 442                                          ""));
 443                 int port = AccessController.doPrivileged(
 444                     new GetIntegerAction("java.rmi.activation.port",
 445                                          ActivationSystem.SYSTEM_PORT));
 446                 currSystem = (ActivationSystem)
 447                     Naming.lookup("//" + host + ":" + port +
 448                                   "/java.rmi.activation.ActivationSystem");
 449             } catch (Exception e) {
 450                 throw new ActivationException(
 451                     "unable to obtain ActivationSystem", e);
 452             }
 453         }
 454         return currSystem;
 455     }
 456 
 457     /**
 458      * This protected method is necessary for subclasses to
 459      * make the <code>activeObject</code> callback to the group's
 460      * monitor. The call is simply forwarded to the group's
 461      * <code>ActivationMonitor</code>.
 462      *
 463      * @param id the object's identifier
 464      * @param mobj a marshalled object containing the remote object's stub
 465      * @exception UnknownObjectException if object is not registered
 466      * @exception RemoteException if call informing monitor fails
 467      * @exception ActivationException if an activation error occurs