Package com.db4o.config

Examples of com.db4o.config.Configuration


    final IEntity e = getTestEntity();
    dao.persist(e);
    setComplete();
    endTransaction();
    dao.getObjectContainer().close();
    final Configuration c = injector.getInstance(Configuration.class);
    final URI db4oUri = injector.getInstance(Key.get(URI.class, Db4oFile.class));
    final ObjectContainer oc = Db4o.openFile(c, db4oUri.getPath());
    dao.setObjectContainer(oc);
    ((Db4oTrans)getDbTrans()).setObjectContainer(oc);
    startNewTransaction();
View Full Code Here


            scheduledBackup(progressMonitor);
        }
      }

      /* Open the DB */
      Configuration config = createConfiguration(false);
      createObjectContainer(config, forRestore);

      /* Notify Listeners that DB is opened */
      fireDatabaseEvent(new DatabaseEvent(fObjectContainer, fLock), true);

View Full Code Here

    try {

      /* Open Source DB */
      sourceDb = Db4o.openFile(createConfiguration(true), source.getAbsolutePath());

      Configuration destinationDbConfiguration = createConfiguration(true);
      if (useLargeBlockSize)
        destinationDbConfiguration.blockSize(LARGE_DB_BLOCK_SIZE);

      /* Open Destination DB */
      destinationDb = Db4o.openFile(destinationDbConfiguration, destination.getAbsolutePath());

      /* Copy (Defragment) */
 
View Full Code Here

   * for the defrag process and <code>false</code> otherwise to return a normal
   * configuration suitable for the application.
   * @return Configuration
   */
  public static final Configuration createConfiguration(boolean forDefrag) {
    Configuration config = Db4o.newConfiguration();

    //TODO We can use dbExists to configure our parameters for a more
    //efficient startup. For example, the following could be used. We'd have
    //to include a file when we need to evolve the schema or something similar
    //config.detectSchemaChanges(false)

    if (getLargeBlockSizeMarkerFile().exists())
      config.blockSize(LARGE_DB_BLOCK_SIZE); //The DB has been migrated to a larger block size

    config.setOut(new PrintStream(new ByteArrayOutputStream()) {
      @Override
      public void write(byte[] buf, int off, int len) {
        if (buf != null && len >= 0 && off >= 0 && off <= buf.length - len)
          CoreUtils.appendLogMessage(new String(buf, off, len));
      }
    });

    config.lockDatabaseFile(true);
    config.queries().evaluationMode(forDefrag ? QueryEvaluationMode.LAZY : QueryEvaluationMode.IMMEDIATE);
    config.automaticShutDown(false);
    config.callbacks(false);
    config.activationDepth(2);
    config.flushFileBuffers(false);
    config.callConstructors(true);
    config.exceptionsOnNotStorable(true);
    configureAbstractEntity(config);
    config.objectClass(BookMark.class).objectField("fFeedLink").indexed(true); //$NON-NLS-1$
    config.objectClass(ConditionalGet.class).objectField("fLink").indexed(true); //$NON-NLS-1$
    configureFeed(config);
    configureNews(config);
    configureFolder(config);
    config.objectClass(Description.class).objectField("fNewsId").indexed(true); //$NON-NLS-1$
    config.objectClass(NewsCounter.class).cascadeOnDelete(true);
    config.objectClass(Preference.class).cascadeOnDelete(true);
    config.objectClass(Preference.class).objectField("fKey").indexed(true); //$NON-NLS-1$
    config.objectClass(SearchFilter.class).objectField("fActions").cascadeOnDelete(true); //$NON-NLS-1$

    if (isIBM_VM_1_6()) //See defect 733
      config.objectClass("java.util.MiniEnumSet").translate(new com.db4o.config.TSerializable()); //$NON-NLS-1$

    return config;
  }
View Full Code Here

    }
  }

  private static void upgradeFile(DefragmentConfig config) {
    File4.copy(config.backupPath(),config.tempPath());
    Configuration db4oConfig=(Configuration)((Config4Impl)config.db4oConfig()).deepClone(null);
    db4oConfig.allowVersionUpdates(true);
    ObjectContainer db=Db4o.openFile(db4oConfig,config.tempPath());
    db.close();
  }
View Full Code Here

TOP

Related Classes of com.db4o.config.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.