@param WorkItemContextInterface $workItemContext

@throws UnexpectedActivityStateException
336982
public function executeWorkItem(WorkItemContextInterface $workItemContext)
    {
        assert($workItemContext->getProcessContext() !== null);
        assert($workItemContext->getProcessContext()->getWorkflow() !== null);
        assert($workItemContext->getActivityId() !== null);
        assert($workItemContext->getProcessContext()->getWorkflow()->getFlowObject($workItemContext->getActivityId()) instanceof ActivityInterface);

        $activity = $workItemContext->getProcessContext()->getWorkflow()->getFlowObject($workItemContext->getActivityId()); /* @var $activity ActivityInterface */
        if ($activity->isAllocatable()) {
            $this->allocateWorkItem($workItemContext);
            $nextWorkItemContext = new WorkItemContext($workItemContext->getParticipant());
            $nextWorkItemContext->setActivityId($workItemContext->getProcessContext()->getWorkflow()->getCurrentFlowObject()->getId());
            $nextWorkItemContext->setProcessContext($workItemContext->getProcessContext());

            return $this->executeWorkItem($nextWorkItemContext);
        } elseif ($activity->isStartable()) {
            $this->startWorkItem($workItemContext);
            $nextWorkItemContext = new WorkItemContext($workItemContext->getParticipant());
            $nextWorkItemContext->setActivityId($workItemContext->getProcessContext()->getWorkflow()->getCurrentFlowObject()->getId());
            $nextWorkItemContext->setProcessContext($workItemContext->getProcessContext());

            return $this->executeWorkItem($nextWorkItemContext);
        } elseif ($activity->isCompletable()) {
            $this->completeWorkItem($workItemContext);
        } else {
            throw new UnexpectedActivityStateException(sprintf('The current work item of the activity "%s" is not executable.', $activity->getId()));
        }
    }
225014
private void fireWorkContextSetupFailed(Object workContext)
   {
      if (workContext != null && workContext instanceof WorkContextLifecycleListener)
      {
         if (trace)
            log.tracef("WorkContextSetupFailed(%s) for %s", workContext, this);  

         WorkContextLifecycleListener listener = (WorkContextLifecycleListener)workContext;
         listener.contextSetupFailed(WorkContextErrorCodes.CONTEXT_SETUP_FAILED);
      }
   }
978266
public void setWorkteams(java.util.Collection<Workteam> workteams) {
        if (workteams == null) {
            this.workteams = null;
            return;
        }

        this.workteams = new java.util.ArrayList<Workteam>(workteams);
    }
430570
public void setWorkPath(String workPath) throws CmsIllegalArgumentException {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(workPath)) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.GUI_ERR_WIDGETVALUE_EMPTY_0));
        }
        // test if it is a valid path:
        if (!m_cms.existsResource(workPath)) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(Messages.GUI_ERR_TAGREPLACE_WORKPATH_1, workPath));
        }
        m_workPath = workPath;

    }
1135778
protected boolean addWork(final ForkJoinContext<?> context) {
	requireNotStopped(this);

	final boolean result = workQueue.addWaitingWork(context);
	if (result) {
	    addWorkerIfNeeded();
	}

	return result;
    }
