AppCacheManagerAdapterFactory.java 4.87 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.contentsync.ContentSyncManager
 *  com.day.cq.replication.Replicator
 *  com.day.jcr.vault.packaging.Packaging
 *  javax.jcr.Session
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.resource.ResourceResolverFactory
 *  org.apache.sling.jcr.api.SlingRepository
 *  org.osgi.service.cm.ConfigurationAdmin
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.cq.mobile.appcache.impl;

import com.adobe.cq.mobile.appcache.impl.AppCacheManager;
import com.adobe.cq.mobile.appcache.impl.AppCacheManagerImpl;
import com.day.cq.contentsync.ContentSyncManager;
import com.day.cq.replication.Replicator;
import com.day.jcr.vault.packaging.Packaging;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.cm.ConfigurationAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(metatype=0)
@Service(value={AppCacheManagerAdapterFactory.class})
public class AppCacheManagerAdapterFactory {
    private static final Logger LOGGER = LoggerFactory.getLogger(AppCacheManagerAdapterFactory.class);
    @Property(name="adapters", propertyPrivate=1)
    private static final String[] ADAPTER_CLASSES = new String[]{AppCacheManager.class.getName()};
    @Property(name="adaptables", propertyPrivate=1)
    private static final String[] ADAPTABLE_CLASSES = new String[]{Session.class.getName()};
    @Reference
    private ContentSyncManager contentSyncManager;
    @Reference
    private Replicator replicator;
    @Reference
    private Packaging packagingService;
    @Reference
    private ConfigurationAdmin configurationAdmin = null;
    @Reference
    private SlingRepository repository;
    @Reference
    private ResourceResolverFactory resourceResolverFactory;

    public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
        if (adaptable instanceof Session) {
            return this.getAdapter((Session)adaptable, type);
        }
        LOGGER.info("Can't adapt {} to {}", (Object)(adaptable == null ? "null" : adaptable.getClass().getName()), type);
        return null;
    }

    private <AdapterType> AdapterType getAdapter(Session session, Class<AdapterType> type) {
        if (AppCacheManager.class == type) {
            AppCacheManagerImpl impl = new AppCacheManagerImpl(session, this.contentSyncManager, this.replicator, this.packagingService, this.configurationAdmin, this.repository, this.resourceResolverFactory);
            return (AdapterType)impl;
        }
        return null;
    }

    protected void bindContentSyncManager(ContentSyncManager contentSyncManager) {
        this.contentSyncManager = contentSyncManager;
    }

    protected void unbindContentSyncManager(ContentSyncManager contentSyncManager) {
        if (this.contentSyncManager == contentSyncManager) {
            this.contentSyncManager = null;
        }
    }

    protected void bindReplicator(Replicator replicator) {
        this.replicator = replicator;
    }

    protected void unbindReplicator(Replicator replicator) {
        if (this.replicator == replicator) {
            this.replicator = null;
        }
    }

    protected void bindPackagingService(Packaging packaging) {
        this.packagingService = packaging;
    }

    protected void unbindPackagingService(Packaging packaging) {
        if (this.packagingService == packaging) {
            this.packagingService = null;
        }
    }

    protected void bindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
        this.configurationAdmin = configurationAdmin;
    }

    protected void unbindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
        if (this.configurationAdmin == configurationAdmin) {
            this.configurationAdmin = null;
        }
    }

    protected void bindRepository(SlingRepository slingRepository) {
        this.repository = slingRepository;
    }

    protected void unbindRepository(SlingRepository slingRepository) {
        if (this.repository == slingRepository) {
            this.repository = null;
        }
    }

    protected void bindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
        this.resourceResolverFactory = resourceResolverFactory;
    }

    protected void unbindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
        if (this.resourceResolverFactory == resourceResolverFactory) {
            this.resourceResolverFactory = null;
        }
    }
}