Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.activecq.core;
- import org.apache.sling.api.adapter.AdapterFactory;
- import org.apache.sling.api.resource.Resource;
- import org.osgi.service.component.ComponentContext;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import com.activecq.core.ActiveComponent;
- /**
- * AdapterFactory that adapts Resources to the ActiveComponent class.
- *
- * @scr.component metatype="no" immediate="true"
- * @scr.property name="service.vendor" value="Active CQ"
- * @scr.property name="service.description" value="Active Component Adapter"
- * @scr.property name="adaptables"
- * values.0="org.apache.sling.api.resource.Resource"
- * @scr.property name="adapters"
- * values.0="com.activecq.core.ActiveComponent"
- * @scr.service interface="org.apache.sling.api.adapter.AdapterFactory"
- */
- public class ActiveComponentAdapterFactory implements AdapterFactory {
- private static final Logger log = LoggerFactory.getLogger(ActiveComponentAdapterFactory.class);
- // ---------- AdapterFactory -----------------------------------------------
- @SuppressWarnings("unchecked")
- public <AdapterType> AdapterType getAdapter(Object adaptable,
- Class<AdapterType> type) {
- log.info("### Adapting Resource to ActiveComponent");
- if(!(adaptable instanceof Resource)) { return null; }
- Resource resource = (Resource) adaptable;
- return (AdapterType) new ActiveComponent(resource);
- }
- protected void activate(ComponentContext context) {
- }
- protected void deactivate(ComponentContext context) {
- }
- }
Add Comment
Please, Sign In to add comment