X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=esr-core%2Fesr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fhibernate%2FHibernateBundleExt.java;fp=esr-core%2Fesr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fhibernate%2FHibernateBundleExt.java;h=0000000000000000000000000000000000000000;hb=1d3d273283587b17768437ece873617254e52d51;hp=d609adc42b6189e5a2b220bde79c763cac87afc2;hpb=5b8935e0094b1f37b3491200796a1a68acf3b90e;p=aai%2Fesr-server.git diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java deleted file mode 100644 index d609adc..0000000 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2016-2017 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.aai.esr.hibernate; - - -import com.google.common.collect.ImmutableList; - -import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; -import io.dropwizard.db.DataSourceFactory; -import io.dropwizard.hibernate.HibernateBundle; -import io.dropwizard.hibernate.SessionFactoryFactory; -import io.dropwizard.setup.Bootstrap; -import io.dropwizard.setup.Environment; -import org.hibernate.SessionFactory; -import org.onap.aai.esr.ExtsysAppConfiguration; - - -public class HibernateBundleExt extends HibernateBundle { - - private static final String DEFAULT_NAME = "hibernate"; - - private SessionFactory sessionFactory; - - private final ImmutableList> entities; - private final SessionFactoryFactory sessionFactoryFactory; - - protected HibernateBundleExt(Class entity, Class... entities) { - this(ImmutableList.>builder().add(entity).add(entities).build(), - new SessionFactoryFactory()); - } - - protected HibernateBundleExt(ImmutableList> entities, - SessionFactoryFactory sessionFactoryFactory) { - super(entities, sessionFactoryFactory); - this.entities = entities; - this.sessionFactoryFactory = sessionFactoryFactory; - } - - public final void initializeExt(Bootstrap bootstrap) { - bootstrap.getObjectMapper().registerModule(createHibernate4Module()); - } - - /** - * Override to configure the {@link Hibernate4Module}. - */ - protected Hibernate4Module createHibernate4Module() { - return new Hibernate4Module(); - } - - protected String name() { - return DEFAULT_NAME; - } - - /** - * ext run function. - * @param configuration inventory configuration - * @param environment environment - * @throws Exception Exception - */ - public final void runExt(ExtsysAppConfiguration configuration, Environment environment) - throws Exception { - final DataSourceFactory dbConfig = getDataSourceFactory(configuration); - this.sessionFactory = - sessionFactoryFactory.build(this, environment, dbConfig, entities, name()); - - } - - public SessionFactory getSessionFactory() { - return sessionFactory; - } - - - @Override - public DataSourceFactory getDataSourceFactory(ExtsysAppConfiguration configuration) { - return configuration.getDataSourceFactory(); - } - -}