1279585
private void setup(WorkWrapper wrapper, WorkListener workListener) throws WorkCompletedException, WorkException
   {
      if (trace)
         log.tracef("Setting up work: %s, work listener: %s", wrapper, workListener);

      Work work = wrapper.getWork();

      if (resourceAdapter != null)
      {
         if (SecurityActions.getClassLoader(work.getClass()) instanceof WorkClassLoader)
         {
            WorkClassLoader wcl = (WorkClassLoader)SecurityActions.getClassLoader(work.getClass());
            ResourceAdapterClassLoader racl =
               new ResourceAdapterClassLoader(SecurityActions.getClassLoader(resourceAdapter.getClass()),
                                              wcl);

            wcl.setResourceAdapterClassLoader(racl);
         }
         if (work instanceof ResourceAdapterAssociation)
         {
            try
            {
               ResourceAdapterAssociation raa = (ResourceAdapterAssociation)work;
               raa.setResourceAdapter(resourceAdapter);
            }
            catch (Throwable t)
            {
               throw new WorkException(bundle.resourceAdapterAssociationFailed(work.getClass().getName()), t);
            }
         }
      }

      //If work is an instanceof WorkContextProvider
      if (work instanceof WorkContextProvider)
      {
         WorkContextProvider wcProvider = (WorkContextProvider) work;
         List<WorkContext> contexts = wcProvider.getWorkContexts();

         if (contexts != null && !contexts.isEmpty())
         {
            boolean isTransactionContext = false;
            boolean isSecurityContext = false;
            boolean isHintcontext = false;

            for (WorkContext context : contexts)
            {
               Class<? extends WorkContext> contextType = null;

               // Get supported work context class
               contextType = getSupportedWorkContextClass(context.getClass());

               // Not supported
               if (contextType == null)
               {
                  if (trace)
                  {
                     log.trace("Not supported work context class : " + context.getClass().getName());
                  }

                  WorkCompletedException wce =
                     new WorkCompletedException(bundle.unsupportedWorkContextClass(context.getClass().getName()),
                                                WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE);

                  fireWorkContextSetupFailed(context, WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE,
                                             workListener, work, wce);

                  throw wce;
               }
               // Duplicate checks
               else
               {
                  // TransactionContext duplicate
                  if (isTransactionContext(contextType))
                  {
                     if (isTransactionContext)
                     {
                        if (trace)
                        {
                           log.trace("Duplicate transaction work context : " + context.getClass().getName());
                        }

                        WorkCompletedException wce =
                           new WorkCompletedException(bundle.duplicateTransactionWorkContextClass(context.getClass()
                              .getName()), WorkContextErrorCodes.DUPLICATE_CONTEXTS);

                        fireWorkContextSetupFailed(context, WorkContextErrorCodes.DUPLICATE_CONTEXTS,
                                                   workListener, work, wce);

                        throw wce;
                     }
                     else
                     {
                        isTransactionContext = true;
                     }
                  }
                  // SecurityContext duplicate
                  else if (isSecurityContext(contextType))
                  {
                     if (isSecurityContext)
                     {
                        if (trace)
                        {
                           log.trace("Duplicate security work context : " + context.getClass().getName());
                        }

                        WorkCompletedException wce =
                           new WorkCompletedException(bundle.duplicateSecurityWorkContextClass(context.getClass()
                              .getName()), WorkContextErrorCodes.DUPLICATE_CONTEXTS);

                        fireWorkContextSetupFailed(context, WorkContextErrorCodes.DUPLICATE_CONTEXTS,
                                                   workListener, work, wce);

                        throw wce;
                     }
                     else
                     {
                        isSecurityContext = true;
                     }
                  }
                  // HintContext duplicate
                  else if (isHintContext(contextType))
                  {
                     if (isHintcontext)
                     {
                        if (trace)
                        {
                           log.trace("Duplicate hint work context : " + context.getClass().getName());
                        }

                        WorkCompletedException wce =
                           new WorkCompletedException(bundle.duplicateHintWorkContextClass(context.getClass()
                              .getName()), WorkContextErrorCodes.DUPLICATE_CONTEXTS);

                        fireWorkContextSetupFailed(context, WorkContextErrorCodes.DUPLICATE_CONTEXTS,
                                                   workListener, work, wce);

                        throw wce;
                     }
                     else
                     {
                        isHintcontext = true;
                     }
                  }
               }

               // Add workcontext instance to the work
               wrapper.addWorkContext(contextType, context);
            }
         }
      }
   }
872582
private void loadArtwork(final Context context, final String artworkUrl) {
        mMainThreadHandler.post(new Runnable() {
            @Override
            public void run() {
                final Picasso picasso = Picasso.with(context);
                picasso.cancelRequest(mMediaSessionArtworkTarget);
                picasso.load(artworkUrl)
                        .centerCrop()
                        .resize(MEDIA_SESSION_ARTWORK_SIZE, MEDIA_SESSION_ARTWORK_SIZE)
                        .into(mMediaSessionArtworkTarget);
            }
        });
    }
446112
@SuppressWarnings("unused")
    @Activate
    protected void activate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Activating the HTTP pipeline event handler");
        }
    }
