Package org.sf.bee.commons.remoting.jrpc.exceptions.impl

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.MarshallException


     * @throws MarshallException If called when currentLocation is empty
     */
    public void pop() throws MarshallException {
        if (_currentLocation.size() == 0) {
            // this is a sanity check
            throw new MarshallException("scope error, attempt to pop too much off the scope stack.");
        }
        _currentLocation.removeLast();
    }
View Full Code Here


        if (null != oclass && !super.isProxy(oclass)) {
            final BeanData bd;
            try {
                bd = BeanSerializer.getBeanData(oclass);
            } catch (IntrospectionException e) {
                throw new MarshallException(oclass.getName()
                        + " is not a bean", e);
            }

            if (_ser.getMarshallClassHints()) {
                try {
                    val.put(IJSONRPCConstants.TAG_JAVACLASS,
                            oclass.getName());
                } catch (Exception e) {
                    throw new MarshallException(
                            "JSONException: " + e.getMessage(), e);
                }
            }
            final Iterator i = bd.readableProps.entrySet().iterator();
            final Object args[] = new Object[0];
            Object result;
            while (i.hasNext()) {
                final Map.Entry ent = (Map.Entry) i.next();
                final String prop = (String) ent.getKey();
                final Method getMethod = (Method) ent.getValue();
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "invoking {0}()", getMethod.getName());
                }
                try {
                    result = getMethod.invoke(o, args);
                } catch (Throwable e) {
                    if (e instanceof InvocationTargetException) {
                        e = ((InvocationTargetException) e).getTargetException();
                    }
                    throw new MarshallException("bean " + oclass.getName()
                            + " can't invoke " + getMethod.getName() + ": " + e.getMessage(), e);
                }
                try {
                    if (result != null || _ser.getMarshallNullAttributes()) {
                        try {
                            Object json = _ser.marshall(state, o, result, prop);

                            // omit the object entirely if it's a circular reference or duplicate
                            // it will be regenerated in the fixups phase
                            if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                                val.put(prop, json);
                            }
                        } catch (JSONException e) {
                            throw new MarshallException(
                                    "JSONException: " + e.getMessage(), e);
                        }
                    }
                } catch (MarshallException e) {
                    throw new MarshallException("bean " + oclass.getName() + " " + e.getMessage(), e);
                }
            }

        }
        return val;
View Full Code Here

                    // put a slot where the object would go, so it can be fixed up properly in the fix up phase
                    jsonOut.put(i, JSONObject.NULL);
                }
            }
        } catch (MarshallException e) {
            throw new MarshallException("element " + i, e);
        } catch (JSONException e) {
            throw new MarshallException("element " + i, e);
        }
        return jsonOut;
    }
View Full Code Here

        if (_ser.getMarshallClassHints()) {
            try {
                // obj.put(TAG_JAVACLASS, BeanUtils.getClassName(o));
                obj.put(TAG_JAVACLASS, LinkedList.class.getName()); // replace with linkedlist
            } catch (JSONException e) {
                throw new MarshallException("javaClass not found!", e);
            }
        }
        try {
            obj.put("list", arr);
            state.push(o, arr, "list");
        } catch (JSONException e) {
            throw new MarshallException("Error setting list: " + e, e);
        }
        int index = 0;
        try {
            Iterator i = list.iterator();
            while (i.hasNext()) {
                Object json = _ser.marshall(state, arr, i.next(), new Integer(index));
                if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                    arr.put(json);
                } else {
                    // put a slot where the object would go, so it can be fixed up properly in the fix up phase
                    arr.put(JSONObject.NULL);
                }
                index++;
            }
        } catch (MarshallException e) {
            throw new MarshallException("element " + index, e);
        } finally {
            state.pop();
        }
        return obj;
    }
View Full Code Here

                return new String((char[]) o);
            } else {
                return o;
            }
        } catch (Throwable t) {
            throw new MarshallException(t.toString(), t);
        }
    }
