private static ApacheConnector getConnector(final Configurable<?> component) { if (!(component instanceof Initializable)) { throw new IllegalArgumentException( LocalizationMessages.INVALID_CONFIGURABLE_COMPONENT_TYPE(component.getClass().getName())); } final Initializable<?> initializable = (Initializable<?>) component; Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector(); } if (connector instanceof ApacheConnector) { return (ApacheConnector) connector; } else { throw new IllegalArgumentException(LocalizationMessages.EXPECTED_CONNECTOR_PROVIDER_NOT_USED()); } } }
/** * Retrieve the underlying Grizzly {@link AsyncHttpClient} instance from * {@link org.glassfish.jersey.client.JerseyClient} or {@link org.glassfish.jersey.client.JerseyWebTarget} * configured to use {@code GrizzlyConnectorProvider}. * * @param component {@code JerseyClient} or {@code JerseyWebTarget} instance that is configured to use * {@code GrizzlyConnectorProvider}. * @return underlying Grizzly {@code AsyncHttpClient} instance. * * @throws java.lang.IllegalArgumentException in case the {@code component} is neither {@code JerseyClient} * nor {@code JerseyWebTarget} instance or in case the component * is not configured to use a {@code GrizzlyConnectorProvider}. * @since 2.8 */ public static AsyncHttpClient getHttpClient(Configurable<?> component) { if (!(component instanceof Initializable)) { throw new IllegalArgumentException( LocalizationMessages.INVALID_CONFIGURABLE_COMPONENT_TYPE(component.getClass().getName())); } final Initializable<?> initializable = (Initializable<?>) component; Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector(); } if (connector instanceof GrizzlyConnector) { return ((GrizzlyConnector) connector).getGrizzlyClient(); } throw new IllegalArgumentException(LocalizationMessages.EXPECTED_CONNECTOR_PROVIDER_NOT_USED()); }
Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector();
private static ApacheConnector getConnector(final Configurable<?> component) { if (!(component instanceof Initializable)) { throw new IllegalArgumentException( LocalizationMessages.INVALID_CONFIGURABLE_COMPONENT_TYPE(component.getClass().getName())); } final Initializable<?> initializable = (Initializable<?>) component; Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector(); } if (connector instanceof ApacheConnector) { return (ApacheConnector) connector; } else { throw new IllegalArgumentException(LocalizationMessages.EXPECTED_CONNECTOR_PROVIDER_NOT_USED()); } } }
Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector();
/** * Retrieve the underlying Grizzly {@link AsyncHttpClient} instance from * {@link org.glassfish.jersey.client.JerseyClient} or {@link org.glassfish.jersey.client.JerseyWebTarget} * configured to use {@code GrizzlyConnectorProvider}. * * @param component {@code JerseyClient} or {@code JerseyWebTarget} instance that is configured to use * {@code GrizzlyConnectorProvider}. * @return underlying Grizzly {@code AsyncHttpClient} instance. * * @throws java.lang.IllegalArgumentException in case the {@code component} is neither {@code JerseyClient} * nor {@code JerseyWebTarget} instance or in case the component * is not configured to use a {@code GrizzlyConnectorProvider}. * @since 2.8 */ public static AsyncHttpClient getHttpClient(Configurable<?> component) { if (!(component instanceof Initializable)) { throw new IllegalArgumentException( LocalizationMessages.INVALID_CONFIGURABLE_COMPONENT_TYPE(component.getClass().getName())); } final Initializable<?> initializable = (Initializable<?>) component; Connector connector = initializable.getConfiguration().getConnector(); if (connector == null) { initializable.preInitialize(); connector = initializable.getConfiguration().getConnector(); } if (connector instanceof GrizzlyConnector) { return ((GrizzlyConnector) connector).getGrizzlyClient(); } throw new IllegalArgumentException(LocalizationMessages.EXPECTED_CONNECTOR_PROVIDER_NOT_USED()); }