Ejemplo n.º 1
0
 @PostConstruct
 public void Init() {
   for (RpcService service : rpcServices) {
     String serviceName = service.getClass().getSimpleName();
     serviceMaps.put(serviceName, service);
   }
 }
Ejemplo n.º 2
0
  @SuppressWarnings({"unchecked", "unused"})
  public List<RpcService> parseService() {
    // TODO Auto-generated method stub
    List<RpcService> slist = new ArrayList<RpcService>();
    Node serviceRoot = root.selectSingleNode("//rpcServices");
    List<Element> serviceList = serviceRoot.selectNodes("//rpcService");

    int i = 0;
    for (Element serviceNode : serviceList) {
      String name = serviceNode.attributeValue("name"); // service name;
      String interfaceStr = serviceNode.attributeValue("interface");
      String overloadStr = serviceNode.attributeValue("overload");
      if (StringUtil.isEmpty(name)) {
        LOGGER.warn(configFile + ":a rpcservice's name is empty");
        continue;
      }
      if (StringUtil.isEmpty(interfaceStr)) {
        LOGGER.warn(configFile + ":rpcservice[" + name + "] has an empty interface configure");
        continue;
      }
      Class<?> type = null;
      try {
        type = Class.forName(interfaceStr);
      } catch (ClassNotFoundException e) {
        LOGGER.error(e.getMessage());
        throw new RuntimeException("can't find rpc Interface:" + interfaceStr);
      }
      RpcService service = new RpcService("" + i, name);
      if (StringUtil.isNotEmpty(overloadStr) && "true".equals(overloadStr.trim())) {
        service.setOverload(true);
      }
      Element rpcImplementor = serviceNode.element("rpcImplementor");
      String processor = rpcImplementor.attributeValue("class");
      Class<?> providerClass = null;
      try {
        providerClass = Class.forName(processor);
      } catch (ClassNotFoundException e) {
        LOGGER.error(e.getMessage());
        throw new RuntimeException(" can't find rpcImplementor class:" + processor);
      }
      RpcImplementor sv = new RpcImplementor(providerClass);
      service.setRpcImplementor(sv);
      slist.add(service);
      i++;
    }
    return slist;
  }