private static Object toAxisTypeSoap(TypeMapping tm,String local, Object value, Set<Object> done) throws PageException { if(local.equals(Constants.SOAP_ARRAY.getLocalPart())) return toArrayList(tm,value,done); if(local.equals(Constants.SOAP_ARRAY12.getLocalPart())) return toArrayList(tm,value,done); if(local.equals(Constants.SOAP_ARRAY_ATTRS11.getLocalPart())) return toArrayList(tm,value,done); if(local.equals(Constants.SOAP_ARRAY_ATTRS12.getLocalPart())) return toArrayList(tm,value,done); if(local.equals(Constants.SOAP_BASE64.getLocalPart())) return Caster.toBinary(value); if(local.equals(Constants.SOAP_BASE64BINARY.getLocalPart())) return Caster.toBinary(value); if(local.equals(Constants.SOAP_BOOLEAN.getLocalPart())) return Caster.toBoolean(value); if(local.equals(Constants.SOAP_BYTE.getLocalPart())) return Caster.toByte(value); if(local.equals(Constants.SOAP_DECIMAL.getLocalPart())) return new BigDecimal(Caster.toDoubleValue(value)); if(local.equals(Constants.SOAP_DOUBLE.getLocalPart())) return Caster.toDouble(value); if(local.equals(Constants.SOAP_FLOAT.getLocalPart())) return new Float(Caster.toDoubleValue(value)); if(local.equals(Constants.SOAP_INT.getLocalPart())) return Caster.toInteger(value); if(local.equals(Constants.SOAP_INTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equals(Constants.SOAP_LONG.getLocalPart())) return Caster.toLong(value); if(local.equals(Constants.SOAP_MAP.getLocalPart())) return toMap(tm,value,done); if(local.equals(Constants.SOAP_SHORT.getLocalPart())) return Caster.toShort(value); if(local.equals(Constants.SOAP_STRING.getLocalPart())) return Caster.toString(value); if(local.equals(Constants.SOAP_VECTOR.getLocalPart())) return toVector(tm,value,done); return _toDefinedType(tm,null,null,null,value,done); }
private static Pojo _toPojo(PageContext pc, Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException {//print.ds();System.exit(0); comp=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp); ComponentScope scope = comp.getComponentScope(); // create Pojo if(pojo==null) { try { pojo = (Pojo) ClassUtil.loadInstance(ComponentUtil.getComponentPropertiesClass(pc,comp)); } catch (ClassException e) { throw Caster.toPageException(e); } } // initialize Pojo Property[] props=ComponentProUtil.getProperties(comp, false, true, false, false); _initPojo(pc,typeEntry,type,pojo,props,scope,comp,tm,done); return pojo; }
private static QueryBean toQueryBean(TypeMapping tm,Object value, Set<Object> done) throws PageException { Query query = Caster.toQuery(value); int recordcount=query.getRecordcount(); String[] columnList = query.getColumns(); QueryColumn[] columns=new QueryColumn[columnList.length]; Object[][] data = new Object[recordcount][columnList.length]; for(int i=0;i<columnList.length;i++) { columns[i]=query.getColumn(columnList[i]); } int row; for(row=1;row<=recordcount;row++) { for(int i=0;i<columns.length;i++) { data[row-1][i]=_toAxisType(tm,null,null,null,null,columns[i].get(row,null),done); } } QueryBean qb = new QueryBean(); qb.setColumnList(columnList); qb.setData(data); return qb; }
private Class map(PageContext pc,SymbolTable symbolTable, Config secondChanceConfig,org.apache.axis.encoding.TypeMapping tm, TypeEntry type) throws PageException { //print.e("MAP"); //print.e(type.getQName()); // Simple Type if(type.getContainedElements()==null) return null; // is class already registered! //Class clazz=tm.getClassForQName(type.getQName()); //if(clazz!=null && clazz.getName().equals(getClientClassName(type))) return clazz; Class clazz = mapComplex(pc,symbolTable,secondChanceConfig,tm, type); // TODO make a better impl; this is not the fastest way to make sure all pojos use the same classloader if(clazz!=null && getClassLoader(pc,secondChanceConfig)!=clazz.getClassLoader()){ clazz=mapComplex(pc,symbolTable,secondChanceConfig,tm, type); } return clazz; }
public static void registerDefaults(TypeMappingRegistry tmr) { TypeMapping tm = tmr.getDefaultTypeMapping(); if(!tm.isRegistered(QueryBean.class, RPCConstants.QUERY_QNAME)) tm.register(QueryBean.class, RPCConstants.QUERY_QNAME, new BeanSerializerFactory(QueryBean.class,RPCConstants.QUERY_QNAME), new BeanDeserializerFactory(QueryBean.class,RPCConstants.QUERY_QNAME)); //Adding custom string serialization for non printable characters. tm.register(String.class, RPCConstants.STRING_QNAME, new StringSerializerFactory(String.class, RPCConstants.STRING_QNAME), new StringDeserializerFactory(String.class, RPCConstants.STRING_QNAME)); }
public static void registerBeanTypeMapping(javax.xml.rpc.encoding.TypeMapping tm, Class clazz, QName qName) { if(tm.isRegistered(clazz, qName)) return; if(clazz.isArray()) { QName ct=AxisCaster.toComponentType(qName,null); if(ct!=null) { tm.register( clazz, qName, new ArraySerializerFactory(clazz, ct), new ArrayDeserializerFactory(ct)); return; } } tm.register( clazz, qName, new BeanSerializerFactory(clazz, qName), new BeanDeserializerFactory(clazz, qName)); }
private static Pojo _toPojo(PageContext pc, Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException {//print.ds();System.exit(0); comp=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp); ComponentScope scope = comp.getComponentScope(); // create Pojo if(pojo==null) { try { pojo = (Pojo) ClassUtil.loadInstance(ComponentUtil.getComponentPropertiesClass(pc,comp)); } catch (ClassException e) { throw Caster.toPageException(e); } } // initialize Pojo Property[] props=comp.getProperties(false, true, false, false); _initPojo(pc,typeEntry,type,pojo,props,scope,comp,tm,done); return pojo; }
public static void main(String[] args) throws Exception { Options opts = new Options(args); String uri = "http://faults.samples"; String serviceName = "EmployeeInfoService"; ServiceFactory serviceFactory = ServiceFactory.newInstance(); Service service = serviceFactory.createService(new QName(uri, serviceName)); TypeMappingRegistry registry = service.getTypeMappingRegistry(); TypeMapping map = registry.getDefaultTypeMapping(); QName employeeQName = new QName("http://faults.samples", "Employee"); map.register(Employee.class, employeeQName, new BeanSerializerFactory(Employee.class, employeeQName), new BeanDeserializerFactory(Employee.class, employeeQName)); QName faultQName = new QName("http://faults.samples", "NoSuchEmployeeFault"); map.register(NoSuchEmployeeFault.class, faultQName, new BeanSerializerFactory(NoSuchEmployeeFault.class, faultQName), new BeanDeserializerFactory(NoSuchEmployeeFault.class, faultQName)); Call call = service.createCall(); call.setTargetEndpointAddress(new URL(opts.getURL()).toString()); call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE); call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://faults.samples"); call.setOperationName( new QName(uri, "getEmployee") ); String[] args2 = opts.getRemainingArgs(); System.out.println("Trying :" + args2[0]); Employee emp = (Employee) call.invoke(new Object[]{ args2[0] }); System.out.println("Got :" + emp.getEmployeeID()); }
private static ArrayList<Object> toArrayList(TypeMapping tm,Object value, Set<Object> done) throws PageException { Array arr = Caster.toArray(value); ArrayList<Object> al=new ArrayList<Object>(); int len=arr.size(); Object o; for(int i=0;i<len;i++) { o=arr.get(i+1,null); al.add(i,_toAxisType(tm,null,null,null,null,o,done)); } return al; }
private static Object[] toNativeArray(TypeMapping tm,Class targetClass,Object value, Set<Object> done) throws PageException { Object[] objs = Caster.toNativeArray(value); Object[] rtns; Class<?> componentClass = null; if(targetClass!=null) { componentClass = targetClass.getComponentType(); } if(componentClass!=null) { componentClass=toAxisTypeClass(componentClass); rtns = (Object[]) java.lang.reflect.Array.newInstance(componentClass, objs.length); } else rtns = new Object[objs.length]; try{ for(int i=0;i<objs.length;i++) { rtns[i]=_toAxisType(tm,null,null,null,componentClass,objs[i],done); } } // just in case something goes wrong with typed array catch(ArrayStoreException ase){ rtns = new Object[objs.length]; for(int i=0;i<objs.length;i++) { rtns[i]=_toAxisType(tm,null,null,null,componentClass,objs[i],done); } } return rtns; }
private static Vector<Object> toVector(TypeMapping tm,Object value, Set<Object> done) throws PageException { Array arr = Caster.toArray(value); Vector<Object> v=new Vector<Object>(); int len=arr.size(); Object o; for(int i=0;i<len;i++) { o=arr.get(i+1,null); v.set(i,_toAxisType(tm,null,null,null,null,o,done)); } return v; }
public static Pojo toPojo(Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException { PageContext pc = ThreadLocalPageContext.get(); try { return _toPojo(pc,pojo, tm,typeEntry,type, comp,done); } catch (Exception e) { throw Caster.toPageException(e); } }
public static Pojo toPojo(Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Struct sct, Set<Object> done) throws PageException { PageContext pc = ThreadLocalPageContext.get(); try { return _toPojo(pc,pojo, tm,typeEntry,type, sct,done); } catch (Exception e) { throw Caster.toPageException(e); } }
private static Map<String,Object> toMap(TypeMapping tm,Object value, Set<Object> done) throws PageException { Struct src = Caster.toStruct(value); HashMap<String,Object> trg=new HashMap<String,Object>(); Iterator<Entry<Key, Object>> it = src.entryIterator(); Entry<Key, Object> e; while(it.hasNext()) { e = it.next(); trg.put(e.getKey().getString(),_toAxisType(tm,null,null,null,null,e.getValue(),done)); } return trg; }
private Class mapComplex(PageContext pc,SymbolTable symbolTable,Config secondChanceConfig,org.apache.axis.encoding.TypeMapping tm, TypeEntry type) throws PageException { TypeEntry ref=type.getRefType(); if(ref==null) return _mapComplex(pc,symbolTable,secondChanceConfig, tm, type); // Array if(ref.getContainedElements()==null) return null; Class clazz = mapComplex(pc,symbolTable,secondChanceConfig, tm, ref); if(clazz==null) return null; Class arr = ClassUtil.toArrayClass(clazz); TypeMappingUtil.registerBeanTypeMapping(tm, arr, type.getQName()); return arr; }
private static Object _invoke(String name, Object[] args) throws PageException { Key key = Caster.toKey(name); Component c=component.get(); PageContext p=pagecontext.get(); MessageContext mc = messageContext.get(); if(c==null) throw new ApplicationException("missing component"); if(p==null) throw new ApplicationException("missing pagecontext"); UDF udf = Caster.toFunction(c.get(p,key,null),null); FunctionArgument[] fa=null; if(udf!=null) fa = udf.getFunctionArguments(); for(int i=0;i<args.length;i++) { if(fa!=null && i<fa.length && fa[i].getType()==CFTypes.TYPE_UNKNOW) { args[i]=AxisCaster.toLuceeType(p,fa[i].getTypeAsString(),args[i]); } else args[i]=AxisCaster.toLuceeType(p,args[i]); } // return type String rtnType=udf!=null?udf.getReturnTypeAsString():"any"; Object rtn = c.call(p, key, args); // cast return value to Axis type try { RPCServer server = RPCServer.getInstance(p.getId(),p.getServletContext()); TypeMapping tm = mc!=null?mc.getTypeMapping():TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry()); rtn=Caster.castTo(p, rtnType, rtn, false); Class<?> clazz = Caster.cfTypeToClass(rtnType); return AxisCaster.toAxisType(tm,rtn,clazz.getComponentType()!=null?clazz:null); } catch (Throwable t) { ExceptionUtil.rethrowIfNecessary(t); throw Caster.toPageException(t); } }
@Override protected Object invokeMethod(MessageContext mc, Method method, Object trg, Object[] args) throws Exception { PageContext pc=(PageContext) mc.getProperty(Constants.PAGE_CONTEXT); Component c= (Component) mc.getProperty(Constants.COMPONENT); RPCServer server = RPCServer.getInstance(pc.getId(),pc.getServletContext()); TypeMapping tm =mc.getTypeMapping();//TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry()); return AxisCaster.toAxisType(tm,c.call(pc,method.getName(),toLuceeType(pc,args)),null); }
public static Object _invoke(String name, Object[] args) throws PageException { Key key = Caster.toKey(name); Component c=component.get(); PageContext p=pagecontext.get(); MessageContext mc = messageContext.get(); if(c==null) throw new ApplicationException("missing component"); if(p==null) throw new ApplicationException("missing pagecontext"); UDF udf = Caster.toFunction(c.get(p,key,null),null); FunctionArgument[] fa=null; if(udf!=null) fa = udf.getFunctionArguments(); for(int i=0;i<args.length;i++) { if(fa!=null && i<fa.length && fa[i].getType()==CFTypes.TYPE_UNKNOW) { args[i]=AxisCaster.toLuceeType(p,fa[i].getTypeAsString(),args[i]); } else args[i]=AxisCaster.toLuceeType(p,args[i]); } // return type String rtnType=udf!=null?udf.getReturnTypeAsString():"any"; Object rtn = c.call(p, key, args); // cast return value to Axis type try { RPCServer server = RPCServer.getInstance(p.getId(),p,p.getServletContext()); TypeMapping tm = mc!=null?mc.getTypeMapping():TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry()); rtn=Caster.castTo(p, rtnType, rtn, false); Class<?> clazz = Caster.cfTypeToClass(rtnType); return AxisCaster.toAxisType(tm,rtn,clazz.getComponentType()!=null?clazz:null); } catch(Throwable t) { ExceptionUtil.rethrowIfNecessary(t); throw Caster.toPageException(t); } }
@Override protected Object invokeMethod(MessageContext mc, Method method, Object trg, Object[] args) throws Exception { PageContext pc=(PageContext) mc.getProperty(Constants.PAGE_CONTEXT); Component c= (Component) mc.getProperty(Constants.COMPONENT); RPCServer server = RPCServer.getInstance(pc.getId(),pc,pc.getServletContext()); TypeMapping tm =mc.getTypeMapping();//TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry()); return AxisCaster.toAxisType(tm,c.call(pc,method.getName(),toLuceeType(pc,args)),null); }
public void register(TypeMapping typeMapping) { // SerializerFactory ser = BaseSerializerFactory.createFactory(getSerFactoryClass(), getClazz(), getqName()); // ((ArraySerializerFactory)ser).setComponentType(componentType); // ((ArraySerializerFactory)ser).setComponentQName(componentQName); // DeserializerFactory deser = BaseDeserializerFactory.createFactory(getDeserFactoryClass(), getClazz(), getqName()); // ((ArrayDeserializerFactory)deser).setComponentType(componentType); ArraySerializerFactory ser = new ArraySerializerFactory(componentType, componentQName); ArrayDeserializerFactory deser = new ArrayDeserializerFactory(); typeMapping.register(getClazz(), getqName(), ser, deser); }
/** * {@inheritDoc} */ @Override protected void postProcessJaxRpcService(Service service) { TypeMappingRegistry registry = service.getTypeMappingRegistry(); TypeMapping mapping = registry.createTypeMapping(); registerBeanMapping(mapping, Db2DbParams.class, "db2dbParams"); registerBeanMapping(mapping, DbReportParams.class, "dbReportParams"); registerBeanMapping(mapping, DbFindParams.class, "dbFindParams"); registerBeanMapping(mapping, DbWalkParams.class, "dbWalkParams"); registerBeanMapping(mapping, DbOrthoParams.class, "dbOrthoParams"); registry.register("http://schemas.xmlsoap.org/soap/encoding/", mapping); }
public static Object toAxisType(TypeMapping tm,Object value, Class targetClass) throws PageException { return _toAxisType(tm,null,null,null,targetClass, value, new HashSet<Object>()); }
/** * cast a value to a Axis Compatible Type * @param type * @param value * @return Axis Compatible Type * @throws PageException */ private static Object _toAxisType(TypeMapping tm,TimeZone tz,TypeEntry typeEntry,QName type, Class targetClass, Object value,Set<Object> done) throws PageException { // first make sure we have no wrapper if(value instanceof ObjectWrap) { value=((ObjectWrap)value).getEmbededObject(); } if(done.contains(value)){ return null;// TODO not sure what in this case is the best solution. } done.add(value); try{ if(type!=null) { // Array Of if(type.getLocalPart().startsWith("ArrayOf")) { return toArray(tm,typeEntry,type,value,done); } // XSD for(int i=0;i<Constants.URIS_SCHEMA_XSD.length;i++) { if(Constants.URIS_SCHEMA_XSD[i].equals(type.getNamespaceURI())) { return toAxisTypeXSD(tm,tz,type.getLocalPart(), value,done); } } if(StringUtil.startsWithIgnoreCase(type.getLocalPart(),"xsd_")) { return toAxisTypeXSD(tm,tz,type.getLocalPart().substring(4), value,done); } //SOAP if(type.getNamespaceURI().indexOf("soap")!=-1) { return toAxisTypeSoap(tm,type.getLocalPart(), value,done); } if(StringUtil.startsWithIgnoreCase(type.getLocalPart(),"soap_")) { return toAxisTypeSoap(tm,type.getLocalPart().substring(5), value,done); } } return _toDefinedType(tm,typeEntry,type,targetClass,value,done); } finally{ done.remove(value); } }
private static Object toArray(TypeMapping tm, TypeEntry typeEntry,QName type, Object value, Set<Object> done) throws PageException { if(type==null || !type.getLocalPart().startsWith("ArrayOf")) throw new ApplicationException("invalid call of the functionn toArray"); // get component Type String tmp = type.getLocalPart().substring(7); QName componentType=null; // no arrayOf embeded anymore if(tmp.indexOf("ArrayOf")==-1 && typeEntry!=null) { TypeEntry ref = typeEntry.getRefType(); componentType=ref.getQName(); } if(componentType==null) { if(tmp.startsWith("_tns1_"))tmp=tmp.substring(6); componentType=new QName(type.getNamespaceURI(), tmp); } Object[] objs = Caster.toNativeArray(value); Object[] rtns; List<Object> list=new ArrayList<Object>(); Class componentClass=null; Object v; for(int i=0;i<objs.length;i++) { v=_toAxisType(tm,null,typeEntry,componentType,null,objs[i],done); list.add(v); if(i==0) { if(v!=null) componentClass=v.getClass(); } else { if(v==null || v.getClass()!=componentClass) componentClass=null; } } if(componentClass!=null) { componentClass=toAxisTypeClass(componentClass); rtns = (Object[]) java.lang.reflect.Array.newInstance(componentClass, objs.length); } else rtns = new Object[objs.length]; return list.toArray(rtns); }
private static Object toAxisTypeXSD(TypeMapping tm,TimeZone tz,String local, Object value, Set<Object> done) throws PageException { //if(local.equals(Constants.XSD_ANY.getLocalPart())) return value; if(local.equalsIgnoreCase(Constants.XSD_ANYSIMPLETYPE.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_ANYURI.getLocalPart())) return toURI(value); if(local.equalsIgnoreCase(Constants.XSD_STRING.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_BASE64.getLocalPart())) return Caster.toBinary(value); if(local.equalsIgnoreCase(Constants.XSD_BOOLEAN.getLocalPart())) return Caster.toBoolean(value); if(local.equalsIgnoreCase(Constants.XSD_BYTE.getLocalPart())) return Caster.toByte(value); if(local.equalsIgnoreCase(Constants.XSD_DATE.getLocalPart())) return Caster.toDate(value,null); if(local.equalsIgnoreCase(Constants.XSD_DATETIME.getLocalPart())) return Caster.toDate(value,null); if(local.equalsIgnoreCase(Constants.XSD_DAY.getLocalPart())) return toDay(value); if(local.equalsIgnoreCase(Constants.XSD_DECIMAL.getLocalPart())) return new BigDecimal(Caster.toDoubleValue(value)); if(local.equalsIgnoreCase(Constants.XSD_DOUBLE.getLocalPart())) return Caster.toDouble(value); if(local.equalsIgnoreCase(Constants.XSD_DURATION.getLocalPart())) return toDuration(value); if(local.equalsIgnoreCase(Constants.XSD_ENTITIES.getLocalPart())) return toEntities(value); if(local.equalsIgnoreCase(Constants.XSD_ENTITY.getLocalPart())) return toEntity(value); if(local.equalsIgnoreCase(Constants.XSD_FLOAT.getLocalPart())) return new Float(Caster.toDoubleValue(value)); if(local.equalsIgnoreCase(Constants.XSD_HEXBIN.getLocalPart())) return Caster.toBinary(value); if(local.equalsIgnoreCase(Constants.XSD_ID.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_IDREF.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_IDREFS.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_INT.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_INTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_LANGUAGE.getLocalPart())) return toLanguage(value); if(local.equalsIgnoreCase(Constants.XSD_LONG.getLocalPart())) return Caster.toLong(value); if(local.equalsIgnoreCase(Constants.XSD_MONTH.getLocalPart())) return toMonth(value); if(local.equalsIgnoreCase(Constants.XSD_MONTHDAY.getLocalPart())) return toMonthDay(value); if(local.equalsIgnoreCase(Constants.XSD_NAME.getLocalPart())) return toName(value); if(local.equalsIgnoreCase(Constants.XSD_NCNAME.getLocalPart())) return toNCName(value); if(local.equalsIgnoreCase(Constants.XSD_NEGATIVEINTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_NMTOKEN.getLocalPart())) return toNMToken(value); if(local.equalsIgnoreCase(Constants.XSD_NMTOKENS.getLocalPart())) return toNMTokens(value); if(local.equalsIgnoreCase(Constants.XSD_NONNEGATIVEINTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_NONPOSITIVEINTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_NORMALIZEDSTRING.getLocalPart())) return Caster.toString(value); if(local.equalsIgnoreCase(Constants.XSD_POSITIVEINTEGER.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_QNAME.getLocalPart())) return toQName(value); if(local.equalsIgnoreCase(Constants.XSD_SCHEMA.getLocalPart())) return toQName(value); if(local.equalsIgnoreCase(Constants.XSD_SHORT.getLocalPart())) return Caster.toShort(value); if(local.equalsIgnoreCase(Constants.XSD_TIME.getLocalPart())) return DateCaster.toTime(tz,value); if(local.equalsIgnoreCase(Constants.XSD_TIMEINSTANT1999.getLocalPart())) return DateCaster.toTime(tz,value); if(local.equalsIgnoreCase(Constants.XSD_TIMEINSTANT2000.getLocalPart())) return DateCaster.toTime(tz,value); if(local.equalsIgnoreCase(Constants.XSD_TOKEN.getLocalPart())) return toToken(value); if(local.equalsIgnoreCase(Constants.XSD_UNSIGNEDBYTE.getLocalPart())) return Caster.toByte(value); if(local.equalsIgnoreCase(Constants.XSD_UNSIGNEDINT.getLocalPart())) return Caster.toInteger(value); if(local.equalsIgnoreCase(Constants.XSD_UNSIGNEDLONG.getLocalPart())) return Caster.toLong(value); if(local.equalsIgnoreCase(Constants.XSD_UNSIGNEDSHORT.getLocalPart())) return Caster.toShort(value); if(local.equalsIgnoreCase(Constants.XSD_YEAR.getLocalPart())) return toYear(value); if(local.equalsIgnoreCase(Constants.XSD_YEARMONTH.getLocalPart())) return toYearMonth(value); return _toDefinedType(tm, null,null,null, value, done); }
private static void _initPojo(PageContext pc, TypeEntry typeEntry, QName type, Pojo pojo, Property[] props, Struct sct, Component comp, TypeMapping tm, Set<Object> done) throws PageException { Property p; Object v; Collection.Key k; CFMLExpressionInterpreter interpreter = new CFMLExpressionInterpreter(false); for(int i=0;i<props.length;i++){ p=props[i]; k=Caster.toKey(p.getName()); // value v=sct.get(k,null); if(v==null && comp!=null)v=comp.get(k, null); // default if(v!=null)v=Caster.castTo(pc, p.getType(), v, false); else{ if(!StringUtil.isEmpty(p.getDefault())){ try { v=Caster.castTo(pc, p.getType(), p.getDefault(), false); } catch(PageException pe) { try { v=interpreter.interpret(pc, p.getDefault()); v=Caster.castTo(pc, p.getType(), v, false); } catch(PageException pe2) { throw new ExpressionException("can not use default value ["+p.getDefault()+"] for property ["+p.getName()+"] with type ["+p.getType()+"]"); } } } } // set or throw if(v==null) { if(p.isRequired())throw new ExpressionException("required property ["+p.getName()+"] is not defined"); } else { TypeEntry childTE=null; QName childT=null; if(typeEntry!=null) { childTE = AxisUtil.getContainedElement(typeEntry,p.getName(),null); if(childTE!=null) childT=childTE.getQName(); } Reflector.callSetter(pojo, p.getName().toLowerCase(), _toAxisType(tm,null,childTE,childT,null,v,done)); } } }
private void map(PageContext pc,SymbolTable symbolTable, Config secondChanceConfig,org.apache.axis.encoding.TypeMapping tm, Vector types) throws PageException { Iterator it = types.iterator(); while(it.hasNext()){ map(pc,symbolTable, secondChanceConfig, tm, (TypeEntry)it.next()); } }
public static org.apache.axis.encoding.TypeMapping getServerTypeMapping(AxisServer axisServer) { org.apache.axis.encoding.TypeMappingRegistry reg = axisServer.getTypeMappingRegistry(); return reg.getOrMakeTypeMapping("http://schemas.xmlsoap.org/soap/encoding/"); }