📄 eventservice.java
字号:
fListEventIDsMapClass = new STAFMapClassDefinition( "STAF/Service/Event/EventID"); fListEventIDsMapClass.addKey("eventID", "Event ID"); fListEventIDsMapClass.addKey("type", "Type"); fListEventIDsMapClass.addKey("subtype", "Subtype"); fListEventIDsMapClass.addKey("numNotifiees", "# Notifiees"); // Construct map class for a LIST EVENTIDS LONG request and for a // QUERY EVENTID <Event ID> LONG request. // List all event IDs, showing the who generated the event as well // as a list of the pending notifications (notifiees that have been // notified about the event but have not yet acknowledged). fEventIDLongMapClass = new STAFMapClassDefinition( "STAF/Service/Event/EventIDLong"); fEventIDLongMapClass.addKey("eventID", "Event ID"); fEventIDLongMapClass.addKey("type", "Type"); fEventIDLongMapClass.addKey("subtype", "Subtype"); fEventIDLongMapClass.addKey("propertyMap", "Properties"); fEventIDLongMapClass.addKey("generatedBy", "Generated By"); fEventIDLongMapClass.addKey("notificationList", "Pending Notifications"); // Construct map class for a QUERY EVENTID <Event ID> request. // Query the event ID, showing the number of pending notifications // (notifiees that have been notified about the event but have not // yet acknowledged). fQueryEventIDMapClass = new STAFMapClassDefinition( "STAF/Service/Event/QueryEventID"); fQueryEventIDMapClass.addKey("eventID", "Event ID"); fQueryEventIDMapClass.addKey("type", "Type"); fQueryEventIDMapClass.addKey("subtype", "Subtype"); fQueryEventIDMapClass.addKey("propertyMap", "Properties"); fQueryEventIDMapClass.addKey("generatedBy", "Generated By"); fQueryEventIDMapClass.addKey("numNotifiees", "# Notifiees"); // Construct map class for the generator of an event ID (used by // a LIST EVENTIDS LONG request (for the generatedBy field). fEventGeneratorMapClass = new STAFMapClassDefinition( "STAF/Service/Event/Generator"); fEventGeneratorMapClass.addKey("machine", "Machine"); fEventGeneratorMapClass.addKey("handleName", "Handle Name"); fEventGeneratorMapClass.addKey("handle", "Handle"); // Construct map class for an event pending notification (used by // a LIST EVENTIDS LONG request (for the notificationList field). fNotifieeMapClass = new STAFMapClassDefinition( "STAF/Service/Event/PendingNotification"); fNotifieeMapClass.addKey("machine", "Machine"); fNotifieeMapClass.addKey("notifyBy", "Notify By"); fNotifieeMapClass.addKey("notifiee", "Notifiee"); fNotifieeMapClass.addKey("attempts", "Attempts Remaining"); fNotifieeMapClass.addKey("timeout", "Timeout"); fNotifieeMapClass.addKey("priority", "Priority"); fNotifieeMapClass.addKey("priorityDelta", "Priority Delta"); // Construct map class for a LIST REGISTRATIONS request. // List all the registrations along with the types and subtypes // for which they are registered (in a short format). fListRegMapClass = new STAFMapClassDefinition( "STAF/Service/Event/ListRegistrations"); fListRegMapClass.addKey("type", "Type"); fListRegMapClass.addKey("subtype", "Subtype"); fListRegMapClass.addKey("machine", "Machine"); fListRegMapClass.addKey("notifyBy", "Notify By"); fListRegMapClass.addKey("notifiee", "Notifiee"); // Construct map class for a LIST REGISTRATIONS LONG request // List the registrations along with the types and subtypes for // which they are registered (in a long format). fListRegLongMapClass = new STAFMapClassDefinition( "STAF/Service/Event/ListRegistrationsLong"); fListRegLongMapClass.addKey("type", "Type"); fListRegLongMapClass.addKey("subtype", "Subtype"); fListRegLongMapClass.addKey("machine", "Machine"); fListRegLongMapClass.addKey("notifyBy", "Notify By"); fListRegLongMapClass.addKey("notifiee", "Notifiee"); fListRegLongMapClass.addKey("attempts", "Max Attempts"); fListRegLongMapClass.setKeyProperty( "attempts", "display-short-name", "Att"); fListRegLongMapClass.addKey("timeout", "Timeout"); fListRegLongMapClass.addKey("priority", "Priority"); fListRegLongMapClass.setKeyProperty( "priority", "display-short-name", "P"); fListRegLongMapClass.addKey("priorityDelta", "Priority Delta"); fListRegLongMapClass.setKeyProperty( "priorityDelta", "display-short-name", "D"); // Construct map class for listing types and their subtypes fTypeMapClass = new STAFMapClassDefinition( "STAF/Service/Event/Type"); fTypeMapClass.addKey("type", "Type"); fTypeMapClass.addKey("subtypeList", "Subtypes"); // Construct map-class for list settings information fSettingsMapClass = new STAFMapClassDefinition( "STAF/Service/Event/Settings"); fSettingsMapClass.addKey("maxAttempts", "Maximum Attempts"); fSettingsMapClass.addKey("ackTimeout", "Acknowledgement Timeout"); fSettingsMapClass.addKey("priority", "Priority"); fSettingsMapClass.addKey("priorityDelta", "Priority Delta"); STAFResult res = new STAFResult(); // Resolve the line separator variable for the local machine res = STAFUtil.resolveInitVar("{STAF/Config/Sep/Line}", fHandle); if (res.rc != STAFResult.Ok) return res; lineSep = res.result; // Resolve the file separator variable for the local machine res = STAFUtil.resolveInitVar("{STAF/Config/Sep/File}", fHandle); if (res.rc != STAFResult.Ok) return res; String fileSep = res.result; // Resolve the machine name variable for the local machine res = STAFUtil.resolveInitVar("{STAF/Config/Machine}", fHandle); if (res.rc != STAFResult.Ok) return res; fLocalMachineName = res.result; // Verify that the parameters specified for the service are valid res = handleParms(info); if (res.rc != STAFResult.Ok) { return new STAFResult( STAFResult.ServiceConfigurationError, "Error validating parameters: RC=" + res.rc + ", Result=" + res.result); } // Verify that the required version of STAF is running on the // local service machine. // Note: Method compareSTAFVersion was added in STAF V3.1.0 try { res = STAFUtil.compareSTAFVersion( "local", fHandle, kRequiredSTAFVersion); if (res.rc != STAFResult.Ok) { if (res.rc == STAFResult.InvalidSTAFVersion) { return new STAFResult( STAFResult.ServiceConfigurationError, "Minimum required STAF version for this service " + "is not running." + lineSep + res.result); } else { return new STAFResult( STAFResult.ServiceConfigurationError, "Error verifying the STAF version. RC: " + res.rc + ", Additional info: " + res.result); } } } catch (Error err) { return new STAFResult( STAFResult.ServiceConfigurationError, "This service requires STAF Version " + kRequiredSTAFVersion + " or later."); } // Store data for the event service in directory: // <STAF writeLocation>/service/<event service name (lower-case)> fDataDir = info.writeLocation; if (!fDataDir.endsWith(fileSep)) { fDataDir += fileSep; } fDataDir = fDataDir + "service" + fileSep + fServiceName.toLowerCase(); File dir = new File(fDataDir); if (!dir.exists()) { dir.mkdirs(); } fRegManagerFileName = fDataDir + fileSep + "RegManager.out"; fGenManagerFileName = fDataDir + fileSep + "GenManager.out"; // read registration data from the RegManager.out file deSerialize(fRegManagerFileName); fGenManager = new GenerationManager(fHandle, fServiceName, fRegManager, fGenManagerFileName); // read EventID from the GenManager.out file deSerialize("fGenManagerFileName"); // Register Help Data registerHelpData( kNoAckPending, "No Acknowledgement Pending", "Already received an acknowledgement for this event from " + "the acknowledging process."); registerHelpData( kNoSuchID, "No such event ID", "An acknowledgement was received but no event with the " + "submitted Event ID has been generated."); registerHelpData( kNotRegisteredForType, "Not registered for Type", "A process tried to unregister for an event Type that it " + "was not currently registered for."); registerHelpData( kNotRegisteredForSubtype, "Not registered for Subtype", "A process tried to unregister for an event Subtype that " + "it was not currently registered for."); registerHelpData( kNoClientsForEvent, "No clients registered", "No clients were registered for the event."); res.rc = STAFResult.Ok; res.result = ""; return res; } catch(STAFException e) { if (DEBUG) e.printStackTrace(); STAFResult res = new STAFResult(STAFResult.Ok); res.rc = STAFResult.STAFRegistrationError; res.result = e.toString(); return res; } } private STAFResult handleParms(STAFServiceInterfaceLevel30.InitInfo info) throws STAFException { STAFCommandParseResult parsedResult= fParmsParser.parse(info.parms); String errmsg = "ERROR: Service Configuration Error for Service " + fServiceName + lineSep + "EventService::handleParms() - "; if (parsedResult.rc != STAFResult.Ok) { return new STAFResult( STAFResult.InvalidRequestString, parsedResult.errorBuffer); } STAFResult resolvedResult; if (parsedResult.optionTimes("MAXATTEMPTS") > 0) { resolvedResult = STAFUtil.resolveInitVarAndCheckInt( "MAXATTEMPTS", parsedResult.optionValue("MAXATTEMPTS"), fHandle); if (resolvedResult.rc != STAFResult.Ok) return resolvedResult; fMaxAttempts = Integer.parseInt(resolvedResult.result); } if (parsedResult.optionTimes("ACKNOWLEDGETIMEOUT") > 0) { resolvedResult = STAFUtil.resolveInitVarAndCheckInt( "ACKNOWLEDGETIMEOUT", parsedResult.optionValue("ACKNOWLEDGETIMEOUT"), fHandle); if (resolvedResult.rc != STAFResult.Ok) return resolvedResult; fAckTimeout = Integer.parseInt(resolvedResult.result);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -