class AbstractCodec implements Codec {
    protected static ConcurrentHashMap<Integer, String> serializations;


    protected void serialize(ObjectOutput output, Object message, Serialization serialize) throws IOException {
        if (message == null) {
            output.writeObject(null);
            return;
        }

        output.writeObject(serialize.serialize(message));
    }

    protected Object deserialize(byte[] value, Class<?> type, Serialization serialize) throws IOException {
        if (value == null) {
            return null;
        }

        return serialize.deserialize(value, type);
    }

    public ObjectOutput createOutput(OutputStream outputStream) {
        try {
            return new ObjectOutputStream(outputStream);
        } catch (Exception e) {
            throw new MotanFrameworkException(this.getClass().getSimpleName() + " createOutput error", e,
                    MotanErrorMsgConstant.FRAMEWORK_ENCODE_ERROR);
        }
    }

    public ObjectInput createInput(InputStream in) {
        try {
            return new ObjectInputStream(in);
        } catch (Exception e) {
            throw new MotanFrameworkException(this.getClass().getSimpleName() + " createInput error", e,
                    MotanErrorMsgConstant.FRAMEWORK_DECODE_ERROR);
        }
    }

    protected static synchronized void initAllSerialization() {<FILL_FUNCTION_BODY>}

    protected Serialization getSerializationByNum(int serializationNum) {
        if (serializations == null) {
            initAllSerialization();
        }
        String name = serializations.get(serializationNum);
        Serialization s = null;
        if (StringUtils.isNotBlank(name)) {
            s = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(name, false);
        }
        if (s == null) {
            throw new MotanServiceException("can not found serialization by number " + serializationNum + ", name: " + name);
        }
        return s;
    }

}

        if (serializations == null) {
            serializations = new ConcurrentHashMap<Integer, String>();
            try {
                ExtensionLoader<Serialization> loader = ExtensionLoader.getExtensionLoader(Serialization.class);
                List<Serialization> exts = loader.getExtensions(null);
                for (Serialization s : exts) {
                    String old = serializations.put(s.getSerializationNumber(), loader.getSpiName(s.getClass()));
                    if (old != null) {
                        LoggerUtil.warn("conflict serialization spi! serialization num :" + s.getSerializationNumber() + ", old spi :" + old
                                + ", new spi :" + serializations.get(s.getSerializationNumber()));
                    }
                }
            } catch (Exception e) {
                LoggerUtil.warn("init all serialzaion fail!", e);
            }
        }
    
<no_super_class>