Returns the deserializer for a class.

@param cl the class of the object that needs to be deserialized.
@return a deserializer object for the serialization.
354863
public Deserializer getDeserializer(Class cl)
        throws HessianProtocolException {
        Deserializer deserializer;

        deserializer = (Deserializer) _cachedDeserializerMap.get(cl);

        if (deserializer != null)
            return deserializer;

        deserializer = loadDeserializer(cl);

        _cachedDeserializerMap.put(cl, deserializer);

        return deserializer;
    }
353490
@VisibleForTesting
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
    Iterable<T> i = ServiceLoader.load(klass, cl);
    // Attempt to load using the context class loader and ServiceLoader.
    // This allows frameworks like http://aries.apache.org/modules/spi-fly.html to plug in.
    if (!i.iterator().hasNext()) {
      i = ServiceLoader.load(klass);
    }
    return i;
  }
1340553
@SuppressWarnings("unchecked")
  private <T> TypeSerializer<T> getSerializer(Class<T> type) {
    TypeSerializer<T> serializer = (TypeSerializer<T>) serializers.get(type);
    if (serializer == null) {
      TypeSerializerFactory factory = registry.factory(type);
      if (factory != null) {
        serializer = (TypeSerializer<T>) factory.createSerializer(type);
        serializers.put(type, serializer);
      }
    }
    return serializer;
  }
440006
public SerDeserializer findDeserializer(Class<?> type) {
        SerDeserializer deser = deserializers.get(type);
        if (deser != null) {
            return deser;
        }
        for (SerDeserializerProvider provider : providers) {
            deser = provider.findDeserializer(type);
            if (deser != null) {
                return deser;
            }
        }
        return defaultDeserializer;
    }
304307
private static Deserializer getDeserializer(HiveRegistrationUnit unit) {
    Optional<String> serdeClass = unit.getSerDeType();
    if (!serdeClass.isPresent()) {
      return null;
    }

    String serde = serdeClass.get();
    HiveConf hiveConf;
    Deserializer deserializer;
    try {
      hiveConf = SharedResourcesBrokerFactory
        .getImplicitBroker().getSharedResource(new HiveConfFactory<>(), SharedHiveConfKey.INSTANCE);
      deserializer =
          ReflectionUtils.newInstance(hiveConf.getClassByName(serde).asSubclass(Deserializer.class), hiveConf);
    } catch (ClassNotFoundException e) {
      LOG.warn("Serde class " + serde + " not found!", e);
      return null;
    } catch (NotConfiguredException nce) {
      LOG.error("Implicit broker is not configured properly", nce);
      return null;
    }

    Properties props = new Properties();
    props.putAll(unit.getProps().getProperties());
    props.putAll(unit.getStorageProps().getProperties());
    props.putAll(unit.getSerDeProps().getProperties());

    try {
      SerDeUtils.initializeSerDe(deserializer, hiveConf, props, null);

      // Temporary check that's needed until Gobblin is upgraded to Hive 1.1.0+, which includes the improved error
      // handling in AvroSerDe added in HIVE-7868.
      if (deserializer instanceof AvroSerDe) {
        try {
          inVokeDetermineSchemaOrThrowExceptionMethod(props, new Configuration());
        } catch (SchemaParseException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
          LOG.warn("Failed to initialize AvroSerDe.");
          throw new SerDeException(e);
        }
      }
    } catch (SerDeException e) {
      LOG.warn("Failed to initialize serde " + serde + " with properties " + props + " for table " + unit.getDbName() +
          "." + unit.getTableName());
      return null;
    }

    return deserializer;
  }
522462
public static Serializer getSerializer(Class<?> type) {
    Class<?> serializable = lookupSerializableType(type);
    Serializer serializer = serializers.get(serializable);
    if (serializer == null) {
      serializer = getInstance().createSerializer(serializable);
      serializers.put(serializable, serializer);
    }
    return serializer;
  }
990065
public Deserializer getDeserializer(String className)
    {
        Deserializer deserializer = _deserializerClassMap.get(className);

        if (deserializer == AbstractDeserializer.NULL)
            return null;
        else
            return deserializer;
    }
124869
public static <T> T unmarshal(Class<T> cl, String s) throws JAXBException {
    return unmarshal(cl, new StringReader(s));
  }
28599
public static ClassLoader getClassLoader(Class<?> cls) {
        ClassLoader cl = cls.getClassLoader();
        if (cl == null) {
            cl = getClassLoader();
        }
        return cl;
    }
