ConfigurationManagerAdapterFactory.java 3.44 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.ReferenceStrategy
 *  org.apache.felix.scr.annotations.References
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.adapter.Adaption
 *  org.apache.sling.api.adapter.AdapterFactory
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.day.cq.wcm.webservicesupport.impl;

import com.day.cq.wcm.webservicesupport.ConfigurationManager;
import com.day.cq.wcm.webservicesupport.ConfigurationManagerFactory;
import com.day.cq.wcm.webservicesupport.impl.ConfigurationManagerImpl;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceStrategy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.adapter.Adaption;
import org.apache.sling.api.adapter.AdapterFactory;
import org.apache.sling.api.resource.ResourceResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component
@Service(value={AdapterFactory.class, ConfigurationManagerFactory.class})
@Properties(value={@Property(name="service.description", value={"Default Configurations Adapter"})})
@References(value={@Reference(referenceInterface=Adaption.class, name="$$scr$$ignore0", strategy=ReferenceStrategy.LOOKUP, target="(&(adaptables=org.apache.sling.api.resource.Resource)(adapters=com.day.cq.wcm.webservicesupport.Configuration))"), @Reference(referenceInterface=Adaption.class, name="$$scr$$ignore1", strategy=ReferenceStrategy.LOOKUP, target="(&(adaptables=org.apache.sling.api.resource.Resource)(adapters=com.day.cq.wcm.webservicesupport.Service))")})
public class ConfigurationManagerAdapterFactory
implements AdapterFactory,
ConfigurationManagerFactory {
    private final Logger log;
    private static final Class<ResourceResolver> RESOURCERESOLVER_CLASS = ResourceResolver.class;
    private static final Class<ConfigurationManager> CONFIGURATIONMANAGER_CLASS = ConfigurationManager.class;
    @Property(name="adapters")
    protected static final String[] ADAPTER_CLASSES = new String[]{CONFIGURATIONMANAGER_CLASS.getName()};
    @Property(name="adaptables")
    protected static final String[] ADAPTABLE_CLASSES = new String[]{RESOURCERESOLVER_CLASS.getName()};

    public ConfigurationManagerAdapterFactory() {
        this.log = LoggerFactory.getLogger(this.getClass());
    }

    public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
        if (adaptable instanceof ResourceResolver) {
            return this.getAdapter((ResourceResolver)adaptable, type);
        }
        this.log.warn("Unable to handle adaptable {}", (Object)adaptable.getClass().getName());
        return null;
    }

    private <AdapterType> AdapterType getAdapter(ResourceResolver resourceResolver, Class<AdapterType> type) {
        return (AdapterType)this.getConfigurationManager(resourceResolver);
    }

    @Override
    public ConfigurationManager getConfigurationManager(ResourceResolver resolver) {
        return new ConfigurationManagerImpl(resolver);
    }
}