org.granite.util.XMap.getAll()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(14.2k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.granite.util.XMap.getAll()方法的一些代码示例,展示了XMap.getAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMap.getAll()方法的具体详情如下:
包路径:org.granite.util.XMap
类名称:XMap
方法名:getAll

XMap.getAll介绍

[英]Returns a list of XMap instances with all elements that match the supplied XPath expression. Note that XPath result nodes that are not instance of Element are ignored. Note also that returned XMaps contain original child elements of the root element of this XMap so modifications made to child elements affect this XMap instance as well.
[中]返回包含与提供的XPath表达式匹配的所有元素的XMap实例列表。请注意,不属于元素实例的XPath结果节点将被忽略。还要注意,返回的XMap包含这个XMap根元素的原始子元素,所以对子元素的修改也会影响这个XMap实例。

代码示例

代码示例来源:origin: org.graniteds/granite-client-java

private void loadCustomInstantiators(XMap element, boolean custom) {
  XMap instantiators = element.getOne("instantiators");
  if (instantiators != null) {
    for (XMap instantiator : instantiators.getAll("instantiator"))
      this.instantiators.put(instantiator.get("@type"), instantiator.get("."));
  }
}

代码示例来源:origin: org.graniteds/granite-server

private void loadCustomInstantiators(XMap element, boolean custom) {
  XMap instantiators = element.getOne("instantiators");
  if (instantiators != null) {
    for (XMap instantiator : instantiators.getAll("instantiator"))
      this.instantiators.put(instantiator.get("@type"), instantiator.get("."));
  }
}

代码示例来源:origin: org.graniteds/granite-client

private void loadCustomInstantiators(XMap element, boolean custom) {
  XMap instantiators = element.getOne("instantiators");
  if (instantiators != null) {
    for (XMap instantiator : instantiators.getAll("instantiator"))
      this.instantiators.put(instantiator.get("@type"), instantiator.get("."));
  }
}

代码示例来源:origin: org.graniteds/granite-client-javafx

private void loadCustomInstantiators(XMap element, boolean custom) {
  XMap instantiators = element.getOne("instantiators");
  if (instantiators != null) {
    for (XMap instantiator : instantiators.getAll("instantiator"))
      this.instantiators.put(instantiator.get("@type"), instantiator.get("."));
  }
}

代码示例来源:origin: org.graniteds/granite-client

private void loadCustomJMFDefaultStoredStrings(XMap element, boolean custom) {
  String jmfDefaultStoredStringsMode = element.get("jmf-default-stored-strings/@mode");
  if (jmfDefaultStoredStringsMode != null) {
    try {
      this.jmfDefaultStoredStringsMode = JMF_EXTENSIONS_MODE.valueOf(jmfDefaultStoredStringsMode.toLowerCase());
    }
    catch (Exception e) {
      throw new GraniteConfigException("Illegal JMF default stored strings mode: " + jmfDefaultStoredStringsMode, e);
    }
  }
  
  for (XMap codec : element.getAll("jmf-default-stored-strings/jmf-default-stored-string"))
    jmfDefaultStoredStrings.add(codec.get("@value"));
}

代码示例来源:origin: org.graniteds/granite-server

private void loadCustomJMFDefaultStoredStrings(XMap element, boolean custom) {
  String jmfDefaultStoredStringsMode = element.get("jmf-default-stored-strings/@mode");
  if (jmfDefaultStoredStringsMode != null) {
    try {
      this.jmfDefaultStoredStringsMode = JMF_EXTENSIONS_MODE.valueOf(jmfDefaultStoredStringsMode.toLowerCase());
    }
    catch (Exception e) {
      throw new GraniteConfigException("Illegal JMF default stored strings mode: " + jmfDefaultStoredStringsMode, e);
    }
  }
  
  for (XMap codec : element.getAll("jmf-default-stored-strings/jmf-default-stored-string"))
    jmfDefaultStoredStrings.add(codec.get("@value"));
}

代码示例来源:origin: org.graniteds/granite-server

/**
 * Read custom class exception converters
 * Converter must have 'type' attribute
 */
private void loadCustomExceptionConverters(XMap element, boolean custom) {
  for (XMap exceptionConverter : element.getAll("exception-converters/exception-converter")) {
    String type = exceptionConverter.get("@type");
    ExceptionConverter converter = null;
    try {
      converter = (ExceptionConverter)TypeUtil.newInstance(type);
      exceptionConverters.add(converter);
    } catch (Exception e) {
      throw new GraniteConfigException("Could not construct exception converter: " + type, e);
    }
  }
}

代码示例来源:origin: org.graniteds/granite-client

/**
 * Read custom class exception converters
 * Converter must have 'type' attribute
 */
private void loadCustomExceptionConverters(XMap element, boolean custom) {
  for (XMap exceptionConverter : element.getAll("exception-converters/exception-converter")) {
    String type = exceptionConverter.get("@type");
    ExceptionConverter converter = null;
    try {
      converter = (ExceptionConverter)TypeUtil.newInstance(type);
      exceptionConverters.add(converter);
    } catch (Exception e) {
      throw new GraniteConfigException("Could not construct exception converter: " + type, e);
    }
  }
}

代码示例来源:origin: org.graniteds/granite-client

public static Service forElement(XMap element) {
    String id = element.get("@id");
    String className = element.get("@class");
    String messageTypes = element.get("@messageTypes");

    Adapter defaultAdapter = null;
    Map<String, Adapter> adaptersMap = new HashMap<String, Adapter>();
    for (XMap adapter : element.getAll("adapters/adapter-definition")) {
      Adapter ad = Adapter.forElement(adapter);
      if (Boolean.TRUE.toString().equals(adapter.get("@default")))
        defaultAdapter = ad;
      adaptersMap.put(ad.getId(), ad);
    }

    Map<String, Destination> destinations = new HashMap<String, Destination>();
    for (XMap destinationElt : element.getAll("destination")) {
      Destination destination = Destination.forElement(destinationElt, defaultAdapter, adaptersMap);
      destinations.put(destination.getId(), destination);
    }

    return new Service(id, className, messageTypes, defaultAdapter, adaptersMap, destinations);
  }
}

