Package org.sf.bee.commons.remoting.jrpc.serializer

Examples of org.sf.bee.commons.remoting.jrpc.serializer.ISerializer


            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


     * @throws Exception If a serialiser has already been registered for a class.
     */
    public void registerSerializer(final ISerializer s) throws Exception {
        final Logger logger = this.getLogger();
        Class classes[] = s.getSerializableClasses();
        ISerializer exists;
        synchronized (_serializerSet) {
            if (_serializableMap == null) {
                _serializableMap = new HashMap<Class, ISerializer>();
            }
            for (int i = 0; i < classes.length; i++) {
                exists = _serializableMap.get(classes[i]);
                if (exists != null && exists.getClass() != s.getClass()) {
                    throw new Exception("different serializer already registered for " + classes[i].getName());
                }
            }
            if (!_serializerSet.contains(s)) {
                if (logger.isLoggable(Level.FINE)) {
View Full Code Here

            }

            throw new UnmarshallException("can't assign null primitive");

        }
        ISerializer s = getSerializer(clazz, json.getClass());
        if (s != null) {
            return s.tryUnmarshall(state, clazz, json);
        }
        // As a last resort, we check if the object is in fact an instance of the
        // desired class. This will typically happen when the parameter is of
        // type java.lang.Object and the passed object is a String or an Integer
        // that is passed verbatim by JSON
View Full Code Here

            }

            throw new UnmarshallException("can't assign null primitive");
        }
        final Class jsonClass = json.getClass();
        final ISerializer s = this.getSerializer(clazz, jsonClass);
        if (s != null) {
            return s.unmarshall(state, clazz, json);
        }

        // As a last resort, we check if the object is in fact an instance of the
        // desired class. This will typically happen when the parameter is of
        // type java.lang.Object and the passed object is a String or an Integer
View Full Code Here

                    new Object[]{clazz == null ? "null" : clazz.getName(),
                        jsoClazz == null ? "null" : jsoClazz.getName()});
        }

        synchronized (_serializerSet) {
            ISerializer s = (ISerializer) _serializableMap.get(clazz);
            if (s != null && s.canSerialize(clazz, jsoClazz)) {
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "direct match serializer {0}",
                            s.getClass().getName());
                }
                return s;
            }
            final Iterator i = _serializerList.iterator();
            while (i.hasNext()) {
                s = (ISerializer) i.next();
                if (s.canSerialize(clazz, jsoClazz)) {
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE, "search found serializer {0}",
                                s.getClass().getName());
                    }
                    return s;
                }
            }
        }
View Full Code Here

            throws IOException, ClassNotFoundException {
        in.defaultReadObject();
        _serializableMap = new HashMap();
        Iterator i = _serializerList.iterator();
        while (i.hasNext()) {
            ISerializer s = (ISerializer) i.next();
            Class classes[] = s.getSerializableClasses();
            for (int j = 0; j < classes.length; j++) {
                _serializableMap.put(classes[j], s);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.sf.bee.commons.remoting.jrpc.serializer.ISerializer

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.