Package com.db4o.config

Examples of com.db4o.config.EmbeddedConfiguration


    this.databaseFile = databaseFile;
    this.xstreamFile = xstreamFile;
  }

  public void toXML() {
    EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
    config.common().activationDepth(Integer.MAX_VALUE);
    ObjectContainer db4o = Db4oEmbedded.openFile(config, databaseFile);
    new XStreamFile(xstreamFile).write(db4o.queryByExample(null));
    db4o.close();
  }
View Full Code Here


  protected void openEngine() {
    db = Db4oEmbedded.openFile(newConfiguration(), filename);
  }

  protected EmbeddedConfiguration newConfiguration() {
    EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
    config.common().activationDepth(0);
    config.common().allowVersionUpdates(true);
    config.common().callConstructors(true);
    config.common().callbacks(false);
    config.common().weakReferences(false);
    config.file().freespace().useRamSystem();
    config.file().storage(new NonFlushingStorage(new FileStorage()));
    return config;
  }
View Full Code Here

    /**
     * Constructor.
     */
    public Application() {
        /** Open and keep the db4o object container. */
        EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
        config.common().updateDepth(2);
        this.container = Db4oEmbedded.openFile(config, System
                .getProperty("user.home")
                + File.separator + "restbook.dbo");
    }
View Full Code Here

    final IEntity e = getTestEntity();
    dao.persist(e);
    getDbTrans().setComplete();
    getDbTrans().endTrans();
    dao.getObjectContainer().close();
    final EmbeddedConfiguration c = injector.getInstance(EmbeddedConfiguration.class);
    final URI db4oUri = injector.getInstance(Key.get(URI.class, Db4oFile.class));
    final EmbeddedObjectContainer oc = Db4oEmbedded.openFile(c, db4oUri.getPath());
    dao.setObjectContainer(oc);
    ((Db4oTrans) getDbTrans()).setObjectContainer(oc);
    ((Db4oEntityFactory) getEntityFactory()).setObjectContainer(oc);
View Full Code Here

    // being thrown
    bind(EmbeddedConfiguration.class).toProvider(new Provider<EmbeddedConfiguration>() {

      @Override
      public EmbeddedConfiguration get() {
        final EmbeddedConfiguration c = Db4oEmbedded.newConfiguration();
        // configure the db4o configuration
        configureConfiguration(c);
        return c;
      }

    }).in(Scopes.NO_SCOPE);

    // ObjectContainer
    bind(EmbeddedObjectContainer.class).toProvider(new Provider<EmbeddedObjectContainer>() {

      @Inject
      @Db4oFile
      URI db4oUri;

      @Inject
      Provider<EmbeddedConfiguration> c;

      @Override
      public EmbeddedObjectContainer get() {
        log.info("Creating db4o session for: " + db4oUri);
        return Db4oEmbedded.openFile(c.get(), db4oUri.getPath());
      }
    }).in(Scopes.SINGLETON);

    // determine whether we do spring transactions
    // this is necessary to avoid un-necessary instantiation of an
View Full Code Here

  final private static boolean DIAGNOSTICS_ENABLED = false;
  final private static boolean DEBUG_OUTPUT_ENABLED = false;
  final private static int DEBUG_OUTPUT_LEVEL = 4;

  public EmbeddedConfiguration createDefaultConfiguration() {
    EmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration();
    configuration.common().reflectWith(new JdkReflector(this.getClass().getClassLoader()));
    configuration.common().add(new TransparentPersistenceSupport());
    configuration.common().objectClass(RequestLogRecord.class).objectField("requestId").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("requestOrigin").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("hostname").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("requestMethod").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("responseCode").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("responseLength").indexed(true);
    configuration.common().objectClass(RequestLogRecord.class).objectField("tagList").indexed(true);
    configuration.common().objectClass(ScanAlert.class).objectField("key").indexed(true);
    configuration.common().objectClass(ScanAlert.class).objectField("resource").indexed(true);
    configuration.common().objectClass(ScanAlert.class).objectField("requestId").indexed(true);
    configuration.common().objectClass(Tag.class).objectField("name").indexed(true);

    configuration.common().weakReferences(false);
   
    if(DIAGNOSTICS_ENABLED) {
      configuration.common().diagnostic().addListener(new DiagnosticToConsole());
    }
    if(DEBUG_OUTPUT_ENABLED) {
      configuration.common().messageLevel(DEBUG_OUTPUT_LEVEL);
    }

    if(LAZY_EVALUATION) {
      configuration.common().queries().evaluationMode(QueryEvaluationMode.LAZY);
    }
    return configuration;

  }
View Full Code Here

  }


  public ObjectContainer openContainer(String path) {
    EmbeddedConfiguration config = createDefaultConfiguration();
    return Db4oEmbedded.openFile(config, path);
  }
View Full Code Here

TOP

Related Classes of com.db4o.config.EmbeddedConfiguration

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.