Android Open Source - Jello Jello Module






From Project

Back to project page Jello.

License

The source code is released under:

Apache License

If you think the Android project Jello listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.atteo.jello;
//w w  w  . jav  a  2 s.c om
import java.util.HashMap;

import android.util.Pool;
import android.util.Pools;

import com.atteo.jello.index.IndexModule;
import com.atteo.jello.klass.KlassManager;
import com.atteo.jello.klass.SimpleKlassManager;
import com.atteo.jello.schema.SchemaModule;
import com.atteo.jello.space.SpaceModule;
import com.atteo.jello.store.PageSizeProvider;
import com.atteo.jello.store.StoreModule;
import com.atteo.jello.transaction.TransactionModule;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.google.inject.name.Names;

public class JelloModule implements Module {
  // ---- SETTINGS
  private final int fileFormatVersion = 0;
  private final String magic = "JelloDatabase";

  private final int recordPoolLimit = 8;

  private int headerPageId = 0;
  private int freeSpaceInfoPageId = 1;
  private int klassManagerPageId = 2;
  private final int minimumPages;

  private final int maxRecordPages = 4;
  private final int maxRecordSize;
  // --------------

  private final String fullpath;

  private final HashMap<String, String> properties;

  public JelloModule(final String fullpath,
      final HashMap<String, String> properties) {
    this.fullpath = fullpath;
    final int pageSize = new PageSizeProvider().get();

    maxRecordSize = maxRecordPages * pageSize;

    this.properties = getDefaultProperties();
    if (properties != null)
      this.properties.putAll(properties);

    headerPageId = Integer.valueOf(this.properties.get("headerPageId"));
    freeSpaceInfoPageId = Integer.valueOf(this.properties
        .get("freeSpaceInfoPageId"));
    klassManagerPageId = Integer.valueOf(this.properties
        .get("klassManagerPageId"));

    minimumPages = Math.max(freeSpaceInfoPageId, klassManagerPageId) + 1;

    this.properties.put("minimumPages", String.valueOf(minimumPages));

  }

  public void configure(final Binder binder) {
    HashMap<String, String> p = new HashMap<String, String>();
    if (properties.containsKey("pageSize")) {
      p.put("pageSize", properties.get("pageSize"));
      properties.remove("pageSize");
    }
    binder.install(new StoreModule(fullpath, p));
    p = new HashMap<String, String>();
    if (properties.containsKey("blockSize")) {
      p.put("blockSize", properties.get("blockSize"));
      properties.remove("blockSize");
    }
    binder.install(new SpaceModule(p));
    binder.install(new IndexModule(null));
    binder.install(new SchemaModule(null));
    binder.install(new TransactionModule(null));

    binder.bind(KlassManager.class).to(SimpleKlassManager.class);

    Names.bindProperties(binder, properties);
    
    binder.requestStaticInjection(Record.class);
    binder.requestStaticInjection(PageUsage.class);
    binder.requestStaticInjection(Storable.class);
    binder.requestStaticInjection(StorableCollection.class);
  }

  private HashMap<String, String> getDefaultProperties() {
    final HashMap<String, String> p = new HashMap<String, String>();
    p.put("fileFormatVersion", String.valueOf(fileFormatVersion));
    p.put("magic", String.valueOf(magic));
    p.put("recordPoolLimit", String.valueOf(recordPoolLimit));
    p.put("headerPageId", String.valueOf(headerPageId));
    p.put("freeSpaceInfoPageId", String.valueOf(freeSpaceInfoPageId));
    p.put("klassManagerPageId", String.valueOf(klassManagerPageId));
    p.put("minimumPages", String.valueOf(minimumPages));
    p.put("maxRecordPages", String.valueOf(maxRecordPages));
    p.put("maxRecordSize", String.valueOf(maxRecordSize));
    return p;
  }

  @Provides
  @Singleton
  Pool<Record> recordPoolProvider(final RecordPoolableManager manager,
      @Named("recordPoolLimit") final int limit) {
    return Pools.finitePool(manager, limit);
  }

}




Java Source Code List

android.util.FinitePool.java
android.util.Pool.java
android.util.PoolableManager.java
android.util.Poolable.java
android.util.Pools.java
android.util.SynchronizedPool.java
com.atteo.jello.DatabaseFile.java
com.atteo.jello.Expression.java
com.atteo.jello.JelloModule.java
com.atteo.jello.Jello.java
com.atteo.jello.PageUsage.java
com.atteo.jello.RecordPoolableManager.java
com.atteo.jello.Record.java
com.atteo.jello.StorableCollection.java
com.atteo.jello.StorableFactory.java
com.atteo.jello.StorableInfo.java
com.atteo.jello.Storable.java
com.atteo.jello.associations.BelongsTo.java
com.atteo.jello.associations.DatabaseField.java
com.atteo.jello.associations.HasMany.java
com.atteo.jello.index.BTree.java
com.atteo.jello.index.IndexFactory.java
com.atteo.jello.index.IndexModule.java
com.atteo.jello.index.Index.java
com.atteo.jello.index.PagePoolProxy.java
com.atteo.jello.klass.KlassManager.java
com.atteo.jello.klass.SimpleKlassManager.java
com.atteo.jello.schema.SchemaManagerFactory.java
com.atteo.jello.schema.SchemaManager.java
com.atteo.jello.schema.SchemaModule.java
com.atteo.jello.schema.Schema.java
com.atteo.jello.schema.SimpleSchemaManager.java
com.atteo.jello.schema.StorableWriter.java
com.atteo.jello.schema.VanillaStorableWriter.java
com.atteo.jello.space.AppendOnlyCacheNative.java
com.atteo.jello.space.AppendOnlyCache.java
com.atteo.jello.space.AppendOnly.java
com.atteo.jello.space.Hybrid.java
com.atteo.jello.space.NextFitHistogramNative.java
com.atteo.jello.space.NextFitHistogram.java
com.atteo.jello.space.NextFit.java
com.atteo.jello.space.SpaceManagerNative.java
com.atteo.jello.space.SpaceManagerPolicy.java
com.atteo.jello.space.SpaceManager.java
com.atteo.jello.space.SpaceModule.java
com.atteo.jello.space.VanillaHistogram.java
com.atteo.jello.store.HeaderPage.java
com.atteo.jello.store.ListPage.java
com.atteo.jello.store.PagePoolableManager.java
com.atteo.jello.store.PageSizeProvider.java
com.atteo.jello.store.Page.java
com.atteo.jello.store.PagedFileNative.java
com.atteo.jello.store.PagedFileRAF.java
com.atteo.jello.store.PagedFile.java
com.atteo.jello.store.StoreModule.java
com.atteo.jello.transaction.LockManager.java
com.atteo.jello.transaction.SimpleLockManager.java
com.atteo.jello.transaction.SimpleTransactionManager.java
com.atteo.jello.transaction.TransactionManager.java
com.atteo.jello.transaction.TransactionModule.java