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

net.java.ao.builder.EntityManagerBuilderWithDatabaseProperties Maven / Gradle / Ivy

Go to download

This is the full Active Objects library, if you don't know which one to use, you probably want this one.

There is a newer version: 6.1.1
Show newest version
package net.java.ao.builder;

import net.java.ao.EntityManager;
import net.java.ao.LuceneConfiguration;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

import java.io.File;
import java.io.IOException;

import static com.google.common.base.Preconditions.checkNotNull;
import static net.java.ao.builder.DatabaseProviderFactory.getDatabaseProvider;

/**
 * This is class used to build {@link net.java.ao.EntityManager}
 *
 * @see EntityManagerBuilder
 * @see EntityManagerBuilderWithUrl
 * @see EntityManagerBuilderWithUrlAndUsername
 */
public final class EntityManagerBuilderWithDatabaseProperties extends AbstractEntityManagerBuilderWithDatabaseProperties
{
    EntityManagerBuilderWithDatabaseProperties(BuilderDatabaseProperties databaseProperties)
    {
        super(databaseProperties);
    }

    public EntityManagerBuilderWithDatabasePropertiesAndLuceneConfiguration withIndex(final File indexDir)
    {
        checkNotNull(indexDir);
        return new EntityManagerBuilderWithDatabasePropertiesAndLuceneConfiguration(getDatabaseProperties(), getEntityManagerConfiguration(), new LuceneConfiguration()
        {
            public Directory getIndexDirectory()
            {
                try
                {
                    return FSDirectory.getDirectory(indexDir);
                }
                catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
            }
        });
    }

    public EntityManager build()
    {
        return new EntityManager(getDatabaseProvider(getDatabaseProperties()), getEntityManagerConfiguration());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy