All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.orientechnologies.common.serialization.OBinaryConverterFactory Maven / Gradle / Ivy

The newest version!
package com.orientechnologies.common.serialization;

/**
 * @author Andrey Lomakin
 * @since 26.07.12
 */
public class OBinaryConverterFactory {
  private static final boolean unsafeWasDetected;

  static {
    boolean unsafeDetected = false;

    try {
      Class sunClass = Class.forName("sun.misc.Unsafe");
      unsafeDetected = sunClass != null;
    } catch (ClassNotFoundException cnfe) {
      // Ignore
    }

    unsafeWasDetected = unsafeDetected;
  }

  public static OBinaryConverter getConverter() {
    boolean useUnsafe = Boolean.valueOf(System.getProperty("memory.useUnsafe"));

    if (useUnsafe && unsafeWasDetected)
      return OUnsafeBinaryConverter.INSTANCE;

    return OSafeBinaryConverter.INSTANCE;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy