/*
(non-Javadoc)

@see jade.core.Agent#setup()
421247
public void setup() {
        JadeAgentIntrospector.getMyInstance(this);
        LogActivator.logToFile(logger, this.getName(), Level.ALL);
        this.template = MessageTemplate.MatchAll();
        addBehaviour(new RequestServer());
    }
396002
void setup() {
    // Cannot set wait for confirmed kill mode if cannot check if task is alive
    if (supportsIsTaskAlive()) {
      waitForConfirmedKill = getConf().getBoolean(WAIT_FOR_CONFIRMED_KILL_KEY,
          WAIT_FOR_CONFIRMED_DEFAULT);
      confirmedKillRetries = getConf().getInt(CONFIRMED_KILL_RETRIES_KEY,
          CONFIRMED_KILL_RETRIES_DEFAULT);
    }
    LOG.info("setup: waitForConfirmedKill=" + waitForConfirmedKill +
        ", confirmedKillRetries=" + confirmedKillRetries);
  }
625232
public void init() {
    Configuration.Builder configuration = Configuration.newBuilder();
    configuration.setStopAtScript(false);
    configuration.setStopAtAbort(false);
    configuration.setStopAtException(false);
    configuration.setStopAtError(false);
    configuration.setStopAtDebuggerStatement(false);
    configuration.setStopAtGc(false);

    executeMessage(EcmascriptDebuggerMessage.SET_CONFIGURATION, configuration);

    if (!updateRuntime()) {
      throw new ScopeException("Could not find a runtime for script injection");
    }

    // TODO: Workaround for internal dialogue
    // The dialog is finally removed but just keeping this here
    // until every platform upgrades to core 2.7+
    executeJavascript("return 1;", true);
  }
100399
def setup(provider=None):
    
    site = init(provider)
    if not site:
        site = yaml.safe_load(_read_file(DEPLOY_YAML))

    provider_class = PROVIDERS[site['provider']]
    provider_class.init(site)
1079968
void setup(final Map<String, Object> properties) {
        final List<SetupAction> successfulActions = new ArrayList<SetupAction>();
        for (final SetupAction action : setupActions) {
            try {
                action.setup(properties);
                successfulActions.add(action);
            } catch (final Throwable e) {
                for (SetupAction s : successfulActions) {
                    try {
                        s.teardown(properties);
                    } catch (final Throwable t) {
                        // we ignore these, and just propagate the exception that caused the setup to fail
                    }
                }
                throw new RuntimeException(e);
            }
        }
    }
496908
protected void setup(T ref, String... requiredParams) {
        thisRef = ref;
        if (requiredParams == null) {
            throw new IllegalArgumentException("Set of required params cannot be null");
        }
        for (String param : requiredParams) {
            required.add(PREFIX + param);
        }
    }
1014446
def deploy(options)
      # Initialize directory settings
      AgentConfig.root_dir = options[:root_dir]
      AgentConfig.cfg_dir = options[:cfg_dir]
      AgentConfig.pid_dir = options[:pid_dir]

      # Configure agent
      cfg = load_init_cfg
      check_agent(options, cfg)
      cfg = configure(options, cfg)

      # Persist configuration
      persist(options, cfg)

      # Setup agent monitoring
      monitor(options) if options[:monit]
      true
    end
612864
public function init()
    {
        parent::init();

        $this->parser = new Jade\Renderer([
          'cachePath' => Yii::getAlias($this->cachePath),
          'lifeTime' => $this->options['lifeTime'],
          'pretty' => $this->options['pretty']
        ]);
    }
671099
@Setup(Level.Trial)
  public void setup() throws Exception {
    super.setup(clientExecutor,
        ExecutorType.DIRECT,
        MessageSize.SMALL,
        responseSize,
        FlowWindowSize.MEDIUM,
        ChannelType.NIO,
        maxConcurrentStreams,
        channelCount);
    callCounter = new AtomicLong();
    completed = new AtomicBoolean();
    record = new AtomicBoolean();
    latch =
        startFlowControlledStreamingCalls(maxConcurrentStreams, callCounter, record, completed, 1);
  }
499329
public void setup(@Observes EventContext<SetupContainer> setup) throws Exception {
        SetupContainer event = setup.getEvent();
        if (isChameleonContainer(event)) {
            initiateChameleon(event);
        }
        setup.proceed();
    }
798676
public static function setup(): void
    {
        $aComponents          = Components::available();
        self::$aContainers    = [];
        self::$aLoadedHelpers = [];
        $aDiscoveredServices  = [
            'nails/common' => self::findServicesForComponent('nails/common'),
        ];

        foreach ($aComponents as $oComponent) {
            $aDiscoveredServices[$oComponent->slug] = self::findServicesForComponent($oComponent->slug);
        }

        $aDiscoveredServices['app'] = self::findServicesForApp();
        $aDiscoveredServices        = array_filter($aDiscoveredServices);

        foreach ($aDiscoveredServices as $sComponentName => $aComponentServices) {

            //  Properties
            if (!empty($aComponentServices['properties'])) {
                if (empty(self::$aContainers[$sComponentName]['properties'])) {
                    self::$aContainers[$sComponentName]['properties'] = new Container();
                }
                foreach ($aComponentServices['properties'] as $sKey => $mValue) {
                    self::$aContainers[$sComponentName]['properties'][$sKey] = $mValue;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * SERVICES
             * All services are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['services'])) {
                if (empty(self::$aContainers[$sComponentName]['services'])) {
                    self::$aContainers[$sComponentName]['services'] = new Container();
                }
                foreach ($aComponentServices['services'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['services'][$sKey] = function () use ($sKey, $cCallable) {
                        return $cCallable;
                    };;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * MODELS
             * All models are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['models'])) {
                if (empty(self::$aContainers[$sComponentName]['models'])) {
                    self::$aContainers[$sComponentName]['models'] = new Container();
                }
                foreach ($aComponentServices['models'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['models'][$sKey] = function () use ($cCallable) {
                        return $cCallable;
                    };
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['factories'])) {
                if (empty(self::$aContainers[$sComponentName]['factories'])) {
                    self::$aContainers[$sComponentName]['factories'] = new Container();
                }
                foreach ($aComponentServices['factories'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['factories'][$sKey] = self::$aContainers[$sComponentName]['factories']
                        ->factory($cWrapper);
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['resources'])) {
                if (empty(self::$aContainers[$sComponentName]['resources'])) {
                    self::$aContainers[$sComponentName]['resources'] = new Container();
                }
                foreach ($aComponentServices['resources'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['resources'][$sKey] = self::$aContainers[$sComponentName]['resources']
                        ->factory($cWrapper);
                }
            }
        }
    }
161722
private void setup(Collection<T> items, int ps, Comparator<T> sort) {
		Collection<T> list;
		Iterator<T> it;

		if( sort == null ) {
			list = items;
		}
		else {
			list = new TreeSet<T>(sort);
			list.addAll(items);			
		}
		sorter = sort;
		pageSize = ps;
        pages = new ArrayList<Collection<T>>();
		it = list.iterator();		
		while( it.hasNext() ) {
			ArrayList<T> page = new ArrayList<T>();
			
			pages.add(page);
			for(int i=0; i<ps; i++ ) {
                T ob;
                
				if( !it.hasNext() ) {
					break;
				}
                ob = it.next();
				page.add(ob);
			}
		}
	}
883663
public void setUp(GroovySourceAST t) {
        super.setUp(t);
        
        // gather and sort all unvisited AST nodes
        unvisitedNodes = new ArrayList<GroovySourceAST>();
        traverse(t);
        Collections.sort(unvisitedNodes);
    }
946106
public void setup() {
        LogActivator.logToFile(logger, this.getName(), Level.ALL);
        
        introspector = JadeAgentIntrospector.getMyInstance(this);
//        introspector.storeBeliefValue(this, Definitions.RECEIVED_MESSAGE_COUNT, 0);
        MockConfiguration configuration = (MockConfiguration) this.getArguments()[0];

        messages = new ArrayList<ACLMessage>();
        
        // Attemps to register the aggent.
        registered = false;
        try {
            AgentRegistration.registerAgent(this, configuration.getDFservice(), this.getLocalName());
            registered = true;
        } catch(FIPAException e) {
            logger.warning("Exception while registring the ListenerMock");
            logger.warning(e.getMessage()); // Will this show anything useful?
        }

        // Adds the behavior to store the messages.
        addBehaviour(new MessageReceiver());
    }
448516
@PostConstruct
    public void runSetup() throws SetupException {
        HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration);
        InterProcessMutex lock = curatorFactory.lockInstance(zookeeperProperties.getZkRoot());
        try {
            LOG.info("Trying to acquire lock for running setup.");
            lock.acquire();
            LOG.info("Acquired lock for running setup.");
            handleSetupInProgress(configuration, zookeeperProperties);
            for (SetupStep step : setupSteps) {
                LOG.info("Running setup step: {}", step);
                step.run();
            }
            clearSetupInProgress(zookeeperProperties);
        } catch (SetupException se) {
            LOG.error("Got setup exception while trying to setup", se);
            throw se;
        } catch (Throwable e) {
            LOG.error("Error running setup steps", e);
            throw new SetupException("Error running setup steps", e);
        } finally {
            releaseLock(lock);
            curatorFactory.close();
        }
    }
406262
@Override
	public final void setup(
	    Mapper<INPUT_KEY, INPUT_VALUE, DatumWrapper<ITuple>, NullWritable>.Context context)
	    throws IOException, InterruptedException {
		try {
			super.setup(context);
			Configuration conf = context.getConfiguration();
			TupleMRConfig tupleMRConfig = TupleMRConfig.get(conf);
			this.context = new TupleMRContext(context, tupleMRConfig);
			this.collector = new Collector(context);
			setup(this.context, this.collector);
		} catch(TupleMRException e) {
			throw new RuntimeException(e);
		}
	}
59787
@Override
	Map<String,String> prepareConfiguration( TargetHandlerParameters parameters, SSHClient ssh, File tmpDir )
	throws IOException {

		try {
			// Reset all the fields
			Map<String,String> keyToNewValue = new HashMap<> ();
			keyToNewValue.put( AGENT_APPLICATION_NAME, "" );
			keyToNewValue.put( AGENT_SCOPED_INSTANCE_PATH, "" );
			keyToNewValue.put( AGENT_DOMAIN, "" );
			keyToNewValue.put( AGENT_PARAMETERS, Constants.AGENT_RESET );

			return keyToNewValue;

		} finally {
			// Consider the IP as not used anymore, no matter what
			this.embedded.releaseIpAddress( this.ip );
		}
	}