ServiceInputProcessor.java 1.93 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Activate
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Deactivate
 *  org.apache.felix.scr.annotations.Service
 *  org.osgi.framework.BundleContext
 */
package com.adobe.aemfd.watchfolder.service;

import com.adobe.aemfd.watchfolder.config.WatchFolderConfiguration;
import com.adobe.aemfd.watchfolder.service.ServiceCallback;
import com.adobe.aemfd.watchfolder.service.ServiceInvoker;
import com.adobe.aemfd.watchfolder.service.api.ContentProcessor;
import com.adobe.aemfd.watchfolder.service.api.ProcessorContext;
import com.adobe.aemfd.watchfolder.util.AbstractSyncInputProcessor;
import java.io.File;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.BundleContext;

@Component(immediate=1)
@Service(value={ServiceInputProcessor.class})
public class ServiceInputProcessor
extends AbstractSyncInputProcessor {
    private BundleContext bundleContext;

    @Activate
    public void activate(BundleContext bundleContext) {
        this.bundleContext = bundleContext;
    }

    protected void doProcess(String jobId, WatchFolderConfiguration config, File source, final ProcessorContext ctxt) throws Exception {
        String filter = config.getInputProcessorId();
        ServiceInvoker cpi = new ServiceInvoker();
        cpi.lookupAndInvoke(this.bundleContext, ContentProcessor.class, filter, new ServiceCallback<ContentProcessor, Void>(){

            @Override
            public Void execute(ContentProcessor service) throws Exception {
                service.processInputs(ctxt);
                return null;
            }
        });
    }

    @Deactivate
    public void deactivate() {
        this.bundleContext = null;
    }

}