1323116
protected void start() throws WorkException
   {
      if (trace)
         log.tracef("Starting work: %s", this);  

      if (workListener != null)
      {
         long duration = System.currentTimeMillis() - startTime;
         if (duration < 0)
            duration = javax.resource.spi.work.WorkManager.UNKNOWN;

         WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_STARTED, work, null, duration);
         workListener.workStarted(event);
      }

      // Transaction setup
      ExecutionContext ctx = getWorkContext(TransactionContext.class);
      if (ctx == null)
      {
         ctx = getExecutionContext();
      }
      
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            //JBAS-4002 base value is in seconds as per the API, here we convert to millis
            long timeout = (ctx.getTransactionTimeout() * 1000);
            workManager.getXATerminator().registerWork(work, xid, timeout);
         }
      }

      // Fire complete for transaction context
      fireWorkContextSetupComplete(ctx);
      
      // Security setup
      javax.resource.spi.work.SecurityContext securityContext = 
         getWorkContext(javax.resource.spi.work.SecurityContext.class);
      if (securityContext != null && workManager.getCallbackSecurity() != null)
      {
         if (trace)
            log.tracef("Setting security context: %s", securityContext);

         try
         {
            // Security context
            org.ironjacamar.core.spi.security.SecurityContext sc = null;

            // Setup callback handler
            CallbackHandler cbh = null;
            if (workManager.getCallbackSecurity() != null && workManager.getCallbackSecurity().isMappingRequired())
            {
               cbh = securityIntegration.createCallbackHandler(workManager.getCallbackSecurity());
            }

            if (cbh == null)
               cbh = securityIntegration.createCallbackHandler();

            // Subjects for execution environment
            Subject executionSubject = null;
            Subject serviceSubject = null;
         
            if (trace)
               log.tracef("Callback security: %s", workManager.getCallbackSecurity());

            if (securityIntegration.getSecurityContext() == null ||
                workManager.getCallbackSecurity().getDomain() != null)
            {
               String scDomain = workManager.getCallbackSecurity().getDomain();

               if (trace)
                  log.tracef("Creating security context: %s", scDomain);

               if (scDomain == null || scDomain.trim().equals(""))
               {
                  fireWorkContextSetupFailed(securityContext);
                  throw new WorkException(bundle.securityContextSetupFailedSinceCallbackSecurityDomainWasEmpty());
               }

               sc = securityIntegration.createSecurityContext(scDomain);
               securityIntegration.setSecurityContext(sc);
            }
            else
            {
               sc = securityIntegration.getSecurityContext();

               if (trace)
                  log.tracef("Using security context: %s", sc);
            }

            executionSubject = sc.getAuthenticatedSubject();

            if (executionSubject == null)
            {
               if (trace)
                  log.tracef("Creating empty subject");

               executionSubject = new Subject();
            }

            // Resource adapter callback
            securityContext.setupSecurityContext(cbh, executionSubject, serviceSubject);

            if (workManager.getCallbackSecurity() != null)
            {
               List<Callback> callbacks = new ArrayList<Callback>();
               if (workManager.getCallbackSecurity().getDefaultPrincipal() != null)
               {
                  Principal defaultPrincipal = workManager.getCallbackSecurity().getDefaultPrincipal();

                  if (trace)
                     log.tracef("Adding default principal: %s", defaultPrincipal);

                  CallerPrincipalCallback cpc =
                     new CallerPrincipalCallback(executionSubject, defaultPrincipal);

                  callbacks.add(cpc);
               }

               if (workManager.getCallbackSecurity().getDefaultGroups() != null)
               {
                  String[] defaultGroups = workManager.getCallbackSecurity().getDefaultGroups();

                  if (trace)
                     log.tracef("Adding default groups: %s", Arrays.toString(defaultGroups));
                  
                  GroupPrincipalCallback gpc = 
                     new GroupPrincipalCallback(executionSubject, defaultGroups);

                  callbacks.add(gpc);
               }

               if (!callbacks.isEmpty())
               {
                  Callback[] cb = new Callback[callbacks.size()];
                  cbh.handle(callbacks.toArray(cb));
               }
            }

            if (trace)
               log.tracef("Setting authenticated subject (%s) on security context (%s)", executionSubject, sc);

            // Set the authenticated subject
            sc.setAuthenticatedSubject(executionSubject);

            // Fire complete for security context
            fireWorkContextSetupComplete(securityContext);
         }
         catch (Throwable t)
         {
            log.securityContextSetupFailed(t.getMessage(), t);
            fireWorkContextSetupFailed(securityContext);
            throw new WorkException(bundle.securityContextSetupFailed(t.getMessage()), t);
         }
      }
      else if (securityContext != null && workManager.getCallbackSecurity() == null)
      {
         log.securityContextSetupFailedCallbackSecurityNull();
         fireWorkContextSetupFailed(securityContext);
         throw new WorkException(bundle.securityContextSetupFailedSinceCallbackSecurityWasNull());
      }
   
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            workManager.getXATerminator().startWork(work, xid);
         }
      }

      if (trace)
         log.tracef("Started work: %s", this);  
   }
