📄 performingoperationthread.java
字号:
/* * 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) or * in the root directory of this distribution. * * 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, Olivier Festor */// $Id: PerformingOperationThread.java,v 1.2 2000/09/05 10:16:51 festor Exp $// $Source: /local/resedas/CVS-Repository/CmisJavaApi/src/fr/dyade/cmis/examples/PerformingOperationThread.java,v $//package fr.dyade.cmis.examples;import java.util.Hashtable;import fr.dyade.cmis.util.TraceManager;import fr.dyade.cmis.api.types.InvokeId;import fr.dyade.cmis.api.types.CMISError;import fr.dyade.cmis.api.operation.*;import fr.dyade.cmis.api.operation.event.CMISServiceEvent;import fr.dyade.cmis.api.operation.event.CancelGetEvent;public abstract class PerformingOperationThread extends Thread { public PerformingOperationThread(CMISServiceEvent pInitialEvent) { // we should use a thread group fInitialEvent=pInitialEvent; if (fTab.put(pInitialEvent._getIndication().getInvokeId(), this)!=null) { TraceManager.debugln(getClass()+" over write tab entry"); } } public final void run() { boolean lContinue=true; fState=PERFORMING; try { while ((fState==PERFORMING) && (lContinue)) { yield(); //I hate java thread model. lContinue=performOnce(); } } catch (Throwable t) { TraceManager.debugln(getClass()+"run: get exception: "+ t); } performEnd(!lContinue); Object dummy=fTab.remove(this.fInitialEvent._getIndication().getInvokeId()); if (dummy==null) { TraceManager.debugln(getClass().getName() +" remove: unknown invoke id: "+this.fInitialEvent._getIndication().getInvokeId()); } } public abstract boolean performOnce(); public void performEnd( boolean pLastPerformDone ) {} public final synchronized void stopPerforming() { fState=STOPPED; } public final CMISServiceEvent _getInitialEvent() { return fInitialEvent; } public final short getState() { return fState; } public static void stop( InvokeId pIid ) throws NoSuchInvokeId { } public static void performCancelGetRequest( CancelGetEvent cgre ) { CancelGetIndication cgi=cgre.getIndication(); PerformingOperationThread op=(PerformingOperationThread)fTab.get(cgi.getGetInvokeId()); TraceManager.debugln("PerformingOperationThread.performCancelGetRequest: try to cancel invokeid: "+cgi.getGetInvokeId()); if (op instanceof PerformingGetThread) { // instanceof => not null ((PerformingGetThread)op)._performCancelGetRequest(cgre); } else { TraceManager.debugln("PerformingOperationThread.performCancelGetRequest: not a current get operation"); CancelGetResponse cgr=cgre.getStack().newCancelGetResponse(); cgr.setInvokeId(cgi.getInvokeId()); cgr.setCMISError(op!=null ? CMISError.MISTYPED_OPERATION : CMISError.NO_SUCH_INVOKE_ID(cgi.getGetInvokeId())); try {cgr.doIt();} catch (Exception e) {e.printStackTrace();} } } private CMISServiceEvent fInitialEvent; private static ThreadGroup gOperationThreadGroup=new ThreadGroup("CMIS-operation-group-thread"); private static Hashtable fTab=new Hashtable(); public static final short INITIALIZED=0; public static final short PERFORMING=1; public static final short STOPPED=2; private short fState=INITIALIZED;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -