http://git-wip-us.apache.org/repos/asf/polygene-website/blob/bb9c9971/content/java/2017/library-spring.html ---------------------------------------------------------------------- diff --git a/content/java/2017/library-spring.html b/content/java/2017/library-spring.html new file mode 100644 index 0000000..3010a69 --- /dev/null +++ b/content/java/2017/library-spring.html @@ -0,0 +1,165 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Spring Integration</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="" /><link rel="up" href="libraries.html" title="Libraries" /><link rel="prev" href="library-shiro-web.html" title="Shiro Web Security" /><link rel="next" href="library-sql.html" title="SQL" /> + + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> + <meta name="description" content=""> + <meta name="author" content=""> + <link rel="icon" href="../../favicon.ico"> + + <title>Starter Template for Bootstrap</title> + + <!-- Bootstrap core CSS --> + <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> + + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> + <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet"> + + <!-- Custom styles for this template --> + <link href="css/polygene-ng.css" rel="stylesheet"> + + <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> + <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> + <script src="js/ie-emulation-modes-warning.js"></script> + + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> + +<!-- favicon --> + +<link rel="shortcut icon" href="http://polygene.apache.org/favicon.ico" type="image/vnd.microsoft.icon" /> +<link rel="icon" href="http://polygene.apache.org/favicon.ico" type="image/x-icon" /> + +<!-- style --> + +<link href="css/shCore.css" rel="stylesheet" type="text/css" /> +<link href="css/shCoreEclipse.css" rel="stylesheet" type="text/css" /> +<link href="css/shThemeEclipse.css" rel="stylesheet" type="text/css" /> +<!--<link href="css/polygene.css" rel="stylesheet" type="text/css" />--> + +<!-- Syntax Highlighter --> + +<script type="text/javascript" src="js/shCore.js"></script> +<script type="text/javascript" src="js/shBrushJava.js"></script> +<script type="text/javascript" src="js/shBrushScala.js"></script> +<script type="text/javascript" src="js/shBrushJScript.js"></script> +<script type="text/javascript" src="js/shBrushBash.js"></script> +<script type="text/javascript" src="js/shBrushPlain.js"></script> +<script type="text/javascript" src="js/shBrushXml.js"></script> +<script type="text/javascript" src="js/shBrushGroovy.js"></script> +<script type="text/javascript" src="js/shBrushPython.js"></script> +<script type="text/javascript" src="js/shBrushRuby.js"></script> +<script type="text/javascript" src="js/shBrushCSharp.js"></script> + +<script type="text/javascript"> + SyntaxHighlighter.defaults['tab-size'] = 4; + SyntaxHighlighter.defaults['gutter'] = false; + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all() +</script> + +<!-- JQuery --> + +<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script> + +<!-- Image Scaler --> + +<script type="text/javascript" src="js/imagescaler.js"></script> + +<!-- Table Styler --> + +<script type="text/javascript" src="js/tablestyler.js"></script> + +<!-- Apache Polygene WebSite Progressive Enhancement --> + +<link href="css/progressive-enhancement.css" rel="stylesheet" type="text/css" /> +<script type="text/javascript" src="js/jquery.scrollTo-1.4.2.js"></script> +<script type="text/javascript" src="js/progressive-enhancement.js"></script> + +<!-- Analytics --> + <script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-62007352-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + </script> + + </head><body><div xmlns="" xmlns:exsl="http://exslt.org/common" class="logo"><a href="index.html"><img src="images/logo-standard.png" /></a></div><nav xmlns="" xmlns:exsl="http://exslt.org/common" class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><a class="navbar-brand" href="#">Apache<br />Polygene + </a></div><div id="navbar" class="collapse navbar-collapse"><span class="nav navbar-nav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#home">Polygeneâ¢</a></span></dt><dt><span class="section"><a href="intro.html">Introduction</a></span></dt><dt><span class="section"><a href="tutorials.html">Tutorials</a></span></dt><dt><span class="section"><a href="javadocs.html">Javadoc</a></span></dt><dt><span class="section"><a href="samples.html">Samples</a></span></dt><dt><span class="section"><a href="core.html">Core</a></span></dt><dt><span class="section"><span xmlns="" href="libraries.html">Libraries</span></span></dt><dt><span class="section"><a href="extensions.html">Extensions</a></span></dt><dt><span class="section"><a href="tools.html">Tools</a></span></dt><dt><span class="section"><a href="glossary.html">Glossary </a></span></dt></dl></div></span></div></div></nav><div xmlns="" xmlns:exsl="http://exslt .org/common" class="sidenav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="libraries.html#_overview_5">Overview</a></span></dt><dt><span class="section"><a href="scripting.html">Scripting</a></span></dt><dt><span class="section"><a href="library-alarm.html">Alarms</a></span></dt><dt><span class="section"><a href="library-circuitbreaker.html">Circuit Breaker</a></span></dt><dt><span class="section"><a href="library-constraints.html">Constraints</a></span></dt><dt><span class="section"><a href="library-fileconfig.html">FileConfig</a></span></dt><dt><span class="section"><a href="library-http.html">HTTP</a></span></dt><dt><span class="section"><a href="library-invocation-cache.html">Invocation Cache</a></span></dt><dt><span class="section"><a href="library-jmx.html">JMX</a></span></dt><dt><span class="section"><a href="library-locking.html">Locking</a></span></dt><dt><span class="section"><a href="library-logging.html">Logging< /a></span></dt><dt><span class="section"><a href="library-osgi.html">OSGi</a></span></dt><dt><span class="section"><a href="library-rdf.html">RDF</a></span></dt><dt><span class="section"><a href="library-rest-client.html">ReST Client</a></span></dt><dt><span class="section"><a href="library-rest-client-primer.html">ReST - HATEOAS Primer</a></span></dt><dt><span class="section"><a href="library-rest-common.html">ReST Common</a></span></dt><dt><span class="section"><a href="library-rest-server.html">ReST Server</a></span></dt><dt><span class="section"><a href="library-restlet.html">Restlet Support</a></span></dt><dt><span class="section"><a href="library-servlet.html">Servlet</a></span></dt><dt><span class="section"><a href="library-shiro.html">Shiro Security</a></span></dt><dt><span class="section"><a href="library-shiro-web.html">Shiro Web Security</a></span></dt><dt><span class="section"><span xmlns="" href="library-spring.html">Spring Integration</span></span></dt><dt><span class= "section"><a href="library-sql.html">SQL</a></span></dt><dt><span class="section"><a href="library-uid.html">UID</a></span></dt><dt><span class="section"><a href="library-uowfile.html">UoWFile</a></span></dt></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="library-spring"></a>Spring Integration</h3></div></div></div><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-beta">code</p><p class="devstatus-docs-brief">docs</p><p class="devstatus-tests-some">tests</p><div class="table"><a id="idm5286"></a><p class="title"><strong>Table 41. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apa che.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.polygene.library.spring</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_using_spring_framework_in_apache_polygene"></a>Using Spring Framework in Apache Polygeneâ¢</h4></div></div></div><p>Polygene⢠supports that Spring Application Context is imported into the Polygene⢠runtime, and the declared Spring +beans will be available as Polygene⢠services. The most important things to remember are;</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> +Only Spring Singletons are currently supported. +</li><li class="listitem"> +One ApplicationContext per Polygene⢠Module. +</li><li class="listitem"> +The Polygene⢠service will be given the same name as the Spring Bean name. +</li><li class="listitem"> +Polygene⢠Configuration is not reacbable from the Spring bean (kind of obvious). +</li></ol></div><pre class="programlisting brush: java">new SpringImporterAssembler( appContext ).assemble( module ); +</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_using_apache_polygene_in_spring_framework"></a>Using Apache Polygene⢠in Spring Framework</h4></div></div></div><p>It is also possible to run a Polygene⢠Application as a Spring Bean and export its Services to Spring.</p><p>Steps to export Polygene⢠service:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> +Create spring BeanFactory service of Polygene services to export. +</li><li class="listitem"> +Create a class that extends PolygeneApplicationBootstrap. +</li><li class="listitem"> +Sets the layer and module that register BeanFactory service. +</li><li class="listitem"> +Assemble Polygene application by implementing #assemble method. +</li><li class="listitem"> +Sets the identity of bean factory service. This identity is the spring bean name. +</li><li class="listitem"> +Declare Polygene bootstrap in spring xml application context. +</li></ol></div><p>To bootstrap the Polygene⢠runtime in Spring, you should have a bootstrap bean that extends the +<code class="literal">org.apache.polygene.library.spring.bootstrap.PolygeneApplicationBootstrap</code> and implement the +<code class="literal">org.springframework.context.ApplicationContextAware</code>.</p><p>A new bean will appear in the application context, called <code class="literal">"polygeneApplication"</code> which is only +intended for internal use of this library.</p><p>Example application context;</p><pre class="programlisting brush: xml"> <?xml version="1.0" encoding="UTF-8"?> + + <beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:polygene="http://polygene.apache.org/schema/polygene/spring" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://polygene.apache.org/schema/polygene/spring http://polygene.apache.org/schema/polygene/spring/spring-0.5.xsd"> + + <!-- class that implements PolygeneApplicationBootstrap --> + + <polygene:bootstrap class="org.hedhman.niclas.MyPolygeneBootstrapper"/> + + <bean id="someService" class="org.hedhman.niclas.SomeService"> + + <constructor-arg ref="someService"/> <!-- Reference polygene comment service --> + + </bean></pre><pre class="programlisting brush: java">public class MyPolygeneBootstrapper extends PolygeneApplicationBootstrap + implements ApplicationContextAware +{ + private ApplicationContext applicationContext; + + @Override + public void assemble(ApplicationAssembly assembly) throws AssemblyException + { + // Normal assembly of an application. + [...snip...] + + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + this.applicationContext = applicationContext; + } + +} +</pre></div></div><footer xmlns="" xmlns:exsl="http://exslt.org/common" class="footer"><div class="container"><p class="text-muted">Copyright © 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/" target="_blank">Apache License, Version 2.0</a>. + Apache Polygene, Polygene, Apache, the Apache feather logo, and the Apache Polygene project logo are + trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners. + </p></div></footer><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common">window.jQuery || document.write('<script src="js/jquery-1.6.4.min.js"></script>')</script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="bootstrap-3.3.7/js/bootstrap.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="js/ie10-viewport-bug-workaround.js"></script></body></html> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/polygene-website/blob/bb9c9971/content/java/2017/library-sql.html ---------------------------------------------------------------------- diff --git a/content/java/2017/library-sql.html b/content/java/2017/library-sql.html new file mode 100644 index 0000000..f6b3c53 --- /dev/null +++ b/content/java/2017/library-sql.html @@ -0,0 +1,212 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SQL</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="" /><link rel="up" href="libraries.html" title="Libraries" /><link rel="prev" href="library-spring.html" title="Spring Integration" /><link rel="next" href="library-uid.html" title="UID" /> + + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> + <meta name="description" content=""> + <meta name="author" content=""> + <link rel="icon" href="../../favicon.ico"> + + <title>Starter Template for Bootstrap</title> + + <!-- Bootstrap core CSS --> + <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> + + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> + <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet"> + + <!-- Custom styles for this template --> + <link href="css/polygene-ng.css" rel="stylesheet"> + + <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> + <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> + <script src="js/ie-emulation-modes-warning.js"></script> + + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> + +<!-- favicon --> + +<link rel="shortcut icon" href="http://polygene.apache.org/favicon.ico" type="image/vnd.microsoft.icon" /> +<link rel="icon" href="http://polygene.apache.org/favicon.ico" type="image/x-icon" /> + +<!-- style --> + +<link href="css/shCore.css" rel="stylesheet" type="text/css" /> +<link href="css/shCoreEclipse.css" rel="stylesheet" type="text/css" /> +<link href="css/shThemeEclipse.css" rel="stylesheet" type="text/css" /> +<!--<link href="css/polygene.css" rel="stylesheet" type="text/css" />--> + +<!-- Syntax Highlighter --> + +<script type="text/javascript" src="js/shCore.js"></script> +<script type="text/javascript" src="js/shBrushJava.js"></script> +<script type="text/javascript" src="js/shBrushScala.js"></script> +<script type="text/javascript" src="js/shBrushJScript.js"></script> +<script type="text/javascript" src="js/shBrushBash.js"></script> +<script type="text/javascript" src="js/shBrushPlain.js"></script> +<script type="text/javascript" src="js/shBrushXml.js"></script> +<script type="text/javascript" src="js/shBrushGroovy.js"></script> +<script type="text/javascript" src="js/shBrushPython.js"></script> +<script type="text/javascript" src="js/shBrushRuby.js"></script> +<script type="text/javascript" src="js/shBrushCSharp.js"></script> + +<script type="text/javascript"> + SyntaxHighlighter.defaults['tab-size'] = 4; + SyntaxHighlighter.defaults['gutter'] = false; + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all() +</script> + +<!-- JQuery --> + +<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script> + +<!-- Image Scaler --> + +<script type="text/javascript" src="js/imagescaler.js"></script> + +<!-- Table Styler --> + +<script type="text/javascript" src="js/tablestyler.js"></script> + +<!-- Apache Polygene WebSite Progressive Enhancement --> + +<link href="css/progressive-enhancement.css" rel="stylesheet" type="text/css" /> +<script type="text/javascript" src="js/jquery.scrollTo-1.4.2.js"></script> +<script type="text/javascript" src="js/progressive-enhancement.js"></script> + +<!-- Analytics --> + <script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-62007352-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + </script> + + </head><body><div xmlns="" xmlns:exsl="http://exslt.org/common" class="logo"><a href="index.html"><img src="images/logo-standard.png" /></a></div><nav xmlns="" xmlns:exsl="http://exslt.org/common" class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><a class="navbar-brand" href="#">Apache<br />Polygene + </a></div><div id="navbar" class="collapse navbar-collapse"><span class="nav navbar-nav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#home">Polygeneâ¢</a></span></dt><dt><span class="section"><a href="intro.html">Introduction</a></span></dt><dt><span class="section"><a href="tutorials.html">Tutorials</a></span></dt><dt><span class="section"><a href="javadocs.html">Javadoc</a></span></dt><dt><span class="section"><a href="samples.html">Samples</a></span></dt><dt><span class="section"><a href="core.html">Core</a></span></dt><dt><span class="section"><span xmlns="" href="libraries.html">Libraries</span></span></dt><dt><span class="section"><a href="extensions.html">Extensions</a></span></dt><dt><span class="section"><a href="tools.html">Tools</a></span></dt><dt><span class="section"><a href="glossary.html">Glossary </a></span></dt></dl></div></span></div></div></nav><div xmlns="" xmlns:exsl="http://exslt .org/common" class="sidenav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="libraries.html#_overview_5">Overview</a></span></dt><dt><span class="section"><a href="scripting.html">Scripting</a></span></dt><dt><span class="section"><a href="library-alarm.html">Alarms</a></span></dt><dt><span class="section"><a href="library-circuitbreaker.html">Circuit Breaker</a></span></dt><dt><span class="section"><a href="library-constraints.html">Constraints</a></span></dt><dt><span class="section"><a href="library-fileconfig.html">FileConfig</a></span></dt><dt><span class="section"><a href="library-http.html">HTTP</a></span></dt><dt><span class="section"><a href="library-invocation-cache.html">Invocation Cache</a></span></dt><dt><span class="section"><a href="library-jmx.html">JMX</a></span></dt><dt><span class="section"><a href="library-locking.html">Locking</a></span></dt><dt><span class="section"><a href="library-logging.html">Logging< /a></span></dt><dt><span class="section"><a href="library-osgi.html">OSGi</a></span></dt><dt><span class="section"><a href="library-rdf.html">RDF</a></span></dt><dt><span class="section"><a href="library-rest-client.html">ReST Client</a></span></dt><dt><span class="section"><a href="library-rest-client-primer.html">ReST - HATEOAS Primer</a></span></dt><dt><span class="section"><a href="library-rest-common.html">ReST Common</a></span></dt><dt><span class="section"><a href="library-rest-server.html">ReST Server</a></span></dt><dt><span class="section"><a href="library-restlet.html">Restlet Support</a></span></dt><dt><span class="section"><a href="library-servlet.html">Servlet</a></span></dt><dt><span class="section"><a href="library-shiro.html">Shiro Security</a></span></dt><dt><span class="section"><a href="library-shiro-web.html">Shiro Web Security</a></span></dt><dt><span class="section"><a href="library-spring.html">Spring Integration</a></span></dt><dt><span class="section"><span xmlns="" href="library-sql.html">SQL</span></span></dt><dt><span class="section"><a href="library-uid.html">UID</a></span></dt><dt><span class="section"><a href="library-uowfile.html">UoWFile</a></span></dt></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="library-sql"></a>SQL</h3></div></div></div><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-good">tests</p><p>The SQL Library provides facilities for working with SQL databases.</p><p>The center piece is the DataSource support that comes with +<a class="xref" href="library-circuitbreaker.html" title="Circuit Breaker">Circuit Breaker Library</a> and <a class="xref" href="library-jmx.html" title="JMX"> JMX Library</a> support.</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>See the <a class="xref" href="sample-sql-support.html" title="SQL Support Sample">SQL Support Sample</a> that demonstrate combined use of <a class="xref" href="library-sql.html" title="SQL">SQL Library</a>, <a class="xref" href="extension-es-sql.html" title="SQL EntityStore"> SQL EntityStore</a> and +<a class="xref" href="extension-indexing-sql.html" title="SQL Index/Query">SQL Index/Query</a>.</p></div><p>Moreover, supplementary libraries helps dealing with different connection pool implementations and schema migrations. +None of theses libraries depends on an actual JDBC driver, you are free to use the one that suits your needs.</p><div class="table"><a id="idm5360"></a><p class="title"><strong>Table 42. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.polygene.library.sql</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_datasource_and_connection_pools"></a>DataSource and connection pools</h4></div></div></div><p>DataSource support comes in three flavors:</p><div c lass="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> +using the <a class="ulink" href="http://jolbox.com/" target="_top">BoneCP</a> connection pool +</li><li class="listitem"> +using the <a class="ulink" href="http://commons.apache.org/dbcp/" target="_top">Apache DBCP</a> connection pool +</li><li class="listitem"> +importing an existing DataSource provided at assembly time +</li></ul></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="_connection_pools"></a>Connection Pools</h5></div></div></div><p>Connection Pools support is provided by supplementary libraries.</p><p><span class="strong"><strong>BoneCP</strong></span></p><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-good">tests</p><div class="table"><a id="idm5400"></a><p class="title"><strong>Table 43. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.pol ygene.library.sql-bonecp</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><p>BoneCP support resides in the <span class="strong"><strong>sql-bonecp</strong></span> module.</p><pre class="programlisting brush: java">// Assemble the BoneCP based Service Importer +new BoneCPDataSourceServiceAssembler(). + identifiedBy( DS_SERVICE_ID ). + visibleIn( Visibility.module ). + withConfig( config, Visibility.layer ). + assemble( module ); +</pre><p><span class="strong"><strong>Apache DBCP</strong></span></p><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-good">tests</p><div class="table"><a id="idm5428"></a><p class="title"><strong>Table 44. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.polygene.library.sql-dbcp</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><pre class="programlisting brush: java">// Assemble the Apache DBCP based Service Im porter +new DBCPDataSourceServiceAssembler(). + identifiedBy( DS_SERVICE_ID ). + visibleIn( Visibility.module ). + withConfig( config, Visibility.layer ). + assemble( module ); +</pre></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="_datasource"></a>DataSource</h5></div></div></div><p><span class="strong"><strong>Assembly</strong></span></p><pre class="programlisting brush: java">// Assemble a DataSource +new DataSourceAssembler(). + withDataSourceServiceIdentity( DS_SERVICE_ID ). + identifiedBy( DS_ID ). + visibleIn( Visibility.module ). + assemble( module ); +// Another DataSource managed by the same C3P0 connection pool +new DataSourceAssembler(). + withDataSourceServiceIdentity( DS_SERVICE_ID ). + identifiedBy( OTHER_DS_ID ). + visibleIn( Visibility.module ). + assemble( module ); +</pre><p>Assembled DataSources must be visible from the connection pool importer service.</p><p><span class="strong"><strong>Configuration</strong></span></p><p>You need to provide a DataSource Configuration Entity per assembled DataSource. +See <a class="xref" href="howto-configure-service.html" title="Configure a Service">Configure a Service</a>.</p><pre class="programlisting brush: java">public interface DataSourceConfigurationState + extends Enabled +{ + Property<String> driver(); + Property<String> url(); + @UseDefaults Property<String> username(); + @UseDefaults Property<String> password(); + @Optional Property<Integer> minPoolSize(); + @Optional Property<Integer> maxPoolSize(); + @Optional Property<Integer> loginTimeoutSeconds(); + @Optional Property<Integer> maxConnectionAgeSeconds(); + @Optional Property<String> validationQuery(); + @UseDefaults Property<String> properties(); +} +</pre><p>Sample DataSource configuration defaults:</p><pre class="programlisting brush: plain"># +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# + +enabled=true +url=jdbc:derby:memory:testdb;create=true +driver=org.apache.derby.jdbc.EmbeddedDriver +username= +password=</pre></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="_importing_an_existing_datasource"></a>Importing an existing DataSource</h5></div></div></div><p>Importing an existing DataSource at assembly time is usefull when your Polygene +Application runs in an environment where DataSource are already provided.</p><pre class="programlisting brush: java">new ExternalDataSourceAssembler( externalDataSource ). + visibleIn( Visibility.module ). + identifiedBy( "datasource-external-id" ). + withCircuitBreaker( DataSources.newDataSourceCircuitBreaker() ). + assemble( module ); +</pre><p>This mechanism is provided as an integration convenience and using the embedded +connection pools described above is recommended.</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_circuit_breaker"></a>Circuit Breaker</h4></div></div></div><p>Assemblers for managed and external DataSource takes an optional +CircuitBreaker and set it as <a class="xref" href="glossary.html#def-metainfo">MetaInfo</a> of the DataSource.</p><pre class="programlisting brush: java">CircuitBreaker circuitBreaker = newDataSourceCircuitBreaker( 5 /* threshold */, + 1000 * 60 * 5 /* 5min timeout */ ); +new DataSourceAssembler(). + withDataSourceServiceIdentity( DS_SERVICE_ID ). + identifiedBy( DS_ID ). + visibleIn( Visibility.layer ). + withCircuitBreaker( circuitBreaker ). + assemble( module ); +</pre><p>Then, when you gets injected or lookup a DataSource it will be automatically wrapped +by a CircuitBreaker proxy.</p><pre class="programlisting brush: java">@Service +DataSource dataSource; // Wrapped with a CircuitBreaker proxy +</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_jmx"></a>JMX</h4></div></div></div><p>Thanks to the <a class="xref" href="library-jmx.html" title="JMX"> JMX Library</a> the Configuration of DataSources is exposed +through JMX.</p><pre class="programlisting brush: java">new DataSourceJMXAssembler().visibleIn( Visibility.module ).assemble( module ); +</pre><p>Every DataSource visible from the DataSourceConfigurationManager Service +will get its Configuration available using a JMX client.</p><p>Note that the JMX support does not apply to existing DataSource imported as +described above.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_schema_migration"></a>Schema migration</h4></div></div></div><p>Database schema migration can be delegated to <a class="ulink" href="http://www.liquibase.org/" target="_top">Liquibase</a>.</p><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-good">tests</p><div class="table"><a id="idm5488"></a><p class="title"><strong>Table 45. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>or g.apache.polygene.library.sql-liquibase</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><p><span class="strong"><strong>Assembly</strong></span></p><pre class="programlisting brush: java">new LiquibaseAssembler() + .withConfig( configModule, Visibility.layer ) + .applyChangelogOnStartup() + .assemble( module ); +</pre><p>The LiquibaseService is activated on Application startup and if enabled it +applies the configured changelog.</p><p><span class="strong"><strong>Configuration</strong></span></p><pre class="programlisting brush: java">public interface LiquibaseConfiguration +{ + @UseDefaults + Property<String> changeLog(); + + @UseDefaults + Property<String> contexts(); +} +</pre><p>For the Liquibase service to be enabled you must set itâs Configuration +<code class="literal">enabled</code> Property to TRUE. <span class="strong"><strong>contexts</strong></span> and <span class="strong"><strong>changeLog</strong></span> are optional.</p></div></div><footer xmlns="" xmlns:exsl="http://exslt.org/common" class="footer"><div class="container"><p class="text-muted">Copyright © 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/" target="_blank">Apache License, Version 2.0</a>. + Apache Polygene, Polygene, Apache, the Apache feather logo, and the Apache Polygene project logo are + trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners. + </p></div></footer><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common">window.jQuery || document.write('<script src="js/jquery-1.6.4.min.js"></script>')</script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="bootstrap-3.3.7/js/bootstrap.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="js/ie10-viewport-bug-workaround.js"></script></body></html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-website/blob/bb9c9971/content/java/2017/library-uid.html ---------------------------------------------------------------------- diff --git a/content/java/2017/library-uid.html b/content/java/2017/library-uid.html new file mode 100644 index 0000000..3b46385 --- /dev/null +++ b/content/java/2017/library-uid.html @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>UID</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="" /><link rel="up" href="libraries.html" title="Libraries" /><link rel="prev" href="library-sql.html" title="SQL" /><link rel="next" href="library-uowfile.html" title="UoWFile" /> + + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> + <meta name="description" content=""> + <meta name="author" content=""> + <link rel="icon" href="../../favicon.ico"> + + <title>Starter Template for Bootstrap</title> + + <!-- Bootstrap core CSS --> + <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> + + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> + <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet"> + + <!-- Custom styles for this template --> + <link href="css/polygene-ng.css" rel="stylesheet"> + + <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> + <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> + <script src="js/ie-emulation-modes-warning.js"></script> + + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> + +<!-- favicon --> + +<link rel="shortcut icon" href="http://polygene.apache.org/favicon.ico" type="image/vnd.microsoft.icon" /> +<link rel="icon" href="http://polygene.apache.org/favicon.ico" type="image/x-icon" /> + +<!-- style --> + +<link href="css/shCore.css" rel="stylesheet" type="text/css" /> +<link href="css/shCoreEclipse.css" rel="stylesheet" type="text/css" /> +<link href="css/shThemeEclipse.css" rel="stylesheet" type="text/css" /> +<!--<link href="css/polygene.css" rel="stylesheet" type="text/css" />--> + +<!-- Syntax Highlighter --> + +<script type="text/javascript" src="js/shCore.js"></script> +<script type="text/javascript" src="js/shBrushJava.js"></script> +<script type="text/javascript" src="js/shBrushScala.js"></script> +<script type="text/javascript" src="js/shBrushJScript.js"></script> +<script type="text/javascript" src="js/shBrushBash.js"></script> +<script type="text/javascript" src="js/shBrushPlain.js"></script> +<script type="text/javascript" src="js/shBrushXml.js"></script> +<script type="text/javascript" src="js/shBrushGroovy.js"></script> +<script type="text/javascript" src="js/shBrushPython.js"></script> +<script type="text/javascript" src="js/shBrushRuby.js"></script> +<script type="text/javascript" src="js/shBrushCSharp.js"></script> + +<script type="text/javascript"> + SyntaxHighlighter.defaults['tab-size'] = 4; + SyntaxHighlighter.defaults['gutter'] = false; + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all() +</script> + +<!-- JQuery --> + +<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script> + +<!-- Image Scaler --> + +<script type="text/javascript" src="js/imagescaler.js"></script> + +<!-- Table Styler --> + +<script type="text/javascript" src="js/tablestyler.js"></script> + +<!-- Apache Polygene WebSite Progressive Enhancement --> + +<link href="css/progressive-enhancement.css" rel="stylesheet" type="text/css" /> +<script type="text/javascript" src="js/jquery.scrollTo-1.4.2.js"></script> +<script type="text/javascript" src="js/progressive-enhancement.js"></script> + +<!-- Analytics --> + <script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-62007352-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + </script> + + </head><body><div xmlns="" xmlns:exsl="http://exslt.org/common" class="logo"><a href="index.html"><img src="images/logo-standard.png" /></a></div><nav xmlns="" xmlns:exsl="http://exslt.org/common" class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><a class="navbar-brand" href="#">Apache<br />Polygene + </a></div><div id="navbar" class="collapse navbar-collapse"><span class="nav navbar-nav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#home">Polygeneâ¢</a></span></dt><dt><span class="section"><a href="intro.html">Introduction</a></span></dt><dt><span class="section"><a href="tutorials.html">Tutorials</a></span></dt><dt><span class="section"><a href="javadocs.html">Javadoc</a></span></dt><dt><span class="section"><a href="samples.html">Samples</a></span></dt><dt><span class="section"><a href="core.html">Core</a></span></dt><dt><span class="section"><span xmlns="" href="libraries.html">Libraries</span></span></dt><dt><span class="section"><a href="extensions.html">Extensions</a></span></dt><dt><span class="section"><a href="tools.html">Tools</a></span></dt><dt><span class="section"><a href="glossary.html">Glossary </a></span></dt></dl></div></span></div></div></nav><div xmlns="" xmlns:exsl="http://exslt .org/common" class="sidenav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="libraries.html#_overview_5">Overview</a></span></dt><dt><span class="section"><a href="scripting.html">Scripting</a></span></dt><dt><span class="section"><a href="library-alarm.html">Alarms</a></span></dt><dt><span class="section"><a href="library-circuitbreaker.html">Circuit Breaker</a></span></dt><dt><span class="section"><a href="library-constraints.html">Constraints</a></span></dt><dt><span class="section"><a href="library-fileconfig.html">FileConfig</a></span></dt><dt><span class="section"><a href="library-http.html">HTTP</a></span></dt><dt><span class="section"><a href="library-invocation-cache.html">Invocation Cache</a></span></dt><dt><span class="section"><a href="library-jmx.html">JMX</a></span></dt><dt><span class="section"><a href="library-locking.html">Locking</a></span></dt><dt><span class="section"><a href="library-logging.html">Logging< /a></span></dt><dt><span class="section"><a href="library-osgi.html">OSGi</a></span></dt><dt><span class="section"><a href="library-rdf.html">RDF</a></span></dt><dt><span class="section"><a href="library-rest-client.html">ReST Client</a></span></dt><dt><span class="section"><a href="library-rest-client-primer.html">ReST - HATEOAS Primer</a></span></dt><dt><span class="section"><a href="library-rest-common.html">ReST Common</a></span></dt><dt><span class="section"><a href="library-rest-server.html">ReST Server</a></span></dt><dt><span class="section"><a href="library-restlet.html">Restlet Support</a></span></dt><dt><span class="section"><a href="library-servlet.html">Servlet</a></span></dt><dt><span class="section"><a href="library-shiro.html">Shiro Security</a></span></dt><dt><span class="section"><a href="library-shiro-web.html">Shiro Web Security</a></span></dt><dt><span class="section"><a href="library-spring.html">Spring Integration</a></span></dt><dt><span class="section"><a hr ef="library-sql.html">SQL</a></span></dt><dt><span class="section"><span xmlns="" href="library-uid.html">UID</span></span></dt><dt><span class="section"><a href="library-uowfile.html">UoWFile</a></span></dt></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="library-uid"></a>UID</h3></div></div></div><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-good">tests</p><p>This library provides Services to easily generate unique identifiers and sequences of numbers.</p><div class="table"><a id="idm5525"></a><p class="title"><strong>Table 46. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valig n="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.polygene.library.uid</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_unique_identifiers"></a>Unique Identifiers</h4></div></div></div><p>Assembly is done using the provided Assembler:</p><pre class="programlisting brush: java">new UuidServiceAssembler().visibleIn( layer ).assemble( moduleAssembly ); +</pre><p>Usage is quite simple:</p><pre class="programlisting brush: java">@Service UuidService uuidService; + +public void doSomething() +{ + String id1 = uuidService.generateUuid( 0 ); + // eg. 1020ECBB-098C-46E0-94DC-F78E2265EAA1-36 + + String id2 = uuidService.generateUuid( 12 ); + // eg. 84E06578EAE3 +} +</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_sequencing"></a>Sequencing</h4></div></div></div><p>Sequencing is used to automatically generate a sequence of numbers.</p><p>The algorithm is that <code class="literal">currentSequenceValue</code> is the number that was last returned in a <code class="literal">newSequenceValue</code> call, and will +initially be zero. Persisting Sequencing services defines "initially" as the first run ever, as subsequent starts may +retrieve the <code class="literal">currentSequenceValue</code> from an EntityStore.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="_transient_sequences"></a>Transient Sequences</h5></div></div></div><p>Assembly is done using the provided Assembler:</p><pre class="programlisting brush: java">new TransientSequencingAssembler().visibleIn( layer ).assemble( moduleAssembly ); +</pre><p>Usage is quite simple:</p><pre class="programlisting brush: java">@Service Sequencing sequencing; + +public void doSomething() +{ + sequencing.currentSequenceValue(); // return 0 + + sequencing.newSequenceValue(); // return 1 + sequencing.currentSequenceValue(); // return 1 +} +</pre></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a id="_persisted_sequences"></a>Persisted Sequences</h5></div></div></div><p>Assembly is done using the provided Assembler:</p><pre class="programlisting brush: java">new PersistingSequencingAssembler().visibleIn( layer ).assemble( moduleAssembly ); +</pre><p>Usage is quite simple:</p><pre class="programlisting brush: java">@Service Sequencing sequencing; + +public void doSomething() +{ + sequencing.currentSequenceValue(); // return 0 + + sequencing.newSequenceValue(); // return 1 + sequencing.currentSequenceValue(); // return 1 +} +</pre></div></div></div><footer xmlns="" xmlns:exsl="http://exslt.org/common" class="footer"><div class="container"><p class="text-muted">Copyright © 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/" target="_blank">Apache License, Version 2.0</a>. + Apache Polygene, Polygene, Apache, the Apache feather logo, and the Apache Polygene project logo are + trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners. + </p></div></footer><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common">window.jQuery || document.write('<script src="js/jquery-1.6.4.min.js"></script>')</script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="bootstrap-3.3.7/js/bootstrap.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="js/ie10-viewport-bug-workaround.js"></script></body></html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/polygene-website/blob/bb9c9971/content/java/2017/library-uowfile.html ---------------------------------------------------------------------- diff --git a/content/java/2017/library-uowfile.html b/content/java/2017/library-uowfile.html new file mode 100644 index 0000000..4c4eddb --- /dev/null +++ b/content/java/2017/library-uowfile.html @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>UoWFile</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="" /><link rel="up" href="libraries.html" title="Libraries" /><link rel="prev" href="library-uid.html" title="UID" /><link rel="next" href="extensions.html" title="Extensions" /> + + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> + <meta name="description" content=""> + <meta name="author" content=""> + <link rel="icon" href="../../favicon.ico"> + + <title>Starter Template for Bootstrap</title> + + <!-- Bootstrap core CSS --> + <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> + + <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> + <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet"> + + <!-- Custom styles for this template --> + <link href="css/polygene-ng.css" rel="stylesheet"> + + <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> + <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> + <script src="js/ie-emulation-modes-warning.js"></script> + + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> + <![endif]--> + +<!-- favicon --> + +<link rel="shortcut icon" href="http://polygene.apache.org/favicon.ico" type="image/vnd.microsoft.icon" /> +<link rel="icon" href="http://polygene.apache.org/favicon.ico" type="image/x-icon" /> + +<!-- style --> + +<link href="css/shCore.css" rel="stylesheet" type="text/css" /> +<link href="css/shCoreEclipse.css" rel="stylesheet" type="text/css" /> +<link href="css/shThemeEclipse.css" rel="stylesheet" type="text/css" /> +<!--<link href="css/polygene.css" rel="stylesheet" type="text/css" />--> + +<!-- Syntax Highlighter --> + +<script type="text/javascript" src="js/shCore.js"></script> +<script type="text/javascript" src="js/shBrushJava.js"></script> +<script type="text/javascript" src="js/shBrushScala.js"></script> +<script type="text/javascript" src="js/shBrushJScript.js"></script> +<script type="text/javascript" src="js/shBrushBash.js"></script> +<script type="text/javascript" src="js/shBrushPlain.js"></script> +<script type="text/javascript" src="js/shBrushXml.js"></script> +<script type="text/javascript" src="js/shBrushGroovy.js"></script> +<script type="text/javascript" src="js/shBrushPython.js"></script> +<script type="text/javascript" src="js/shBrushRuby.js"></script> +<script type="text/javascript" src="js/shBrushCSharp.js"></script> + +<script type="text/javascript"> + SyntaxHighlighter.defaults['tab-size'] = 4; + SyntaxHighlighter.defaults['gutter'] = false; + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all() +</script> + +<!-- JQuery --> + +<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script> + +<!-- Image Scaler --> + +<script type="text/javascript" src="js/imagescaler.js"></script> + +<!-- Table Styler --> + +<script type="text/javascript" src="js/tablestyler.js"></script> + +<!-- Apache Polygene WebSite Progressive Enhancement --> + +<link href="css/progressive-enhancement.css" rel="stylesheet" type="text/css" /> +<script type="text/javascript" src="js/jquery.scrollTo-1.4.2.js"></script> +<script type="text/javascript" src="js/progressive-enhancement.js"></script> + +<!-- Analytics --> + <script type="text/javascript"> + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-62007352-1']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + </script> + + </head><body><div xmlns="" xmlns:exsl="http://exslt.org/common" class="logo"><a href="index.html"><img src="images/logo-standard.png" /></a></div><nav xmlns="" xmlns:exsl="http://exslt.org/common" class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><a class="navbar-brand" href="#">Apache<br />Polygene + </a></div><div id="navbar" class="collapse navbar-collapse"><span class="nav navbar-nav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#home">Polygeneâ¢</a></span></dt><dt><span class="section"><a href="intro.html">Introduction</a></span></dt><dt><span class="section"><a href="tutorials.html">Tutorials</a></span></dt><dt><span class="section"><a href="javadocs.html">Javadoc</a></span></dt><dt><span class="section"><a href="samples.html">Samples</a></span></dt><dt><span class="section"><a href="core.html">Core</a></span></dt><dt><span class="section"><span xmlns="" href="libraries.html">Libraries</span></span></dt><dt><span class="section"><a href="extensions.html">Extensions</a></span></dt><dt><span class="section"><a href="tools.html">Tools</a></span></dt><dt><span class="section"><a href="glossary.html">Glossary </a></span></dt></dl></div></span></div></div></nav><div xmlns="" xmlns:exsl="http://exslt .org/common" class="sidenav"><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><dl class="toc"><dt><span class="section"><a href="libraries.html#_overview_5">Overview</a></span></dt><dt><span class="section"><a href="scripting.html">Scripting</a></span></dt><dt><span class="section"><a href="library-alarm.html">Alarms</a></span></dt><dt><span class="section"><a href="library-circuitbreaker.html">Circuit Breaker</a></span></dt><dt><span class="section"><a href="library-constraints.html">Constraints</a></span></dt><dt><span class="section"><a href="library-fileconfig.html">FileConfig</a></span></dt><dt><span class="section"><a href="library-http.html">HTTP</a></span></dt><dt><span class="section"><a href="library-invocation-cache.html">Invocation Cache</a></span></dt><dt><span class="section"><a href="library-jmx.html">JMX</a></span></dt><dt><span class="section"><a href="library-locking.html">Locking</a></span></dt><dt><span class="section"><a href="library-logging.html">Logging< /a></span></dt><dt><span class="section"><a href="library-osgi.html">OSGi</a></span></dt><dt><span class="section"><a href="library-rdf.html">RDF</a></span></dt><dt><span class="section"><a href="library-rest-client.html">ReST Client</a></span></dt><dt><span class="section"><a href="library-rest-client-primer.html">ReST - HATEOAS Primer</a></span></dt><dt><span class="section"><a href="library-rest-common.html">ReST Common</a></span></dt><dt><span class="section"><a href="library-rest-server.html">ReST Server</a></span></dt><dt><span class="section"><a href="library-restlet.html">Restlet Support</a></span></dt><dt><span class="section"><a href="library-servlet.html">Servlet</a></span></dt><dt><span class="section"><a href="library-shiro.html">Shiro Security</a></span></dt><dt><span class="section"><a href="library-shiro-web.html">Shiro Web Security</a></span></dt><dt><span class="section"><a href="library-spring.html">Spring Integration</a></span></dt><dt><span class="section"><a hr ef="library-sql.html">SQL</a></span></dt><dt><span class="section"><a href="library-uid.html">UID</a></span></dt><dt><span class="section"><span xmlns="" href="library-uowfile.html">UoWFile</span></span></dt></dl></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="library-uowfile"></a>UoWFile</h3></div></div></div><p class="remark"><em><span class="comment"></span></em></p><p class="devstatus-code-stable">code</p><p class="devstatus-docs-good">docs</p><p class="devstatus-tests-complete">tests</p><p>The UoWFile Library provides an easy way to bind file operations to UnitOfWorks.</p><p>In other words, using this library you can easily attach files to your +Composites, mostly EntityComposites, so that if the UoW gets discarded, changes +to files are discarded too. Concurrent modifications are properly handled.</p><p>Note that it has a performance impact relative to the files size as it +duplicates the file to keep a backup for eventual rollback. However, the API +provides a way to get non-managed handles on the attached files to keep your +read-only operations fast.</p><p>The location of files is left to the developer using a private mixin.</p><div class="table"><a id="idm5579"></a><p class="title"><strong>Table 47. Artifact</strong></p><div class="table-contents"><table summary="Artifact" border="1"><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /></colgroup><thead><tr><th align="left" valign="top">Group ID</th><th align="left" valign="top">Artifact ID</th><th align="left" valign="top">Version</th></tr></thead><tbody><tr><td align="left" valign="top"><p>org.apache.polygene.libraries</p></td><td align="left" valign="top"><p>org.apache.polygene.library.uowfile</p></td><td align="left" valign="top"><p>0</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_logging_4"></a>Logging</h4></div></div></div><p>The SLF4J Logger used by this library is named "org.apache.polygene.library.uowfile".</p></div><div c lass="section"><div class="titlepage"><div><div><h4 class="title"><a id="_add_an_attached_file_to_an_entity"></a>Add an attached file to an Entity</h4></div></div></div><p>Letâs say you have the following Entity:</p><pre class="programlisting brush: java">public interface TestedEntity + [...snip...] + +{ + Property<String> name(); +} +</pre><p>To add an attached file to it you first need to extends HasUoWFileLifecycle:</p><pre class="programlisting brush: java">public interface TestedEntity + , HasIdentity +{ + Property<String> name(); +} +</pre><p>This provides you with the following contract:</p><pre class="programlisting brush: java">public interface HasUoWFile +{ + /** + * IMPORTANT Use this {@link File} inside read-only {@link UnitOfWork}s only + * @return The file that is attached. + */ + File attachedFile(); + + File managedFile(); + [...snip...] + + +} +</pre><p>Next you need to write the UoWFileLocator mixin:</p><pre class="programlisting brush: java">public static class TestedFileLocatorMixin + implements UoWFileLocator +{ + @This + private HasIdentity meAsIdentity; + + @Structure + private PolygeneSPI spi; + + @Override + public File locateAttachedFile() + { + File baseDir = spi.entityDescriptorFor( meAsIdentity ).metaInfo( File.class ); + return new File( baseDir, meAsIdentity.identity().get().toString() ); + } +} +</pre><p>Assemble all this as follow:</p><pre class="programlisting brush: java">public void assemble( ModuleAssembly module ) + throws AssemblyException +{ + new UoWFileAssembler().assemble( module ); + + module.entities( TestedEntity.class ).withMixins( TestedFileLocatorMixin.class ); + [...snip...] + +} +</pre><p>You can now use the following methods on your EntityComposite:</p><pre class="programlisting brush: java">File attachedFile = entity.attachedFile(); +File managedFile = entity.managedFile(); +</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="_going_plural"></a>Going plural</h4></div></div></div><p>Now if you want to attach several files to one entity, this library provides a +simple mechanism allowing you to use any enum as discriminator.</p><p>Letâs say you have the following Entity:</p><pre class="programlisting brush: java">public interface TestedEntity + [...snip...] + +{ + Property<String> name(); +} +</pre><p>Itâs the very same as the one used to start the singular file support described +above.</p><p>To add an attached file to it you first need to write an enum and extends +HasUoWFilesLifecycle:</p><pre class="programlisting brush: java">public enum MyEnum +{ + fileOne, fileTwo +} + +public interface TestedEntity + , HasIdentity +{ + Property<String> name(); +} +</pre><p>This provides you with the following contract:</p><pre class="programlisting brush: java">public interface HasUoWFiles<T extends Enum<T>> +{ + /** + * IMPORTANT Use this {@link File} only inside read-only {@link UnitOfWork}s + */ + File attachedFile( T key ); + + /** + * IMPORTANT Use these {@link File}s only inside read-only {@link UnitOfWork}s + */ + Iterable<File> attachedFiles(); + + File managedFile( T key ); + + Iterable<File> managedFiles(); + [...snip...] + +} +</pre><p>Next you need to write the UoWFileLocator mixin:</p><pre class="programlisting brush: java">public static abstract class TestedFilesLocatorMixin + implements UoWFilesLocator<MyEnum> +{ + @This + private HasIdentity meAsIdentity; + + @Structure + private PolygeneSPI spi; + + @Override + public Iterable<File> locateAttachedFiles() + { + File baseDir = spi.entityDescriptorFor( meAsIdentity ).metaInfo( File.class ); + List<File> list = new ArrayList<>(); + for( MyEnum eachValue : MyEnum.values() ) + { + list.add( new File( baseDir, meAsIdentity.identity().get() + "." + eachValue.name() ) ); + } + return list; + } + + @Override + public File locateAttachedFile( MyEnum key ) + { + File baseDir = spi.entityDescriptorFor( meAsIdentity ).metaInfo( File.class ); + return new File( baseDir, meAsIdentity.identity().get() + "." + key.name() ); + } +} +</pre><p>Assemble all this as follow:</p><pre class="programlisting brush: java">public void assemble( ModuleAssembly module ) + throws AssemblyException +{ + new UoWFileAssembler().assemble( module ); + + module.entities( TestedEntity.class ).withMixins( TestedFilesLocatorMixin.class ); + [...snip...] + +} +</pre><p>You can now use the following methods on your EntityComposite:</p><pre class="programlisting brush: java">File attachedFileTwo = entity.attachedFile( MyEnum.fileTwo ); +File managedFileOne = entity.managedFile( MyEnum.fileOne ); +</pre></div></div><footer xmlns="" xmlns:exsl="http://exslt.org/common" class="footer"><div class="container"><p class="text-muted">Copyright © 2017 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/" target="_blank">Apache License, Version 2.0</a>. + Apache Polygene, Polygene, Apache, the Apache feather logo, and the Apache Polygene project logo are + trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners. + </p></div></footer><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common">window.jQuery || document.write('<script src="js/jquery-1.6.4.min.js"></script>')</script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="bootstrap-3.3.7/js/bootstrap.min.js"></script><script xmlns="" xmlns:exsl="http://exslt.org/common" src="js/ie10-viewport-bug-workaround.js"></script></body></html> \ No newline at end of file
