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

com.github.zhengframework.jpa.JpaMultiModule Maven / Gradle / Ivy

package com.github.zhengframework.jpa;

import static com.google.inject.name.Names.named;

import com.github.zhengframework.configuration.ConfigurationAwareModule;
import com.github.zhengframework.configuration.ConfigurationBeanMapper;
import java.util.Map;
import java.util.Map.Entry;

public class JpaMultiModule extends ConfigurationAwareModule {

  @Override
  protected void configure() {
    Map persistenceConfigMap = ConfigurationBeanMapper
        .resolve(getConfiguration(), JpaConfig.class);
    for (Entry entry : persistenceConfigMap
        .entrySet()) {
      String name = entry.getKey();
      JpaConfig jpaConfig = entry.getValue();
      if (jpaConfig.getPersistenceUnitName() == null) {
        jpaConfig.setPersistenceUnitName("zheng-jpa-" + name);
      }
      install(new JpaPrivateModule(name.isEmpty() ? null : named(name), jpaConfig));
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy