Search in sources :

Example 1 with TypeMapping

use of javax.xml.rpc.encoding.TypeMapping in project Lucee by lucee.

the class TypeMappingUtil method registerDefaults.

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));
}
Also used : BeanDeserializerFactory(org.apache.axis.encoding.ser.BeanDeserializerFactory) TypeMapping(javax.xml.rpc.encoding.TypeMapping) BeanSerializerFactory(org.apache.axis.encoding.ser.BeanSerializerFactory) StringSerializerFactory(lucee.runtime.net.rpc.server.StringSerializerFactory) StringDeserializerFactory(lucee.runtime.net.rpc.server.StringDeserializerFactory) QueryBean(coldfusion.xml.rpc.QueryBean)

Example 2 with TypeMapping

use of javax.xml.rpc.encoding.TypeMapping in project Lucee by lucee.

the class ComponentController method _invoke.

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);
    }
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) UDF(lucee.runtime.type.UDF) TypeMapping(javax.xml.rpc.encoding.TypeMapping) PageContext(lucee.runtime.PageContext) MessageContext(org.apache.axis.MessageContext) Component(lucee.runtime.Component) FunctionArgument(lucee.runtime.type.FunctionArgument) Key(lucee.runtime.type.Collection.Key)

Example 3 with TypeMapping

use of javax.xml.rpc.encoding.TypeMapping in project Lucee by lucee.

the class ComponentProvider method invokeMethod.

@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());
    // TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry());
    TypeMapping tm = mc.getTypeMapping();
    return AxisCaster.toAxisType(tm, c.call(pc, method.getName(), toLuceeType(pc, args)), null);
}
Also used : TypeMapping(javax.xml.rpc.encoding.TypeMapping) PageContext(lucee.runtime.PageContext) Component(lucee.runtime.Component)

Aggregations

TypeMapping (javax.xml.rpc.encoding.TypeMapping)3 Component (lucee.runtime.Component)2 PageContext (lucee.runtime.PageContext)2 QueryBean (coldfusion.xml.rpc.QueryBean)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 StringDeserializerFactory (lucee.runtime.net.rpc.server.StringDeserializerFactory)1 StringSerializerFactory (lucee.runtime.net.rpc.server.StringSerializerFactory)1 Key (lucee.runtime.type.Collection.Key)1 FunctionArgument (lucee.runtime.type.FunctionArgument)1 UDF (lucee.runtime.type.UDF)1 MessageContext (org.apache.axis.MessageContext)1 BeanDeserializerFactory (org.apache.axis.encoding.ser.BeanDeserializerFactory)1 BeanSerializerFactory (org.apache.axis.encoding.ser.BeanSerializerFactory)1