public void introduceType(SpaceTypeDescriptor typeDescriptor) {

    DBCollection m = getConnection().getCollection(METADATA_COLLECTION_NAME);

    BasicDBObjectBuilder builder =
        BasicDBObjectBuilder.start().add(Constants.ID_PROPERTY, typeDescriptor.getTypeName());
    try {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream out = new ObjectOutputStream(bos);
      IOUtils.writeObject(
          out, SpaceTypeDescriptorVersionedSerializationUtils.toSerializableForm(typeDescriptor));

      builder.add(TYPE_DESCRIPTOR_FIELD_NAME, bos.toByteArray());

      WriteResult wr = m.save(builder.get());

      if (logger.isTraceEnabled()) logger.trace(wr);

      indexBuilder.ensureIndexes(typeDescriptor);

    } catch (IOException e) {
      logger.error(e);

      throw new SpaceMongoException(
          "error occurs while serialize and save type descriptor: " + typeDescriptor, e);
    }
  }
  private void readMetadata(Object b) {
    try {

      ObjectInput in = new ClassLoaderAwareInputStream(new ByteArrayInputStream((byte[]) b));
      Serializable typeDescWrapper = IOUtils.readObject(in);
      SpaceTypeDescriptor typeDescriptor =
          SpaceTypeDescriptorVersionedSerializationUtils.fromSerializableForm(typeDescWrapper);
      indexBuilder.ensureIndexes(typeDescriptor);

      cacheTypeDescriptor(typeDescriptor);

    } catch (ClassNotFoundException e) {
      logger.error(e);
      throw new SpaceMongoDataSourceException("Failed to deserialize: " + b, e);
    } catch (IOException e) {
      logger.error(e);
      throw new SpaceMongoDataSourceException("Failed to deserialize: " + b, e);
    }
  }