anchor.diff:   :members NIL)
   
   
  -(defun poamanager-new-state (pm new-state)
  +(defun in-invocation-context (pm)
  +  "True if in an invocation context for some POA in the same ORB as PM"
  +  (when *poa-current*
  +    (let ((pm-poas (managed-poas pm)))
  +      (when pm-poas
  +        (eql (the-orb (poa-current-poa *poa-current*))
  +             (the-orb (car pm-poas)))))))
  +
  +
  +(defun poamanager-new-state (pm new-state wait-for-completion
  +                                    &optional etheralize-objects)
  +  (when wait-for-completion 
  +    (when (in-invocation-context pm)
  +      (raise-system-exception 'CORBA:bad_inv_order 3)))
     (with-slots (state) pm
       (when (eq state :inactive)
  -      (error 'POAManager/AdapterInactive))
  -    (setf state new-state)))
  +      (unless (eq new-state :inactive)
  +        (error 'POAManager/AdapterInactive)))
  +    (let ((old-state state))
  +      (setf state new-state)
  +      (unless (eql new-state old-state)
  +        (when etheralize-objects
  +          (dolist (poa (managed-poas pm))
  +            (start-etheralize poa))))))
  +  (when wait-for-completion
  +    (dolist (poa (managed-poas pm))
  +      (wait-for-completion poa))))
  +
  +
  +(defmethod add-poa ((pm PortableServer:POAManager) poa)
  +  (push poa (managed-poas pm)))
  +
  +(defmethod remove-poa ((pm PortableServer:POAManager) poa)
  +  (setf (managed-poas pm) (delete poa (managed-poas pm))))
   
   
   ;;; void activate()
   ;;;	raises(AdapterInactive);
   (define-method activate ((pm PortableServer:POAManager))
  -  (POAManager-new-state pm :active))
  +  (POAManager-new-state pm :active nil))
   
   
   ;;; void hold_requests(in boolean wait_for_completion)
   ;;;     raises(AdapterInactive);
  -(define-method hold_requests ((pm PortableServer:POAManager) wait_for_completion)
  -  (when wait_for_completion
  -    ;;(check-not-processing-request )
  -    (when *poa-current*
  -      ;; FIXME: check same ORB 
  -      (raise-system-exception 'CORBA:BAD_INV_ORDER 3)))
  -  (POAManager-new-state pm :holding))
  +(define-method hold_requests ((pm PortableServer:POAManager) wait-for-completion)
  +  (POAManager-new-state pm :holding wait-for-completion))
   
   
   ;;; void discard_requests(in boolean wait_for_completion)
   ;;;        raises(AdapterInactive);
  -(define-method discard_requests ((pm PortableServer:POAManager) wait_for_completion)
  -  (when wait_for_completion
  -    (when *poa-current*
  -      (raise-system-exception 'CORBA:bad_inv_order 3)))
  -  (POAManager-new-state pm :discarding))
  +(define-method discard_requests ((pm PortableServer:POAManager) wait-for-completion)
  +  (POAManager-new-state pm :discarding wait-for-completion))
  +
   
   
   ;;; void deactivate(	in boolean etherealize_objects,
  
positive.code:   ;; Combine state from POAManager and other operations on the POA.
    (or (poa-state poa)
        (op:get_state (op:the_poamanager poa))))
  
  ;;;; PortableServer::Current
  
negative.code: 
  |#
  
  
  (defun start-etheralize (poa)
    (when (and (poa-has-policy poa :retain)
               (poa-has-policy poa :use_servant_manager)
               (POA-servant-manager poa))
      (maptrie (lambda (oid servant)
                 (op:etherealize (POA-servant-manager poa) 
                                 oid poa servant t 
                                 (not (null (gethash servant (poa-active-servant-map poa))))))
               (POA-active-object-map poa))))
  
  
  (define-method destroy ((poa PortableServer:POA) etherealize-objects wait-for-completion)
  #|
  * If wait_for_completion is TRUE and the current thread is in an invocation
  