markAsShared();
final ServiceLocator locator = Injections.createLocator(new ClientBinder());
locator.setDefaultClassAnalyzerName(JerseyClassAnalyzer.NAME);
final CommonConfig runtimeConfig = new CommonConfig(this.commonConfig);
// AutoDiscoverable.
if (!PropertiesHelper.getValue(runtimeConfig.getProperties(), RuntimeType.CLIENT,
CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, Boolean.FALSE, Boolean.class)) {
runtimeConfig.configureAutoDiscoverableProviders(locator);
}
// Configure binders and features.
runtimeConfig.configureMetaProviders(locator);
// Bind configuration.
final ExtendedConfig configuration = runtimeConfig.getConfiguration();
final AbstractBinder configBinder = new AbstractBinder() {
@Override
protected void configure() {
bind(configuration).to(Configuration.class);
}
};
final DynamicConfiguration dc = Injections.getConfiguration(locator);
configBinder.bind(dc);
dc.commit();
// Bind providers.
ProviderBinder.bindProviders(runtimeConfig.getComponentBag(), RuntimeType.CLIENT, null, locator);
final ClientRuntime crt = new ClientRuntime(configuration, connector, locator);
client.addListener(new JerseyClient.LifecycleListener() {
@Override
public void onClose() {