strolch-website/docs/development/index.html

63 lines
21 KiB
HTML

<!doctype html><html lang=en class="js csstransforms3d"><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=generator content="Hugo 0.80.0"><meta name=description content="Strolch is a parameterized framework for use on servers and IoT"><meta name=author content="Strolch"><link rel=icon href=/favicon.ico type=image/ico><title>Development - Strolch</title><link href=/css/nucleus.css?1660651465 rel=stylesheet><link href=/css/fontawesome-all.min.css?1660651465 rel=stylesheet><link href=/css/hybrid.css?1660651465 rel=stylesheet><link href=/css/featherlight.min.css?1660651465 rel=stylesheet><link href=/css/perfect-scrollbar.min.css?1660651465 rel=stylesheet><link href=/css/auto-complete.css?1660651465 rel=stylesheet><link href=/css/atom-one-dark-reasonable.css?1660651465 rel=stylesheet><link href=/css/theme.css?1660651465 rel=stylesheet><link href=/css/hugo-theme.css?1660651465 rel=stylesheet><link href=/css/theme-green.css?1660651465 rel=stylesheet><script src=/js/jquery-3.3.1.min.js?1660651465></script><style>:root #header+#content>#left>#rlblock_left{display:none!important}</style></head><body data-url=/development/><nav id=sidebar><div id=header-wrapper><div id=header><a id=logo href=/><img src=/logo.png></a></div><div class=searchbox><label for=search-by><i class="fas fa-search"></i></label><input data-search-input id=search-by type=search placeholder=Search...>
<span data-search-clear><i class="fas fa-times"></i></span></div><script type=text/javascript src=/js/lunr.min.js?1660651465></script><script type=text/javascript src=/js/auto-complete.js?1660651465></script><script type=text/javascript>var baseurl="https:\/\/strolch.li\/";</script><script type=text/javascript src=/js/search.js?1660651465></script></div><section id=homelinks><ul><li><a class=padding href=/><i class="fas fa-home"></i>Home</a></li></ul></section><div class=highlightable><ul class=topics><li data-nav-id=/api/ title=API class=dd-item><a href=/api/>API</a></li><li data-nav-id=/documentation/ title=Documentation class=dd-item><a href=/documentation/>Documentation</a><ul><li data-nav-id=/documentation/architecture/ title=Architecture class=dd-item><a href=/documentation/architecture/>Architecture</a></li><li data-nav-id=/documentation/model/ title=Model class=dd-item><a href=/documentation/model/>Model</a></li><li data-nav-id=/documentation/do-and-donts/ title="Do and Don't" class=dd-item><a href=/documentation/do-and-donts/>Do and Don't</a></li><li data-nav-id=/documentation/runtime-configuration/ title="Runtime Configuration" class=dd-item><a href=/documentation/runtime-configuration/>Runtime Configuration</a></li><li data-nav-id=/documentation/realms/ title=Realms class=dd-item><a href=/documentation/realms/>Realms</a></li><li data-nav-id=/documentation/components/ title=Components class=dd-item><a href=/documentation/components/>Components</a></li><li data-nav-id=/documentation/services-and-commands/ title="Services and Commands" class=dd-item><a href=/documentation/services-and-commands/>Services and Commands</a></li><li data-nav-id=/documentation/searches/ title=Searches class=dd-item><a href=/documentation/searches/>Searches</a></li><li data-nav-id=/documentation/queries/ title=Queries class=dd-item><a href=/documentation/queries/>Queries</a></li><li data-nav-id=/documentation/transactions/ title=Transactions class=dd-item><a href=/documentation/transactions/>Transactions</a></li><li data-nav-id=/documentation/policies/ title=Policies class=dd-item><a href=/documentation/policies/>Policies</a></li><li data-nav-id=/documentation/observers/ title=Observers class=dd-item><a href=/documentation/observers/>Observers</a></li><li data-nav-id=/documentation/versioning/ title=Versioning class=dd-item><a href=/documentation/versioning/>Versioning</a></li><li data-nav-id=/documentation/reports/ title=Reports class=dd-item><a href=/documentation/reports/>Reports</a></li><li data-nav-id=/documentation/priviles/ title=Privileges class=dd-item><a href=/documentation/priviles/>Privileges</a></li></ul></li><li data-nav-id=/plc/ title=PLC class=dd-item><a href=/plc/>PLC</a><ul><li data-nav-id=/plc/architecture/ title=Architecture class=dd-item><a href=/plc/architecture/>Architecture</a></li><li data-nav-id=/plc/example-set-up/ title="Example Set-Up" class=dd-item><a href=/plc/example-set-up/>Example Set-Up</a></li></ul></li><li data-nav-id=/tutorial/ title=Tutorial class=dd-item><a href=/tutorial/>Tutorial</a><ul><li data-nav-id=/tutorial/configuration/ title=Configuration class=dd-item><a href=/tutorial/configuration/>Configuration</a></li><li data-nav-id=/tutorial/model/ title=Model class=dd-item><a href=/tutorial/model/>Model</a></li><li data-nav-id=/tutorial/crud-book/ title="CRUD Book" class=dd-item><a href=/tutorial/crud-book/>CRUD Book</a></li></ul></li><li data-nav-id=/download/ title=Download class=dd-item><a href=/download/>Download</a></li><li data-nav-id=/development/ title=Development class="dd-item
parent
active"><a href=/development/>Development</a></li><li data-nav-id=/blog/ title=Blog class=dd-item><a href=/blog/>Blog</a><ul><li data-nav-id=/blog/post-00016/ title="Strolch PLC now also on Maven Central" class=dd-item><a href=/blog/post-00016/>Strolch PLC now also on Maven Central</a></li><li data-nav-id=/blog/post-00015/ title="Release of Strolch 1.6.100" class=dd-item><a href=/blog/post-00015/>Release of Strolch 1.6.100</a></li><li data-nav-id=/blog/post-00014/ title="Strolch Reports" class=dd-item><a href=/blog/post-00014/>Strolch Reports</a></li><li data-nav-id=/blog/post-00013/ title="Strolch Searches" class=dd-item><a href=/blog/post-00013/>Strolch Searches</a></li><li data-nav-id=/blog/post-00012/ title="Wow, the many changes!" class=dd-item><a href=/blog/post-00012/>Wow, the many changes!</a></li><li data-nav-id=/blog/post-00011/ title="Strolch now on Maven Central" class=dd-item><a href=/blog/post-00011/>Strolch now on Maven Central</a></li><li data-nav-id=/blog/post-00010/ title="Versioning of objects" class=dd-item><a href=/blog/post-00010/>Versioning of objects</a></li><li data-nav-id=/blog/post-00009/ title="Release 1.2.0" class=dd-item><a href=/blog/post-00009/>Release 1.2.0</a></li><li data-nav-id=/blog/post-00008/ title="Strolch Update" class=dd-item><a href=/blog/post-00008/>Strolch Update</a></li><li data-nav-id=/blog/post-00007/ title="Activities: Beginning of the planning engine" class=dd-item><a href=/blog/post-00007/>Activities: Beginning of the planning engine</a></li><li data-nav-id=/blog/post-00006/ title="Strolch Documentation" class=dd-item><a href=/blog/post-00006/>Strolch Documentation</a></li><li data-nav-id=/blog/post-00005/ title="Strolch Release 1.0.0" class=dd-item><a href=/blog/post-00005/>Strolch Release 1.0.0</a></li><li data-nav-id=/blog/post-00004/ title="DurationParameter and other minor changes: Release 1.0.0-RC4" class=dd-item><a href=/blog/post-00004/>DurationParameter and other minor changes: Release 1.0.0-RC4</a></li><li data-nav-id=/blog/post-00003/ title="DB Initialization: Release 1.0.0-RC3" class=dd-item><a href=/blog/post-00003/>DB Initialization: Release 1.0.0-RC3</a></li><li data-nav-id=/blog/post-00002/ title="Release 1.0.0-RC2" class=dd-item><a href=/blog/post-00002/>Release 1.0.0-RC2</a></li><li data-nav-id=/blog/post-00001/ title="Release 1.0.0-RC1" class=dd-item><a href=/blog/post-00001/>Release 1.0.0-RC1</a></li></ul></li></ul><section id=shortcuts><h3>More</h3><ul><li><a class=padding href=https://strolch.li/tags><i class="fas fa-tags"></i>Tags</a></li><li><a class=padding href=https://github.com/strolch-li target=_blank><i class="fab fa-github"></i>GitHub project</a></li></ul></section><section id=footer><p>Built with <a href=https://github.com/matcornic/hugo-theme-learn target=_blank><i class="fas fa-heart"></i></a>from <a href=https://getgrav.org target=_blank>Grav</a> and <a href=https://gohugo.io/ target=_blank>Hugo</a></p></section></div></nav><section id=body><div id=overlay></div><div class="padding highlightable"><div><div id=top-bar><div id=top-github-link><a class=github-link title="Edit this page" href=https://github.com/strolch-li/strolch-website/tree/develop/content/development/_index.md target=blank><i class="fas fa-code-branch"></i><span id=top-github-link-text>Edit this page</span></a></div><div id=breadcrumbs itemscope itemtype=http://data-vocabulary.org/Breadcrumb><span id=sidebar-toggle-span><a href=# id=sidebar-toggle data-sidebar-toggle><i class="fas fa-bars"></i></a></span><span id=toc-menu><i class="fas fa-list-alt"></i></span><span class=links><a href=/>Strolch Overview</a> > Development</span></div><div class=progress><div class=wrapper><nav id=TableOfContents><ul><li><a href=#prerequisites>Prerequisites</a></li><li><a href=#building-strolch>Building Strolch</a></li><li><a href=#creating-a-strolch-app>Creating a Strolch App</a><ul><li><a href=#creating-a-java-strolch-web-app>Creating a Java Strolch Web App</a></li><li><a href=#creating-a-simple-java-strolch-app>Creating a simple Java Strolch App</a></li></ul></li><li><a href=#converting-an-existing-application>Converting an existing application</a></li><li><a href=#tools-used>Tools used</a></li></ul></nav></div></div></div></div><div id=head-tags></div><div id=body-inner><h1>Development</h1><h2 id=prerequisites>Prerequisites</h2><p>To start developing Strolch you need an installed:</p><ul><li>Java JDK 17</li><li>Apache Maven 3.x</li></ul><h2 id=building-strolch>Building Strolch</h2><div class="notices tip"><p>Note: You don&rsquo;t have to build Strolch if you want to use the
version on Maven central, but if you need a snapshot version, or the release you
want isn&rsquo;t on central, then go ahead and build Strolch.</p></div><p>Building Strolch is just a few lines:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>git clone https://github.com/strolch-li/strolch.git
cd strolch
mvn clean install -DskipTests
</code></pre></div><div class="notices warning"><p>Note: To run the tests you will need to configure the PostgreSQL Databases. See
the README in the module.</p></div><p>After running the Maven build, you will have a full build of all Strolch
projects. Now you can start modifying the projects, and add your own features,
or, far more interesting, start developing your projects using the Strolch
agent.</p><h2 id=creating-a-strolch-app>Creating a Strolch App</h2><p>To create your own Strolch App, you can use Maven&rsquo;s archetype generation. There
are two versions, one is a simple Java App which you can use to directly access
the Strolch runtime, and the second is to create a Java Web App, which is the
usual way to run Strolch runtimes.</p><div class="notices warning"><p>Note: you need to have installed Strolch to your local maven repo, otherwise the
archetype won&rsquo;t be available.</p></div><h3 id=creating-a-java-strolch-web-app>Creating a Java Strolch Web App</h3><p>The following shows the maven command to create the new maven project. Note that you should replace the placeholders in the brackets:</p><div class="notices tip"><p>The code is also available on <a href=https://github.com/strolch-li/strolch/tree/develop/li.strolch.mvn.archetype.webapp target=_blank>GitHub</a>.</p></div><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>mvn archetype:generate <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeGroupId<span style=color:#f92672>=</span>li.strolch <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeArtifactId<span style=color:#f92672>=</span>li.strolch.mvn.archetype.webapp <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeVersion<span style=color:#f92672>=</span>1.8.0-SNAPSHOT <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DgroupId<span style=color:#f92672>=</span>&lt;my.groupid&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DartifactId<span style=color:#f92672>=</span>&lt;my-artifactId&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -Dversion<span style=color:#f92672>=</span>&lt;my.version&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -Dpackage<span style=color:#f92672>=</span>&lt;my.package&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DappName<span style=color:#f92672>=</span><span style=color:#e6db74>&#34;&lt;my app name&gt;&#34;</span>
</code></pre></div><h4 id=install-the-web-dependencies>Install the web dependencies</h4><p>The Strolch Web App uses <a href=https://nodejs.org/download/release/v11.15.0/ target=_blank>NodeJS v11.x</a> to build the web dependencies. Please
download the relevant platform&rsquo;s package, unpack it, and add the <code>bin</code> directory
to your path variable.</p><p>Once NodeJS is installed, then you can prepare the web dependencies:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>cd src/main/webapp/
npm install bower -g
npm install gulp -g
npm install
gulp
cd ../../..
</code></pre></div><div class="notices warning"><p>Note: Whenever the bower.json is changed then you should
again call npm install inside the webapp folder.</p></div><h4 id=building-and-running-the-war>Building and running the WAR</h4><p>Building the WAR uses the <code>package</code> maven goal, but to have the optimized WAR
use the <code>release</code> profile.</p><p>To run this WAR, we must configure the path of Strolch&rsquo;s runtime in the <code>StrolchBootstrap.xml</code> file, by updating the following block,
setting the absolute path to the <code>runtime</code> from the new project:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml><span style=color:#f92672>&lt;env</span> <span style=color:#a6e22e>id=</span><span style=color:#e6db74>&#34;test&#34;</span> <span style=color:#a6e22e>default=</span><span style=color:#e6db74>&#34;true&#34;</span><span style=color:#f92672>&gt;</span>
<span style=color:#f92672>&lt;root&gt;</span>/absolute/path/to/&amp;lt;my-artifactId&amp;gt;/runtime<span style=color:#f92672>&lt;/root&gt;</span>
<span style=color:#f92672>&lt;environment&gt;</span>test<span style=color:#f92672>&lt;/environment&gt;</span>
<span style=color:#f92672>&lt;/env&gt;</span>
</code></pre></div><p>Now we can build the project using the configured environment:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>mvn clean package -Prelease -Dstrolch.env<span style=color:#f92672>=</span>test
</code></pre></div><p>Now copy the WAR from the <code>target/</code> directory to the <code>webapps/</code> directory of your Tomcat 9.x installation. Now you can start tomcat using:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>catalina.sh run
</code></pre></div><p>In the console you&rsquo;ll then see something like this:</p><pre><code class=language-log data-lang=log>INFO l.s.a.impl.ComponentContainerImpl:283 start - System: OS: Linux 5.16.15 Arch: amd64 on Java Azul Systems, Inc. 17 CPU Cores: 32
INFO l.s.a.impl.ComponentContainerImpl:284 start - Memory: Memory available 16.8 GB / Used: 604.0 MB / Free: 540.6 MB
INFO l.s.a.impl.ComponentContainerImpl:285 start - Using locale en with timezone Europe/Zurich
INFO l.s.a.impl.ComponentContainerImpl:288 start - file.encoding: UTF-8 / sun.jnu.encoding UTF-8
INFO l.s.a.impl.ComponentContainerImpl:307 start - eSyTest:test All 12 Strolch Components started. Took 43ms. Strolch is now ready to be used. Have fun =))
INFO c.atexxi.esytest.web.StartupListener:43 contextInitialized - Started eSyTest in 244ms
</code></pre><p>And now you can open a browser and login: <code>http://localhost:8080/&lt;my-artifactId></code></p><p>The default username and password are <code>admin</code> / <code>admin</code>. After logging you, you should see the following view:</p><p><img src=/assets/images/demo-app.png alt="Strolch Demo App"></p><p>Happy coding =))</p><h3 id=creating-a-simple-java-strolch-app>Creating a simple Java Strolch App</h3><p>The following shows the maven command to create the new maven project. Note that
you should replace the placeholders in the brackets:</p><div class="notices tip"><p>The code is also available on <a href=https://github.com/strolch-li/strolch/tree/develop/li.strolch.mvn.archetype.main target=_blank>GitHub</a>.</p></div><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>mvn archetype:generate <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeGroupId<span style=color:#f92672>=</span>li.strolch <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeArtifactId<span style=color:#f92672>=</span>li.strolch.mvn.archetype.main <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DarchetypeVersion<span style=color:#f92672>=</span>1.8.0-SNAPSHOT <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DgroupId<span style=color:#f92672>=</span>&lt;my.groupid&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DartifactId<span style=color:#f92672>=</span>&lt;my-artifactId&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -Dversion<span style=color:#f92672>=</span>&lt;my.version&gt; <span style=color:#ae81ff>\
</span><span style=color:#ae81ff></span> -DappName<span style=color:#f92672>=</span><span style=color:#e6db74>&#34;&lt;my app name&gt;&#34;</span>
</code></pre></div><p>You change into the directory of the new project and then build the project by calling:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>cd &lt;my-artifactId&gt;
mvn clean package
</code></pre></div><p>Start the program using:</p><div class=highlight><pre style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell>mvn exec:java
</code></pre></div><p>Happy coding =))</p><h2 id=converting-an-existing-application>Converting an existing application</h2><p>You can convert an existing application to a Strolch agent, but this might be a
bit daunting in the beginning. If you are planning on doing this, first create a
test application using the maven archetypes, so that you can get a feel for the configuration.</p><p>Once that works, use the archetypes configuration to reconfigure your project to start as a Strolch agent.</p><div class="notices warning"><p>Note: Beware to select the archetype pertaining to your use case:</p><ul><li>For a web app use the <a href=/development/#creating-a-java-strolch-web-app>li.strolch.mvn.archetype.webapp</a></li><li>For a application with a main method use <a href=/development/#creating-a-simple-java-strolch-app>li.strolch.mvn.archetype.main</a></li></ul></div><h2 id=tools-used>Tools used</h2><p>The following tools are used to develop Strolch and Strolch-based projects:</p><ul><li><a href="https://www.jetbrains.com/idea/download/#section=linux" target=_blank>IntelliJ</a></li><li><a href=https://maven.apache.org/ target=_blank>Apache Maven</a></li><li><a href=http://git-scm.com/ target=_blank>Git SCM</a></li></ul><footer class=footline></footer></div></div><div id=navigation><a class="nav nav-prev" href=/download/ title=Download><i class="fa fa-chevron-left"></i></a><a class="nav nav-next" href=/blog/ title=Blog style=margin-right:0><i class="fa fa-chevron-right"></i></a></div></section><div style=left:-1000px;overflow:scroll;position:absolute;top:-1000px;border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px><div style=border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px></div></div><script src=/js/clipboard.min.js?1660651465></script><script src=/js/perfect-scrollbar.min.js?1660651465></script><script src=/js/perfect-scrollbar.jquery.min.js?1660651465></script><script src=/js/jquery.sticky.js?1660651465></script><script src=/js/featherlight.min.js?1660651465></script><script src=/js/highlight.pack.js?1660651465></script><script>hljs.initHighlightingOnLoad();</script><script src=/js/modernizr.custom-3.6.0.js?1660651465></script><script src=/js/learn.js?1660651465></script><script src=/js/hugo-learn.js?1660651465></script><script src=/mermaid/mermaid.js?1660651465></script><script>mermaid.initialize({startOnLoad:true});</script><script type=text/javascript>var _paq=window._paq=window._paq||[];_paq.push(["setDocumentTitle",document.domain+"/"+document.title]);_paq.push(["setCookieDomain","*.strolch.li"]);_paq.push(['trackPageView']);_paq.push(['enableLinkTracking']);(function(){var u="https://piwik.eitchnet.ch/";_paq.push(['setTrackerUrl',u+'matomo.php']);_paq.push(['setSiteId','2']);var d=document,g=d.createElement('script'),s=d.getElementsByTagName('script')[0];g.type='text/javascript';g.async=true;g.src=u+'matomo.js';s.parentNode.insertBefore(g,s);})();</script></body></html>