system/src/sc/layer/LayeredSystem.java
public void activateLayers(List<String> allLayerNames, List<String> dynLayers) {
      boolean completed = false;
      // TODO: if any of the layer names in the run configuration have changed, throw it all away and restart from scratch.
      // this is the simple approach.  It would not be too hard to figure out the differences, and peel-away unused layers, and
      // add in used ones.  That would make the builds a lot faster I think in some cases since you can save the compiled state of
      // the previous layers.  But maybe a good incremental compile will be fast enough?  And now that we are doing external builds, this is not
      // going to be helpful since these layers are not being built.
      try {
         if (activatedLayerNames == null || !activatedLayerNames.equals(allLayerNames) || !DynUtil.equalObjects(dynLayers, activatedDynLayerNames)) {
            if (activatedLayerNames != null) {
               clearActiveLayers(true);
            }

            activatedLayerNames = new ArrayList<String>(allLayerNames);
            activatedDynLayerNames = dynLayers == null ? null : new ArrayList<String>(dynLayers);
            // This will create layers for all referenced dependent layers. We use this layered system to store that list while
            // we figure out which runtimes and processes we want to include. After that, we mark the ones we will exclude then
            // initialize the runtimes. We also must accumulate the list of processes and runtimes that are actually defined. There
            // might be some layers which are included in a runtime or process, but that runtime or process is not referenced in this
            // set of layers. We remove those layers at the end from all layered systems.
            initLayersWithNames(allLayerNames, false, false, dynLayers, true, false);
            // First mark all layers that will be excluded
            removeExcludedLayers(true);

            // Init the runtimes, using the excluded layers as a guide
            initRuntimes(dynLayers, true, false, true, false);

            ArrayList<IProcessDefinition> procs = new ArrayList<IProcessDefinition>();
            ArrayList<IRuntimeProcessor> runtimes = new ArrayList<IRuntimeProcessor>();
            for (int i = 0; i < layers.size(); i++) { // Get the list of processes and runtimes actually required by this program and then filter the active layers in each runtime by that
               Layer l = layers.get(i);
               if (l.hasDefinedProcess)
                  procs.add(l.definedProcess);
               if (l.hasDefinedRuntime)
                  runtimes.add(l.definedRuntime);
            }
            // When no framework layers are included, no runtimes are defined, need to at least include the default runtime or else no runtime matches
            if (procs.size() == 0 && runtimes.size() == 0)
               runtimes.add(null);

            if (!procs.contains(processDefinition) && ((procs.size() > 0 && processDefinition.getProcessName() != null) || !runtimes.contains(runtimeProcessor))) {
               clearActiveLayers(false);
            }
            else {
               // Now actually remove the excluded layers.
               removeExcludedLayers(false);
            }

            for (int i = 0; i < peerSystems.size(); i++) {
               LayeredSystem peerSys = peerSystems.get(i);
               if (!procs.contains(peerSys.processDefinition) && (peerSys.processDefinition.getProcessName() != null || !runtimes.contains(peerSys.runtimeProcessor)))
                  peerSys.clearActiveLayers(false);
            }

            LayeredSystem runtimeSys = getActiveLayeredSystem(null);
            if (runtimeSys != null)
               runtimeSys.initBuildSystem(true, true);

            buildSeparateLayers();

            // Finally initialize the build system from scratch and we are ready to go.
            initBuildSystem(true, true);

            systemCompiled = false;

            // TODO: do we need to always do a new build when the layers have changed?  We should at least skip this the first time
            //if (!options.buildAllFiles)
            //   options.buildAllFiles = true;

            // Make sure hte layers are started - otherwise, the layers view does not work sin
            if (layers.size() > 0)
               startLayers(layers, false);

            for (int i = 0; i < peerSystems.size(); i++) {
               LayeredSystem peerSys = peerSystems.get(i);
               if (peerSys.layers.size() > 0)
                  peerSys.startLayers(peerSys.layers, false);
            }

         }
         completed = true;
      }
      catch (RuntimeException exc) {
         System.err.println("*** RuntimeException in activateLayers: " + exc);
         throw exc;
      }
      finally {
         if (!completed) {
            System.err.println("*** Clearing active layers - failed to complete");
            clearActiveLayers(true);
            activatedLayerNames = activatedDynLayerNames = null;
         }
         else {
            if (layers.size() == 0) {
               boolean foundLayers = false;
               if (peerSystems != null) {
                  for (int i = 0; i < peerSystems.size(); i++) {
                     LayeredSystem peerSys = peerSystems.get(i);
                     if (peerSys.layers.size() != 0)
                        foundLayers = true;
                  }
               }
               if (!foundLayers) {
                  System.err.println("*** found no active layers after activate!");
               }
            }
         }
      }
   }
