pce(gnpy) for Sulfur
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / gnpy / consumer / GnpyConsumerImpl.java
index cd4b6eb69913b9f7c070c8101772948ef6f504d8..b0854e02b128628d5527e67a2276ed76c00aa2cd 100644 (file)
@@ -18,28 +18,27 @@ import org.glassfish.jersey.logging.LoggingFeature;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.yang.gen.v1.gnpy.gnpy.api.rev220221.Request;
-import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.Result;
+import org.opendaylight.yang.gen.v1.gnpy.path.rev220615.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class GnpyConsumerImpl implements GnpyConsumer {
     private static final Logger LOG = LoggerFactory.getLogger(GnpyConsumerImpl.class);
 
-    private GnpyResource api;
-    JsonStringConverter<Request> gnpyRequestConverter;
-    JsonStringConverter<Result> resultConverter;
+    private final GnpyResource api;
 
     public GnpyConsumerImpl(String baseUrl, String username, String password,
             BindingDOMCodecServices bindingDOMCodecServices) {
-        gnpyRequestConverter = new JsonStringConverter<>(bindingDOMCodecServices);
-        resultConverter = new JsonStringConverter<>(bindingDOMCodecServices);
+        JsonStringConverter<Request> gnpyRequestConverter = new JsonStringConverter<>(bindingDOMCodecServices);
+        JsonStringConverter<Result> resultConverter = new JsonStringConverter<>(bindingDOMCodecServices);
 
-        JsonConfigurator jsonConfigurator = new JsonConfigurator(gnpyRequestConverter, resultConverter);
         Client client = ClientBuilder.newClient();
         HttpAuthenticationFeature authFeature = HttpAuthenticationFeature.basic(username, password);
         client.register(authFeature);
         client.register(new LoggingFeature(java.util.logging.Logger.getLogger(this.getClass().getName())))
-            .register(JacksonFeature.class).register(jsonConfigurator);
+            .register(JacksonFeature.class)
+                .register(new ResultMessageBodyReader(resultConverter))
+                .register(new RequestMessageBodyWriter(gnpyRequestConverter));
         api = WebResourceFactory.newResource(GnpyResource.class, client.target(baseUrl));
     }