cmisstackimpl.java

来自「CmisJavaApi」· Java 代码 · 共 448 行 · 第 1/2 页

JAVA
448
字号
/* * The contents of this file are subject to the Dyade Public License,  * as defined by the file DYADE_PUBLIC_LICENSE.TXT * * You may not use this file except in compliance with the License. You may * obtain a copy of the License on the Dyade web site (www.dyade.fr). * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific terms governing rights and limitations under the License. * * The Original Code is CmisJava API, including the java package  * fr.dyade.cmis, released September 5, 2000. * * The Initial Developer of the Original Code is Dyade. The Original Code and * portions created by Dyade are Copyright Bull and Copyright INRIA.  * All Rights Reserved. *//*      Copyright 1996-2000 by Institut National de Recherche en Informatique  *                             et en Automatique (INRIA) *          All rights reserved.  See COPYRIGHT in top-level directory. * *      Authors: Laurent Andrey, Eric Dillon, Olivier Festor *///---------------------------------------------------------------------------////  CVS Info//---------------------------------------------------------------------------//////  $Id: CMISStackImpl.java,v 1.2 2000/09/05 14:30:32 festor Exp $//  $Source: /local/resedas/CVS-Repository/CmisJavaApi/src/fr/dyade/cmis/impl/CMISStackImpl.java,v $//---------------------------------------------------------------------------////  Todo//---------------------------------------------------------------------------//// - Completely revisit the data structure for the PendingRequest queue....//   : we need a kind of hash table with invokeid (integer) as key.// - Check if PendingQueue can indeed handle the abtract interface fr.dyade.cmis.api.operation.CmisRequestpackage fr.dyade.cmis.impl;import java.util.*;import fr.dyade.cmis.api.*;import fr.dyade.cmis.api.operation.*;import fr.dyade.cmis.api.operation.event.*;import fr.dyade.cmis.api.types.*;import fr.dyade.cmis.util.TraceManager;//TODO?: replace by cmis.api.operation.CMISRequestimport fr.dyade.cmis.impl.operation.CMISRequestImpl;/** Basic implementation for a Agent/Manager CMISStack.  *   * This implementation framework for CMISStack provides:  * <menu>  * <li>basic features for event (ind/conf) queuing and dispatching   * (includes list of various kinds of listeners) for agent AND manager side. So this implementation  * implements {@link fr.dyade.cmis.api.CMISAgentStack} and {@link fr.dyade.cmis.api.CMISManagerStack}  * <li>a queue of pending (confirmed) cmis requests   * to allow response correlation and event generation.  * </menu>  *  * No support for listening thread is provided, that means that is up   * to concrete final implementations to provide mecanisms to get incomming   * messages (indications, replies) from transport level   * (see {@link fr.dyade.cmis.om.OMListeningThread},   * {@link fr.dyade.cmis.rmi.AssociationEndPointImpl#pushIndication} or  * {@link fr.dyade.cmis.rmi.AssociationEndPointImpl#pushConfirmation}).  * Therefore is a partial and still abstract implementation.  * NOTE: CMISStackImpl implements ErrorHandler interface so  default synchronous error handlers  * are the instances themself (see {@link CMISStackImpl#setSynchronousErrorHandler}).  *  * @see fr.dyade.cmis.api.CMISStack  *  * @version cvs $Id: CMISStackImpl.java,v 1.2 2000/09/05 14:30:32 festor Exp $  */public abstract class CMISStackImpl implements CMISAgentStack, CMISManagerStack, ErrorHandler {      /** Constructor with shared event queue.	* @param  pEventQueue the event queue the listening thread will post 	*         the incomming events (ind, conf, completion)	*         in. If this parameter is null a private queue is created	*         and this constructor is therefore equivalent to defaut one.	*/      protected CMISStackImpl( CMISEventQueue pEventQueue ) { 	 if (pEventQueue!=null) {	    fEventQueue = pEventQueue;	    fPrivateEventQueue=false;	 } else {	    fEventQueue=new CMISEventQueue();	    fPrivateEventQueue=true;	 }      }      /** Default construct.	* Default constructor implies use of a private event queue.	*/      public CMISStackImpl() {	 this(null);      }            /**	*  Adds a <code>EventReportListener</code> to the list of EventReportListener.	*  @param pErl the <code>EventReportListener</code> to add.	*/      public final void addEventReportListener(EventReportListener pErl) {	 fEventReportListeners.addElement(pErl);      }            /**	*  Deletes a <code>EventReportListener</code> from the list of EventReportListener.	*  @param pErl the <code>EventReportListener</code> to delete.	*/      public final void removeEventReportListener(EventReportListener pErl) {	 fEventReportListeners.removeElement(pErl);      }      // agent side stuff 	       public final void addActionListener(ActionListener pListener) {	 synchronized(fActionListeners) {	    fActionListeners.addElement(pListener);	 }      }      public final void removeActionListener(ActionListener pListener){	 synchronized(fActionListeners) {	    fActionListeners.removeElement(pListener);	 }      }      public final void addCancelGetListener(CancelGetListener pListener){	 synchronized(fCancelGetListeners) {	    fCancelGetListeners.addElement(pListener);	 }      }      public final void removeCancelGetListener(CancelGetListener pListener){	 synchronized(fCancelGetListeners) {	    fCancelGetListeners.removeElement(pListener);	 }      }      public final void addDeleteListener(DeleteListener pListener){	 synchronized(fDeleteListeners) {	    fDeleteListeners.addElement(pListener);	 }      }      public final void removeDeleteListener(DeleteListener pListener){	 synchronized(fDeleteListeners) {	    fDeleteListeners.removeElement(pListener);	 }      }      public final void addCreateListener(CreateListener pListener){	 synchronized(fCreateListeners) {	    fCreateListeners.addElement(pListener);	 }      }      public final void removeCreateListener(CreateListener pListener){	 synchronized(fCreateListeners) {	    fCreateListeners.removeElement(pListener);	 }      }      public final void addGetListener(GetListener pListener){	 synchronized(fGetListeners) { 	    fGetListeners.addElement(pListener);	    }      }      public final void removeGetListener(GetListener pListener){	    synchronized(fGetListeners) { 	       fGetListeners.removeElement(pListener);	    }      }      public final void addSetListener(SetListener pListener){	 synchronized(fSetListeners) {	       fSetListeners.addElement(pListener);	 }      }      public final void removeSetListener(SetListener pListener){	 synchronized(fSetListeners) {	    fSetListeners.removeElement(pListener);	 }      }// common stuff       /** Add an "asynchrounous" listener for internal runtime stack error seen as event.	* More one listener can be handled by the stack.	* @param pListener a new listener to call on error event	* @see fr.dyade.cmis.api.operation.event.InternalErrorEvent	*/      public final void addInternalErrorListener( InternalErrorListener pListener ) {	 synchronized(fInternalErrorListeners) {	    fInternalErrorListeners.addElement(pListener);	 }      }      /** Remove a listener internal runtime stack error.	* @param pListener the listener to remove	*/      public final void removeInternalErrorListener( InternalErrorListener pListener ){	 synchronized(fInternalErrorListeners) {	    fInternalErrorListeners.removeElement(pListener);	 }      }      /** Set the  synchronous error handler.	* This "last chance" error handler is call when asynchronous error reporting	* via <code>{@link InternalErrorListener}</code> is unsafe or not appropriated.	* One and only one synchrounous error handler is setable.	* @param pHandler the handler to use, if null a handler is reset to default default one (the stack itself see <code>{@link CMISStackImpl#handle(Throwable)}</code>).	*/      public final void setSynchronousErrorHandler( ErrorHandler pHandler ) {	 fSynchronousErrorHandler=(pHandler==null)?this:pHandler;      }      /** The dispatch METHOD for event loop.	* @param pEvent the event (Indication Event or error) to dispatch on stack	* @see CMISEventQueue	* TODO: add limitation according to fRole value.	*/      public final void dispatchEvent( CMISEvent pEvent ) throws CMISException {	 /* the add remove into fxxListeners are synchronized on the vector itself =>	    the enumeration pass through would be save */	 switch (pEvent.getTag()) {	       case CMISEvent.ACTION_INDICATION_EVENT:		  synchronized(fActionListeners) {		     for (Enumeration e=fActionListeners.elements(); e.hasMoreElements() ;) {        			((ActionListener)e.nextElement()).perform((ActionEvent)pEvent);		     }		  }		  break;	    case CMISEvent.CANCEL_GET_INDICATION_EVENT:	       synchronized(fCancelGetListeners) {		  for (Enumeration e=fCancelGetListeners.elements(); e.hasMoreElements() ;) {        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?