summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider/src/main
diff options
context:
space:
mode:
authorning.xi <ning.xi@est.tech>2019-04-01 03:07:40 +0000
committerning.xi <ning.xi@est.tech>2019-04-01 03:07:40 +0000
commit2d99454e725df9f0f74572ac10de2b97f7e84c55 (patch)
tree9752cb83dbe3b59fa027acc01f900e1182a99d12 /models-interactions/model-actors/actorServiceProvider/src/main
parentfbed360c0acdc127fdf56a99401c1aea691ce57e (diff)
move actors code in drools-applications to policy/models
remove white-space in policy/models Issue-ID: POLICY-1264 Change-Id: I8856fc7cd2c2a57af0031637870ca33c684bacf5 Signed-off-by: ning.xi <ning.xi@est.tech>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src/main')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java73
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java36
2 files changed, 109 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
new file mode 100644
index 000000000..809936146
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ActorService
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.policy.controlloop.actorserviceprovider;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ActorService {
+
+ private static final Logger logger = LoggerFactory.getLogger(ActorService.class);
+ private static ActorService service;
+
+ // USed to load actors
+ private final ServiceLoader<Actor> loader;
+
+ private ActorService() {
+ loader = ServiceLoader.load(Actor.class);
+ }
+
+ /**
+ * Get the single instance.
+ *
+ * @return the instance
+ */
+ public static synchronized ActorService getInstance() {
+ if (service == null) {
+ service = new ActorService();
+ }
+ return service;
+ }
+
+ /**
+ * Get the actors.
+ *
+ * @return the actors
+ */
+ public ImmutableList<Actor> actors() {
+ Iterator<Actor> iter = loader.iterator();
+ logger.debug("returning actors");
+ while (iter.hasNext()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Got {}", iter.next().actor());
+ }
+ }
+
+ return ImmutableList.copyOf(loader.iterator());
+ }
+}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java
new file mode 100644
index 000000000..88f3c16eb
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Actor
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.policy.controlloop.actorserviceprovider.spi;
+
+import java.util.List;
+
+public interface Actor {
+
+ String actor();
+
+ List<String> recipes();
+
+ List<String> recipeTargets(String recipe);
+
+ List<String> recipePayloads(String recipe);
+
+}