Exemple #1
0
  protected static final ObjectContainer openMemoryFile1(MemoryFile memoryFile) {
    synchronized (Db4o.lock) {
      if (memoryFile == null) {
        memoryFile = new MemoryFile();
      }
      ObjectContainer oc = null;
      if (Deploy.debug) {
        System.out.println("db4o Debug is ON");
        oc = new YapMemoryFile(memoryFile);

        // intentionally no exception handling,
        // in order to follow uncaught errors
      } else {
        try {
          oc = new YapMemoryFile(memoryFile);
        } catch (Throwable t) {
          Messages.logErr(i_config, 4, "Memory File", t);
          return null;
        }
      }
      if (oc != null) {
        Platform4.postOpen(oc);
        Messages.logMsg(i_config, 5, "Memory File");
      }
      return oc;
    }
  }
 /**
  * todo: Move the GenericClass creation into a utility/factory class.
  *
  * @return
  */
 public GenericClass initGenericClass() {
   GenericReflector reflector =
       new GenericReflector(null, Platform4.reflectorForType(GenericObjectsTest.class));
   GenericClass _objectIClass = (GenericClass) reflector.forClass(Object.class);
   GenericClass result = new GenericClass(reflector, null, PERSON_CLASSNAME, _objectIClass);
   result.initFields(fields(result, reflector));
   return result;
 }
Exemple #3
0
  /**
   * Search for slot that corresponds to class. <br>
   * If not found add it. <br>
   * Constrain it. <br>
   */
  public Constraint constrain(Object example) {
    synchronized (streamLock()) {
      ReflectClass claxx = reflectClassForClass(example);
      if (claxx != null) {
        return addClassConstraint(claxx);
      }

      QConEvaluation eval = Platform4.evaluationCreate(_trans, example);
      if (eval != null) {
        return addEvaluationToAllConstraints(eval);
      }

      Collection4 constraints = new Collection4();
      addConstraint(constraints, example);
      return toConstraint(constraints);
    }
  }
  public static ReflectConstructorSpec createConstructor(
      final ConstructorAwareReflectClass claxx,
      Class clazz,
      ReflectorConfiguration config,
      ReflectConstructor[] constructors) {

    if (claxx == null) {
      return ReflectConstructorSpec.INVALID_CONSTRUCTOR;
    }

    if (claxx.isAbstract() || claxx.isInterface()) {
      return ReflectConstructorSpec.INVALID_CONSTRUCTOR;
    }

    if (!Platform4.callConstructor()) {
      boolean skipConstructor = !config.callConstructor(claxx);
      if (!claxx.isCollection()) {
        ReflectConstructor serializableConstructor =
            skipConstructor(claxx, skipConstructor, config.testConstructors());
        if (serializableConstructor != null) {
          return new ReflectConstructorSpec(serializableConstructor, null);
        }
      }
    }

    if (!config.testConstructors()) {
      return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
    }

    if (ReflectPlatform.createInstance(clazz) != null) {
      return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
    }

    Tree sortedConstructors = sortConstructorsByParamsCount(constructors);
    return findConstructor(claxx, sortedConstructors);
  }
Exemple #5
0
 private static final Object initialize() {
   Platform4.getDefaultConfiguration(i_config);
   return new Object();
 }