Package org.gridgain.grid.marshaller.optimized

Examples of org.gridgain.grid.marshaller.optimized.GridOptimizedMarshallable


     * @throws IOException In case of error.
     */
    static GridOptimizedClassDescriptor classDescriptor(Class<?> cls, @Nullable Object obj) throws IOException {
        if (obj != null) {
            if (obj instanceof GridOptimizedMarshallable) {
                GridOptimizedMarshallable m = (GridOptimizedMarshallable)obj;

                Object clsId = m.ggClassId();

                if (clsId != null && !(clsId instanceof GridOptimizedClassDescriptor))
                    throw new IOException("Method '" + obj.getClass().getName() + ".ggClassId() must return " +
                        "the value of the field '" + CLS_ID_FIELD_NAME + "'.");

                GridOptimizedClassDescriptor desc = (GridOptimizedClassDescriptor)clsId;

                if (desc == null) {
                    desc = new GridOptimizedClassDescriptor(cls);

                    try {
                        Field field = obj.getClass().getDeclaredField(CLS_ID_FIELD_NAME);

                        field.setAccessible(true);

                        Object o = field.get(null);

                        if (o == null) {
                            if ((field.getModifiers() & Modifier.STATIC) == 0)
                                throw new IOException("Field '" + CLS_ID_FIELD_NAME + "' must be declared static: " +
                                    obj.getClass().getName());

                            field.set(null, desc);

                            if (m.ggClassId() == null)
                                throw new IOException( "Method '" + obj.getClass().getName() + ".ggClassId() must " +
                                    "return the value of the field '" + CLS_ID_FIELD_NAME + "': "
                                    + obj.getClass().getName());
                        }
                        else if (!(o instanceof GridOptimizedClassDescriptor))
View Full Code Here

TOP

Related Classes of org.gridgain.grid.marshaller.optimized.GridOptimizedMarshallable

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.