2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.m2.base;
23 import org.onap.policy.drools.core.PolicyContainer;
24 import org.onap.policy.drools.core.PolicySession;
25 import org.onap.policy.drools.system.PolicyController;
26 import org.onap.policy.drools.system.PolicyControllerConstants;
27 import org.onap.policy.drools.system.PolicyEngineConstants;
30 * This class contains static utility methods.
33 // Add a private Util to hide the implicit public one.
39 * Find the PolicyController associated with the specified PolicySession.
41 * @param session the current PolicySession
42 * @return the associated PolicyController (or 'null' if not found)
44 public static PolicyController getPolicyController(PolicySession session) {
45 PolicyContainer container = session.getPolicyContainer();
46 return PolicyControllerConstants.getFactory().get(
47 container.getGroupId(), container.getArtifactId());
51 * Send a UEB/DMAAP message to the specified topic, using the specified
54 * @param topic UEB/DMAAP topic
55 * @param event the message to encode, and send
56 * @return 'true' if successful, 'false' if delivery failed
57 * @throws IllegalStateException if the topic can't be found,
58 * or there are multiple topics with the same name
60 public static boolean deliver(String topic, Object event) {
61 return PolicyEngineConstants.getManager().deliver(topic, event);