代码示例来源:origin: org.graniteds/granite-client

private void loadCustomConverters(XMap element, boolean custom) {
  XMap converters = element.getOne("converters");
  if (converters != null) {
    // Should we override standard config converters?
    String override = converters.get("@override");
    if (Boolean.TRUE.toString().equals(override))
      converterClasses.clear();
    int i = 0;
    for (XMap converter : converters.getAll("converter")) {
      String type = converter.get("@type");
      try {
        // For custom config, shifts any standard converters to the end of the list...
        converterClasses.add(i++, TypeUtil.forName(type, Converter.class));
      } catch (Exception e) {
        throw new GraniteConfigException("Could not get converter class for: " + type, e);
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-server

private void loadCustomConverters(XMap element, boolean custom) {
  XMap converters = element.getOne("converters");
  if (converters != null) {
    // Should we override standard config converters?
    String override = converters.get("@override");
    if (Boolean.TRUE.toString().equals(override))
      converterClasses.clear();
    int i = 0;
    for (XMap converter : converters.getAll("converter")) {
      String type = converter.get("@type");
      try {
        // For custom config, shifts any standard converters to the end of the list...
        converterClasses.add(i++, TypeUtil.forName(type, Converter.class));
      } catch (Exception e) {
        throw new GraniteConfigException("Could not get converter class for: " + type, e);
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-client-javafx

private void loadCustomConverters(XMap element, boolean custom) {
  XMap converters = element.getOne("converters");
  if (converters != null) {
    // Should we override standard config converters?
    String override = converters.get("@override");
    if (Boolean.TRUE.toString().equals(override))
      converterClasses.clear();
    int i = 0;
    for (XMap converter : converters.getAll("converter")) {
      String type = converter.get("@type");
      try {
        // For custom config, shifts any standard converters to the end of the list...
        converterClasses.add(i++, TypeUtil.forName(type, Converter.class));
      } catch (Exception e) {
        throw new GraniteConfigException("Could not get converter class for: " + type, e);
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-client-java

private void loadCustomConverters(XMap element, boolean custom) {
  XMap converters = element.getOne("converters");
  if (converters != null) {
    // Should we override standard config converters?
    String override = converters.get("@override");
    if (Boolean.TRUE.toString().equals(override))
      converterClasses.clear();
    int i = 0;
    for (XMap converter : converters.getAll("converter")) {
      String type = converter.get("@type");
      try {
        // For custom config, shifts any standard converters to the end of the list...
        converterClasses.add(i++, TypeUtil.forName(type, Converter.class));
      } catch (Exception e) {
        throw new GraniteConfigException("Could not get converter class for: " + type, e);
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-server

private void loadCustomExternalizers(XMap element, boolean custom) {
  externalizersConfiguration = element.getOne("externalizers/configuration");
  
  for (XMap externalizer : element.getAll("externalizers/externalizer")) {
    String externalizerType = externalizer.get("@type");
    for (XMap include : externalizer.getAll("include")) {
      String type = include.get("@type");
      if (type != null)
        externalizersByType.put(type, EXTERNALIZER_FACTORY.getInstance(externalizerType, this));
      else {
        String instanceOf = include.get("@instance-of");
        if (instanceOf != null)
          externalizersByInstanceOf.put(instanceOf, externalizerType);
        else {
          String annotatedWith = include.get("@annotated-with");
          if (annotatedWith == null)
            throw new GraniteConfigException(
              "Element 'include' has no attribute 'type', 'instance-of' or 'annotated-with'");
          externalizersByAnnotatedWith.put(annotatedWith, externalizerType);
        }
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-server

public static Service forElement(XMap element) {
    String id = element.get("@id");
    String className = element.get("@class");
    String messageTypes = element.get("@messageTypes");

    Adapter defaultAdapter = null;
    Map<String, Adapter> adaptersMap = new HashMap<String, Adapter>();
    for (XMap adapter : element.getAll("adapters/adapter-definition")) {
      Adapter ad = Adapter.forElement(adapter);
      if (Boolean.TRUE.toString().equals(adapter.get("@default")))
        defaultAdapter = ad;
      adaptersMap.put(ad.getId(), ad);
    }

    Map<String, Destination> destinations = new HashMap<String, Destination>();
    for (XMap destinationElt : element.getAll("destination")) {
      Destination destination = Destination.forElement(destinationElt, defaultAdapter, adaptersMap);
      destinations.put(destination.getId(), destination);
    }

    return new Service(id, className, messageTypes, defaultAdapter, adaptersMap, destinations);
  }
}

代码示例来源:origin: org.graniteds/granite-client

public static Destination forElement(XMap element, Adapter defaultAdapter, Map<String, Adapter> adaptersMap) {
    String id = element.get("@id");

    List<String> channelRefs = new ArrayList<String>();
    for (XMap channel : element.getAll("channels/channel[@ref]"))
      channelRefs.add(channel.get("@ref"));

    XMap properties = new XMap(element.getOne("properties"));

    List<String> rolesList = null;
    if (element.containsKey("security/security-constraint/roles/role")) {
      rolesList = new ArrayList<String>();
      for (XMap role : element.getAll("security/security-constraint/roles/role"))
        rolesList.add(role.get("."));
    }

    XMap adapter = element.getOne("adapter[@ref]");
    Adapter adapterRef = adapter != null && adaptersMap != null
      ? adaptersMap.get(adapter.get("@ref"))
      : defaultAdapter;

    return new Destination(id, channelRefs, properties, rolesList, adapterRef, null);
  }
}

代码示例来源:origin: org.graniteds/granite-server

public static Destination forElement(XMap element, Adapter defaultAdapter, Map<String, Adapter> adaptersMap) {
    String id = element.get("@id");

    List<String> channelRefs = new ArrayList<String>();
    for (XMap channel : element.getAll("channels/channel[@ref]"))
      channelRefs.add(channel.get("@ref"));

    XMap properties = new XMap(element.getOne("properties"));

    List<String> rolesList = null;
    if (element.containsKey("security/security-constraint/roles/role")) {
      rolesList = new ArrayList<String>();
      for (XMap role : element.getAll("security/security-constraint/roles/role"))
        rolesList.add(role.get("."));
    }

    XMap adapter = element.getOne("adapter[@ref]");
    Adapter adapterRef = adapter != null && adaptersMap != null
      ? adaptersMap.get(adapter.get("@ref"))
      : defaultAdapter;

    return new Destination(id, channelRefs, properties, rolesList, adapterRef, null);
  }
}

代码示例来源:origin: org.graniteds/granite-server-ejb

public EjbServiceMetadata(XMap properties, Class<?> invokeeClass) {
  stateful = properties.containsKey("ejb-stateful");
  
  if (stateful) {
    for (XMap removeMethod : properties.getAll("ejb-stateful/remove-method")) {
      
      String signature = removeMethod.get("signature");
      if (signature == null)
        throw new ServiceException("Missing signature in remove-method declaration: " + properties);
      
      Boolean retainIfException = Boolean.valueOf(removeMethod.get("retain-if-exception"));
      try {
        removeMethods.put(TypeUtil.getMethod(invokeeClass, signature), retainIfException);
      }
      catch (NoSuchMethodException e) {
        throw new ServiceException("Could not find method: " + invokeeClass.getName() + "." + signature);
      }
    }
  }
}

代码示例来源:origin: org.graniteds/granite-client

private void loadCustomJMFExtendedCodecs(XMap element, boolean custom) {
  String jmfExtendedCodecsMode = element.get("jmf-extended-codecs/@mode");
  if (jmfExtendedCodecsMode != null) {
    try {
      this.jmfExtendedCodecsMode = JMF_EXTENSIONS_MODE.valueOf(jmfExtendedCodecsMode.toLowerCase());
    }
    catch (Exception e) {
      throw new GraniteConfigException("Illegal JMF extended codecs mode: " + jmfExtendedCodecsMode, e);
    }
  }
  
  for (XMap codec : element.getAll("jmf-extended-codecs/jmf-extended-codec")) {
    String codecType = codec.get("@type");
    try {
      jmfExtendedCodecs.add((ExtendedObjectCodec)TypeUtil.newInstance(codecType));
    }
    catch (Exception e) {
      throw new GraniteConfigException("Could not instantiate JMF extended codec: " + codecType, e);
    }
  }
}

代码示例来源:origin: org.graniteds/granite-server

private void loadCustomJMFExtendedCodecs(XMap element, boolean custom) {
  String jmfExtendedCodecsMode = element.get("jmf-extended-codecs/@mode");
  if (jmfExtendedCodecsMode != null) {
    try {
      this.jmfExtendedCodecsMode = JMF_EXTENSIONS_MODE.valueOf(jmfExtendedCodecsMode.toLowerCase());
    }
    catch (Exception e) {
      throw new GraniteConfigException("Illegal JMF extended codecs mode: " + jmfExtendedCodecsMode, e);
    }
  }
  
  for (XMap codec : element.getAll("jmf-extended-codecs/jmf-extended-codec")) {
    String codecType = codec.get("@type");
    try {
      jmfExtendedCodecs.add((ExtendedObjectCodec)TypeUtil.newInstance(codecType));
    }
    catch (Exception e) {
      throw new GraniteConfigException("Could not instantiate JMF extended codec: " + codecType, e);
    }
  }
}

相关文章