Skip to content

Commit

Permalink
Optional Injection-less client side for SE (#5232)
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed Feb 16, 2023
1 parent 55b7aa9 commit 149650d
Show file tree
Hide file tree
Showing 70 changed files with 1,895 additions and 296 deletions.
@@ -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
@@ -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
@@ -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

0 comments on commit 149650d

Please sign in to comment.