/**
    * Provides the complete list of layer names and a separate list of 'recursive dyn layers' - i.e. the subset of allLayerNames
    * that should be explicitly made dynamic.
    */
Provides the complete list of layer names and a separate list of 'recursive dyn layers' - i.e. the subset of allLayerNames
that should be explicitly made dynamic.
Provides the complete list of layer names and a separate list of ' recursive dyn layers ' - i . e . the subset of allLayerNames that should be explicitly made dynamic .
public void activateLayers(List<String> allLayerNames, List<String> dynLayers) {
      boolean completed = false;
      try {
         if (activatedLayerNames == null || !activatedLayerNames.equals(allLayerNames) || !DynUtil.equalObjects(dynLayers, activatedDynLayerNames)) {
            if (activatedLayerNames != null) {
               clearActiveLayers(true);
            }
            activatedLayerNames = new ArrayList<String>(allLayerNames);
            activatedDynLayerNames = dynLayers == null ? null : new ArrayList<String>(dynLayers);
            initLayersWithNames(allLayerNames, false, false, dynLayers, true, false);
            removeExcludedLayers(true);
            initRuntimes(dynLayers, true, false, true, false);
            ArrayList<IProcessDefinition> procs = new ArrayList<IProcessDefinition>();
            ArrayList<IRuntimeProcessor> runtimes = new ArrayList<IRuntimeProcessor>();
            for (int i = 0; i < layers.size(); i++) { 
               Layer l = layers.get(i);
               if (l.hasDefinedProcess)
                  procs.add(l.definedProcess);
               if (l.hasDefinedRuntime)
                  runtimes.add(l.definedRuntime);
            }
            if (procs.size() == 0 && runtimes.size() == 0)
               runtimes.add(null);
            if (!procs.contains(processDefinition) && ((procs.size() > 0 && processDefinition.getProcessName() != null) || !runtimes.contains(runtimeProcessor))) {
               clearActiveLayers(false);
            }
            else {
               removeExcludedLayers(false);
            }
            for (int i = 0; i < peerSystems.size(); i++) {
               LayeredSystem peerSys = peerSystems.get(i);
               if (!procs.contains(peerSys.processDefinition) && (peerSys.processDefinition.getProcessName() != null || !runtimes.contains(peerSys.runtimeProcessor)))
                  peerSys.clearActiveLayers(false);
            }
            LayeredSystem runtimeSys = getActiveLayeredSystem(null);
            if (runtimeSys != null)
               runtimeSys.initBuildSystem(true, true);
            buildSeparateLayers();
            initBuildSystem(true, true);
            systemCompiled = false;
            if (layers.size() > 0)
               startLayers(layers, false);
            for (int i = 0; i < peerSystems.size(); i++) {
               LayeredSystem peerSys = peerSystems.get(i);
               if (peerSys.layers.size() > 0)
                  peerSys.startLayers(peerSys.layers, false);
            }
         }
         completed = true;
      }
      catch (RuntimeException exc) {
         System.err.println("*** RuntimeException in activateLayers: " + exc);
         throw exc;
      }
      finally {
         if (!completed) {
            System.err.println("*** Clearing active layers - failed to complete");
            clearActiveLayers(true);
            activatedLayerNames = activatedDynLayerNames = null;
         }
         else {
            if (layers.size() == 0) {
               boolean foundLayers = false;
               if (peerSystems != null) {
                  for (int i = 0; i < peerSystems.size(); i++) {
                     LayeredSystem peerSys = peerSystems.get(i);
                     if (peerSys.layers.size() != 0)
                        foundLayers = true;
                  }
               }
               if (!foundLayers) {
                  System.err.println("*** found no active layers after activate!");
               }
            }
         }
      }
   }
