Thanks for the help. I figured it out.
It as because I declared my adapter factory service like:
@Component(metatype = false, immediate = true, label = "Brainsciences Facebook
Adapter Factory")
@Service(FacebookAdapterFactory.class)
public class FacebookAdapterFactory implements AdapterFactory {
When I changed it to:
@Component(metatype = false, immediate = true, label = "Brainsciences Facebook
Adapter Factory")
@Service
public class FacebookAdapterFactory implements AdapterFactory {
It works fine.
It was confusing because when declared the first way above it still shows up in
the Sling Adapters. But when you look at the services its type shows up as:
[org.brainsciences.bmn.facebook.services.FacebookAdapterFactory]
And then when I change it to the second declaration above, it still shows up in
the Sling Adapters, and now its type is:
[org.apache.sling.api.adapter.AdapterFactory]
And now it works.
Rob
On Jun 26, 2012, at 9:47 AM, Felix Meschberger wrote:
> Hi
>
> Am 26.06.2012 um 00:34 schrieb Robert A. Decker:
>
>> Hi,
>>
>> I've written an AdapterFactory that appears to be set up correctly. It shows
>> up in my services and has adaptables and adapters. And when I look under the
>> System Console 'Sling Adapters' tab it shows up as well with the proper
>> values under the Adaptable Class column and under the AdapterClass column.
>>
>> However, when I adaptTo on a Resource instance to one of my classes I get
>> null.
>>
>> Out of curiosity I tried adapting the Resource instance to a Node instance
>> and adapting that. However, I get compile time error that I'm unable to
>> resolve the method adaptTo with my class type.
>>
>> I don't get this compile error with Resource or ResourceResolver, but
>> perhaps that's being resolved by something like the AdapterManager… I'm
>> really not sure.
>>
>> But one thing I'm pretty sure is that no code is ever called in my
>> AdapterFactory. I'm not sure when the getAdapter method is called normally
>> but when I put a breakpoint in the method during a bundle install or when I
>> try to do the apaption my breakpoint is never hit…
>>
>> Any ideas? Am I missing a step?
>
> Are you sure to not have confused adapter and adaptable in your
> AdapterFactory ? Your own class would be an adapter and Sling's Resource
> would be adaptable.
>
> Regards
> Felix
>
>