ActivationCallbackFactory.java 2.17 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  javax.jcr.Node
 *  javax.jcr.Session
 *  org.apache.felix.scr.annotations.Activate
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Deactivate
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 */
package com.adobe.aemfd.watchfolder.factory;

import com.adobe.aemfd.watchfolder.spi.ActivationCallback;
import com.adobe.aemfd.watchfolder.workflow.WorkflowLauncherHandler;
import java.util.ArrayList;
import java.util.List;
import javax.jcr.Node;
import javax.jcr.Session;
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.Reference;
import org.apache.felix.scr.annotations.Service;

@Component(immediate=1)
@Service(value={ActivationCallbackFactory.class})
public class ActivationCallbackFactory {
    @Reference
    private WorkflowLauncherHandler workflowLauncherHandler;
    private List<ActivationCallback> callbacks = new ArrayList<ActivationCallback>();

    @Activate
    public void activate() {
        this.callbacks.add(this.workflowLauncherHandler);
    }

    @Deactivate
    public void deactivate() {
        this.callbacks.clear();
    }

    public void onLocalConfigNodeAdd(String watchFolderId, Node configNode) throws Exception {
        for (ActivationCallback c : this.callbacks) {
            c.onLocalConfigNodeAdd(watchFolderId, configNode);
        }
    }

    public void onLocalConfigNodeDelete(Session session, String watchFolderId) throws Exception {
        for (ActivationCallback c : this.callbacks) {
            c.onLocalConfigNodeDelete(session, watchFolderId);
        }
    }

    protected void bindWorkflowLauncherHandler(WorkflowLauncherHandler workflowLauncherHandler) {
        this.workflowLauncherHandler = workflowLauncherHandler;
    }

    protected void unbindWorkflowLauncherHandler(WorkflowLauncherHandler workflowLauncherHandler) {
        if (this.workflowLauncherHandler == workflowLauncherHandler) {
            this.workflowLauncherHandler = null;
        }
    }
}