Beispiel #1
0
        public override void stop(StopContext context)
        {
            ManagedReference reference = null;

            try
            {
                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                invokePreUndeploy(processApplication);
            }
            catch (Exception e)
            {
                LOGGER.log(Level.SEVERE, "Exception while stopping process application", e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }
Beispiel #2
0
 protected internal virtual void ensureInitialized()
 {
     if (selfReference == null)
     {
         selfReference = lookupSelfReference();
     }
     if (ejbProcessApplicationReference == null)
     {
         ejbProcessApplicationReference = new EjbProcessApplicationReference(selfReference, Name);
     }
 }
Beispiel #3
0
        /// <summary>
        /// <para>Takes a callable and executes all engine API invocations within that callable in the context
        /// of the given process application
        ///
        /// </para>
        /// <para>Equivalent to
        /// <pre>
        ///   try {
        ///     ProcessApplicationContext.setCurrentProcessApplication("someProcessApplication");
        ///     callable.call();
        ///   } finally {
        ///     ProcessApplicationContext.clear();
        ///   }
        /// </pre>
        ///
        /// </para>
        /// </summary>
        /// <param name="callable"> the callable to execute </param>
        /// <param name="processApplication"> the process application to switch into </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static <T> T withProcessApplicationContext(java.util.concurrent.Callable<T> callable, ProcessApplicationInterface processApplication) throws Exception
        public static T withProcessApplicationContext <T>(Callable <T> callable, ProcessApplicationInterface processApplication)
        {
            try
            {
                CurrentProcessApplication = processApplication;
                return(callable.call());
            }
            finally
            {
                clear();
            }
        }
Beispiel #4
0
        /// <summary>
        /// <para>Takes a callable and executes all engine API invocations within that callable in the context
        /// of the given process application
        ///
        /// </para>
        /// <para>Equivalent to
        /// <pre>
        ///   try {
        ///     ProcessApplicationContext.setCurrentProcessApplication("someProcessApplication");
        ///     callable.call();
        ///   } finally {
        ///     ProcessApplicationContext.clear();
        ///   }
        /// </pre>
        ///
        /// </para>
        /// </summary>
        /// <param name="callable"> the callable to execute </param>
        /// <param name="reference"> a reference of the process application to switch into </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static <T> T withProcessApplicationContext(java.util.concurrent.Callable<T> callable, ProcessApplicationReference reference) throws Exception
        public static T withProcessApplicationContext <T>(Callable <T> callable, ProcessApplicationReference reference)
        {
            try
            {
                CurrentProcessApplication = reference;
                return(callable.call());
            }
            finally
            {
                clear();
            }
        }
Beispiel #5
0
        /// <summary>
        /// <para>Takes a callable and executes all engine API invocations within that callable in the context
        /// of the given process application
        ///
        /// </para>
        /// <para>Equivalent to
        /// <pre>
        ///   try {
        ///     ProcessApplicationContext.setCurrentProcessApplication("someProcessApplication");
        ///     callable.call();
        ///   } finally {
        ///     ProcessApplicationContext.clear();
        ///   }
        /// </pre>
        ///
        /// </para>
        /// </summary>
        /// <param name="callable"> the callable to execute </param>
        /// <param name="name"> the name of the process application to switch into </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static <T> T withProcessApplicationContext(java.util.concurrent.Callable<T> callable, String processApplicationName) throws Exception
        public static T withProcessApplicationContext <T>(Callable <T> callable, string processApplicationName)
        {
            try
            {
                CurrentProcessApplication = processApplicationName;
                return(callable.call());
            }
            finally
            {
                clear();
            }
        }
Beispiel #6
0
        public virtual void postProcessApplicationDeploy(ProcessApplicationInterface processApplication)
        {
            ProcessApplicationInterface rawPa = processApplication.RawObject;

            if (rawPa is AbstractProcessApplication)
            {
                initializeVariableSerializers((AbstractProcessApplication)rawPa);
            }
            else
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                LOG.logNoDataFormatsInitiailized("process application data formats", "process application is not a sub class of " + typeof(AbstractProcessApplication).FullName);
            }
        }
Beispiel #7
0
 /// <summary>
 /// <para> Stops a process application. Exceptions are logged but not re-thrown).
 ///
 /// </para>
 /// </summary>
 /// <param name="processApplicationReference"> </param>
 protected internal virtual void stopProcessApplication(ProcessApplicationReference processApplicationReference)
 {
     try
     {
         // unless the user has overridden the stop behavior,
         // this causes the process application to remove its services
         // (triggers nested undeployment operation)
         ProcessApplicationInterface processApplication = processApplicationReference.ProcessApplication;
         processApplication.undeploy();
     }
     catch (Exception t)
     {
         LOG.exceptionWhileStopping("Process Application", processApplicationReference.Name, t);
     }
 }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("resource") @Override public void postProcessApplicationUndeploy(org.camunda.bpm.application.ProcessApplicationInterface processApplication)
        public virtual void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication)
        {
            // some tests deploy multiple PAs. => only clean DB after last PA is undeployed
            // if the deployment fails for example during parsing the deployment counter was not incremented
            // so we have to check if the counter is already zero otherwise we go into the negative values
            // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
            if (counter.get() == 0 || counter.decrementAndGet() == 0)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.ProcessEngine defaultProcessEngine = org.camunda.bpm.BpmPlatform.getDefaultProcessEngine();
                ProcessEngine defaultProcessEngine = BpmPlatform.DefaultProcessEngine;
                try
                {
                    logger.log(Level.INFO, "=== Ensure Clean Database ===");
                    ManagementServiceImpl managementService = (ManagementServiceImpl)defaultProcessEngine.ManagementService;
                    PurgeReport           report            = managementService.purge();

                    if (report.Empty)
                    {
                        logger.log(Level.INFO, "Clean DB and cache.");
                    }
                    else
                    {
                        StringBuilder builder = new StringBuilder();

                        DatabasePurgeReport databasePurgeReport = report.DatabasePurgeReport;
                        if (!databasePurgeReport.Empty)
                        {
                            builder.Append(DATABASE_NOT_CLEAN).Append(databasePurgeReport.PurgeReportAsString);
                        }

                        CachePurgeReport cachePurgeReport = report.CachePurgeReport;
                        if (!cachePurgeReport.Empty)
                        {
                            builder.Append(CACHE_IS_NOT_CLEAN).Append(cachePurgeReport.PurgeReportAsString);
                        }
                        logger.log(Level.INFO, builder.ToString());
                    }
                }
                catch (Exception e)
                {
                    logger.log(Level.SEVERE, "Could not clean DB:", e);
                }
            }
        }
