diff options
Diffstat (limited to 'policy-management/src/main')
4 files changed, 46 insertions, 42 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java index d926bed6..726e7217 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java @@ -52,6 +52,7 @@ import javax.ws.rs.core.Response.Status; import org.onap.policy.common.endpoints.event.comm.Topic; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.drools.controller.DroolsController; @@ -1611,7 +1612,7 @@ public class RestManager { @ApiOperation(value = "Retrieves the managed topics", notes = "Network Topics Aggregation", response = TopicEndpoint.class) public Response topics() { - return Response.status(Response.Status.OK).entity(TopicEndpoint.manager).build(); + return Response.status(Response.Status.OK).entity(TopicEndpointManager.getManager()).build(); } @GET @@ -1634,9 +1635,9 @@ public class RestManager { @ApiResponses(value = {@ApiResponse(code = 406, message = "The system is an administrative state that prevents " + "this request to be fulfilled")}) public Response topicsLock() { - final boolean success = TopicEndpoint.manager.lock(); + final boolean success = TopicEndpointManager.getManager().lock(); if (success) { - return Response.status(Status.OK).entity(TopicEndpoint.manager).build(); + return Response.status(Status.OK).entity(TopicEndpointManager.getManager()).build(); } else { return Response.status(Status.NOT_ACCEPTABLE).entity(new Error("cannot perform operation")).build(); } @@ -1654,9 +1655,9 @@ public class RestManager { @ApiResponses(value = {@ApiResponse(code = 406, message = "The system is an administrative state that prevents " + "this request to be fulfilled")}) public Response topicsUnlock() { - final boolean success = TopicEndpoint.manager.unlock(); + final boolean success = TopicEndpointManager.getManager().unlock(); if (success) { - return Response.status(Status.OK).entity(TopicEndpoint.manager).build(); + return Response.status(Status.OK).entity(TopicEndpointManager.getManager()).build(); } else { return Response.status(Status.NOT_ACCEPTABLE).entity(new Error("cannot perform operation")).build(); } @@ -1672,7 +1673,7 @@ public class RestManager { @ApiOperation(value = "Retrieves the managed topic sources", notes = "Network Topic Sources Agregation", responseContainer = "List", response = TopicSource.class) public Response sources() { - return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getTopicSources()).build(); + return Response.status(Response.Status.OK).entity(TopicEndpointManager.getManager().getTopicSources()).build(); } /** @@ -1685,7 +1686,7 @@ public class RestManager { @ApiOperation(value = "Retrieves the managed topic sinks", notes = "Network Topic Sinks Agregation", responseContainer = "List", response = TopicSink.class) public Response sinks() { - return Response.status(Response.Status.OK).entity(TopicEndpoint.manager.getTopicSinks()).build(); + return Response.status(Response.Status.OK).entity(TopicEndpointManager.getManager().getTopicSinks()).build(); } /** @@ -1702,13 +1703,13 @@ public class RestManager { Status status = Status.OK; switch (CommInfrastructure.valueOf(comm.toUpperCase())) { case UEB: - sources.addAll(TopicEndpoint.manager.getUebTopicSources()); + sources.addAll(TopicEndpointManager.getManager().getUebTopicSources()); break; case DMAAP: - sources.addAll(TopicEndpoint.manager.getDmaapTopicSources()); + sources.addAll(TopicEndpointManager.getManager().getDmaapTopicSources()); break; case NOOP: - sources.addAll(TopicEndpoint.manager.getNoopTopicSources()); + sources.addAll(TopicEndpointManager.getManager().getNoopTopicSources()); break; default: status = Status.BAD_REQUEST; @@ -1732,13 +1733,13 @@ public class RestManager { Status status = Status.OK; switch (CommInfrastructure.valueOf(comm.toUpperCase())) { case UEB: - sinks.addAll(TopicEndpoint.manager.getUebTopicSinks()); + sinks.addAll(TopicEndpointManager.getManager().getUebTopicSinks()); break; case DMAAP: - sinks.addAll(TopicEndpoint.manager.getDmaapTopicSinks()); + sinks.addAll(TopicEndpointManager.getManager().getDmaapTopicSinks()); break; case NOOP: - sinks.addAll(TopicEndpoint.manager.getNoopTopicSinks()); + sinks.addAll(TopicEndpointManager.getManager().getNoopTopicSinks()); break; default: status = Status.BAD_REQUEST; @@ -1762,7 +1763,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic) { return Response .status(Response.Status.OK) - .entity(TopicEndpoint.manager + .entity(TopicEndpointManager.getManager() .getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic)) .build(); } @@ -1780,7 +1781,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic) { return Response .status(Response.Status.OK) - .entity(TopicEndpoint.manager + .entity(TopicEndpointManager.getManager() .getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic)) .build(); } @@ -1797,9 +1798,9 @@ public class RestManager { @ApiParam(value = "Communication Mechanism", required = true) @PathParam("comm") String comm, @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic) { return Response.status(Status.OK) - .entity(Arrays - .asList(TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic) - .getRecentEvents())) + .entity(Arrays.asList(TopicEndpointManager.getManager() + .getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic) + .getRecentEvents())) .build(); } @@ -1815,9 +1816,9 @@ public class RestManager { @ApiParam(value = "Communication Mechanism", required = true) @PathParam("comm") String comm, @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic) { return Response.status(Status.OK) - .entity(Arrays - .asList(TopicEndpoint.manager.getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic) - .getRecentEvents())) + .entity(Arrays.asList(TopicEndpointManager.getManager() + .getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic) + .getRecentEvents())) .build(); } @@ -1860,7 +1861,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSource source = - TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, source.lock(), source); } @@ -1877,7 +1878,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSource source = - TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, source.unlock(), source); } @@ -1894,7 +1895,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSource source = - TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, source.start(), source); } @@ -1911,7 +1912,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSource source = - TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, source.stop(), source); } @@ -1928,7 +1929,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSink sink = - TopicEndpoint.manager.getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, sink.lock(), sink); } @@ -1945,7 +1946,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSink sink = - TopicEndpoint.manager.getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, sink.unlock(), sink); } @@ -1962,7 +1963,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSink sink = - TopicEndpoint.manager.getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, sink.start(), sink); } @@ -1979,7 +1980,7 @@ public class RestManager { @ApiParam(value = "Topic Name", required = true) @PathParam("topic") String topic ) { TopicSink sink = - TopicEndpoint.manager.getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSink(CommInfrastructure.valueOf(comm.toUpperCase()), topic); return getResponse(topic, sink.stop(), sink); } @@ -2016,7 +2017,7 @@ public class RestManager { try { TopicSource source = - TopicEndpoint.manager.getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); + TopicEndpointManager.getManager().getTopicSource(CommInfrastructure.valueOf(comm.toUpperCase()), topic); if (source.offer(json)) { return Response.status(Status.OK) .entity(Arrays.asList(source.getRecentEvents())) diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java index 38af4138..d1cdc564 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java @@ -21,7 +21,7 @@ package org.onap.policy.drools.system; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.properties.DroolsProperties; import org.onap.policy.drools.utils.PropertyUtil; @@ -80,7 +80,7 @@ public class Main { /* 2. Add topics */ for (Properties topicProperties : SystemPersistence.manager.getTopicProperties()) { - TopicEndpoint.manager.addTopics(topicProperties); + TopicEndpointManager.getManager().addTopics(topicProperties); } /* 3. Start the Engine with the basic services only (no Policy Controllers) */ 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 963aced4..811a9c80 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 @@ -34,11 +34,13 @@ import org.onap.policy.common.capabilities.Startable; import org.onap.policy.common.endpoints.event.comm.Topic; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactory; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.annotation.GsonJsonIgnore; import org.onap.policy.common.gson.annotation.GsonJsonProperty; @@ -1562,11 +1564,11 @@ class PolicyEngineManager implements PolicyEngine { } protected TopicEndpoint getTopicEndpointManager() { - return TopicEndpoint.manager; + return TopicEndpointManager.getManager(); } protected HttpServletServerFactory getServletFactory() { - return HttpServletServer.factory; + return HttpServletServerFactoryInstance.getServerFactory(); } protected PolicyControllerFactory getControllerFactory() { diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java index 6fd05fb3..bdcb19ad 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java @@ -7,9 +7,9 @@ * 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. @@ -29,6 +29,7 @@ import java.util.Properties; import java.util.stream.Collectors; import org.onap.policy.common.endpoints.event.comm.Topic; import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.TopicSource; @@ -107,10 +108,10 @@ public class AggregatedPolicyController implements PolicyController, TopicListen /** * Constructor version mainly used for bootstrapping at initialization time a policy engine * controller. - * + * * @param name controller name * @param properties - * + * * @throws IllegalArgumentException when invalid arguments are provided */ public AggregatedPolicyController(String name, Properties properties) { @@ -175,7 +176,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen /** * initialize drools layer. - * + * * @throws IllegalArgumentException if invalid parameters are passed in */ private void initDrools(Properties properties) { @@ -190,7 +191,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen /** * initialize sinks. - * + * * @throws IllegalArgumentException if invalid parameters are passed in */ private void initSinks() { @@ -716,13 +717,13 @@ public class AggregatedPolicyController implements PolicyController, TopicListen } // the following methods may be overridden by junit tests - + protected SystemPersistence getPersistenceManager() { return SystemPersistence.manager; } protected TopicEndpoint getEndpointManager() { - return TopicEndpoint.manager; + return TopicEndpointManager.getManager(); } protected DroolsControllerFactory getDroolsFactory() { |