Hi,
I've implemented the ability to inject custom resources into components. There were a number of use cases around support for caching and injecting specific types of resources such as Redis clients into components.
I originally mentioned I wanted to create an @Injectable annotation to support this. However, in looking at it further, I realized the existing @Resource annotation fits this and the custom injectables are "application resources" as opposed to "system resources" (services provided by the runtime).
To use this feature:
1. Create an application resource factory with the DSL in a Provider:
@Provides
public static Composite createComposite() {
QName name = new QName(Namespaces.F3, "ResourceComposite");
CompositeBuilder builder = CompositeBuilder.newBuilder(name);
// the resource is created using ApplicationResourceBuilder by passing a name and a Supplier and added to the composite
builder.resource(ApplicationResourceBuilder.newBuilder("AppResource", SomeResourceImpl::new).build()).deployable();
return builder.build();
}
2. Inject the resource on a component:
@Resource(name = "AppResource")
protected SomeResource resource;
I think this should solve the issue of integrating F3 with caches and other third-party libraries. Let me know how it works.
Jim