synchronized void activeGroup(ActivationInstantiator inst, long instIncarnation) throws ActivationException, UnknownGroupException { if (incarnation != instIncarnation) { throw new ActivationException("invalid incarnation"); } if (group != null) { if (group.equals(inst)) { return; } else { throw new ActivationException("group already active"); } } if (child != null && status != CREATING) { throw new ActivationException("group not being created"); } group = inst; status = NORMAL; notifyAll(); }
synchronized void registerObject(ActivationID id, ActivationDesc desc, boolean addRecord) throws UnknownGroupException, ActivationException { checkRemoved(); objects.put(id, new ObjectEntry(desc)); if (desc.getRestartMode() == true) { restartSet.add(id); } // table insertion must take place before log update idTable.put(id, groupID); if (addRecord) { addLogRecord(new LogRegisterObject(id, desc)); } }
synchronized void unregisterObject(ActivationID id, boolean addRecord) throws UnknownGroupException, ActivationException { ObjectEntry objEntry = getObjectEntry(id); objEntry.removed = true; objects.remove(id); if (objEntry.desc.getRestartMode() == true) { restartSet.remove(id); } // table removal must take place before log update idTable.remove(id); if (addRecord) { addLogRecord(new LogUnregisterObject(id)); } }
synchronized void unregisterGroup(boolean addRecord) throws UnknownGroupException, ActivationException { checkRemoved(); removed = true; for (Map.Entry<ActivationID,ObjectEntry> entry : objects.entrySet()) { ActivationID id = entry.getKey(); idTable.remove(id); ObjectEntry objEntry = entry.getValue(); objEntry.removed = true; } objects.clear(); restartSet.clear(); reset(); childGone(); // removal should be recorded before log update if (addRecord) { addLogRecord(new LogUnregisterGroup(groupID)); } }
synchronized ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc, boolean addRecord) throws UnknownObjectException, UnknownGroupException, ActivationException { ObjectEntry objEntry = getObjectEntry(id); ActivationDesc oldDesc = objEntry.desc; objEntry.desc = desc; if (desc.getRestartMode() == true) { restartSet.add(id); } else { restartSet.remove(id); } // restart information should be recorded before log update if (addRecord) { addLogRecord(new LogUpdateDesc(id, desc)); } return oldDesc; }
synchronized MarshalledObject<? extends Remote> activate(ActivationID id, boolean force, ActivationInstantiator inst) throws RemoteException, ActivationException { MarshalledObject<? extends Remote> nstub = stub; if (removed) { throw new UnknownObjectException("object removed"); } else if (!force && nstub != null) { return nstub; } nstub = inst.newInstance(id, desc); stub = nstub; /* * stub could be set to null by a group reset, so return * the newstub here to prevent returning null. */ return nstub; }
/** * Acquire the group semaphore and return a group name. Each * Pstartgroup must be followed by a Vstartgroup. The calling thread * will wait until there are fewer than <code>N</code> other threads * holding the group semaphore. The calling thread will then acquire * the semaphore and return. */ private synchronized String Pstartgroup() throws ActivationException { while (true) { checkShutdown(); // Wait until positive, then decrement. if (groupSemaphore > 0) { groupSemaphore--; return "Group-" + groupCounter++; } try { wait(); } catch (InterruptedException e) { } } }
/** * The group's <code>activeObject</code> method is called when an * object is exported (either by <code>Activatable</code> object * construction or an explicit call to * <code>Activatable.exportObject</code>. The group must inform its * <code>ActivationMonitor</code> that the object is active (via * the monitor's <code>activeObject</code> method) if the group * hasn't already done so. * * @param id the object's identifier * @param obj the remote object implementation * @exception UnknownObjectException if object is not registered * @exception RemoteException if call informing monitor fails */ public void activeObject(ActivationID id, Remote impl) throws ActivationException, UnknownObjectException, RemoteException { try { acquireLock(id); synchronized (this) { if (groupInactive == true) throw new ActivationException("group is inactive"); } if (!active.contains(id)) { ActiveEntry entry = new ActiveEntry(impl); active.put(id, entry); // created new entry, so inform monitor of active object try { super.activeObject(id, entry.mobj); } catch (RemoteException e) { // daemon can still find it by calling newInstance } } } finally { releaseLock(id); checkInactiveGroup(); } }
/** * The group's <code>activeObject</code> method is called when an * object is exported (either by <code>Activatable</code> object * construction or an explicit call to * <code>Activatable.exportObject</code>. The group must inform its * <code>ActivationMonitor</code> that the object is active (via * the monitor's <code>activeObject</code> method) if the group * hasn't already done so. * * @param id the object's identifier * @param impl the remote object implementation * @exception UnknownObjectException if object is not registered * @exception RemoteException if call informing monitor fails */ public void activeObject(ActivationID id, Remote impl) throws ActivationException, UnknownObjectException, RemoteException { try { acquireLock(id); synchronized (this) { if (groupInactive == true) throw new ActivationException("group is inactive"); } if (!active.contains(id)) { ActiveEntry entry = new ActiveEntry(impl); active.put(id, entry); // created new entry, so inform monitor of active object try { super.activeObject(id, entry.mobj); } catch (RemoteException e) { // daemon can still find it by calling newInstance } } } finally { releaseLock(id); checkInactiveGroup(); } }