<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by kanav bahri on Medium]]></title>
        <description><![CDATA[Stories by kanav bahri on Medium]]></description>
        <link>https://medium.com/@kanavbahri?source=rss-a145d892d9d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by kanav bahri on Medium</title>
            <link>https://medium.com/@kanavbahri?source=rss-a145d892d9d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:58:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kanavbahri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ECMAScript]]></title>
            <link>https://kanavbahri.medium.com/ecmascript-5a5ad954073a?source=rss-a145d892d9d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a5ad954073a</guid>
            <category><![CDATA[js]]></category>
            <category><![CDATA[ecmascript2019]]></category>
            <dc:creator><![CDATA[kanav bahri]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 04:40:00 GMT</pubDate>
            <atom:updated>2021-02-18T04:40:00.756Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_cXwYKQwwVlvzFKI" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=medium&amp;utm_medium=referral">Safar Safarov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>ECMAScript</strong> is a language specification standardized by <strong>European Computer Manufacturers Association(ECMA)</strong>. ECMAScript (ES) is a scripting language specification standardized by ECMAScript International. It is used by applications to enable client-side scripting.</p><blockquote>Its New Features</blockquote><h3>Asynchronous Generators and Iteration</h3><p>Asynchronous generators can be made asynchronous by using the <strong>async</strong> keyword. The <strong>syntax</strong> for defining an async generator is given below −</p><pre>async function* generator_name() {<br>   //statements<br>}</pre><h3>Example</h3><p>Following example shows an async generator which returns Promise on each call to the <strong>next()</strong>method of generator.</p><pre>&lt;script&gt;<br>   async function* load(){<br>      yield await Promise.resolve(1);<br>      yield await Promise.resolve(2);<br>      yield await Promise.resolve(3);<br>   }<br>   <br>   let x= load();<br>   x.next().then(r=&gt;console.log(r))<br>   x.next().then(r=&gt;console.log(r))<br>   x.next().then(r=&gt;console.log(r))<br>   x.next().then(r=&gt;console.log(r))<br>&lt;/script&gt;</pre><pre>The output of the above code will be as follows −</pre><pre>{value: 1, done: false}<br>{value: 2, done: false}<br>{value: 3, done: false}<br>{value: undefined, done: true}</pre><h3>for await of loop</h3><p>Asynchronous iterables cannot be iterated using the traditional <strong>for..of loop</strong> syntax as they return promises. ES9 introduces the <strong>for await of loop</strong> to support <strong>asynchronous iteration</strong>.</p><p>The syntax for using the <strong>for await of loop</strong> is given below, where,</p><ul><li>On each iteration a value of a different property is assigned to <strong>variable</strong> and a variable may be declared with const, let, or var.</li><li><strong>iterable</strong> − Object whose iterable properties are to be iterated over.</li></ul><pre>for await (variable of iterable) {<br>   statement<br>}</pre><h3>Example</h3><p>The following example shows the use of for await of loop to iterate an async generator.</p><pre>&lt;script&gt;<br>   async function* load(){<br>      yield await Promise.resolve(1);<br>      yield await Promise.resolve(2);<br>      yield await Promise.resolve(3);<br>   }</pre><pre>   async function test(){<br>      for await (const val of load()){<br>         console.log(val)<br>      }<br>   }<br>   test();<br>   console.log(&#39;end of script&#39;)<br>&lt;/script&gt;</pre><p>The output of the above code will be as shown below −</p><pre>end of script<br>1<br>2<br>3</pre><h3>Rest/Spread Properties</h3><p>ES9 supports the use of Rest and Spread operators with Objects.</p><h3>Example: Object and Rest Operator</h3><p>The following example shows the use of rest operator with an object. The value of age property of student is copied into the age variable while the values of the remaining properties are copied into the other variable using the rest syntax `…`.</p><pre>&lt;script&gt;<br>   const student = {<br>      age:10,<br>      height:5,<br>      weight:50<br>   }<br>   const {age,...other} = student;<br>   console.log(age)<br>   console.log(other)<br>&lt;/script&gt;</pre><p>The output of the above code will be as given below −</p><pre>10<br>{height: 5, weight: 50}</pre><h3>Promise: finally()</h3><p>The <strong>finally()</strong> is executed whenever a promise is settled, regardless of its outcome. This function returns a promise. It can be used to avoid code duplication in both the promise’s <strong>then()</strong> and <strong>catch()</strong>handlers.</p><h3>Syntax</h3><p>The below mentioned syntax is for the function <strong>finally()</strong>.</p><pre>promise.finally(function() {<br>});<br>promise.finally(()=&gt; {<br>});</pre><h3>Example</h3><p>The following example declares a async function that returns the square of a positive number after a delay of 3 seconds. The function throws an error if a negative number is passed. The statements in the finally block is executed in either case, whether the promise is rejected or resolved.</p><pre>&lt;script&gt;<br>   let asyncSquareFn = function(n1){<br>      return new Promise((resolve,reject)=&gt;{<br>         setTimeout(()=&gt;{<br>            if(n1&gt;=0){<br>               resolve(n1*n1)<br>            }<br>            else reject(&#39;NOT_POSITIVE_NO&#39;)<br>         },3000)<br>      })<br>   }<br>   console.log(&#39;Start&#39;)</pre><pre>   asyncSquareFn(10)//modify to add -10<br>   .then(result=&gt;{<br>      console.log(&quot;result is&quot;,result)<br>   }).catch(error=&gt;console.log(error))<br>   .finally(() =&gt;{<br>      console.log(&quot;inside finally&quot;)<br>      console.log(&quot;executes all the time&quot;)<br>   })</pre><pre>   console.log(&quot;End&quot;);<br>&lt;/script&gt;</pre><h3>Regular Expression feature</h3><p>In regular expressions, the dot operator or a period is use to match a single character. The <strong>. dot operator</strong> skips line break characters like <strong>\n, \r</strong> as shown in the below example −</p><pre>console.log(/Tutorials.Point/.test(&#39;Tutorials_Point&#39;)); //true<br>console.log(/Tutorials.Point/.test(&#39;Tutorials\nPoint&#39;)); //false<br>console.log(/Tutorials.Point/.test(&#39;Tutorials\rPoint&#39;)); //false</pre><p>A regular expression pattern is represented as the / <strong>regular_expression /.</strong> The test() method takes a string parameter and searches for the regex pattern. In the above example, the <strong>test() method</strong>searches for pattern starting with Tutorials, followed by any single character and ending with Point. If we use the <strong>\n</strong> or <strong>\r</strong> in the input string between Tutorials and Point the test() method will return false.</p><pre>true<br>false<br>false</pre><p>ES9 introduces a new flag — <strong>DotAllFlag (\s)</strong> that can be used with Regex to match line terminators and emojis. This is shown in the following example −</p><pre>console.log(/Tutorials.Point/s.test(&#39;Tutorials\nPoint&#39;));<br>console.log(/Tutorials.Point/s.test(&#39;Tutorials\rPoint&#39;));</pre><p>The output of the above code will be as mentioned below −</p><pre>true<br>true</pre><h3>Named Capture Groups</h3><p>Prior to ES9, capture groups were accessed by indexes. ES9 allows us to assign names to capture groups. The syntax for the same is given below −</p><pre>(?&lt;Name1&gt;pattern1)</pre><h3>Example</h3><pre>const birthDatePattern = /(?&lt;myYear&gt;[0-9]{4})-(?&lt;myMonth&gt;[0-9]{2})/;<br>const birthDate = birthDatePattern.exec(&#39;1999-04&#39;);<br>console.log(birthDate.groups.myYear);<br>console.log(birthDate.groups.myMonth);</pre><p>The output of the above code is as shown below −</p><pre>1999<br>04</pre><p>ref: <a href="https://www.tutorialspoint.com/es6/index.htm">https://www.tutorialspoint.com/es6/index.htm</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LQeSRiz8u7xK3YmG" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a5ad954073a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[While Designing we require icons and photos for our apps]]></title>
            <link>https://kanavbahri.medium.com/while-designing-we-require-icons-and-photos-for-our-apps-7cf74eeb7fc6?source=rss-a145d892d9d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cf74eeb7fc6</guid>
            <category><![CDATA[ui-ux-design]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[free]]></category>
            <dc:creator><![CDATA[kanav bahri]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 11:43:57 GMT</pubDate>
            <atom:updated>2021-02-14T11:43:57.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_XAOGTrskn1-9B9l" /><figcaption>Photo by <a href="https://unsplash.com/@uxstore?utm_source=medium&amp;utm_medium=referral">UX Store</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>While Designing we require icons and photos for our apps</blockquote><p>Here these are…</p><p>Wunderstock</p><p><a href="https://wunderstock.com/">Wunderstock: Free Photos for Everyone</a></p><p>FlatIcons</p><p><a href="https://www.flaticon.com/">Free Icons and Stickers - Millions of resources to download</a></p><p>Vecteezy</p><p><a href="https://www.vecteezy.com/">Download Free Vectors, Images, Photos &amp; Videos | Vecteezy</a></p><p>Material Icons</p><p><a href="https://material.io/resources/icons/?style=baseline">Material Icons</a></p><p>Freepik</p><p><a href="https://www.freepik.com/">Freepik | Graphic Resources for everyone</a></p><p>Font Awesome</p><p><a href="https://fontawesome.com/">Font Awesome</a></p><p>Unsplash</p><p><a href="https://unsplash.com/">Beautiful Free Images &amp; Pictures | Unsplash</a></p><p>Iconfinder</p><p><a href="https://www.iconfinder.com/icon-sets/featured/free">Browse staff picks</a></p><p>StockSnap.io</p><p><a href="https://stocksnap.io/">Free Stock Photos and Images - StockSnap.io</a></p><p>FreeIcons</p><p><a href="https://freeicons.io/">Free icons - Free vector icons - Free SVG, PSD, PNG, EPS, Ai &amp; Icon Font</a></p><p>I hope the above mentioned sites will help you guys…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YgPo2Arh61KsfaCA" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cf74eeb7fc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON Compact Overview]]></title>
            <link>https://kanavbahri.medium.com/json-compact-overview-dfaaa50b9526?source=rss-a145d892d9d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfaaa50b9526</guid>
            <category><![CDATA[parsing]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[stringify]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-object]]></category>
            <dc:creator><![CDATA[kanav bahri]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 10:12:34 GMT</pubDate>
            <atom:updated>2021-02-14T10:12:34.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hahUVuudcsNaBdWA" /><figcaption>Photo by <a href="https://unsplash.com/@maxcodes?utm_source=medium&amp;utm_medium=referral">Maxwell Nelson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>JavaScript Object Notation</strong>, commonly known as <strong>&#39;JSON&#39;</strong>, is heavily leveraged as a data-interchange format. JSON is a subset of the JavaScript Programming language</p><p>JSON is a <strong>lightweight text format</strong> that is <strong>independent of any programming Languages</strong> thus making it an ideal option for data-interchange in today&#39;s Business world.</p><h3>JSON Usage</h3><ul><li><strong>Transfers data</strong> between a <strong>server and various web applications</strong>.</li><li><strong>Performs asynchronous</strong> data calls without requiring a page refresh. This is widely used for <strong>asynchronous browser/server communicatio.</strong></li><li><strong>APIs and web services</strong> use JSON to <strong>transfer real-time sensitive data</strong>.</li><li><strong>Compiles</strong> user data for local storage.</li><li>JSON is now being supported by almost all <strong>Programming languages</strong>.</li><li>JSON supports for <strong>sending, reading, and receiving</strong> texts available in all the real-world business.</li></ul><h3>JSON Syntax Rules</h3><p>JSON syntax is basically considered as a subset of JavaScript syntax; it includes the following</p><ul><li>Keys must necessarily be strings, written with double quotes. <strong>Example: </strong><strong>&quot;Value&quot;</strong></li><li>Data can be a <strong>Name/value pairs</strong> that consist of a field name inside double quotes, followed by a colon, and then by a value inside double quotes <strong>Example:</strong><strong>&quot;Value&quot;:&quot;12345&quot;</strong></li><li>Data must be separated by Commas ‘<strong>,</strong>’. <strong>Example: </strong><strong>&quot;Katsa&quot;, &quot;Aelin&quot;</strong></li><li>Curly brackets <strong>{}</strong> to hold objects <strong>Example: </strong><strong>{ &quot;Value&quot;:&quot;12345&quot; }</strong></li><li>Square brackets <strong>[]</strong> hold arrays <strong>Example: </strong><strong>{&quot;Animals&quot;:[ &quot;Tiger&quot;, &quot;Leopard &quot;, &quot;Lion&quot; ]}</strong></li></ul><h3>Valid Data Types</h3><p>In JSON, values must be one of the following data types:</p><ul><li>a string</li><li>a number</li><li>an object (JSON object)</li><li>an array</li><li>a boolean</li><li><em>null</em></li></ul><p>JSON values <strong>cannot </strong>be one of the following data types:</p><ul><li>a function</li><li>a date</li><li><em>undefined</em></li></ul><h3>JSON.parse()</h3><p>When receiving data from a web server, the data is always a string. Parse the data with JSON.parse()</p><p>Example <br>‘{ “name”:”Aelin”, “age”:17, “city”:”Terrassen”}’<br>var obj = JSON.parse(‘{ “name”:”Aelin”, “age”:17, “city”:”Terrassen”}’);</p><p>By this you can access name or other properties via obj.name…</p><h3>JSON.stringify()</h3><p>When sending data to a web server, the data has to be a string. Convert a JavaScript object into a string with JSON.stringify().</p><p>var obj = { name: “Rowan”, age: 30, city: “NA” };<br>var myJSON = JSON.stringify(obj);</p><p>Result: {“name”:”Rowan”,”age”:30,”city”:”NA”}</p><p>Ref: <a href="https://www.json.org/json-en.html">https://www.json.org/json-en.html</a><br><a href="https://www.w3schools.com/js/js_json_intro.asp">https://www.w3schools.com/js/js_json_intro.asp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h_1ekTDFWINOky5T" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfaaa50b9526" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JS Shorthands in a Clean and Easy way]]></title>
            <link>https://kanavbahri.medium.com/js-shorthands-in-a-clean-and-easy-way-3ad8c0009d9e?source=rss-a145d892d9d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ad8c0009d9e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[shorthand]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[kanav bahri]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 09:01:39 GMT</pubDate>
            <atom:updated>2021-02-14T09:01:39.412Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pq1kDkl0zINZ-aD2" /><figcaption>Photo by <a href="https://unsplash.com/@4themorningshoot?utm_source=medium&amp;utm_medium=referral">Oliver Hale</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>Better</em> <em>way to return</em></blockquote><p>Instead of this</p><blockquote>const meaningFullName = (element) =&gt; {</blockquote><blockquote>return element.values</blockquote><blockquote>}</blockquote><p>use this</p><blockquote>const meaningFullName = (element) =&gt; element.values</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0AKLs4CFBcBs1qSK" /><figcaption>Photo by <a href="https://unsplash.com/@girlwithredhat?utm_source=medium&amp;utm_medium=referral">Girl with red hat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>Arrays Naming convention</em></blockquote><p><strong>Reasons for using a naming convention</strong> include the following:</p><ul><li>To reduce the effort needed to read and understand source code.</li><li>To enable code reviews to focus on more important issues than arguing over syntax and naming standards.</li><li>To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences.</li></ul><blockquote>const students = [‘Rowan ’, ‘Lisa’, ‘Katsa’, ‘Aelin’]</blockquote><p>The above <strong>variable</strong> example will usually hold a list of items; therefore, append an ’<strong>s</strong>’ to your variable name.</p><blockquote><em>Better way to log the objects (console.log…)</em></blockquote><p>Instead of this</p><blockquote>console.log(obj1);</blockquote><blockquote>console.log(obj2);</blockquote><p>use this</p><blockquote>console.log({obj1, obj2})</blockquote><blockquote>Strong type checks</blockquote><p>Use === instead of ==, Becasue we want the value and the type to be equal below is the example.</p><blockquote>const val = “xyz”;</blockquote><blockquote>if (val === xyz) {</blockquote><blockquote>console.log(val);</blockquote><blockquote>// it cannot not be reached</blockquote><blockquote>}</blockquote><blockquote>if (val === “xyz”) {</blockquote><blockquote>console.log(val);</blockquote><blockquote>// it can be reached</blockquote><blockquote>}</blockquote><blockquote><em>Better way to log conditionally</em></blockquote><p>instead of this way</p><blockquote>if(condition ){</blockquote><blockquote>console.log(‘output’);</blockquote><blockquote>}</blockquote><p>use the following way</p><blockquote>condition &amp;&amp; console.log(‘output’);</blockquote><blockquote>Boolean</blockquote><p>Simply start with <strong>is</strong> or <strong>has</strong> to be close to natural language. Reason for using <strong>is</strong> or <strong>has</strong> because we are either expecting true or false depends upon the logic being used.</p><blockquote>const isAvailable= true // OR false</blockquote><blockquote><em>Assigning Alternate Value for null variables</em></blockquote><p>instead of this way</p><blockquote>const meaningFullName(val){</blockquote><blockquote>if(val == null ){</blockquote><blockquote>val=11;</blockquote><blockquote>}</blockquote><blockquote>}</blockquote><p>use the following way</p><blockquote>const meaningFullName(val=50){</blockquote><blockquote>// Your Code</blockquote><blockquote>}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BIXO7RlYJQteLvO5" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ad8c0009d9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activiti Overview]]></title>
            <link>https://kanavbahri.medium.com/activiti-overview-e6d2754687c1?source=rss-a145d892d9d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6d2754687c1</guid>
            <category><![CDATA[activiti]]></category>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[bpmn2]]></category>
            <dc:creator><![CDATA[kanav bahri]]></dc:creator>
            <pubDate>Mon, 20 Jan 2020 02:27:20 GMT</pubDate>
            <atom:updated>2020-01-20T02:27:20.402Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*3Yf0KpKJe5nomeuiz3ToFw.png" /></figure><p><strong>Activiti </strong>is an open-source <strong>workflow engine </strong>written in Java that can execute business processes described in <strong>BPMN 2.0</strong>. <strong>Activiti </strong>is the foundation for Alfresco’s <strong>Alfresco Process Services </strong>and <strong>Alfresco </strong>is the <strong>Activiti </strong>project’s leading sponsor.</p><h3><strong>Overview:</strong></h3><p><strong>Activiti API </strong>is a <strong>workflow </strong>and <strong>Business Process Management</strong> system. We can define a process in it, execute it, and manipulate it in different ways using the services provided by the API. It requires JDK 7+.</p><p><strong>Activiti </strong>development can be done with the <strong>IDE </strong>of your choice. If you would like to use the <strong>Activiti Designer</strong> then you need <strong>Eclipse Kepler or Luna</strong>.</p><h3>Activiti setup</h3><p>To install Activiti you’ll need a working <a href="http://java.sun.com/javase/downloads/index.jsp">Java runtime</a> and <a href="http://tomcat.apache.org/download-70.cgi">Apache Tomcat</a> installation.</p><p>To get the Activiti UI and REST web applications running just copy the WARs downloaded from the Activiti download page to the <strong>webapps</strong> folder in your Tomcat installation directory. By default the UI application runs with an in-memory database along with a default user.</p><p>userId: admin</p><p>password: test</p><h3>Maven Dependencies</h3><p>To use this API, we need to include the Activiti dependency:</p><p>&lt;dependency&gt;</p><p>&lt;groupId&gt;org.activiti&lt;/groupId&gt;</p><p>&lt;artifactId&gt;activiti-engine&lt;/artifactId&gt;</p><p>&lt;/dependency&gt;</p><h3>Configuration</h3><h4>Creating a ProcessEngine</h4><p>The Activiti process engine is configured through an XML file called <strong>activiti.cfg.xml</strong>.</p><p>&lt;beans xmlns=&quot;...&quot;&gt;</p><p>&lt;bean id=&quot;processEngineConfiguration&quot; class=</p><p>&quot;org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration&quot;&gt;</p><p>value=&quot;jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000&quot; /&gt;</p><p>&lt;property name=&quot;jdbcDriver&quot; value=&quot;org.postgresql.Driver /&gt;</p><p>&lt;property name=&quot;jdbcUsername&quot; value=&quot;root&quot; /&gt;</p><p>&lt;property name=&quot;jdbcPassword&quot; value=&quot;&quot; /&gt;</p><p>&lt;property name=&quot;databaseSchemaUpdate&quot; value=&quot;true&quot; /&gt;</p><p>&lt;/bean&gt;</p><p>&lt;/beans&gt;</p><p>Now we can obtain the <em>ProcessEngine</em> using the <em>ProcessEngines</em> class:</p><p>ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();</p><h3>Activiti Process Engine API and Services</h3><p>The engine API is the most common way of interacting with Activiti. From the ProcessEngine, you can obtain the various services that contain the workflow/BPM methods. ProcessEngine and the services objects are thread safe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*HT-Vlo1s09wWE38v38i6jw.png" /></figure><h3>Services</h3><ul><li><strong><em>RepositoryService</em></strong> helps us manipulate the deployment of process definitions. This service deals with the static data related to a process definition</li><li><strong><em>RuntimeService</em></strong> manages the <em>ProcessInstances</em> (currently running processes) as well as the process variables</li><li><strong><em>TaskService</em></strong> keeps track of the <em>UserTasks</em>. The <em>Tasks</em> that need to be carried out manually by a user are at the core of the Activiti API. We can create a task, claim and complete a task, manipulate the assignee of the task, etc. using this service</li><li><strong><em>FormService</em></strong> is an optional service. The API can be used without it, and without sacrificing any of its features. It is used to define the start form and task form in a process.</li><li><strong><em>IdentityService</em></strong> manages the <em>Users</em> and <em>Groups</em></li><li><strong><em>HistoryService</em></strong> keeps track of the history of Activiti Engine. We can also set different history levels.</li><li><strong><em>ManagementService</em></strong> is related to the metadata and usually not required when creating an application.</li><li><strong><em>DynamicBpmnService </em></strong>helps us to change anything in a process without redeploying it.</li></ul><h3>Working with the Activiti services</h3><p>The way to interact with the Activiti engine is through the services exposed by an instance of the <strong>org.activiti.engine.ProcessEngine</strong> class. The following code snippets assume you have a working Activiti environment, i.e. you have access to a valid <strong>org.activiti.engine.ProcessEngine</strong>.</p><p>As we can see in the diagram, it is a very simple process. The employee makes a vacation request, providing the number of days and the start date of vacation. The request goes to the manager. They can approve/disapprove the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*DagPo6XOM2V__noCIKkeZA.png" /></figure><p>If approved, there is a Service task defined to send the confirmation email. If disapproved, the Employee can either select to modify and resend the request, or do nothing.</p><h4>Deploying the process</h4><p>Everything that is related to <em>static</em> data (such as process definitions) are accessed through the <strong>RepositoryService</strong>. Conceptually, every such static piece of data is content of the <em>repository</em> of the Activiti engine.</p><h4>Starting a process instance</h4><p>After deploying the process definition to the Activiti engine, we can start new process instances from it. For each process definition, there are typically many process instances. The process definition is the <em>blueprint</em>, while a process instance is a runtime execution of it.</p><p>Everything related to the runtime state of processes can be found in the <strong>RuntimeService</strong>.</p><h4>Completing tasks</h4><p>When the process starts, the first step will be a user task. This is a step that must be performed by a user of the system. Typically, such a user will have an <em>inbox of tasks</em> which lists all the tasks that need to be done by this user.</p><p>To continue the process instance, we need to finish this task. For the Activiti engine, this means you need to <strong>complete</strong> the task.</p><h4>Suspending and activating a process</h4><p>It’s possible to suspend a process definition. When a process definition is suspended, new process instance can’t be created (an exception will be thrown). Suspending the process definition is done through the <strong>RepositoryService</strong></p><p>Reference</p><p><a href="https://www.activiti.org/userguide/">https://www.activiti.org/userguide/</a></p><p><a href="https://www.baeldung.com/java-activiti">https://www.baeldung.com/java-activiti</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6d2754687c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>