View Full Code Here

                        BeanUtils.getClassName(o));
            }
            obj.put("map", mapdata);
            state.push(o, mapdata, "map");
        } catch (JSONException e) {
            throw new MarshallException("Could not put data" + e.getMessage(), e);
        }
        Object key = null;

        try {
            Enumeration en = ht.keys();
            while (en.hasMoreElements()) {
                key = en.nextElement();
                String keyString = key.toString()// only support String keys

                Object json = _ser.marshall(state, mapdata, ht.get(key), keyString);

                // omit the object entirely if it's a circular reference or duplicate
                // it will be regenerated in the fixups phase
                if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                    mapdata.put(keyString, json);
                }

            }
        } catch (MarshallException e) {
            throw new MarshallException("map key " + key + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new MarshallException("map key " + key + " " + e.getMessage(), e);
        } finally {
            state.pop();
        }
        return obj;
    }
View Full Code Here

        JSONObject setdata = new JSONObject();
        if (_ser.getMarshallClassHints()) {
            try {
                obj.put(TAG_JAVACLASS, BeanUtils.getClassName(o));
            } catch (JSONException e) {
                throw new MarshallException("javaClass not found!", e);
            }
        }
        try {
            obj.put("set", setdata);
            state.push(o, setdata, "set");
        } catch (JSONException e) {
            throw new MarshallException("Could not set 'set': " + e.getMessage(), e);
        }
        Object key = null;
        Iterator i = set.iterator();

        try {
            while (i.hasNext()) {
                key = i.next();
                String keyString = key.toString()// only support String keys
                Object json = _ser.marshall(state, setdata, key, keyString);

                // omit the object entirely if it's a circular reference or duplicate
                // it will be regenerated in the fixups phase
                if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                    setdata.put(keyString, json);
                }
            }
        } catch (MarshallException e) {
            throw new MarshallException("set key " + key + e.getMessage(), e);
        } catch (JSONException e) {
            throw new MarshallException("set key " + key + e.getMessage(), e);
        } finally {
            state.pop();
        }
        return obj;
    }
View Full Code Here

        JSONObject mapdata = new JSONObject();
        if (_ser.getMarshallClassHints()) {
            try {
                obj.put(TAG_JAVACLASS, BeanUtils.getClassName(o));
            } catch (JSONException e) {
                throw new MarshallException("javaClass not found!", e);
            }
        }
        try {
            obj.put("map", mapdata);
            state.push(o, mapdata, "map");
        } catch (JSONException e) {
            throw new MarshallException("Could not add map to object: " + e.getMessage(), e);
        }
        Object key = null;
        try {
            Iterator i = map.entrySet().iterator();
            while (i.hasNext()) {
                Map.Entry ent = (Map.Entry) i.next();
                key = ent.getKey();
                String keyString = key.toString()// only support String keys

                Object json = _ser.marshall(state, mapdata, ent.getValue(), keyString);

                // omit the object entirely if it's a circular reference or duplicate
                // it will be regenerated in the fixups phase
                if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                    mapdata.put(keyString, json);
                }
            }
        } catch (MarshallException e) {
            throw new MarshallException("map key " + key + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new MarshallException("map key " + key + " " + e.getMessage(), e);
        } finally {
            state.pop();
        }
        return obj;
    }
View Full Code Here

            throws MarshallException {
        long time;
        if (o instanceof Date) {
            time = ((Date) o).getTime();
        } else {
            throw new MarshallException("cannot marshall date using class " + o.getClass());
        }
        JSONObject obj = new JSONObject();
        try {
            if (_ser.getMarshallClassHints()) {
                obj.put(TAG_JAVACLASS, BeanUtils.getClassName(o));
            }
            obj.put("time", time);
        } catch (JSONException e) {
            throw new MarshallException(e.getMessage(), e);
        }
        return obj;
    }
View Full Code Here

                if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != j) {
                    jsonOut.put(key, j);
                }
            }
        } catch (MarshallException e) {
            throw new MarshallException("JSONObject key " + key + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new MarshallException("JSONObject key " + key + " " + e.getMessage(), e);
        }
        return jsonOut;
    }
View Full Code Here

TOP

Related Classes of org.sf.bee.commons.remoting.jrpc.exceptions.impl.MarshallException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.