本文整理匯總了Java中io.dropwizard.client.JerseyClientBuilder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java JerseyClientBuilder.build方法的具體用法?Java JerseyClientBuilder.build怎麽用?Java JerseyClientBuilder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.dropwizard.client.JerseyClientBuilder
的用法示例。
在下文中一共展示了JerseyClientBuilder.build方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import io.dropwizard.client.JerseyClientBuilder; //導入方法依賴的package包/類
@Override
public void run(ServerConfiguration configuration, Environment environment) throws Exception {
environment.jersey().disable();
// Create dataserver client
final JerseyClientBuilder jerseyClientBuilder = new JerseyClientBuilder(environment).using(configuration.getDataserverClientConfig());
final DataserverClient dataserverClient = new DataserverClient(jerseyClientBuilder.build("dataserver"), configuration.getDataserverClientConfig());
// Create session manager
final SessionManager sessionManager = new SessionManager(dataserverClient);
environment.lifecycle().manage(sessionManager);
// Create blind acceptor
final ClientAcceptor acceptor = new ClientAcceptor(environment.metrics(), configuration.getPort());
environment.lifecycle().manage(acceptor);
// TODO: This should really be handled in some kind of configuration?
acceptor.addPacketHandler(67, new PingHandler());
acceptor.addPacketHandler(0, new LoginHandler(sessionManager, environment.metrics(), (RSAPrivateKey) configuration.getKeyPair().getPrivate()));
acceptor.addPacketHandler(29, new LogoutHandler());
// TODO: Register outgoing message types, these should also be in some config
// acceptor.addPacketType(131, SystemMessagePacket.class); // TODO: I don't think these IDs are correct
// acceptor.addPacketType(93, ShowBankScreenPacket.class);
// acceptor.addPacketType(0, SetPositionPacket.class);
}
示例2: createRestClient
import io.dropwizard.client.JerseyClientBuilder; //導入方法依賴的package包/類
private static Client createRestClient(Environment environment, SamConfiguration configuration, String name) {
final JerseyClientBuilder builder = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration());
if (configuration.isLogRequests()) {
builder.withProvider(new LoggingFeature(HTTP_LOGGER, Level.INFO, Verbosity.PAYLOAD_ANY, LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));
}
return builder.build(name);
}
示例3: buildJerseyClient
import io.dropwizard.client.JerseyClientBuilder; //導入方法依賴的package包/類
public Client buildJerseyClient(JerseyClientConfiguration configuration, String clientName)
{
ConnectorProvider localConnectorProvider;
if ( connectorProvider != null )
{
localConnectorProvider = connectorProvider;
}
else
{
HttpClientBuilder apacheHttpClientBuilder = new HttpClientBuilder(environment).using(configuration);
CloseableHttpClient closeableHttpClient = apacheHttpClientBuilder.build(clientName);
localConnectorProvider = new JerseyRetryConnectorProvider(retryComponents, closeableHttpClient, configuration.isChunkedEncodingEnabled());
}
JerseyClientBuilder builder = new JerseyClientBuilder(environment)
.using(configuration)
.using(localConnectorProvider);
for ( Class<?> klass : providerClasses )
{
builder = builder.withProvider(klass);
}
for ( Object provider : providers )
{
builder = builder.withProvider(provider);
}
Client client = builder
.build(clientName);
SoaBundle.getFeatures(environment).putNamed(client, Client.class, clientName);
return client;
}