1/*
2 * Copyright (c) 1997, 2002, 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
26package sun.rmi.server;
27
28import java.rmi.activation.ActivationGroupDesc;
29import java.rmi.activation.ActivationGroupID;
30import java.rmi.activation.ActivationGroup;
31
32/**
33 * This is the bootstrap code to start a VM executing an activation
34 * group.
35 *
36 * The activator spawns (as a child process) an activation group as needed
37 * and directs activation requests to the appropriate activation
38 * group. After spawning the VM, the activator passes some
39 * information to the bootstrap code via its stdin:
40 * <ul>
41 * <li> the activation group's id,
42 * <li> the activation group's descriptor (an instance of the class
43 *    java.rmi.activation.ActivationGroupDesc) for the group, adn
44 * <li> the group's incarnation number.
45 * </ul><p>
46 *
47 * When the bootstrap VM starts executing, it reads group id and
48 * descriptor from its stdin so that it can create the activation
49 * group for the VM.
50 *
51 * @author Ann Wollrath
52 */
53public abstract class ActivationGroupInit
54{
55    /**
56     * Main program to start a VM for an activation group.
57     */
58    public static void main(String args[])
59    {
60        try {
61            if (System.getSecurityManager() == null) {
62                System.setSecurityManager(new SecurityManager());
63            }
64            // read group id, descriptor, and incarnation number from stdin
65            MarshalInputStream in = new MarshalInputStream(System.in);
66            ActivationGroupID id  = (ActivationGroupID)in.readObject();
67            ActivationGroupDesc desc = (ActivationGroupDesc)in.readObject();
68            long incarnation = in.readLong();
69
70            // create and set group for the VM
71            ActivationGroup.createGroup(id, desc, incarnation);
72        } catch (Exception e) {
73            System.err.println("Exception in starting ActivationGroupInit:");
74            e.printStackTrace();
75        } finally {
76            try {
77                System.in.close();
78                // note: system out/err shouldn't be closed
79                // since the parent may want to read them.
80            } catch (Exception ex) {
81                // ignore exceptions
82            }
83        }
84    }
85}
86