-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
feature-requestTicket will request a new featureTicket will request a new featurepriority-lowHas a low priority, maybe something else might be more pressingHas a low priority, maybe something else might be more pressing
Milestone
Description
Type of feature request
A completely New Feature
What kind of feature would you like to see
The annotation processor can, in a lot of situations generate code that is kind of "pre-compiled".
For example: If you have any dependencies in a method annotated with @aspect, the annotation processor will generate an instance of the AspectHandler interface and declare these as constructor parameters, hence declaring them as required parameters.
In contrast to that, you might be tempted to not have them as a constructor parameter, but fetch them from the WireRepository lazily and on demand.
This can be used, if classes are commonly exchanged in the BeanContainer during runtime.
Code Examples
public class MyHandler {
@Aspect(around = Example.class)
@LifecycleScope(COMPILE)
public Object handle(ExecutionContext<Example> context, MyService myService) {
// ...
}
}Will compile to:
@Wire
@Generated
public final class MyHandler$handle$AspectHandler implements AspectHandler<Example> {
private final MyHandler delegate;
private final MyService myService;
protected TransactionalHandler$handle$AspectHandler(
MyHandler delegate,
MyService myService
) {
this.delegate = delegate;
this.myService = myService;
}
@Override
@Nullable
public final Object process(@NotNull final ExecutionContext<Transactional> context) {
return delegate.handle(
context,
myService
);
}
}whilst
public class MyHandler {
@Aspect(around = Example.class)
@LifecycleScope(RUNTIME)
public Object handle(ExecutionContext<Example> context, MyService myService) {
// ...
}
}Will compile to:
@Wire
@Generated
public final class MyHandler$handle$AspectHandler implements AspectHandler<Example> {
private final MyHandler delegate;
private final WireRepository wireRepository;
protected TransactionalHandler$handle$AspectHandler(
MyHandler delegate,
WireRepository wireRepository
) {
this.delegate = delegate;
this.wireRepository = wireRepository;
}
@Override
@Nullable
public final Object process(@NotNull final ExecutionContext<Transactional> context) {
return delegate.handle(
context,
wireRepository.require(MyService.class) // fetch the dependency on demand
);
}
}Feature Design
No response
Metadata
Metadata
Assignees
Labels
feature-requestTicket will request a new featureTicket will request a new featurepriority-lowHas a low priority, maybe something else might be more pressingHas a low priority, maybe something else might be more pressing