Search in sources :

Example 1 with JpaModule

use of ninja.jpa.JpaModule in project ninja by ninjaframework.

the class NinjaDaoTestBase method initialize.

@Before
public final void initialize() {
    NinjaPropertiesImpl ninjaProperties = new NinjaPropertiesImpl(ninjaMode);
    injector = Guice.createInjector(new JpaModule(ninjaProperties));
    jpaInitializer = injector.getInstance(JpaInitializer.class);
    jpaInitializer.start();
}
Also used : NinjaPropertiesImpl(ninja.utils.NinjaPropertiesImpl) JpaInitializer(ninja.jpa.JpaInitializer) JpaModule(ninja.jpa.JpaModule) Before(org.junit.Before)

Example 2 with JpaModule

use of ninja.jpa.JpaModule in project ninja by ninjaframework.

the class NinjaClassicModule method configure.

@Override
public void configure() {
    // NOTE: these are grouped to line up with third-party dependencies
    // (e.g. jackson supports templates & body parsers)
    // Text & post require no 3rd party libs
    bind(TemplateEngineText.class);
    bind(BodyParserEnginePost.class);
    // Freemarker
    if (freemarker) {
        bind(TemplateEngineFreemarker.class);
    }
    // Jackson json support
    if (json) {
        OptionalBinder.newOptionalBinder(binder(), ObjectMapper.class).setDefault().toProvider(ObjectMapperProvider.class).in(Singleton.class);
        bind(TemplateEngineJson.class);
        bind(TemplateEngineJsonP.class);
        bind(BodyParserEngineJson.class);
    }
    // Jackson xml support
    if (xml) {
        OptionalBinder.newOptionalBinder(binder(), XmlMapper.class).setDefault().toProvider(XmlMapperProvider.class).in(Singleton.class);
        bind(TemplateEngineXml.class);
        bind(BodyParserEngineXml.class);
    }
    // Postoffice
    if (postoffice) {
        bind(Postoffice.class).toProvider(PostofficeProvider.class);
    }
    // Cache
    if (cache) {
        bind(Cache.class).toProvider(CacheProvider.class);
    }
    // Migrations
    if (migrations) {
        bind(MigrationEngine.class).toProvider(MigrationEngineProvider.class);
        bind(MigrationInitializer.class).asEagerSingleton();
    }
    // JPA
    if (jpa) {
        install(new JpaModule(ninjaProperties));
    }
}
Also used : MigrationEngine(ninja.migrations.MigrationEngine) XmlMapperProvider(ninja.utils.XmlMapperProvider) Postoffice(ninja.postoffice.Postoffice) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ObjectMapperProvider(ninja.utils.ObjectMapperProvider) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper) Cache(ninja.cache.Cache) MigrationInitializer(ninja.migrations.MigrationInitializer) JpaModule(ninja.jpa.JpaModule)

Aggregations

JpaModule (ninja.jpa.JpaModule)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 Cache (ninja.cache.Cache)1 JpaInitializer (ninja.jpa.JpaInitializer)1 MigrationEngine (ninja.migrations.MigrationEngine)1 MigrationInitializer (ninja.migrations.MigrationInitializer)1 Postoffice (ninja.postoffice.Postoffice)1 NinjaPropertiesImpl (ninja.utils.NinjaPropertiesImpl)1 ObjectMapperProvider (ninja.utils.ObjectMapperProvider)1 XmlMapperProvider (ninja.utils.XmlMapperProvider)1 Before (org.junit.Before)1