Gets the lifecycle for phase.

@param phase the phase
@return the lifecycle for phase
@throws BuildFailureException the build failure exception
@throws LifecycleExecutionException the lifecycle execution exception
480122
private Lifecycle getLifecycleForPhase( String phase )
        throws BuildFailureException, LifecycleExecutionException
    {
        Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase );

        if ( lifecycle == null )
        {
            throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" );
        }
        return lifecycle;
    }
1056064
public B camundaFailedJobRetryTimeCycle(String retryTimeCycle) {
    CamundaFailedJobRetryTimeCycle failedJobRetryTimeCycle = createInstance(CamundaFailedJobRetryTimeCycle.class);
    failedJobRetryTimeCycle.setTextContent(retryTimeCycle);

    addExtensionElement(failedJobRetryTimeCycle);

    return myself;
  }
635842
@Nullable
    @MainThread
    private static LifecycleOwner getLifecycleOwner(ViewDataBinding binding) {
        if (!fieldFaild && lifecycleOwnerField == null) {
            try {
                lifecycleOwnerField = ViewDataBinding.class.getDeclaredField("mLifecycleOwner");
                lifecycleOwnerField.setAccessible(true);
            } catch (NoSuchFieldException e) {
                fieldFaild = true;
                return null;
            }
        }
        if (lifecycleOwnerField == null) {
            return null;
        }
        try {
            return (LifecycleOwner) lifecycleOwnerField.get(binding);
        } catch (IllegalAccessException e) {
            return null;
        }
    }
868532
public synchronized void commit_one_phase() throws RollbackException, HeuristicHazardException, SystemException {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "commit_one_phase", this);

        // Ensure timeout cannot rollback the underlying transaction
        ((DistributableTransaction) _transaction).addAssociation();

        // If the transaction that this object represents has already been completed,
        // raise an exception if necessary.
        boolean rolledBack = false; // Use locals in case of async completion
        boolean sysException = false;

        final int state = _transaction.getTransactionState().getState();
        switch (state) {
            case TransactionState.STATE_ACTIVE:
                // We have received a commit one phase request
                // from our superior. This transaction should
                // no longer act as a subordinate and should
                // assume superior status prior to beginning
                // commit processing - this is enabled by calling
                // the top-level commit operation.

                // The commit operation may throw the HeuristicHazard exception.  In this case
                // allow it to go back to the caller.  The commit call performs all state checks.
                try {
                    // Resume the transaction created from the incoming
                    // request so that it is installed on the thread.
                    ((EmbeddableTranManagerSet) TransactionManagerFactory.getTransactionManager()).resume(_transaction);

                    // need to prolongFinish to deal with heuristics
                    // as commit_one_phase always calls notifyCompletion
                    _transaction.prolongFinish();
                    _transaction.commit_one_phase();
                    _transaction.notifyCompletion();
                } catch (HeuristicMixedException exc) {
                    // No FFDC code needed.
                    _heuristic = StatefulResource.HEURISTIC_MIXED;
                } catch (HeuristicHazardException exc) {
                    // No FFDC code needed.
                    _heuristic = StatefulResource.HEURISTIC_HAZARD;
                } catch (HeuristicRollbackException exc) {
                    // No FFDC code needed.
                    rolledBack = true;
                    _transaction.notifyCompletion();
                } catch (RollbackException exc) {
                    // No FFDC as rollback is a valid response
                    rolledBack = true;
                    _transaction.notifyCompletion();
                } catch (Throwable exc) { // SecurityException/IllegalStateException/SystemException
                    FFDCFilter.processException(exc, "com.ibm.tx.remote.TransactionWrapper.commit_one_phase", "456", this);
                    Tr.error(tc, "WTRN0070_ONE_PHASE_COMMIT_FAILED", exc);
                    sysException = true;
                    _transaction.notifyCompletion();
                    // destroy();
                }
                break;

            case TransactionState.STATE_COMMITTING:
                // We should only get in this state if the superior failed to get a
                // response on the original commit calls.  We can be in committing
                // state either if we are retrying local resources or in recovery
                // Check the heuristic state and return that.
                _heuristic = _transaction.getResources().getHeuristicOutcome();
                if (_heuristic != StatefulResource.NONE)
                    break;

                // If we are not in any heuristic state then we are not retrying and
                // must be in recovery about to perform the commit. 
                // Continue to return transient until we have a real outcome to return.
                // The superior will consider this as heuristic hazard.  Also the
                // same for LPS state.
            case TransactionState.STATE_LAST_PARTICIPANT:
                ((DistributableTransaction) _transaction).removeAssociation();
                final TRANSIENT tre = new TRANSIENT();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "commit_one_phase", tre);
                throw tre;

            case TransactionState.STATE_COMMITTED:
                // this is probably a retry ... check heuristic state 
                _heuristic = _transaction.getResources().getHeuristicOutcome();
                break;

            case TransactionState.STATE_HEURISTIC_ON_COMMIT:
            case TransactionState.STATE_HEURISTIC_ON_ROLLBACK:
                // Should never get in this state as C1P never gets
                // in this state as it presumes superior status even
                // for admin heuristic commit
                break;

            case TransactionState.STATE_ROLLING_BACK:
            case TransactionState.STATE_ROLLED_BACK:
                // Transaction timed out or admin heuristic rollback or LPS rollback
                // again, probably a retry ... throw exception
                rolledBack = true;
                break;

            case TransactionState.STATE_NONE:
                // Transaction has completed and is now finished
                // Normally the remoteable object would be disconnected from the orb,
                // but ... timing may mean get got here while it was happenning
                ((DistributableTransaction) _transaction).removeAssociation();
                final OBJECT_NOT_EXIST one = new OBJECT_NOT_EXIST();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "commit_one_phase", one);
                throw one;

            default:
                Tr.error(tc, "WTRN0069_COMMIT_BAD_STATE", TransactionState.stateToString(state));
                sysException = true;
                break;
        } // end switch

        ((DistributableTransaction) _transaction).removeAssociation();

        switch (_heuristic)
        {
            case StatefulResource.NONE:
                break;

            default:
//                _transaction.addHeuristic();
                final HeuristicHazardException hh = new HeuristicHazardException();
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "commit_one_phase", hh);
                throw hh;
        }

        if (rolledBack)
        {
            final TRANSACTION_ROLLEDBACK tre = new TRANSACTION_ROLLEDBACK(0, Boolean.TRUE);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "commit_one_phase", tre);
            throw tre;
        }
        else if (sysException)
        {
            final INTERNAL ie = new INTERNAL(MinorCode.LOGIC_ERROR, null);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "commit_one_phase", ie);
            throw ie;
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "commit_one_phase");
    }
