public static Object getObject(Parameter p, Context context) { Object o = context.get(p.getName()); if (o != null) { return o; } return getObjectByGenerator(p, context); }
public static Object convertBasicTypeCollection(String[] stringArray, String collectionClass, String className, ClassLoader loader) { Collection<Object> collection = Context2ObjectUtil.getCollectionInstance(collectionClass, loader); Object value = convertBasicTypeArray(stringArray, className); if (value == null) { return null; } Object[] tArray = (Object[]) value; for (Object t : tArray) { collection.add(t); } return collection; }
protected boolean isSimpleType(Class<?> clazz) { return Context2ObjectUtil.isSimpleType(clazz); }
private Object getArgument(Context context, Parameter param) { String paramName = param.getName(); Object obj = Context2ObjectUtil.getObject(param, context, this .getClass().getClassLoader()); if (obj == null) { if (param.isRequired()) { // 如果输入参数是必须的,则抛出异常 LOGGER.logMessage(LogLevel.ERROR, "参数{paramName}未传递", paramName); throw new ParamIsNullException(paramName); } else { // 如果输出参数非必须,直接返回null return null; } } if (!(obj instanceof String)) { return obj; } return ValueUtil.getValue((String) obj, param.getType()); } }
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); } }
private Object getArgument(Context context, int i) { Parameter des = inputParameters.get(i); String paramName = des.getName(); // =============20130619修改bengin================ Object obj = Context2ObjectUtil.getObject(des, context); // =============20130619修改end================ if (obj == null) { if (des.isRequired()) { // 如果输入参数是必须的,则抛出异常 logger.logMessage(LogLevel.ERROR, "参数{paramName}未传递", paramName); throw new ParamIsNullException(paramName); } else { // 如果输出参数非必须,直接返回null return null; } } if (!(obj instanceof String)) { return obj; } return ValueUtil.getValue((String) obj, des.getType()); }
private Object getArgument(Context context, int i) { Parameter des = inputParameters.get(i); String paramName = des.getName(); // =============20130619修改bengin================ Object obj = Context2ObjectUtil.getObject(des, context, loader); // =============20130619修改end================ if (obj == null) { if (des.isRequired()) { // 如果输入参数是必须的,则抛出异常 LOGGER.logMessage(LogLevel.ERROR, "参数{paramName}未传递", paramName); throw new ParamIsNullException(paramName); } else { // 如果输出参数非必须,直接返回null return null; } } if (!(obj instanceof String)) { return obj; } return ValueUtil.getValue((String) obj, des.getType()); }
public static Object getObject(Parameter p, Context context, ClassLoader loader) { if (context.exist(p.getName())) return context.get(p.getName()); return getObjectByGenerator(p, context, loader); }
public static Object getObjectByGenerator(Parameter parameter, Context context, ClassLoader loader) { String collectionType = parameter.getCollectionType();// 集合类型 String paramName = parameter.getName(); String paramType = parameter.getType(); ClassNameObjectGenerator generator = BeanContainerFactory .getBeanContainer(Context2ObjectUtil.class.getClassLoader()) .getBean(GeneratorFileProcessor.CLASSNAME_OBJECT_GENERATOR_BEAN); if (!StringUtil.isBlank(collectionType)) {// 如果集合类型非空 return generator.getObjectCollection(paramName, collectionType, paramType, loader, context); } else if (parameter.isArray()) {// 如果是数组 return generator.getObjectArray(paramName, paramType, loader, context); } // 否则就是对象 if (isSimpleType(paramType) && !context.exist(paramName)) { return null; } return generator.getObject(paramName, paramName, paramType, loader, context); }
if (!oldContext.exist(inputName)) { return Context2ObjectUtil.getObject(input, oldContext, loader); } else {
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; }