| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package io.v.impl.google.rpc; |
| |
| import io.v.v23.rpc.AddressChooser; |
| import io.v.v23.rpc.NetworkAddress; |
| import io.v.v23.verror.VException; |
| |
| /** |
| * An implementation of {@link AddressChooser} interface that calls to native |
| * code for most of its functionalities. |
| */ |
| public class AddressChooserImpl implements AddressChooser { |
| private final long nativePtr; |
| |
| private native NetworkAddress[] nativeChoose(long nativePtr, |
| String protocol, NetworkAddress[] candidates) throws VException; |
| private native void nativeFinalize(long nativePtr); |
| |
| private AddressChooserImpl(long nativePtr) { |
| this.nativePtr = nativePtr; |
| } |
| @Override |
| public NetworkAddress[] choose(String protocol, NetworkAddress[] candidates) throws VException { |
| return nativeChoose(this.nativePtr, protocol, candidates); |
| } |
| @Override |
| protected void finalize() { |
| nativeFinalize(this.nativePtr); |
| } |
| } |