597299
public static MultiMap<String, Method> defineLifecycleMethod(final Component<?> component) {

        final MultiMap<String, Method> lifecycleMethod = new MultiMap<>();

        manageLifecycleAnnotation(component, lifecycleMethod, BeforeInit.class);
        manageLifecycleAnnotation(component, lifecycleMethod, AfterInit.class);
        manageLifecycleAnnotation(component, lifecycleMethod, OnRelease.class);

        return lifecycleMethod;
    }
1214877
@Nonnull
  public static <T> JPAExecutionResult <T> createFailure (@Nullable final Exception ex)
  {
    return new JPAExecutionResult <> (ESuccess.FAILURE, null, ex);
  }
582676
@Override
    public void executeTo(@Nonnull final LifecycleStage lifecycleStage)
    {
        boolean foundStage = false;
        do {
            final LifecycleStage nextStage = lifecycleDriver.getNextStage();

            if (nextStage == null) {
                throw new IllegalStateException("Never reached stage '" + lifecycleStage.getName() + "' before ending the lifecycle.");
            }

            foundStage = nextStage.equals(lifecycleStage);
            execute(nextStage);

        } while(!foundStage);
    }
834350
public static <T> T getCompleted(CompletionStage<T> stage) {
    CompletableFuture<T> future = stage.toCompletableFuture();
    Preconditions.checkArgument(future.isDone() && !future.isCompletedExceptionally());
    try {
      return future.get();
    } catch (InterruptedException | ExecutionException e) {
      // Neither can happen given the precondition
      throw new AssertionError("Unexpected error", e);
    }
  }
1071824
def _execute_phase_once(self, phase_desc, is_last_repeat):
    """"""
    # Check this before we create a PhaseState and PhaseRecord.
    if phase_desc.options.run_if and not phase_desc.options.run_if():
      _LOG.debug('Phase %s skipped due to run_if returning falsey.',
                 phase_desc.name)
      return PhaseExecutionOutcome(openhtf.PhaseResult.SKIP)

    override_result = None
    with self.test_state.running_phase_context(phase_desc) as phase_state:
      _LOG.debug('Executing phase %s', phase_desc.name)
      with self._current_phase_thread_lock:
        # Checking _stopping must be in the lock context, otherwise there is a
        # race condition: this thread checks _stopping and then switches to
        # another thread where stop() sets _stopping and checks
        # _current_phase_thread (which would not be set yet).  In that case, the
        # new phase thread will be still be started.
        if self._stopping.is_set():
          # PhaseRecord will be written at this point, so ensure that it has a
          # Killed result.
          result = PhaseExecutionOutcome(threads.ThreadTerminationError())
          phase_state.result = result
          return result
        phase_thread = PhaseExecutorThread(phase_desc, self.test_state)
        phase_thread.start()
        self._current_phase_thread = phase_thread

      phase_state.result = phase_thread.join_or_die()
      if phase_state.result.is_repeat and is_last_repeat:
        _LOG.error('Phase returned REPEAT, exceeding repeat_limit.')
        phase_state.hit_repeat_limit = True
        override_result = PhaseExecutionOutcome(openhtf.PhaseResult.STOP)
      self._current_phase_thread = None

    # Refresh the result in case a validation for a partially set measurement
    # raised an exception.
    result = override_result or phase_state.result
    _LOG.debug('Phase %s finished with result %s', phase_desc.name,
               result.phase_result)
    return result
