forked from eclipse-ee4j/jersey
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from dukesway/FISH-665
FISH-665 MP Rest Client 2.0 support
- Loading branch information
Showing
53 changed files
with
1,495 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
...client/src/main/java/org/glassfish/jersey/client/ClientComponentProviderConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2017, 2021 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 | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package org.glassfish.jersey.client; | ||
|
||
import org.glassfish.jersey.client.spi.ClientComponentProvider; | ||
import java.util.Collection; | ||
import java.util.Comparator; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.StreamSupport; | ||
|
||
import org.glassfish.jersey.internal.BootstrapBag; | ||
import org.glassfish.jersey.internal.BootstrapConfigurator; | ||
import org.glassfish.jersey.internal.ServiceConfigurationError; | ||
import org.glassfish.jersey.internal.ServiceFinder; | ||
import org.glassfish.jersey.internal.inject.InjectionManager; | ||
import org.glassfish.jersey.internal.util.collection.LazyValue; | ||
import org.glassfish.jersey.internal.util.collection.Value; | ||
import org.glassfish.jersey.internal.util.collection.Values; | ||
import org.glassfish.jersey.model.internal.RankedComparator; | ||
import org.glassfish.jersey.model.internal.RankedProvider; | ||
import org.glassfish.jersey.spi.ComponentProvider; | ||
|
||
/** | ||
* Configurator which initializes and register {@link ClientComponentProvider} | ||
* instances into {@link BootstrapBag}. | ||
* | ||
* @author Petr Bouda | ||
*/ | ||
public class ClientComponentProviderConfigurator implements BootstrapConfigurator { | ||
|
||
private static final Comparator<RankedProvider<ClientComponentProvider>> RANKED_COMPARATOR | ||
= new RankedComparator<>(RankedComparator.Order.DESCENDING); | ||
|
||
@Override | ||
public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { | ||
// There are situation in which ComponentProviders are not needed therefore their entire initialization is wrapped | ||
// into a lazy block. | ||
LazyValue<Collection<ComponentProvider>> componentProviders | ||
= Values.lazy((Value<Collection<ComponentProvider>>) () -> getRankedComponentProviders() | ||
.stream() | ||
.map(RankedProvider::getProvider) | ||
.peek(provider -> provider.initialize(injectionManager)) | ||
.collect(Collectors.toList())); | ||
bootstrapBag.setComponentProviders(componentProviders); | ||
} | ||
|
||
@Override | ||
public void postInit(InjectionManager injectionManager, BootstrapBag bootstrapBag) { | ||
bootstrapBag.getComponentProviders().get().forEach(ComponentProvider::done); | ||
} | ||
|
||
private static Collection<RankedProvider<ClientComponentProvider>> getRankedComponentProviders() | ||
throws ServiceConfigurationError { | ||
return StreamSupport.stream(ServiceFinder.find(ClientComponentProvider.class).spliterator(), false) | ||
.map(RankedProvider::new) | ||
.sorted(RANKED_COMPARATOR) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
core-client/src/main/java/org/glassfish/jersey/client/spi/ClientComponentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2021 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 | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.client.spi; | ||
|
||
import org.glassfish.jersey.spi.ComponentProvider; | ||
|
||
/** | ||
* Component provider interface to allow custom management of 3rd party | ||
* components life-cycle and dependency injection. | ||
* <p /> | ||
* An implementation (a component-provider) identifies itself by placing a provider-configuration | ||
* file (if not already present), {@code org.glassfish.jersey.spi.ComponentProvider} | ||
* in the resource directory <tt>META-INF/services</tt>, and adding the fully | ||
* qualified service-provider-class of the implementation in the file. | ||
* | ||
* Jersey will not even try to inject component provider instances with Jersey artifacts. | ||
* The SPI providers should be designed so that no dependency injection is needed at the bind time phase. | ||
*/ | ||
public interface ClientComponentProvider extends ComponentProvider { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.