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

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


            try {
                jso.put("JSONRPCType", "Reference");
                jso.put(TAG_JAVACLASS, BeanUtils.getClassName(clazz));
                jso.put("objectID", identity);
            } catch (JSONException e) {
                throw new MarshallException(e.getMessage(), e);
            }
            return jso;
        } else if (bridge.isCallableReference(clazz)) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("marshalling callable reference to object " +
                        identity + " of class " + clazz.getName());
            }
            bridge.registerObject(identity, o);
            bridge.addReference(o);

            JSONObject jso = new JSONObject();
            try {
                jso.put("JSONRPCType", "CallableReference");
                jso.put(TAG_JAVACLASS, BeanUtils.getClassName(clazz));
                jso.put("objectID", identity);
            } catch (JSONException e) {
                throw new MarshallException(e.getMessage(), e);
            }

            return jso;
        }
        return null;
View Full Code Here


        // Have a single function to do it.
        if (_ser.getMarshallClassHints()) {
            try {
                obj.put(TAG_JAVACLASS, BeanUtils.getClassName(o));
            } 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 arr;

        } catch (JSONException e) {
            throw new MarshallException(e.getMessage() + " threw json exception", e);
        }

    }
View Full Code Here

            boolean foundCircRef = state.isAncestor(p, parent);

            // throw an exception if a circular reference found, and the
            // serializer option is not set to fixup these circular references
            if (!_fixupCircRefs && foundCircRef) {
                throw new MarshallException("Circular Reference");
            }

            // if its a duplicate only, and we aren't fixing up duplicates or if
            // it is a primitive, and fixing up of primitives is not allowed then
            // re-serialize the object into the json.
            if (!foundCircRef
                    && (!_fixupDuplicates || (!_fixupDuplicatePrimitives && isPrimitive(java)))) {
                //todo: if a duplicate is being reserialized... it will overwrite the original location of the
                //todo: first one found... need to think about the ramifications of this -- optimally, circ refs found
                //todo: underneath duplicates need to point to the "original" one found, but they also need to be fixed
                //todo: up to the correct location, of course.
                state.push(parent, java, ref);
            } else {
                // generate a fix up entry for the duplicate/circular reference
                state.addFixUp(p.getLocation(), ref);
                return CIRC_REF_OR_DUPLICATE;
            }
        }

        try {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE,
                        "marshall class {0}",
                        java.getClass().getName());
            }
            final ISerializer s = this.getSerializer(java.getClass(), null);
            if (s != null) {
                return s.marshall(state, parent, java);
            }
            throw new MarshallException("can't marshall " + java.getClass().getName());
        } finally {
            state.pop();
        }
    }
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.