Package io.quarkus.arc
Interface ClientProxy
-
public interface ClientProxy
Represents a client proxy - a contextual reference to a bean with a normal scope.Client proxy delegates all method invocations to a target contextual instance. Note that only method invocations are delegated. So a field of a normal scoped bean should never be read or written in order to avoid working with non-contextual or stale data.
In general, client proxies allow for:
- Lazy instantiation - the instance is created once a method is invoked upon the proxy.
- Ability to inject a bean with "narrower" scope to a bean with "wider" scope; i.e. you can inject a
@RequestScoped
bean into an@ApplicationScoped
bean. - Circular dependencies in the dependency graph. Having circular dependencies is often an indication that a redesign should be considered, but sometimes it’s inevitable.
- In rare cases it’s practical to destroy the beans manually. A direct injected reference would lead to a stale bean instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description InjectableBean<?>
arc_bean()
Object
arc_contextualInstance()
static <T> T
unwrap(T obj)
Attempts to unwrap the object if it represents a client proxy.
-
-
-
Method Detail
-
arc_contextualInstance
Object arc_contextualInstance()
- Returns:
- the contextual instance
-
arc_bean
InjectableBean<?> arc_bean()
- Returns:
- the bean
-
unwrap
static <T> T unwrap(T obj)
Attempts to unwrap the object if it represents a client proxy.This method should only be used with caution. If you unwrap a client proxy then certain key functionality will not work as expected.
- Type Parameters:
T
-- Parameters:
obj
-- Returns:
- the contextual instance if the object represents a client proxy, the object otherwise
-
-