499615
public static @CheckForNull Class<?> _findLoadedClass(ClassLoader cl, String name) {
        synchronized (getClassLoadingLock(cl, name)) {
            return (Class) invoke(FIND_LOADED_CLASS, RuntimeException.class, cl, name);
        }
    }
1204127
@SuppressWarnings("unchecked")
    public <T> Deserializer<T> getDeserializer(Class<T> type, String mediaType) throws SerializationException {
        checkNotNull(type, "Type (Class<T>) cannot be null.");
        checkNotNull(mediaType, "Media-Type cannot be null.");

        final String typeName = getClassName(type);
        final Key key = new Key(typeName, mediaType);

        logger.log(Level.FINE, "Querying for Deserializer of type '" + typeName + "' and " + "media-type '" + mediaType
                + "'.");

        ArrayList<DeserializerHolder> holders = deserializers.get(typeName);
        if (holders != null) {
            for (DeserializerHolder holder : holders) {
                if (holder.key.matches(key)) {
                    logger.log(Level.FINE, "Deserializer for type '" + holder.deserializer.handledType() + "' and " +
                            "media-type '" + Arrays.toString(holder.deserializer.mediaType()) + "' matched: " +
                            holder.deserializer.getClass().getName());
                    return (Deserializer<T>) holder.deserializer;
                }
            }
        }

        logger.log(Level.WARNING, "There is no Deserializer registered for " + type.getName() +
                " and media-type " + mediaType + ". If you're relying on auto-generated deserializers," +
                " please make sure you imported the correct GWT Module.");

        return null;
    }
28740
public static <T extends Serializable> T deserializeObject( byte[] bytes, Class<T> clazz )
	throws IOException, ClassNotFoundException {

		ByteArrayInputStream is = new ByteArrayInputStream( bytes );
		ObjectInputStream deserializer = new ObjectInputStream( is );
		return clazz.cast( deserializer.readObject());
	}
732571
public <T> T readObject(Class<T> cls) {
    return kryo.readObject(input, cls);
  }
146524
public TypeSerializer<T> getReconfiguredSerializer() {
		Preconditions.checkState(
			isCompatibleWithReconfiguredSerializer(),
			"It is only possible to get a reconfigured serializer if the compatibility type is %s, but the type is %s",
			Type.COMPATIBLE_WITH_RECONFIGURED_SERIALIZER, resultType);
		return reconfiguredNewSerializer;
	}
636473
public Object readObject(Class cl)
        throws IOException
    {
        if (cl == null || cl == Object.class)
            return readObject();

        int tag = read();

        switch (tag) {
            case 'N':
                return null;

            case 'M': {
                String type = readType();

                // hessian/3386
                if ("".equals(type)) {
                    Deserializer reader;
                    reader = _serializerFactory.getDeserializer(cl);

                    return reader.readMap(this);
                }
                else {
                    Deserializer reader;
                    reader = _serializerFactory.getObjectDeserializer(type);

                    return reader.readMap(this);
                }
            }

            case 'V': {
                String type = readType();
                int length = readLength();

                Deserializer reader;
                reader = _serializerFactory.getObjectDeserializer(type);

                if (cl != reader.getType() && cl.isAssignableFrom(reader.getType()))
                    return reader.readList(this, length);

                reader = _serializerFactory.getDeserializer(cl);

                Object v = reader.readList(this, length);

                return v;
            }

            case 'R': {
                int ref = parseInt();

                return _refs.get(ref);
            }

            case 'r': {
                String type = readType();
                String url = readString();

                return resolveRemote(type, url);
            }
        }

        _peek = tag;

        // hessian/332i vs hessian/3406
        //return readObject();

        Object value = _serializerFactory.getDeserializer(cl).readObject(this);

        return value;
    }
873924
@Override
    public ISerializer<?> get(Class<?> clazz) {
        ISerializer<?> contextSerializer = super.get(clazz);

        if (contextSerializer != null) {
            return contextSerializer;
        }

        for (ISerializer<?> item : this) {
            if (item.getType().isAssignableFrom(clazz)) {
                return item;
            }
        }

        return null;
    }
601977
public Deserializer getObjectDeserializer(String type, Class cl)
        throws HessianProtocolException {
        Deserializer reader = getObjectDeserializer(type);

        if (cl == null
            || cl.equals(reader.getType())
            || cl.isAssignableFrom(reader.getType())
            || reader.isReadResolve()
            || HessianHandle.class.isAssignableFrom(reader.getType())) {
            return reader;
        }

        if (log.isLoggable(Level.FINE)) {
            log.fine("hessian: expected deserializer '" + cl.getName() + "' at '" + type + "' ("
                + reader.getType().getName() + ")");
        }

        return getDeserializer(cl);
    }