aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2024-08-22 13:31:32 +0000
committerGerrit Code Review <gerrit@onap.org>2024-08-22 13:31:32 +0000
commita01eb33c635ff73525a2e184517aacb765c32ccd (patch)
tree9692bb7e1d259933b0748a2b2f1431f54bb60ab2 /a1-policy-management/src/main/java
parent65d88c2fe722a1af41b87283862f7c5f3428148a (diff)
parentfdfb070d8a5139963fa02e59814855b8b19576a3 (diff)
Merge "Add database migration configuration"
Diffstat (limited to 'a1-policy-management/src/main/java')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java27
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java (renamed from a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/ExcludeDatabaseAutoConfiguration.java)31
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java57
3 files changed, 85 insertions, 30 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
index 0f077a13..4d1fa331 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/BeanFactory.java
@@ -21,15 +21,11 @@
package org.onap.ccsdk.oran.a1policymanagementservice;
-
import org.apache.catalina.connector.Connector;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.SecurityContext;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
-import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
@@ -37,7 +33,6 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
@Configuration
public class BeanFactory {
@@ -56,28 +51,6 @@ public class BeanFactory {
}
@Bean
- @DependsOn("springContextProvider")
- public Services getServices(@Autowired ApplicationConfig applicationConfig) {
- Services services = new Services(applicationConfig);
- services.restoreFromDatabase().subscribe();
- return services;
- }
-
- @Bean
- @DependsOn("springContextProvider")
- public PolicyTypes getPolicyTypes(@Autowired ApplicationConfig applicationConfig) {
- PolicyTypes types = new PolicyTypes(applicationConfig);
- types.restoreFromDatabase().blockLast();
- return types;
- }
-
- @Bean
- @DependsOn("springContextProvider")
- public Policies getPolicies(@Autowired ApplicationConfig applicationConfig) {
- return new Policies(applicationConfig);
- }
-
- @Bean
public A1ClientFactory getA1ClientFactory(@Autowired ApplicationConfig applicationConfig,
@Autowired SecurityContext securityContext) {
return new A1ClientFactory(applicationConfig, securityContext);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/ExcludeDatabaseAutoConfiguration.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java
index 799a8cb2..305499d0 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/ExcludeDatabaseAutoConfiguration.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/DatabaseIndependentBeanFactory.java
@@ -18,15 +18,40 @@
* ========================LICENSE_END===================================
*/
-package org.onap.ccsdk.oran.a1policymanagementservice.database;
+package org.onap.ccsdk.oran.a1policymanagementservice;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnProperty(prefix = "app", name = "database-enabled", havingValue = "false")
-@EnableAutoConfiguration(exclude = R2dbcAutoConfiguration.class)
-public class ExcludeDatabaseAutoConfiguration {
+@EnableAutoConfiguration(exclude = { R2dbcAutoConfiguration.class, FlywayAutoConfiguration.class })
+public class DatabaseIndependentBeanFactory {
+ @Bean
+ public Services getServices(@Autowired ApplicationConfig applicationConfig) {
+ Services services = new Services(applicationConfig);
+ services.restoreFromDatabase().subscribe();
+ return services;
+ }
+
+ @Bean
+ public PolicyTypes getPolicyTypes(@Autowired ApplicationConfig applicationConfig) {
+ PolicyTypes types = new PolicyTypes(applicationConfig);
+ types.restoreFromDatabase().blockLast();
+ return types;
+ }
+
+ @Bean
+ public Policies getPolicies(@Autowired ApplicationConfig applicationConfig) {
+ return new Policies(applicationConfig);
+ }
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java
new file mode 100644
index 00000000..f463ecd0
--- /dev/null
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/database/DatabaseDependentBeanFactory.java
@@ -0,0 +1,57 @@
+/*-
+ * ========================LICENSE_START=================================
+ * ONAP : ccsdk oran
+ * ======================================================================
+ * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+ * ======================================================================
+ * 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.
+ * ========================LICENSE_END===================================
+ */
+
+package org.onap.ccsdk.oran.a1policymanagementservice.database;
+
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
+import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
+
+@Configuration
+@ConditionalOnProperty(prefix = "app", name = "database-enabled", havingValue = "true")
+public class DatabaseDependentBeanFactory {
+ @Bean
+ @DependsOn({ "springContextProvider", "flywayInitializer" })
+ public Services getServices(@Autowired ApplicationConfig applicationConfig) {
+ Services services = new Services(applicationConfig);
+ services.restoreFromDatabase().subscribe();
+ return services;
+ }
+
+ @Bean
+ @DependsOn({ "springContextProvider", "flywayInitializer" })
+ public PolicyTypes getPolicyTypes(@Autowired ApplicationConfig applicationConfig) {
+ PolicyTypes types = new PolicyTypes(applicationConfig);
+ types.restoreFromDatabase().blockLast();
+ return types;
+ }
+
+ @Bean
+ @DependsOn({ "springContextProvider", "flywayInitializer" })
+ public Policies getPolicies(@Autowired ApplicationConfig applicationConfig) {
+ return new Policies(applicationConfig);
+ }
+}