Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Injection-less client side for SE #5232

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -43,10 +43,15 @@
@ConstrainedTo(RuntimeType.CLIENT)
class ChunkedInputReader implements MessageBodyReader<ChunkedInput> {

private final Provider<MessageBodyWorkers> messageBodyWorkers;
private final Provider<PropertiesDelegate> propertiesDelegateProvider;

@Inject
private Provider<MessageBodyWorkers> messageBodyWorkers;
@Inject
private Provider<PropertiesDelegate> propertiesDelegateProvider;
public ChunkedInputReader(Provider<MessageBodyWorkers> messageBodyWorkers,
Provider<PropertiesDelegate> propertiesDelegateProvider) {
this.messageBodyWorkers = messageBodyWorkers;
this.propertiesDelegateProvider = propertiesDelegateProvider;
}

@Override
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018 Payara Foundation and/or its affiliates.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -35,6 +35,7 @@
import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.ExtendedConfig;
import org.glassfish.jersey.client.internal.LocalizationMessages;
import org.glassfish.jersey.client.innate.inject.NonInjectionManager;
import org.glassfish.jersey.client.internal.inject.ParameterUpdaterConfigurator;
import org.glassfish.jersey.client.spi.Connector;
import org.glassfish.jersey.client.spi.ConnectorProvider;
Expand Down Expand Up @@ -410,7 +411,7 @@ private ClientRuntime initRuntime() {
final State runtimeCfgState = this.copy();
runtimeCfgState.markAsShared();

InjectionManager injectionManager = Injections.createInjectionManager();
final InjectionManager injectionManager = findInjectionManager();
injectionManager.register(new ClientBinder(runtimeCfgState.getProperties()));

final ClientBootstrapBag bootstrapBag = new ClientBootstrapBag();
Expand Down Expand Up @@ -471,6 +472,14 @@ private ClientRuntime initRuntime() {
return crt;
}

private final InjectionManager findInjectionManager() {
try {
return Injections.createInjectionManager(RuntimeType.CLIENT);
} catch (IllegalStateException ise) {
return new NonInjectionManager(true);
}
}

@Override
public boolean equals(final Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -49,10 +49,15 @@
* @author Martin Matula
*/
public final class EncodingFilter implements ClientRequestFilter {
@Inject
private InjectionManager injectionManager;

private final InjectionManager injectionManager;
private volatile List<Object> supportedEncodings = null;

@Inject
public EncodingFilter(InjectionManager injectionManager) {
this.injectionManager = injectionManager;
}

@Override
public void filter(ClientRequestContext request) throws IOException {
if (getSupportedEncodings().isEmpty()) {
Expand Down
Loading