package com.camunda.fox.cockpit.spi.engine.impl;

import com.camunda.fox.cockpit.spi.engine.ConfigurableProcessEngineLookup;
import com.camunda.fox.cockpit.spi.engine.ProcessEngines;
import com.camunda.fox.cockpit.persistence.CockpitQueryCommandExecutor;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import org.activiti.engine.ProcessEngine;

/**
 *
 * @author nico.rehwaldt
 */
@SessionScoped
public class PlatformProcessEngineLookup implements ConfigurableProcessEngineLookup, Serializable {
  
  @Inject
  private ProcessEngines processEnginesProvider;
  
  protected ProcessEngine engine; 
  protected CockpitQueryCommandExecutor executor;
  
  @Override
  public ProcessEngine getProcessEngine() {
    if (engine == null) {
      initUsing(getDefaultProcessEngine());
    }
    return engine;
  }
  
  @Override
  public boolean isConfigurable() {
    return true;
  }
  
  @Override
  public void setProcessEngine(ProcessEngine engine) {
    initUsing(engine);
  }
  
  @Produces
  @RequestScoped
  public CockpitQueryCommandExecutor getCockpitCommandExecutor() {
    if (executor == null) {
      initUsing(getDefaultProcessEngine());
    }
    return executor;
  }

  private ProcessEngine getDefaultProcessEngine() {
    return processEnginesProvider.getDefaultProcessEngine();
  }
  
  private void initUsing(ProcessEngine engine) {
    this.engine = engine;
    this.executor = CockpitQueryCommandExecutor.createFromEngine(engine);
  }

  @Override
  public void ungetProcessEngine() {
    // Platform
  }
}

@@ -47,213 +47,8 @@
 l;%0A%0A
-import com.camunda.fox.cockpit.spi.engine.ConfigurableProcessEngineLookup;%0Aimport com.camunda.fox.cockpit.spi.engine.ProcessEngines;%0Aimport com.camunda.fox.cockpit.persistence.CockpitQueryCommandExecutor;%0A
 impo
@@ -72,16 +72,17 @@
 izable;%0A
+%0A
 import j
@@ -236,16 +236,17 @@
 Inject;%0A
+%0A
 import o
@@ -280,16 +280,217 @@
 ngine;%0A%0A
+import com.camunda.fox.cockpit.persistence.CockpitCommandExecutor;%0Aimport com.camunda.fox.cockpit.spi.engine.ConfigurableProcessEngineLookup;%0Aimport com.camunda.fox.cockpit.spi.engine.ProcessEngines;%0A%0A
 /**%0A *%0A 
@@ -743,37 +743,32 @@
 rotected Cockpit
-Query
 CommandExecutor 
@@ -1144,37 +1144,32 @@
   public Cockpit
-Query
 CommandExecutor 
@@ -1497,16 +1497,16 @@
 engine;%0A
+
     this
@@ -1528,13 +1528,8 @@
 kpit
-Query
 Comm

Fix renaming of component in cockpit webapp fox