TimelineAdapterFactory.java 2.11 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  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.adapter.AdapterFactory
 *  org.apache.sling.api.resource.Resource
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.granite.timeline.internal;

import com.adobe.granite.timeline.Timeline;
import com.adobe.granite.timeline.TimelineAggregator;
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.adapter.AdapterFactory;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
@Component
@Service
public class TimelineAdapterFactory
implements AdapterFactory {
    private static final Logger log = LoggerFactory.getLogger(TimelineAdapterFactory.class);
    @Property(name="adapters", propertyPrivate=1)
    private static final String[] ADAPTER_CLASSES = new String[]{Timeline.class.getName()};
    @Property(name="adaptables", propertyPrivate=1)
    private static final String[] ADAPTABLE_CLASSES = new String[]{Resource.class.getName()};
    @Reference
    private TimelineAggregator timelineAggregator;

    public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
        if (adaptable instanceof Resource) {
            return (AdapterType)this.timelineAggregator.createTimeline((Resource)adaptable);
        }
        return null;
    }

    protected void bindTimelineAggregator(TimelineAggregator timelineAggregator) {
        this.timelineAggregator = timelineAggregator;
    }

    protected void unbindTimelineAggregator(TimelineAggregator timelineAggregator) {
        if (this.timelineAggregator == timelineAggregator) {
            this.timelineAggregator = null;
        }
    }
}