public void activateLayers ( List < String > allLayerNames , List < String > dynLayers ) { boolean completed = false ; try { if ( activatedLayerNames == null || ! activatedLayerNames . equals ( allLayerNames ) || ! DynUtil . equalObjects ( dynLayers , activatedDynLayerNames ) ) { if ( activatedLayerNames != null ) { clearActiveLayers ( true ) ; } activatedLayerNames = new ArrayList < String > ( allLayerNames ) ; activatedDynLayerNames = dynLayers == null ? null : new ArrayList < String > ( dynLayers ) ; initLayersWithNames ( allLayerNames , false , false , dynLayers , true , false ) ; removeExcludedLayers ( true ) ; initRuntimes ( dynLayers , true , false , true , false ) ; ArrayList < IProcessDefinition > procs = new ArrayList < IProcessDefinition > ( ) ; ArrayList < IRuntimeProcessor > runtimes = new ArrayList < IRuntimeProcessor > ( ) ; for ( int i = 0 ; i < layers . size ( ) ; i ++ ) { Layer l = layers . get ( i ) ; if ( l . hasDefinedProcess ) procs . add ( l . definedProcess ) ; if ( l . hasDefinedRuntime ) runtimes . add ( l . definedRuntime ) ; } if ( procs . size ( ) == 0 && runtimes . size ( ) == 0 ) runtimes . add ( null ) ; if ( ! procs . contains ( processDefinition ) && ( ( procs . size ( ) > 0 && processDefinition . getProcessName ( ) != null ) || ! runtimes . contains ( runtimeProcessor ) ) ) { clearActiveLayers ( false ) ; } else { removeExcludedLayers ( false ) ; } for ( int i = 0 ; i < peerSystems . size ( ) ; i ++ ) { LayeredSystem peerSys = peerSystems . get ( i ) ; if ( ! procs . contains ( peerSys . processDefinition ) && ( peerSys . processDefinition . getProcessName ( ) != null || ! runtimes . contains ( peerSys . runtimeProcessor ) ) ) peerSys . clearActiveLayers ( false ) ; } LayeredSystem runtimeSys = getActiveLayeredSystem ( null ) ; if ( runtimeSys != null ) runtimeSys . initBuildSystem ( true , true ) ; buildSeparateLayers ( ) ; initBuildSystem ( true , true ) ; systemCompiled = false ; if ( layers . size ( ) > 0 ) startLayers ( layers , false ) ; for ( int i = 0 ; i < peerSystems . size ( ) ; i ++ ) { LayeredSystem peerSys = peerSystems . get ( i ) ; if ( peerSys . layers . size ( ) > 0 ) peerSys . startLayers ( peerSys . layers , false ) ; } } completed = true ; } catch ( RuntimeException exc ) { System . err . println ( "*** RuntimeException in activateLayers: " + exc ) ; throw exc ; } finally { if ( ! completed ) { System . err . println ( "*** Clearing active layers - failed to complete" ) ; clearActiveLayers ( true ) ; activatedLayerNames = activatedDynLayerNames = null ; } else { if ( layers . size ( ) == 0 ) { boolean foundLayers = false ; if ( peerSystems != null ) { for ( int i = 0 ; i < peerSystems . size ( ) ; i ++ ) { LayeredSystem peerSys = peerSystems . get ( i ) ; if ( peerSys . layers . size ( ) != 0 ) foundLayers = true ; } } if ( ! foundLayers ) { System . err . println ( "*** found no active layers after activate!" ) ; } } } } }
Provides the complete list of layer names and a separate list of 'recursive dyn layers' - i.e.
Provides the complete list of layer names and a separate list of ' recursive dyn layers ' - i . e .
// TODO: if any of the layer names in the run configuration have changed, throw it all away and restart from scratch. // this is the simple approach.  It would not be too hard to figure out the differences, and peel-away unused layers, and // add in used ones.  That would make the builds a lot faster I think in some cases since you can save the compiled state of // the previous layers.  But maybe a good incremental compile will be fast enough?  And now that we are doing external builds, this is not // going to be helpful since these layers are not being built. // This will create layers for all referenced dependent layers. We use this layered system to store that list while // we figure out which runtimes and processes we want to include. After that, we mark the ones we will exclude then // initialize the runtimes. We also must accumulate the list of processes and runtimes that are actually defined. There // might be some layers which are included in a runtime or process, but that runtime or process is not referenced in this // set of layers. We remove those layers at the end from all layered systems. // First mark all layers that will be excluded // Init the runtimes, using the excluded layers as a guide // Get the list of processes and runtimes actually required by this program and then filter the active layers in each runtime by that // When no framework layers are included, no runtimes are defined, need to at least include the default runtime or else no runtime matches // Now actually remove the excluded layers. // Finally initialize the build system from scratch and we are ready to go. // TODO: do we need to always do a new build when the layers have changed?  We should at least skip this the first time //if (!options.buildAllFiles) //   options.buildAllFiles = true; // Make sure hte layers are started - otherwise, the layers view does not work sin