package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.Map;
-import lombok.Getter;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
/**
* Operator that uses HTTP. The operator's parameters must be an {@link HttpParams}.
*/
-public class HttpOperator extends OperatorPartial {
-
- /**
- * Function to make an operation.
- */
- @SuppressWarnings("rawtypes")
- private final OperationMaker<HttpConfig, HttpOperation> operationMaker;
-
- /**
- * Current configuration. This is set by {@link #doConfigure(Map)}.
- */
- @Getter
- private HttpConfig currentConfig;
-
+public class HttpOperator extends TypedOperator<HttpConfig,HttpOperation<?>> {
/**
* Constructs the object.
* @param operationMaker function to make an operation
*/
public HttpOperator(String actorName, String name,
- @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
- super(actorName, name);
- this.operationMaker = operationMaker;
- }
-
- /**
- * Translates the parameters to an {@link HttpParams} and then extracts the relevant
- * values.
- */
- @Override
- protected void doConfigure(Map<String, Object> parameters) {
- currentConfig = makeConfiguration(parameters);
+ OperationMaker<HttpConfig, HttpOperation<?>> operationMaker) {
+ super(actorName, name, operationMaker);
}
/**
return new HttpConfig(getBlockingExecutor(), params, getClientFactory());
}
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- if (operationMaker == null) {
- throw new UnsupportedOperationException("cannot make operation for " + getFullName());
- }
-
- verifyRunning();
-
- return operationMaker.apply(params, currentConfig);
- }
-
// these may be overridden by junit tests
protected HttpClientFactory getClientFactory() {