Пример #1
0
  public void process(Event event) {
    String serviceId = event.getServiceRequest().getServiceId();
    Service service = null;
    ServiceProviderInterface serviceProvider = null;

    for (ServiceProviderInterface provider : providers) {
      service = provider.getService(serviceId);
      if (service != null) {
        serviceProvider = provider;
        break;
      }
    }

    if (service != null) {
      serviceProvider.execute(service, event.getServiceRequest().getContext());
      // 回写Context,event返回时
      ServiceRegistryItem item = serviceProvider.getServiceRegistryItem(service);
      Context oldC = event.getServiceRequest().getContext();
      Context c = ContextFactory.getContext();
      for (Parameter p : item.getResults()) {
        if (("void").equals(p.getTitle()) || ("").equals(p.getTitle()) || p.getType() == null) {
        } else {
          String name = p.getName();
          c.put(name, oldC.get(name));
        }
      }
      event.getServiceRequest().setContext(c);
    } else {
      logger.logMessage(LogLevel.ERROR, "未找到合适的Service[id:{0}]", serviceId);
    }
  }
Пример #2
0
 public static Object getObjectByGenerator(Parameter parameter, Context context) {
   String collectionType = parameter.getCollectionType(); // 集合类型
   String paramName = parameter.getName();
   String paramType = parameter.getType();
   ClassNameObjectGenerator generator =
       SpringUtil.getBean(GeneratorFileProcessor.CLASSNAME_OBJECT_GENERATOR_BEAN);
   if (!isNull(collectionType)) { // 如果集合类型非空
     return generator.getObjectCollection(paramName, collectionType, paramType, context);
   } else if (parameter.isArray()) { // 如果是数组
     return generator.getObjectArray(paramName, paramType, context);
   }
   // 否则就是对象
   return generator.getObject(paramName, paramName, paramType, context);
 }