Skip to content

Package: ThriftClientManager

ThriftClientManager

Coverage

1: /*
2: * Copyright (c) 2012, 2017 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly.thrift.client;
18:
19: import org.apache.thrift.TServiceClient;
20: import org.apache.thrift.TServiceClientFactory;
21:
22: /**
23: * The interface for managing thrift clients
24: *
25: * @author Bongjae Chang
26: */
27: public interface ThriftClientManager {
28: /**
29: * Creates a new {@link ThriftClientBuilder} for the named thrift client to be
30: * managed by this thrift client manager.
31: * <p>
32: * The returned ThriftClientBuilder is associated with this ThriftClientManager.
33: * The ThriftClient will be created, added to this ThriftClientManager and
34: * started when {@link ThriftClientBuilder#build()} is called.
35: *
36: * @param thriftClientName the name of the thrift client to build. A thrift
37: * client name must consist of at least one non-whitespace character.
38: * @param thriftClientFactory thrift client factory
39: * @return the ThriftClientBuilder for the named thrift client
40: */
41: <T extends TServiceClient> ThriftClientBuilder createThriftClientBuilder(final String thriftClientName,
42: final TServiceClientFactory<T> thriftClientFactory);
43:
44: /**
45: * Looks up a named thrift client.
46: *
47: * @param thriftClientName the name of the thrift client to look for
48: * @return the ThriftClient or null if it does exist
49: */
50: <T extends TServiceClient> ThriftClient<T> getThriftClient(final String thriftClientName);
51:
52: /**
53: * Remove a thrift client from the ThriftClientManager. The thrift client will
54: * be stopped.
55: *
56: * @param thriftClientName the thrift client name
57: * @return true if the thrift client was removed
58: */
59: boolean removeThriftClient(final String thriftClientName);
60:
61: /**
62: * Shuts down the ThriftClientManager.
63: */
64: void shutdown();
65: }