From 7bf40c2ceac4154e1b3b08d91e9707c5cc1830f1 Mon Sep 17 00:00:00 2001 From: jhh Date: Thu, 6 Feb 2020 14:10:52 -0600 Subject: Store DomainMaker in PolicyEngine. Since this is going to be used in drools-applications, better to have it globally, reusing underlying "schema resources" rather than maintaining one or more instances in drools-applications. Issue-ID: POLICY-2345 Signed-off-by: jhh Change-Id: I0e339e77ea6281308be00381c7eda2cc9f4d6ac1 --- .../java/org/onap/policy/drools/lifecycle/LifecycleFsm.java | 3 ++- .../java/org/onap/policy/drools/system/PolicyEngine.java | 13 +++++++++++-- .../org/onap/policy/drools/system/PolicyEngineManager.java | 12 +++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java index b37d0149..e2c212cd 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java @@ -49,6 +49,7 @@ import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.drools.persistence.SystemPersistenceConstants; import org.onap.policy.drools.policies.DomainMaker; import org.onap.policy.drools.system.PolicyController; +import org.onap.policy.drools.system.PolicyEngineConstants; import org.onap.policy.models.pdp.concepts.PdpResponseDetails; import org.onap.policy.models.pdp.concepts.PdpStateChange; import org.onap.policy.models.pdp.concepts.PdpStatus; @@ -85,7 +86,7 @@ public class LifecycleFsm implements Startable { protected final Properties properties; @Getter(AccessLevel.PACKAGE) - protected final DomainMaker domainMaker = new DomainMaker(); + protected final DomainMaker domainMaker = PolicyEngineConstants.getManager().getDomainMaker(); protected TopicSource source; protected TopicSinkClient client; diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java index db09cb47..685cf235 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================= - * policy-management + * ONAP * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. 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. @@ -33,6 +33,7 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.drools.core.lock.Lock; import org.onap.policy.drools.core.lock.LockCallback; import org.onap.policy.drools.features.PolicyEngineFeatureApi; +import org.onap.policy.drools.policies.DomainMaker; import org.onap.policy.drools.protocol.configuration.ControllerConfiguration; import org.onap.policy.drools.protocol.configuration.PdpdConfiguration; @@ -233,6 +234,14 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener { */ List getFeatures(); + + /** + * get domain maker. + * + * @return the domain maker. + */ + DomainMaker getDomainMaker(); + /** * Attempts the dispatching of an "event" object. * diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java index 0f046d23..0edb06f8 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. 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. @@ -67,6 +67,7 @@ import org.onap.policy.drools.features.PolicyEngineFeatureApi; import org.onap.policy.drools.features.PolicyEngineFeatureApiConstants; import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.persistence.SystemPersistenceConstants; +import org.onap.policy.drools.policies.DomainMaker; import org.onap.policy.drools.properties.DroolsPropertyConstants; import org.onap.policy.drools.protocol.coders.EventProtocolCoder; import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants; @@ -154,6 +155,8 @@ class PolicyEngineManager implements PolicyEngine { @Getter(AccessLevel.PROTECTED) private PolicyResourceLockManager lockManager = null; + private DomainMaker domainMaker = new DomainMaker(); + /** * gson parser to decode configuration requests. */ @@ -194,6 +197,13 @@ class PolicyEngineManager implements PolicyEngine { return this.environment; } + @JsonIgnore + @GsonJsonIgnore + @Override + public DomainMaker getDomainMaker() { + return this.domainMaker; + } + @Override public synchronized String getEnvironmentProperty(String envKey) { String value = this.environment.getProperty(envKey); -- cgit 1.2.3-korg