示例#1
0
 /**
  * Add a ServiceMonitorFilter to this MonitorFilter
  *
  * @param serviceMonitorFilter Service Specific Filter
  * @exception MonitorFilterException
  * @return ServiceMonitorFilter Modified Filter to the capabilities of the service
  */
 public ServiceMonitorFilter addServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
     throws MonitorFilterException {
   ModuleClassID moduleClassID = serviceMonitorFilter.getModuleClassID();
   if (serviceMonitorFilters.get(moduleClassID) != null)
     throw new MonitorFilterException(
         "Attempt to add a second Monitor Filter for: " + moduleClassID);
   serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
   return serviceMonitorFilter;
 }
示例#2
0
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element serviceElement = (TextElement) e.nextElement();
      String tagName = (String) serviceElement.getKey();

      if (tagName.equals("service")) {
        try {
          ModuleClassID moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(
                      new URI(
                          DocumentSerializableUtilities.getString(
                              serviceElement, "moduleClassID", "ERROR")));

          try {
            ServiceMonitorFilter serviceMonitorFilter =
                MonitorResources.createServiceMonitorFilter(moduleClassID);
            serviceMonitorFilter.init(moduleClassID);
            Element serviceMonitorFilterElement =
                DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter");
            serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement);
            serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
          } catch (Exception ex) {
            if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList();

            unknownModuleClassIDs.add(moduleClassID);
          }
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't get ModuleClassID", jex);
        }
      }
    }
  }
示例#3
0
  /** {@inheritDoc} */
  public void serializeTo(Element element) throws DocumentSerializationException {
    DocumentSerializableUtilities.addString(element, "description", description);

    for (Iterator i = serviceMonitorFilters.values().iterator(); i.hasNext(); ) {
      ServiceMonitorFilter serviceMonitorFilter = (ServiceMonitorFilter) i.next();

      Element serviceElement = DocumentSerializableUtilities.createChildElement(element, "service");

      DocumentSerializableUtilities.addString(
          serviceElement, "moduleClassID", serviceMonitorFilter.getModuleClassID().toString());
      DocumentSerializableUtilities.addDocumentSerializable(
          serviceElement, "serviceFilter", serviceMonitorFilter);
    }
  }
示例#4
0
 /**
  * Get Iterator of all ServiceMonitorFilters subfilters
  *
  * @return Iterator of all ServiceMonitorFilters subfilters
  */
 public Iterator getServiceMonitorFilters() {
   return serviceMonitorFilters.values().iterator();
 }
示例#5
0
 /**
  * get ModuleClassIDs of contained subfilters
  *
  * @return Iterator of ServiceMonitor ClassIDs
  */
 public Iterator getModuleClassIDs() {
   return serviceMonitorFilters.keySet().iterator();
 }
示例#6
0
 /**
  * Get the number of subfilters
  *
  * @return int
  */
 public int getServiceMonitorFilterCount() {
   return serviceMonitorFilters.size();
 }
示例#7
0
 /**
  * remove ServiceMonitorFilter
  *
  * @param moduleClassID ServiceMonitor's moduleClassID
  */
 public void removeServiceMonitorFilter(ModuleClassID moduleClassID) {
   serviceMonitorFilters.remove(moduleClassID);
 }
示例#8
0
 /**
  * Get ServiceMonitorFilter subfilter
  *
  * @param moduleClassID ServiceMonitor's moduleClassID
  * @return ServiceMonitorFilter SubFilter or null if not found
  */
 public ServiceMonitorFilter getServiceMonitorFilter(ModuleClassID moduleClassID) {
   return (ServiceMonitorFilter) serviceMonitorFilters.get(moduleClassID);
 }