568744
public static <T> T step(final ThrowableContextRunnable<T, StepContext> runnable) {
        final String uuid = UUID.randomUUID().toString();
        getLifecycle().startStep(uuid, new StepResult().setName("step"));

        try {
            final T result = runnable.run(new DefaultStepContext(uuid));
            getLifecycle().updateStep(uuid, step -> step.setStatus(Status.PASSED));
            return result;
        } catch (Throwable throwable) {
            getLifecycle().updateStep(s -> s
                    .setStatus(getStatus(throwable).orElse(Status.BROKEN))
                    .setStatusDetails(getStatusDetails(throwable).orElse(null)));
            ExceptionUtils.sneakyThrow(throwable);
            return null;
        } finally {
            getLifecycle().stopStep(uuid);
        }
    }
890561
private void handleLifecycleTransitionFailure(Throwable t) {
      if (t.getCause() != null && t.getCause() instanceof CacheConfigurationException)
         throw (CacheConfigurationException) t.getCause();
      else if (t.getCause() != null && t.getCause() instanceof InvocationTargetException && t.getCause().getCause() != null && t.getCause().getCause() instanceof CacheConfigurationException)
         throw (CacheConfigurationException) t.getCause().getCause();
      else if (t instanceof CacheException)
         throw (CacheException) t;
      else if (t instanceof RuntimeException)
         throw (RuntimeException) t;
      else if (t instanceof Error)
         throw (Error) t;
      else
         throw new CacheException(t);
   }
30947
@Override
    public Scene getScene()
    {
        final Node<?> parent = getParent();// change, no iteration, no testing, no casting, recurses upwards to a Scene, and Scene returns itself, CYCLES!!!

        if (null != parent)
        {
            return parent.getScene();
        }
        return null;
    }
964923
public List getFailureReason() {
    List fr =  (List)jmo.getField(TrmFirstContactAccess.BODY_CLIENTATTACHREPLY_FAILUREREASON);
    if (fr != null) {
      return new ArrayList(fr);
    } else {
      return null;
    }
  }
824886
private function getFailure(MethodInvocation $invocation, FailureInterface $failure, \ReflectionMethod $onFailure = null)
    {
        if ($onFailure) {
            return $onFailure->invoke($invocation->getThis(), $failure);
        }

        return $this->failureException($invocation, $failure);
    }
663546
public AnalysisEngineDescription buildComponent(int stageId, int phase, AnyObject aeDescription)
          throws Exception {
    Map<String, Object> tuples = Maps.newLinkedHashMap();
    tuples.put(BasePhase.QA_INTERNAL_PHASEID, new Integer(phase));
    tuples.put(EXPERIMENT_UUID_PROPERTY, experimentUuid);
    tuples.put(STAGE_ID_PROPERTY, stageId);
    Class<? extends AnalysisComponent> ac = getFromClassOrInherit(aeDescription,
            AnalysisComponent.class, tuples);
    Object[] params = getParamList(tuples);
    AnalysisEngineDescription description = AnalysisEngineFactory.createPrimitiveDescription(ac,
            typeSystem, typePriorities, params);
    String name = (String) tuples.get("name");
    description.getAnalysisEngineMetaData().setName(name);
    return description;
  }
951379
private Element lifeCycle(HttpServletRequest request,
                              String id,
                              LifeCycle lc,
                              String name)
    {
        Composite comp=new Composite();
        comp.add(new Target(id));
        Font font = new Font();
        comp.add(font);
        font.color(lc.isStarted()?"green":"red");
        font.add(name);

        String action=lc.isStarted()?"Stop":"Start";
        
        comp.add("&nbsp;[");
        comp.add(new Link(URI.addPaths(request.getContextPath(),request.getServletPath())+
                          "?T="+Long.toString(System.currentTimeMillis(),36)+
                          "&A="+action+
                          "&ID="+UrlEncoded.encodeString(id),
                          action));
        comp.add("]");
        return comp;
    }
105339
public Fault buildFault(Throwable ex) {
		Fault fault;
		int stacktracelength = configuration.getStacktracelength();
		if (stacktracelength == 0 || logger.isDebugEnabled()) {
			logger.error("Invocation failed", ex);
		}
		fault = new Fault(ex, stacktracelength);
		return fault;
	}