Adapters tab on the Felix Console.
The Sling Adapters Console does rely on additional metadata to retrieve the list of Adapters, so you may have to add some additional annotations to get existing custom adaptors to display on this list.
To get your custom Adapter to display in the Sling Adapters Console, it should implement the org.apache.sling.api.adapter.AdapterFactory interface and has the following Felix properties:
adaptables - Classes which this adapter can adapt
adapters - Classes to which the adaptables can be adapted
adapter.condition - (optional) under what conditions the adaptables can be adapted to the adapters
An example of what the annotations would look like would be:
@Component
@Service(value = AdapterFactory.class)
@Properties({
@Property(name = "adaptables", value = "org.apache.sling.api.resource.Resource"),
@Property(name="adapter.condition", value="Any existing resource"),
@Property(name = "service.vendor", value = "Six Dimensions"),
@Property(name = "service.description", value = "Service for adapting Sling Resources to JSON Objects.") ,
@Property(name = "adapters", value = { "org.apache.sling.commons.json.JSONObject" }) })
This provides the metadata for an adapter that adapts Sling Resources to JSONObjects.
To read more on the genesis of the Sling Adapters Console, read the proposal discussion on Nabble:
apache-sling.73963.n3.nabble.com/PROPOSAL-add-Adapter-Metadata-services-td3501542.html
The Sling Adapters Console does rely on additional metadata to retrieve the list of Adapters, so you may have to add some additional annotations to get existing custom adaptors to display on this list.
To get your custom Adapter to display in the Sling Adapters Console, it should implement the org.apache.sling.api.adapter.AdapterFactory interface and has the following Felix properties:
adaptables - Classes which this adapter can adapt
adapters - Classes to which the adaptables can be adapted
adapter.condition - (optional) under what conditions the adaptables can be adapted to the adapters
An example of what the annotations would look like would be:
@Component
@Service(value = AdapterFactory.class)
@Properties({
@Property(name = "adaptables", value = "org.apache.sling.api.resource.Resource"),
@Property(name="adapter.condition", value="Any existing resource"),
@Property(name = "service.vendor", value = "Six Dimensions"),
@Property(name = "service.description", value = "Service for adapting Sling Resources to JSON Objects.") ,
@Property(name = "adapters", value = { "org.apache.sling.commons.json.JSONObject" }) })
This provides the metadata for an adapter that adapts Sling Resources to JSONObjects.
To read more on the genesis of the Sling Adapters Console, read the proposal discussion on Nabble:
apache-sling.73963.n3.nabble.com/PROPOSAL-add-Adapter-Metadata-services-td3501542.html
No comments:
Post a Comment
If you have any doubts or questions, please let us know.