Hey,
I am using Sling and Felix (Day CQ to be exact).
I am trying to provide my own AdapterFactory so that I can do
resource.adaptTo(Foo.class);
This is what I have:
@Component(name="...", metatype=false, immediate=true)
@Service
public class FooAdapterFactory implements AdapterFactory {
...
@Property(value={Resource.class.getCanonicalName()})
private static final String ADAPTERS = AdapterFactory.ADAPTER_CLASSES;
}
Obviously, this won't compile because Resource.class.getCanonicalName() is
not constant expression.
Workaround would be using String literal:
@Property(value={"org.apache.sling.api.resource.Resource"})
private static final String ADAPTERS = AdapterFactory.ADAPTER_CLASSES;
Is there other way to register AdapterFactory to Felix?
@Property annotation does not take Class ....
And I don't want to use string literal.
Thanks.