Exemplo n.º 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);
    }
  }
Exemplo n.º 2
0
 public static Object getObject(Parameter p, Context context) {
   if (context.exist(p.getName())) return context.get(p.getName());
   //		Object o = context.get(p.getName());
   //		if (o != null) {
   //			return o;
   //		}
   return getObjectByGenerator(p, context);
 }
Exemplo n.º 3
0
 public static Context getContext(Event event, ServiceInfo info, ClassLoader loder) {
   Context c = new ContextImpl();
   Context oldContext = event.getServiceRequest().getContext();
   if (info.getParameters() == null) {
     return c;
   }
   for (Parameter p : info.getParameters()) {
     Object value = Context2ObjectUtil.getObject(p, oldContext, loder);
     if (value != null && !(value instanceof java.io.Serializable)) {
       throw new ParamNotSerializableException(
           event.getServiceRequest().getServiceId(), p.getName());
     }
     c.put(p.getName(), value);
   }
   return c;
 }
Exemplo n.º 4
0
 protected Object formaterValue(Object value, String name, Context context) {
   Integer lengthLevel = null;
   if (context == null) {
     lengthLevel = DEFAULT_LEVEL_LENGTH;
   } else {
     String lengthLevelName =
         ModelUtil.getSpliceParamterName(name, EntityModelHelper.LEVEL_LENGTH);
     Object objectValue = context.get(lengthLevelName);
     if (objectValue != null) {
       lengthLevel = Integer.parseInt(String.valueOf(objectValue));
     }
   }
   lengthLevel = ObjectUtil.defaultIfNull(lengthLevel, DEFAULT_LEVEL_LENGTH);
   if (value != null) {
     int lengthValue = String.valueOf(value).length();
     lengthValue += lengthLevel;
     return lengthValue;
   } else {
     return lengthLevel;
   }
 }
Exemplo n.º 5
0
 public void execute(Context context) {
   context.put(resultKey, a + b);
 }