Beispiel #9
0
        protected internal virtual IDictionary <string, IList <ExecutableScript> > getPaEnvScripts(ProcessApplicationReference pa)
        {
            try
            {
                ProcessApplicationInterface processApplication = pa.ProcessApplication;
                ProcessApplicationInterface 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);
            }
        }
Beispiel #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void invokePostDeploy(final org.camunda.bpm.application.ProcessApplicationInterface processApplication) throws ClassNotFoundException, org.jboss.msc.service.StartException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        protected internal virtual void invokePostDeploy(ProcessApplicationInterface processApplication)
        {
            Type paClass = getPaClass(postDeployDescription);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Method postDeployMethod = org.camunda.bpm.container.impl.deployment.util.InjectionUtil.detectAnnotatedMethod(paClass, org.camunda.bpm.application.PostDeploy.class);
            System.Reflection.MethodInfo postDeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, typeof(PostDeploy));

            if (postDeployMethod != null)
            {
                try
                {
                    processApplication.execute(new CallableAnonymousInnerClass(this, processApplication, postDeployMethod));
                }
                catch (Exception e)
                {
                    throw new StartException("Exception while invoking the @PostDeploy method ", e);
                }
            }
        }
Beispiel #11
0
        public override void stop(StopContext arg0)
        {
            ManagedReference reference = null;

            try
            {
                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                BpmPlatformPlugins        bpmPlatformPlugins = platformPluginsInjector.Value;
                IList <BpmPlatformPlugin> plugins            = bpmPlatformPlugins.Plugins;

                foreach (BpmPlatformPlugin bpmPlatformPlugin in plugins)
                {
                    bpmPlatformPlugin.postProcessApplicationUndeploy(processApplication);
                }
            }
            catch (Exception e)
            {
                LOGGER.log(Level.WARNING, "Exception while invoking BpmPlatformPlugin.postProcessApplicationUndeploy", e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }
Beispiel #12
0
        public static T executeWithinProcessApplication <T>(Callable <T> callback, ProcessApplicationReference processApplicationReference, InvocationContext invocationContext)
        {
            string paName = processApplicationReference.Name;

            try
            {
                ProcessApplicationInterface processApplication = processApplicationReference.ProcessApplication;
                CurrentProcessApplication = processApplicationReference;

                try
                {
                    // wrap callback
                    ProcessApplicationClassloaderInterceptor <T> wrappedCallback = new ProcessApplicationClassloaderInterceptor <T>(callback);
                    // execute wrapped callback
                    return(processApplication.execute(wrappedCallback, invocationContext));
                }
                catch (Exception e)
                {
                    // unwrap exception
                    if (e.InnerException != null && e.InnerException is Exception)
                    {
                        throw (Exception)e.InnerException;
                    }
                    else
                    {
                        throw new ProcessEngineException("Unexpected exeption while executing within process application ", e);
                    }
                }
                finally
                {
                    removeCurrentProcessApplication();
                }
            }
            catch (ProcessApplicationUnavailableException e)
            {
                throw new ProcessEngineException("Cannot switch to process application '" + paName + "' for execution: " + e.Message, e);
            }
        }
Beispiel #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void notifyTaskListener(org.camunda.bpm.engine.delegate.DelegateTask task) throws Exception
        protected internal virtual void notifyTaskListener(DelegateTask task)
        {
            ProcessApplicationReference processApp = Context.CurrentProcessApplication;

            try
            {
                ProcessApplicationInterface processApplication = processApp.ProcessApplication;
                TaskListener taskListener = processApplication.TaskListener;
                if (taskListener != null)
                {
                    taskListener.notify(task);
                }
                else
                {
                    LOG.paDoesNotProvideTaskListener(processApp.Name);
                }
            }
            catch (ProcessApplicationUnavailableException e)
            {
                // Process Application unavailable => ignore silently
                LOG.cannotInvokeListenerPaUnavailable(processApp.Name, e);
            }
        }
Beispiel #14
0
 public CallableAnonymousInnerClass2(ProcessApplicationStartService outerInstance, ProcessApplicationInterface processApplication, System.Reflection.MethodInfo preUndeployMethod)
 {
     this.outerInstance      = outerInstance;
     this.processApplication = processApplication;
     this.preUndeployMethod  = preUndeployMethod;
 }
Beispiel #15
0
 public virtual void postProcessApplicationDeploy(ProcessApplicationInterface processApplication)
 {
     counter.incrementAndGet();
 }
Beispiel #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void performDeployment() throws org.jboss.msc.service.StartException
        protected internal virtual void performDeployment()
        {
            ManagedReference reference = null;

            try
            {
                // get process engine
                ProcessEngine processEngine = processEngineInjector.Value;

                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                // get the application name
                string processApplicationName = processApplication.Name;

                // build the deployment
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.RepositoryService repositoryService = processEngine.getRepositoryService();
                RepositoryService repositoryService = processEngine.RepositoryService;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.repository.ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());
                ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.Reference);

                // enable duplicate filtering
                deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_DEPLOY_CHANGED_ONLY, false));

                // enable resuming of previous versions:
                if (PropertyHelper.getBooleanProperty(processArchive.Properties, org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml_Fields.PROP_IS_RESUME_PREVIOUS_VERSIONS, true))
                {
                    enableResumingOfPreviousVersions(deploymentBuilder);
                }

                // set the name for the deployment
                string deploymentName = processArchive.Name;
                if (string.ReferenceEquals(deploymentName, null) || deploymentName.Length == 0)
                {
                    deploymentName = processApplicationName;
                }
                deploymentBuilder.name(deploymentName);

                // set the tenant id for the deployment
                string tenantId = processArchive.TenantId;
                if (!string.ReferenceEquals(tenantId, null) && tenantId.Length > 0)
                {
                    deploymentBuilder.tenantId(tenantId);
                }

                // add deployment resources
                foreach (KeyValuePair <string, sbyte[]> resource in deploymentMap.SetOfKeyValuePairs())
                {
                    deploymentBuilder.addInputStream(resource.Key, new MemoryStream(resource.Value));
                }

                // let the process application component add resources to the deployment.
                processApplication.createDeployment(processArchive.Name, deploymentBuilder);

                ICollection <string> resourceNames = deploymentBuilder.ResourceNames;
                if (resourceNames.Count > 0)
                {
                    logDeploymentSummary(resourceNames, deploymentName, processApplicationName);
                    // perform the actual deployment
                    deployment = Tccl.runUnderClassloader(new OperationAnonymousInnerClass(this, deploymentBuilder)
                                                          , module.ClassLoader);
                }
                else
                {
                    LOGGER.info("Not creating a deployment for process archive '" + processArchive.Name + "': no resources provided.");
                }
            }
            catch (Exception e)
            {
                throw new StartException("Could not register process application with shared process engine ", e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }
Beispiel #17
0
 public EjbProcessApplicationReference(ProcessApplicationInterface selfReference, string name)
 {
     this.selfReference          = selfReference;
     this.processApplicationName = name;
 }
Beispiel #18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
        public override void start(StartContext context)
        {
            ManagedReference reference = null;

            try
            {
                // get the process application component
                ProcessApplicationInterface processApplication = null;
                ComponentView componentView = paComponentViewInjector.OptionalValue;
                if (componentView != null)
                {
                    reference          = componentView.createInstance();
                    processApplication = (ProcessApplicationInterface)reference.Instance;
                }
                else
                {
                    processApplication = noViewProcessApplication.Value;
                }

                // create & populate the process application info object
                processApplicationInfo            = new ProcessApplicationInfoImpl();
                processApplicationInfo.Name       = processApplication.Name;
                processApplicationInfo.Properties = processApplication.Properties;

                referencedProcessEngines = new HashSet <ProcessEngine>();
                IList <ProcessApplicationDeploymentInfo> deploymentInfos = new List <ProcessApplicationDeploymentInfo>();

                foreach (ServiceName deploymentServiceName in deploymentServiceNames)
                {
                    ProcessApplicationDeploymentService value = getDeploymentService(context, deploymentServiceName);
                    referencedProcessEngines.Add(value.ProcessEngineInjector.Value);

                    ProcessApplicationDeployment deployment = value.Deployment;
                    if (deployment != null)
                    {
                        foreach (string deploymentId in deployment.ProcessApplicationRegistration.DeploymentIds)
                        {
                            ProcessApplicationDeploymentInfoImpl deploymentInfo = new ProcessApplicationDeploymentInfoImpl();
                            deploymentInfo.DeploymentId      = deploymentId;
                            deploymentInfo.ProcessEngineName = value.ProcessEngineName;
                            deploymentInfos.Add(deploymentInfo);
                        }
                    }
                }
                processApplicationInfo.DeploymentInfo = deploymentInfos;

                notifyBpmPlatformPlugins(platformPluginsInjector.Value, processApplication);

                if (postDeployDescription != null)
                {
                    invokePostDeploy(processApplication);
                }

                // install the ManagedProcessApplication Service as a child to this service
                // if this service stops (at undeployment) the ManagedProcessApplication service is removed as well.
                ServiceName serviceName = ServiceNames.forManagedProcessApplication(processApplicationInfo.Name);
                MscManagedProcessApplication managedProcessApplication = new MscManagedProcessApplication(processApplicationInfo, processApplication.Reference);
                context.ChildTarget.addService(serviceName, managedProcessApplication).install();
            }
            catch (StartException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new StartException(e);
            }
            finally
            {
                if (reference != null)
                {
                    reference.release();
                }
            }
        }
Beispiel #19
0
 protected internal virtual void notifyBpmPlatformPlugins(BpmPlatformPlugins value, ProcessApplicationInterface processApplication)
 {
     foreach (BpmPlatformPlugin plugin in value.Plugins)
     {
         plugin.postProcessApplicationDeploy(processApplication);
     }
 }
Beispiel #20
0
 public virtual void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication)
 {
 }
Beispiel #21
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected void executeScript(final org.camunda.bpm.application.ProcessApplicationInterface processApplication)
        protected internal virtual void executeScript(ProcessApplicationInterface processApplication)
        {
            processEngineConfiguration.CommandExecutorTxRequired.execute(new CommandAnonymousInnerClass(this, processApplication));
        }
Beispiel #22
0
 public ProcessApplicationIdentifier(ProcessApplicationInterface processApplication)
 {
     this.processApplication = processApplication;
 }
Beispiel #23
0
 public CommandAnonymousInnerClass(EnvScriptCachingTest outerInstance, ProcessApplicationInterface processApplication)
 {
     this.outerInstance      = outerInstance;
     this.processApplication = processApplication;
 }
Beispiel #24
0
 public ProcessApplicationScriptEnvironment(ProcessApplicationInterface processApplication)
 {
     this.processApplication = processApplication;
 }