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

📄 eventservice.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                if (resolvedResult.rc != 0) return resolvedResult;                timeout = Integer.parseInt(resolvedResult.result);            }            if (parsedRequest.optionTimes("priority") > 0)            {                resolvedResult = STAFUtil.resolveRequestVarAndCheckInt(                    "priority", parsedRequest.optionValue("priority"),                    fHandle, info.requestNumber);                if (resolvedResult.rc != 0) return resolvedResult;                priority = Integer.parseInt(resolvedResult.result);            }            if (parsedRequest.optionTimes("priorityDelta") > 0)            {                resolvedResult = STAFUtil.resolveRequestVarAndCheckInt(                    "priorityDelta", parsedRequest.optionValue("priorityDelta"),                    fHandle, info.requestNumber);                if (resolvedResult.rc != 0) return resolvedResult;                priorityDelta = Integer.parseInt(resolvedResult.result);            }            int subTimes = parsedRequest.optionTimes("subtype");            String[] subTypes = new String[subTimes];            for (int count = 1; count <= subTimes; count++)            {                resolvedResult = STAFUtil.resolveRequestVar(                    parsedRequest.optionValue("subtype", count),                    fHandle, info.requestNumber);                if (resolvedResult.rc != 0) return resolvedResult;                subTypes[count - 1] = resolvedResult.result;            }            if ((parsedRequest.optionTimes("byHandle") == 0) &&                (sResult.rc == 0))            {                fRegManager.registerClient(                    new Client(info.endpoint, info.handleName,                               maxAttempts, timeout, priority,                               priorityDelta), type, subTypes);            }            else if (sResult.rc == 0)            {                fRegManager.registerClient(                    new Client(info.endpoint, info.handle,                               maxAttempts, timeout, priority,                               priorityDelta), type, subTypes);            }            serialize(fRegManagerFileName);        }        catch (Exception e)        {            if (DEBUG) e.printStackTrace();            return new STAFResult(STAFResult.JavaError, "Internal Java error.");        }        return sResult;    }    /***************************************************************************/    /* handleQuery:                                                            */    /*                                                                         */    /* Handles QUERY EVENTID <EventID> [LONG] reqests.                         */    /* Lists, by EVENTID, the above data about registered                      */    /*              processes that have not yet acknowledged a generated event.*/    /*              Also lists the following data about the process that       */    /*              generated the event:                                       */    /*                                                                         */    /*              eventID#, generating machine name, generating process name,*/    /*              generating process handle, generating, type of event,      */    /*              subtype of event                                           */    /*                                                                         */    /* accepts: the submitting machine name, the submitting process, the sub-  */    /*          mitting process handle, a string containing any command options*/    /*          & option values.                                               */    /*                                                                         */    /* returns: if successful, STAFResult.rc = STAFResult.Ok (0);              */    /*                         STAFResult.result contains the data described   */    /*                         above.                                          */    /*          if unsuccessful, STAFResult.rc   = error code > 0;             */    /*                           STAFResult.result contains a message          */    /*                           correspond to error code in STAFResult.rc     */    /***************************************************************************/    private STAFResult handleQuery(STAFServiceInterfaceLevel30.RequestInfo info)    {        String type = null;        String subtype = null;        String eid = null;        int id = 0;        STAFResult resolvedResult = null;        STAFMarshallingContext mc = new STAFMarshallingContext();        try        {            // Verify the requesting machine/user has at least trust level 2            STAFResult trustResult = STAFUtil.validateTrust(                2, fServiceName, "QUERY", fLocalMachineName, info);            if (trustResult.rc != STAFResult.Ok) return trustResult;            // Parse the reqeust            STAFCommandParseResult parsedRequest = fQueryParser.parse(                info.request);            if (parsedRequest.rc != STAFResult.Ok)            {                return new STAFResult(STAFResult.InvalidRequestString,                                      parsedRequest.errorBuffer);            }            if (parsedRequest.optionTimes("eventID") > 0)            {                resolvedResult = STAFUtil.resolveRequestVarAndCheckInt(                    "eventID", parsedRequest.optionValue("eventID"),                    fHandle, info.requestNumber);                if (resolvedResult.rc != 0) return resolvedResult;                id = Integer.parseInt(resolvedResult.result);                Vector clientsForEvent = fGenManager.getClientsForEvent(id);                boolean longFormat = false;                if (parsedRequest.optionTimes("LONG") > 0)                {                    longFormat = true;                    mc.setMapClassDefinition(fEventIDLongMapClass);                    mc.setMapClassDefinition(fNotifieeMapClass);                    mc.setMapClassDefinition(fEventGeneratorMapClass);                }                else                {                    mc.setMapClassDefinition(fQueryEventIDMapClass);                    mc.setMapClassDefinition(fEventGeneratorMapClass);                }                if ((clientsForEvent != null) && (clientsForEvent.size() > 0))                {                    for (Enumeration cfe = clientsForEvent.elements();                         cfe.hasMoreElements();)                    {                        Map notificationMap =                            ((GenerationManager.Notification)                             cfe.nextElement()).getNotificationMap();                        if (longFormat)                        {                            mc.setRootObject(notificationMap);                            break;                        }                        else                        {                            Map eventIDMap = fQueryEventIDMapClass.                                createInstance();                            eventIDMap.put(                                "eventID", notificationMap.get("eventID"));                            eventIDMap.put(                                "type", notificationMap.get("type"));                            eventIDMap.put(                                "subtype", notificationMap.get("subtype"));                            // Note that property values that contain private                            // data will be masked.                            eventIDMap.put(                                "propertyMap",                                notificationMap.get("propertyMap"));                            eventIDMap.put(                                "generatedBy",                                notificationMap.get("generatedBy"));                            int numNotifiees = ((List)notificationMap.get(                                "notificationList")).size();                            eventIDMap.put("numNotifiees", "" + numNotifiees);                            mc.setRootObject(eventIDMap);                            break;                        }                    }                }                else                {                    return new STAFResult(kNoClientsForEvent,                           "No processes are waiting to be notified about " +                           "eventID " + id + ".");                }            }        }        catch(Exception e)        {            if (DEBUG)e.printStackTrace();            return new STAFResult(STAFResult.JavaError, "Internal Java error.");        }        return new STAFResult(STAFResult.Ok, mc.marshall());    }    /***************************************************************************/    /* handleList:                                                             */    /*                                                                         */    /* For a LIST TYPES request, lists all event types for which at least one  */    /* process is currently registered.                                        */    /*                                                                         */    /* For a LIST SUBTYPES TYPE <Type> request, lists all event subtypes for   */    /* the specified TYPE for which at least one process is currently          */    /* registered.                                                             */    /*                                                                         */    /* For a LIST REGISTRATIONS request, lists all the registrations, or if    */    /* TYPE/SUBTYPE is specified, just the registrations for the specified     */    /* types and subtypes.                                                     */    /*                                                                         */    /* For a LIST EVENTIDS request, lists, by EVENTID, data about registered   */    /* processes that have not yet acknowledged a generated event.             */    /*                                                                         */    /* For a LIST SETTINGS request, lists the operational settings for the     */    /* event service (maxAttempts, ackTimeout, priority, priorityDelta)        */    /*                                                                         */    /* accepts: STAFServiceInterfaceLevel30 request information                */    /*          (including the submitting machine name, the submitting process,*/    /*          the submitting process handle, a string containing any command */    /*          options & option values).                                      */    /*                                                                         */    /* returns: if successful, STAFResult.rc = STAFResult.Ok (0);              */    /*                         STAFResult.result contains the marshalled data  */    /*                         described above.                                */    /*          if unsuccessful, STAFResult.rc   = error code > 0;             */    /*                           STAFResult.result contains a message          */    /*                           correspond to error code in STAFResult.rc     */    /***************************************************************************/    private STAFResult handleList(STAFServiceInterfaceLevel30.RequestInfo info)    {        String type = null;        String subtype = null;        String eid = null;        int id = 0;        STAFResult resolvedResult = null;        STAFMarshallingContext mc = new STAFMarshallingContext();        try        {            // Verify that the requesting machine/user has at least trust level 2            STAFResult trustResult = STAFUtil.validateTrust(                2, fServiceName, "LIST", fLocalMachineName, info);            if (trustResult.rc != STAFResult.Ok) return trustResult;            // Parse the reqeust            STAFCommandParseResult parsedRequest = fListParser.parse(                info.request);                        if (parsedRequest.rc != STAFResult.Ok)            {                return new STAFResult(STAFResult.InvalidRequestString,                                      parsedRequest.errorBuffer);            }            if (parsedRequest.optionTimes("REGISTRATIONS") > 0)            {                boolean longFormat = false;                if (parsedRequest.optionTimes("LONG") > 0)                {                    longFormat = true;                    mc.setMapClassDefinition(fListRegLongMapClass);                }                else                {                    mc.setMapClassDefinition(fListRegMapClass);                }                List regClientList = new ArrayList();                if (parsedRequest.optionTimes("TYPE") == 0)                {                    // List all registrations                    for (Enumeration e = fRegManager.fRegistrationTable.keys();

⌨️ 快捷键说明

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