/// <param name="reference"> </param> public DefaultProcessApplicationRegistration(IProcessApplicationReference reference, IList <string> deploymentIds, string processEnginenName) { this.reference = reference; this.deploymentIds = deploymentIds; processEngineName = processEnginenName; }
//private static void loggContextSwitchDetails(CaseExecutionEntity execution) //{ // //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': // //ORIGINAL LINE: final CoreExecutionContext<? extends org.camunda.bpm.engine.impl.core.instance.CoreExecution> executionContext = Context.getCoreExecutionContext(); // //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: // var executionContext = Context.CoreExecutionContext; // // only log for first atomic op: // //if (executionContext == null || (executionContext.Execution != (CoreExecution)execution)) // //{ // // var processApplicationManager = Context.ProcessEngineConfiguration.ProcessApplicationManager; // // _logger.DebugNoTargetProcessApplicationFoundForCaseExecution(execution, processApplicationManager); // //} //} public static bool RequiresContextSwitch(IProcessApplicationReference processApplicationReference) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.application.ProcessApplicationReference currentProcessApplication = Context.getCurrentProcessApplication(); var currentProcessApplication = Context.CurrentProcessApplication; if (processApplicationReference == null) { return(false); } if (currentProcessApplication == null) { return(true); } if (!processApplicationReference.Name.Equals(currentProcessApplication.Name)) { return(true); } // check whether the thread context has been manipulated since last context switch. This can happen as a result of // an operation causing the container to switch to a different application. // Example: JavaDelegate implementation (inside PA) invokes an EJB from different application which in turn interacts with the Process engine. //ClassLoader processApplicationClassLoader = // ProcessApplicationClassloaderInterceptor.ProcessApplicationClassLoader; //ClassLoader currentClassloader = ClassLoaderUtil.ContextClassloader; //return currentClassloader != processApplicationClassLoader; return(true); }
/// <summary> /// Loads the given script engine by language name. Will throw an exception if no script engine can be loaded for the given language name. /// </summary> /// <param name="language"> the name of the script language to lookup an implementation for </param> /// <returns> the script engine </returns> /// <exception cref="ProcessEngineException"> if no such engine can be found. </exception> public virtual IScriptEngine GetScriptEngineForLanguage(string language) { if (language != null) { language = language.ToLower(); } IProcessApplicationReference pa = Context.CurrentProcessApplication; ProcessEngineConfigurationImpl config = Context.ProcessEngineConfiguration; IScriptEngine engine = null; if (config.IsEnableFetchScriptEngineFromProcessApplication) { if (pa != null) { engine = GetPaScriptEngine(language, pa); } } if (engine == null) { engine = GetGlobalScriptEngine(language); } return(engine); }
public virtual IProcessApplicationRegistration RegisterProcessApplicationForDeployments( IList <string> deploymentsToRegister, IProcessApplicationReference reference) { lock (this) { // create process application registration var registration = CreateProcessApplicationRegistration(deploymentsToRegister, reference); // register with job executor CreateJobExecutorRegistrations(deploymentsToRegister); LogRegistration(deploymentsToRegister, reference); return(registration); } }
//protected internal virtual T doCall<T>(Callable<T> callable) //{ // try // { // return callable.call(); // } // catch (Exception e) // { // throw new ProcessEngineException(e); // } //} //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: public void submitFormVariables(final org.camunda.bpm.engine.Variable.VariableMap properties, final org.camunda.bpm.engine.delegate.VariableScope variableScope) //public virtual void submitFormVariables(IVariableMap properties, IVariableScope variableScope) //{ // performContextSwitch(new CallableAnonymousInnerClass2(this, properties, variableScope)); //} //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: protected <T> T performContextSwitch(final java.Util.concurrent.Callable<T> callable) protected internal virtual T PerformContextSwitch <T>(Func <T> callable) { IProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.GetTargetProcessApplication(deploymentId); if (targetProcessApplication != null) { return(Context.ExecuteWithinProcessApplication(/*new CallableAnonymousInnerClass(this, callable),*/ callable, targetProcessApplication)); } else { return(callable.Invoke()); } }
public virtual object Execute(CommandContext commandContext) { EnsureUtil.EnsureNotNull("deploymentId", DeploymentId); foreach (ICommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers) { checker.CheckDeleteDeployment(DeploymentId); } IUserOperationLogManager logManager = commandContext.OperationLogManager; IList <PropertyChange> propertyChanges = new List <PropertyChange>() { new PropertyChange("cascade", null, Cascade) }; logManager.LogDeploymentOperation(UserOperationLogEntryFields.OperationTypeDelete, DeploymentId, propertyChanges); commandContext.DeploymentManager.DeleteDeployment(DeploymentId, Cascade, SkipCustomListeners /*, skipIoMappings*/); IProcessApplicationReference processApplicationReference = Context.ProcessEngineConfiguration.ProcessApplicationManager.GetProcessApplicationForDeployment(DeploymentId); DeleteDeploymentFailListener listener = new DeleteDeploymentFailListener(DeploymentId, processApplicationReference /*, Context.ProcessEngineConfiguration.CommandExecutorTxRequiresNew*/); try { commandContext.RunWithoutAuthorization(() => { (new UnregisterProcessApplicationCmd(DeploymentId, false)).Execute(commandContext); (new UnregisterDeploymentCmd(new List <string>() { DeploymentId })).Execute(commandContext); }); } finally { try { commandContext.TransactionContext.AddTransactionListener(TransactionJavaStatus.RolledBack, listener); } catch (System.Exception) { TxLog.DebugTransactionOperation("Could not register transaction synchronization. Probably the TX has already been rolled back by application code."); listener.Execute(commandContext); } } return(null); }
public virtual object ResolveDelegateClass(IActivityExecution execution) { IProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.GetTargetProcessApplication((ExecutionEntity)execution); if (ProcessApplicationContextUtil.RequiresContextSwitch(targetProcessApplication)) { return(Context.ExecuteWithinProcessApplication( () => ResolveDelegateClass(execution), targetProcessApplication, new InvocationContext(execution))); } else { return(InstantiateDelegateClass(execution)); } }
protected internal virtual DefaultProcessApplicationRegistration CreateProcessApplicationRegistration( IList <string> deploymentsToRegister, IProcessApplicationReference reference) { var processEngineName = context.Impl.Context.ProcessEngineConfiguration.ProcessEngineName; var registration = new DefaultProcessApplicationRegistration(reference, deploymentsToRegister, processEngineName); // add to registration map foreach (var deploymentId in deploymentsToRegister) { RegistrationsByDeploymentId[deploymentId] = registration; } return(registration); }
/// <summary> ///用queuedInvocations里面的executionOperation执行execution /// </summary> protected internal virtual void PerformNext() { var nextInvocation = queuedInvocations.Peek();//[0]; //如果执行器允许异步执行,且已经进入异步操作 直接返回 if (nextInvocation.Operation.AsyncCapable && isExecuting) { // will be picked up by while loop below return; } IProcessApplicationReference targetProcessApplication = GetTargetProcessApplication(nextInvocation.execution); if (RequiresContextSwitch(targetProcessApplication)) { Context.ExecuteWithinProcessApplication <object>(() => { PerformNext(); return(null); }, targetProcessApplication, new InvocationContext(nextInvocation.execution)); } else { if (!nextInvocation.Operation.AsyncCapable)//如果执行器不支持异步操作 直接执行 { // if operation is not async capable, perform right away. InvokeNext(); } else//异步操作 { try { isExecuting = true; while (queuedInvocations.Count > 0) { // assumption: all operations are executed within the same process application... nextInvocation = queuedInvocations.Peek();//[0]; InvokeNext(); } } finally { isExecuting = false; } } } }
protected internal virtual IDictionary <string, IList <ExecutableScript> > getEnv(string language) { ProcessEngineConfigurationImpl config = Context.ProcessEngineConfiguration; IProcessApplicationReference processApplication = Context.CurrentProcessApplication; IDictionary <string, IList <ExecutableScript> > result = null; if (config.IsEnableFetchScriptEngineFromProcessApplication) { if (processApplication != null) { result = GetPaEnvScripts(processApplication); } } return(result != null ? result : env); }
public static IProcessApplicationReference GetTargetProcessApplication(ExecutionEntity execution) { if (execution == null) { return(null); } IProcessApplicationReference processApplicationForDeployment = GetTargetProcessApplication(execution.GetProcessDefinition()); //logg application context switch details if (Log.ContextSwitchLoggable && processApplicationForDeployment == null) { //打印 ENGINE-07023 no target process application found for... LoggContextSwitchDetails(execution); } return(processApplicationForDeployment); }
public virtual void testRegisterProcessApplicationAsCamundaAdmin() { // given identityService.SetAuthentication(userId, new List <string>() { GroupsFields.CamundaAdmin }); EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); IProcessApplicationReference reference = processApplication.Reference; string deploymentId = createDeployment(null, FIRST_RESOURCE).Id; // when IProcessApplicationRegistration registration = managementService.RegisterProcessApplication(deploymentId, reference); // then Assert.NotNull(registration); Assert.NotNull(GetProcessApplicationForDeployment(deploymentId)); DeleteDeployment(deploymentId); }
// register process application /////////////////////////////////// public virtual void testRegisterProcessApplicationWithoutAuthorization() { // given EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication(); IProcessApplicationReference reference = processApplication.Reference; string deploymentId = createDeployment(null, FIRST_RESOURCE).Id; try { // when managementService.RegisterProcessApplication(deploymentId, reference); Assert.Fail("Exception expected: It should not be possible to register a process application"); } catch (AuthorizationException e) { //then string message = e.Message; AssertTextPresent("ENGINE-03029 Required authenticated group 'camunda-admin'", message); } DeleteDeployment(deploymentId); }
protected internal virtual IScriptEngine GetPaScriptEngine(string language, IProcessApplicationReference pa) { try { IProcessApplicationInterface processApplication = pa.ProcessApplication; IProcessApplicationInterface rawObject = processApplication.RawObject; if (rawObject is AbstractProcessApplication) { AbstractProcessApplication abstractProcessApplication = (AbstractProcessApplication)rawObject; return(abstractProcessApplication.GetScriptEngineForName(language, enableScriptEngineCaching)); } return(null); } catch (ProcessApplicationUnavailableException e) { throw new ProcessEngineException("Process Application is unavailable.", e); } catch (System.Exception ex) { throw ex; } }
//protected internal virtual IProcessApplicationReference GetTargetProcessApplication(CaseExecutionEntity execution) //{ // return ProcessApplicationContextUtil.getTargetProcessApplication(execution); //} protected internal virtual bool RequiresContextSwitch(IProcessApplicationReference processApplicationReference) { return(ProcessApplicationContextUtil.RequiresContextSwitch(processApplicationReference)); }
protected internal virtual IDictionary <string, IList <ExecutableScript> > GetPaEnvScripts(IProcessApplicationReference pa) { try { IProcessApplicationInterface processApplication = pa.ProcessApplication; IProcessApplicationInterface rawObject = processApplication.RawObject; if (rawObject is AbstractProcessApplication) { AbstractProcessApplication abstractProcessApplication = (AbstractProcessApplication)rawObject; return(abstractProcessApplication.EnvironmentScripts); } return(null); } catch (ProcessApplicationUnavailableException e) { throw new ProcessEngineException("Process Application is unavailable.", e); } }
public virtual IProcessApplicationDeploymentBuilder CreateDeployment( IProcessApplicationReference processApplication) { return(new ProcessApplicationDeploymentBuilderImpl(this, processApplication)); }
protected internal virtual void RegisterProcessApplication(string deploymentId, IProcessApplicationReference reference) { disableAuthorization(); managementService.RegisterProcessApplication(deploymentId, reference); enableAuthorization(); }
public ProcessApplicationIdentifier(IProcessApplicationReference reference) { this.reference = reference; }
public virtual IProcessApplicationRegistration RegisterProcessApplication(string deploymentId, IProcessApplicationReference reference) { return(CommandExecutor.Execute(new RegisterProcessApplicationCmd(deploymentId, reference))); }
public DeleteDeploymentFailListener(string deploymentId, IProcessApplicationReference processApplicationReference) { this.DeploymentId = deploymentId; this.processApplicationReference = processApplicationReference; }
public RegisterProcessApplicationCmd(IList <string> deploymentsToRegister, IProcessApplicationReference appReference) { this.DeploymentsToRegister = deploymentsToRegister; Reference = appReference; }
public RegisterProcessApplicationCmd(string deploymentId, IProcessApplicationReference reference) : this(new List <string>() { deploymentId }, reference) { }
public ProcessApplicationDeploymentBuilderImpl(RepositoryServiceImpl repositoryService, IProcessApplicationReference reference) : base(repositoryService) { ProcessApplicationReference = reference; Source(ProcessApplicationDeploymentFields.ProcessApplicationDeploymentSource); }