org.eclipse.microprofile.rest.client.inject.RestClient Java Examples

The following examples show how to use org.eclipse.microprofile.rest.client.inject.RestClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestClientProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void setup(BuildProducer<FeatureBuildItem> feature,
        BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        RestClientRecorder restClientRecorder) {

    feature.produce(new FeatureBuildItem(Feature.REST_CLIENT));

    restClientRecorder.setRestClientBuilderResolver();

    additionalBeans.produce(new AdditionalBeanBuildItem(RestClient.class));

    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
            DefaultResponseExceptionMapper.class.getName(),
            AsyncInterceptorRxInvokerProvider.class.getName(),
            ResteasyProviderFactoryImpl.class.getName(),
            ProxyBuilderImpl.class.getName(),
            ClientRequestFilter[].class.getName(),
            ClientResponseFilter[].class.getName(),
            javax.ws.rs.ext.ReaderInterceptor[].class.getName()));

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
            ResteasyClientBuilder.class.getName()));
}
 
Example #2
Source File: GameRound.java    From liberty-bikes with Eclipse Public License 1.0 6 votes vote down vote up
private void updatePlayerStats() {
    if (gameState != State.FINISHED)
        throw new IllegalStateException("Cannot update player stats while game is still running.");

    PlayerService playerSvc = CDI.current().select(PlayerService.class, RestClient.LITERAL).get();
    int rank = 1;
    for (Player p : playerRanks) {
        log("Player " + p.name + " came in place " + rank);
        if (p.isRealPlayer()) {
            String jwt = createJWT();
            String authHeader = "Bearer " + jwt;
            playerSvc.recordGame(p.id, rank, authHeader);
        }
        rank++;
    }
}
 
Example #3
Source File: CDIInvokeAsyncSimpleGetOperationTest.java    From microprofile-rest-client with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the component injected has Dependent scope
 */
@Test
public void testHasDependentScopedByDefault() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApiAsync.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), Dependent.class);
}
 
Example #4
Source File: CDIInvokeSimpleGetOperationTest.java    From microprofile-rest-client with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the component injected has Dependent scope
 */
@Test
public void testHasDependentScopedByDefault() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), Dependent.class);
}
 
Example #5
Source File: HasSingletonScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSingletonScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), Singleton.class);
}
 
Example #6
Source File: RestClientBean.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Annotation> getQualifiers() {
    return new HashSet<>(Arrays.asList(DEFAULT_LITERAL, RestClient.RestClientLiteral.LITERAL));
}
 
Example #7
Source File: HasAppScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasApplicationScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MyAppScopedApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ApplicationScoped.class);
}
 
Example #8
Source File: HasAppScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasApplicationScopedFromConfigKey() {
    Set<Bean<?>> beans = beanManager.getBeans(ConfigKeyClient.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ApplicationScoped.class);
}
 
Example #9
Source File: HasAppScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasApplicationScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ApplicationScoped.class);
}
 
Example #10
Source File: HasRequestScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasRequestScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MyRequestScopedApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), RequestScoped.class);
}
 
Example #11
Source File: HasRequestScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasRequestScopedFromConfigKey() {
    Set<Bean<?>> beans = beanManager.getBeans(ConfigKeyClient.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), RequestScoped.class);
}
 
Example #12
Source File: HasRequestScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasRequestScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), RequestScoped.class);
}
 
Example #13
Source File: HasSingletonScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSingletonScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MySingletonApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), Singleton.class);
}
 
Example #14
Source File: HasSingletonScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSingletonScopedFromConfigKey() {
    Set<Bean<?>> beans = beanManager.getBeans(ConfigKeyClient.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), Singleton.class);
}
 
Example #15
Source File: ClientResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/cdi/mp-rest-default-scope")
@Produces("text/plain")
public String getDefaultScope() {
    return Arc.container().instance(RestInterface.class, RestClient.LITERAL).getBean().getScope().getName();
}
 
Example #16
Source File: HasConversationScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasConversationScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MyConversationScopedApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ConversationScoped.class);
}
 
Example #17
Source File: HasConversationScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasConversationScopedFromConfigKey() {
    Set<Bean<?>> beans = beanManager.getBeans(ConfigKeyClient.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ConversationScoped.class);
}
 
Example #18
Source File: HasConversationScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasConversationScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ConversationScoped.class);
}
 
Example #19
Source File: HasSessionScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSessionScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MySessionScopedApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), SessionScoped.class);
}
 
Example #20
Source File: HasSessionScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSessionScopedFromConfigKey() {
    Set<Bean<?>> beans = beanManager.getBeans(ConfigKeyClient.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), SessionScoped.class);
}
 
Example #21
Source File: HasSessionScopeTest.java    From microprofile-rest-client with Apache License 2.0 4 votes vote down vote up
@Test
public void testHasSingletonScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), SessionScoped.class);
}
 
Example #22
Source File: ClientResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/cdi/default-scope-on-interface")
@Produces("text/plain")
public String getDefaultInterfaceScope() {
    return Arc.container().instance(RestClientInterface.class, RestClient.LITERAL).getBean().getScope().getName();
}