437902
protected void activate(ComponentContext compContext) {
        BundleContext ctx = compContext.getBundleContext();
        mDelayedMBeanActivator = new DelayedMBeanActivator(ctx);
        pipeline.insert(mDelayedMBeanActivator);
        try {
            mbeanTracker = new ServiceTracker<Object, ServiceReference<?>>(ctx, ctx.createFilter("(jmx.objectname=*)"), this);
            mbeanTracker.open(true);
        } catch (InvalidSyntaxException ise) {

        }
    }
1065194
public void setSbbContext(SbbContext sbbContext) {
		this.sbbContext = (SbbContextExt) sbbContext;
		if (tracer == null) {
			tracer = sbbContext.getTracer(XDMClientChildSbb.class
					.getSimpleName());
		}
		try {
			Context context = (Context) new InitialContext()
					.lookup("java:comp/env");
			xcapClientSbbInterface = (XCAPClientResourceAdaptorSbbInterface) context
					.lookup("slee/resources/xcapclient/2.0/sbbrainterface");
			xcapClientACIF = (XCAPClientActivityContextInterfaceFactory) context
					.lookup("slee/resources/xcapclient/2.0/acif");
		} catch (NamingException e) {
			tracer.severe("Can't set sbb context.", e);
		}
	}
1317418
public function onChannelPreDelete(ResourceControllerEvent $event): void
    {
        $channel = $event->getSubject();

        if (!$channel instanceof ChannelInterface) {
            throw new UnexpectedTypeException(
                $channel,
                ChannelInterface::class
            );
        }

        $results = $this->channelRepository->findBy(['enabled' => true]);

        if (!$results || (count($results) === 1 && current($results) === $channel)) {
            $event->stop('sylius.channel.delete_error');
        }
    }
14487
protected void activate(ComponentContext compcontext) {
        if (TC.isDebugEnabled()) {
            Tr.debug(TC, "Activating " + this.getClass().getName());
        }
        this.userTransaction.activate(compcontext);
        this.transactionManager.activate(compcontext);
    }
579821
private void loadArtwork(final Context context, final String artworkUrl) {
        if (mLoadArtworkRunnable != null) {
            mMainThreadHandler.removeCallbacks(mLoadArtworkRunnable);
        }

        mLoadArtworkRunnable = new Runnable() {
            @Override
            public void run() {
                final Picasso picasso = Picasso.with(context);
                picasso.cancelRequest(mThumbnailArtworkTarget);

                picasso.load(artworkUrl)
                        .centerCrop()
                        .resize(mArtworkBitmapSize, mArtworkBitmapSize)
                        .into(mThumbnailArtworkTarget);
            }
        };
        mMainThreadHandler.postDelayed(mLoadArtworkRunnable, LOAD_ARTWORK_DELAY);
    }
1155008
@Override
    public void visitClassContext(ClassContext clsContext) {
        try {
            if ((collectionCls == null) || (setCls == null) || (mapCls == null)) {
                return;
            }

            stack = new OpcodeStack();
            super.visitClassContext(clsContext);
        } finally {
            stack = null;
        }
    }
487913
@Override
  public void abortTask(TaskAttemptContext context) throws IOException {
    try {
      if (workPath != null) { 
        context.progress();
        if (!outputFileSystem.delete(workPath, true)) {
          LOG.warn("Deleting output in " + workPath + " returns false");
        }
      }
    } catch (IOException ie) {
      LOG.warn("Error discarding output in " + workPath, ie);
      throw ie;
    }
  }
1146958
public WorkflowContext execute(WorkflowContext context) throws WorkflowException {
		if (context instanceof MapModelWorkflowContext) {
			MapModelWorkflowContext mmContext = (MapModelWorkflowContext) context;
			FeatureTransaction ft = mmContext.getFeatureTransaction();
			if (ft.getNewFeatures() != null) {
				for (Feature feature : ft.getNewFeatures()) {
					if (!feature.getGeometry().isValid()) {
						throw new WorkflowException(I18nProvider.getGlobal().validationActivityError());
					}
				}
			}
		}
		return context;
	}