Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / tools / gnu / classpath / tools / rmi / rmid / ActivationSystemImpl.java
blobdda40b06c027fd99f685e529514ee15228810ddf
1 /* ActivationSystemImpl.java -- implementation of the activation system.
2 Copyright (c) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package gnu.classpath.tools.rmi.rmid;
40 import gnu.classpath.tools.rmi.Persistent;
41 import gnu.classpath.tools.rmi.PersistentBidiHashTable;
42 import gnu.java.rmi.activation.ActivationSystemTransient;
44 import java.io.File;
45 import java.io.IOException;
46 import java.io.ObjectInputStream;
47 import java.io.ObjectOutputStream;
48 import java.io.Serializable;
49 import java.rmi.MarshalledObject;
50 import java.rmi.RemoteException;
51 import java.rmi.activation.ActivationDesc;
52 import java.rmi.activation.ActivationException;
53 import java.rmi.activation.ActivationGroupDesc;
54 import java.rmi.activation.ActivationGroupID;
55 import java.rmi.activation.ActivationID;
56 import java.rmi.activation.ActivationInstantiator;
57 import java.rmi.activation.ActivationMonitor;
58 import java.rmi.activation.ActivationSystem;
59 import java.rmi.activation.Activator;
60 import java.rmi.activation.UnknownGroupException;
61 import java.rmi.activation.UnknownObjectException;
63 /**
64 * Implements the rmid activation system.
66 * @author Audrius Meskauskas (audriusa@bioinformatics.org)
68 public class ActivationSystemImpl extends ActivationSystemTransient implements
69 ActivationSystem, Activator, ActivationMonitor, Serializable
71 /**
72 * Use for interoperability.
74 private static final long serialVersionUID = 1;
76 /**
77 * The singleton instance of this class.
79 public static ActivationSystemImpl singleton2;
81 /**
82 * Obtain the singleton instance of this class.
84 * @param folder the folder, where the activation system will keep its files.
85 * @param cold do the cold start if true, hot (usual) if false.
87 public static ActivationSystem getInstance(File folder, boolean cold)
89 if (singleton2 == null)
90 singleton2 = new ActivationSystemImpl(folder, cold);
91 return singleton2;
94 /**
95 * Creates the group with transient maps.
97 * @param folder
98 * the folder, where the activation system will keep its files.
99 * @param cold
100 * do the cold start if true, hot (usual) if false.
102 protected ActivationSystemImpl(File folder, boolean cold)
104 super(new PersistentBidiHashTable(), new PersistentBidiHashTable());
105 singleton2 = this;
106 ((PersistentBidiHashTable) groupDescs).init(
107 new File(folder, "asi_objects.data"), cold);
108 ((PersistentBidiHashTable) descriptions).init(
109 new File(folder, "asi_groups.data"), cold);
112 /** @inheritDoc */
113 public MarshalledObject activate(ActivationID id, boolean force)
114 throws ActivationException, UnknownObjectException, RemoteException
116 return super.activate(id, force);
119 /** @inheritDoc */
120 public ActivationMonitor activeGroup(ActivationGroupID id,
121 ActivationInstantiator group,
122 long incarnation)
123 throws UnknownGroupException, ActivationException, RemoteException
125 return super.activeGroup(id, group, incarnation);
128 /** @inheritDoc */
129 public void activeObject(ActivationID id, MarshalledObject obj)
130 throws UnknownObjectException, RemoteException
132 super.activeObject(id, obj);
135 /** @inheritDoc */
136 public ActivationDesc getActivationDesc(ActivationID id)
137 throws ActivationException, UnknownObjectException, RemoteException
139 return super.getActivationDesc(id);
142 public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID groupId)
143 throws ActivationException, UnknownGroupException, RemoteException
145 return super.getActivationGroupDesc(groupId);
148 /** @inheritDoc */
149 public void inactiveGroup(ActivationGroupID groupId, long incarnation)
150 throws UnknownGroupException, RemoteException
152 super.inactiveGroup(groupId, incarnation);
155 /** @inheritDoc */
156 public void inactiveObject(ActivationID id) throws UnknownObjectException,
157 RemoteException
159 super.inactiveObject(id);
162 /** @inheritDoc */
163 public ActivationGroupID registerGroup(ActivationGroupDesc groupDesc)
164 throws ActivationException, RemoteException
166 return super.registerGroup(groupDesc);
169 /** @inheritDoc */
170 public ActivationID registerObject(ActivationDesc desc)
171 throws ActivationException, UnknownGroupException, RemoteException
173 return super.registerObject(desc);
176 /** @inheritDoc */
177 public ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc)
178 throws ActivationException, UnknownObjectException,
179 UnknownGroupException, RemoteException
181 return super.setActivationDesc(id, desc);
184 /** @inheritDoc */
185 public ActivationGroupDesc setActivationGroupDesc(
186 ActivationGroupID groupId, ActivationGroupDesc groupDesc)
187 throws ActivationException, UnknownGroupException, RemoteException
189 return super.setActivationGroupDesc(groupId, groupDesc);
193 * This method saves the state of the activation system and then
194 * terminates in 10 seconds.
196 public void shutdown() throws RemoteException
198 super.shutdown();
199 System.out.println("Shutdown command received. Will terminate in 10 s");
200 Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
203 /** @inheritDoc */
204 public void unregisterGroup(ActivationGroupID groupId)
205 throws ActivationException, UnknownGroupException, RemoteException
207 super.unregisterGroup(groupId);
210 /** @inheritDoc */
211 public void unregisterObject(ActivationID id) throws ActivationException,
212 UnknownObjectException, RemoteException
214 super.unregisterObject(id);
218 * Read the object from the input stream.
220 * @param in the stream to read from
222 * @throws IOException if thrown by the stream
223 * @throws ClassNotFoundException
225 private void readObject(ObjectInputStream in) throws IOException,
226 ClassNotFoundException
228 // Read no fields.
232 * Write the object to the output stream.
234 * @param out the stream to write int
235 * @throws IOException if thrown by the stream
236 * @throws ClassNotFoundException
238 private void writeObject(ObjectOutputStream out) throws IOException,
239 ClassNotFoundException
241 // Write no fields.