⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventservice.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2001, 2004, 2005                                  *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************/package com.ibm.staf.service.event;import com.ibm.staf.*;import com.ibm.staf.service.*;import java.util.*;import java.io.*;/**********************************************************************//* STAF Event Service                                                 *//* By Doug McWhorter and Benjamin Vera-Tudela (C) IBM 2000            *//* Version 0.90                                                       *//**********************************************************************//* Supplied Methods                                                   *//* ------------------                                                 *//* public int init(String name, String parms)                         *//*                                                                    *//* public int term()                                                  *//*                                                                    *//* public STAFResult acceptRequest(String machine, String process,    *//*                                     int handle, String request)    *//*                                                                    *//* synchronized private void serialize(String theFileName)            *//*                                                                    *//* synchronized private void deSerialize(String theFileName)          *//*                                                                    *//**********************************************************************///  Class EventService administrates client requests to the Event Service.//  Requests include:////  REGISTER a process to be notified of an event of TYPE t, SUBTYPE s.//  GENERATE an event of TYPE t, SUBTYPE s.//  ACKNOWLEDGE that an event of TYPE t, SUBTYPE s has notified.//  UNREGISTER a process that is currently registered for event notification.//  QUERY information about processes that have generated an event by//      EVENTID #.//  LIST information about TYPES and SUBTYPES of events that processes are//      registered to be notified about or lists information about events//      that have been generated by EVENTID #, or lists information about//      proesses that are registered to be notified about events (all or//      by type, or by type/subtype).//  VERSION: display the installed version of Event Service.//  HELPpublic class EventService implements STAFServiceInterfaceLevel30{    static final long serialVersionUID = 0;    transient static final boolean DEBUG = false;    transient final String kVersion = "3.1.0";    // Version of STAF (or later) required for this service    // STAF Version 3.1.0 or later is required so that the privacy methods    // in STAFUtil are available.    transient final String kRequiredSTAFVersion = "3.1.0";    public static String lineSep;    // global error constants    transient static final int kNoAckPending = 4001;    transient static final int kNoSuchID = 4002;    transient static final int kNotRegisteredForType = 4003;    transient static final int kNotRegisteredForSubtype = 4004;    transient static final int kNoClientsForEvent = 4005;    // Default service initialization parameters    private int fMaxAttempts = 1;    private int fAckTimeout = 60000;    private int fPriority = 5;    private int fPriorityDelta = 1;    transient private STAFHandle fHandle = null;    transient private String fServiceName = null;    transient private String fLocalMachineName = "";    // Directory where the Event Service writes data to    transient private String fDataDir = null;    transient private String fRegManagerFileName = null;    transient private String fGenManagerFileName = null;    // stores & processes registration information    transient RegistrationManager fRegManager = null;    // stores & processes information about events    transient GenerationManager fGenManager = null;    // a STAFCommandParser for each request's options    transient STAFCommandParser fListParser = null;    transient STAFCommandParser fQueryParser = null;    transient STAFCommandParser fRegisterParser = null;    transient STAFCommandParser fGenerateParser = null;    transient STAFCommandParser fAckParser = null;    transient STAFCommandParser fResetParser = null;    transient STAFCommandParser fUnregisterParser = null;    transient STAFCommandParser fVersionParser = null;    // parses any initialization arguments    transient STAFCommandParser fParmsParser = null;    // Map Class Definitions used to create marshalled results    public static STAFMapClassDefinition fTypeMapClass;    public static STAFMapClassDefinition fEventGeneratorMapClass;    private static STAFMapClassDefinition fListEventIDsMapClass;    public static STAFMapClassDefinition fEventIDLongMapClass;    private static STAFMapClassDefinition fQueryEventIDMapClass;    public static STAFMapClassDefinition fNotifieeMapClass;    private static STAFMapClassDefinition fListRegMapClass;    private static STAFMapClassDefinition fListRegLongMapClass;    private static STAFMapClassDefinition fSettingsMapClass;    // default constructor    public EventService()    { /* Do Nothing */ }    /***************************************************************/    /* init - Initializes Event Service with STAF.  Instantiates   */    /* all parsers, fGenManager (deserializes fGenManager.EventID) */    /* and fRegManager (Deserializes all registration data from    */    /* file.                                                       */    /*                                                             */    /* accepts: STAFServiceInterfaceLevel30 initialization info    */    /*                                                             */    /* Returns: STAFResult.Ok or STAFResult.STAFRegistrationError  */    /***************************************************************/    public STAFResult init(STAFServiceInterfaceLevel30.InitInfo info)    {        try        {            // instantiate parsers as not case sensitive            fRegisterParser = new STAFCommandParser(0, false);            fGenerateParser = new STAFCommandParser(0, false);            fAckParser = new STAFCommandParser(0, false);            fResetParser = new STAFCommandParser(0, false);            fUnregisterParser = new STAFCommandParser(0, false);            fListParser = new STAFCommandParser(0, false);            fQueryParser = new STAFCommandParser(0, false);            fVersionParser = new STAFCommandParser(0, false);            fParmsParser = new STAFCommandParser(0, false);            //initialize all parsers to accept request options            fParmsParser.addOption("MAXATTEMPTS", 1,                                   STAFCommandParser.VALUEALLOWED);            fParmsParser.addOption("ACKNOWLEDGETIMEOUT", 1,                                   STAFCommandParser.VALUEALLOWED);            fParmsParser.addOption("PRIORITY", 1,                                   STAFCommandParser.VALUEALLOWED);            fParmsParser.addOption("PRIORITYDELTA", 1,                                   STAFCommandParser.VALUEALLOWED);            fRegisterParser.addOption("REGISTER", 1,                                      STAFCommandParser.VALUENOTALLOWED);            fRegisterParser.addOption("TYPE", 1,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("SUBTYPE", 0,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("ACKNOWLEDGETIMEOUT", 1,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("MAXATTEMPTS", 1,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("PRIORITY", 1,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("PRIORITYDELTA", 1,                                      STAFCommandParser.VALUEREQUIRED);            fRegisterParser.addOption("BYHANDLE", 1,                                      STAFCommandParser.VALUENOTALLOWED);            fRegisterParser.addOption("BYNAME", 1,                                      STAFCommandParser.VALUENOTALLOWED);            fRegisterParser.addOptionGroup("BYHANDLE BYNAME", 0, 1);            fRegisterParser.addOptionNeed("REGISTER", "TYPE");            fGenerateParser.addOption("GENERATE", 1,                                      STAFCommandParser.VALUENOTALLOWED);            fGenerateParser.addOption("TYPE", 1,                                      STAFCommandParser.VALUEREQUIRED);            fGenerateParser.addOption("SUBTYPE", 1,                                      STAFCommandParser.VALUEREQUIRED);            fGenerateParser.addOption("PROPERTY", 0,                                      STAFCommandParser.VALUEREQUIRED);            fGenerateParser.addOptionNeed("GENERATE", "TYPE, SUBTYPE");            fGenerateParser.addOptionGroup("TYPE SUBTYPE", 2, 2);            fAckParser.addOption("ACKNOWLEDGE", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fAckParser.addOption("EVENTID", 1,                                 STAFCommandParser.VALUEREQUIRED);            fAckParser.addOption("FORCE", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fAckParser.addOption("MACHINE", 1,                                 STAFCommandParser.VALUEREQUIRED);            fAckParser.addOption("NAME", 1,                                 STAFCommandParser.VALUEREQUIRED);            fAckParser.addOption("HANDLE", 1,                                 STAFCommandParser.VALUEREQUIRED);            fAckParser.addOptionGroup("EVENTID", 1, 1);            fAckParser.addOptionNeed("MACHINE", "FORCE");            fAckParser.addOptionNeed("HANDLE", "FORCE");            fAckParser.addOptionNeed("NAME", "FORCE");            fAckParser.addOptionNeed("ACKNOWLEDGE", "EVENTID");            fResetParser.addOption("RESET", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fResetParser.addOption("GEN", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fResetParser.addOption("REG", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fResetParser.addOption("FORCE", 1,                                 STAFCommandParser.VALUENOTALLOWED);            fResetParser.addOptionGroup("GEN REG", 1, 1);            fUnregisterParser.addOption("UNREGISTER", 1,                                        STAFCommandParser.VALUENOTALLOWED);            fUnregisterParser.addOption("TYPE", 1,                                        STAFCommandParser.VALUEREQUIRED);            fUnregisterParser.addOption("SUBTYPE", 0,                                        STAFCommandParser.VALUEREQUIRED);            fUnregisterParser.addOption("BYNAME", 1,                                        STAFCommandParser.VALUENOTALLOWED);            fUnregisterParser.addOption("FORCE", 1,                                        STAFCommandParser.VALUENOTALLOWED);            fUnregisterParser.addOption("MACHINE", 1,                                        STAFCommandParser.VALUEREQUIRED);            fUnregisterParser.addOption("NAME", 1,                                        STAFCommandParser.VALUEREQUIRED);            fUnregisterParser.addOption("HANDLE", 1,                                        STAFCommandParser.VALUEREQUIRED);            fUnregisterParser.addOptionGroup("NAME HANDLE", 0, 1);            fUnregisterParser.addOptionGroup("TYPE", 1, 1);            fUnregisterParser.addOptionNeed("UNREGISTER", "TYPE");            fUnregisterParser.addOptionNeed("SUBTYPE", "TYPE");            fUnregisterParser.addOptionNeed("FORCE", "TYPE");            fUnregisterParser.addOptionNeed("MACHINE", "FORCE");            fUnregisterParser.addOptionNeed("HANDLE", "FORCE");            fUnregisterParser.addOptionNeed("NAME", "FORCE");            fUnregisterParser.addOptionGroup("FORCE", 0, 1);            fListParser.addOption("LIST", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("TYPES", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("SUBTYPES", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("TYPE", 1,                                  STAFCommandParser.VALUEREQUIRED);            fListParser.addOption("SUBTYPE", 1,                                  STAFCommandParser.VALUEREQUIRED);            fListParser.addOption("REGISTRATIONS", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("EVENTIDS", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("LONG", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOption("SETTINGS", 1,                                  STAFCommandParser.VALUENOTALLOWED);            fListParser.addOptionGroup(                "TYPES SUBTYPES REGISTRATIONS EVENTIDS SETTINGS", 1, 1);            fListParser.addOptionNeed("LONG", "TYPES EVENTIDS REGISTRATIONS");            fListParser.addOptionNeed("TYPE", "SUBTYPES REGISTRATIONS EVENTIDS");            fListParser.addOptionNeed("SUBTYPE", "TYPE");            fListParser.addOptionNeed("SUBTYPES", "TYPE");            fQueryParser.addOption("QUERY", 1,                                   STAFCommandParser.VALUENOTALLOWED);            fQueryParser.addOption("EVENTID", 1,                                   STAFCommandParser.VALUEREQUIRED);            fQueryParser.addOption("LONG", 1,                                   STAFCommandParser.VALUENOTALLOWED);            fQueryParser.addOptionNeed("LONG", "EVENTID");            fQueryParser.addOptionNeed("QUERY", "EVENTID");            fVersionParser.addOption("VERSION", 1,                                     STAFCommandParser.VALUENOTALLOWED);            fHandle = new STAFHandle("STAF/SERVICE/" + info.name);            fServiceName = info.name;            // Construct map class for a LIST EVENTIDS request.            // List each event ID that has not yet been acknowledged and            // the number of pending notifications (notifiees that have been            // notified about the event but have not yet acknowledged).

⌨️ 快捷键说明

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