tag:blogger.com,1999:blog-27165848707878718122024-03-05T19:19:26.606-08:00jlinks"It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to remove"
Antoine de Saint ExupéryUnknownnoreply@blogger.comBlogger174125tag:blogger.com,1999:blog-2716584870787871812.post-61700959672128026602021-08-13T01:41:00.000-07:002021-08-13T01:41:04.614-07:00Legacy Displacement<p> </p><p><i style="background: rgb(255, 255, 255); border: 0px; box-sizing: inherit; color: #303633; font-family: Lora, serif; font-size: 16px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">"When faced with the need to replace existing software systems, organizations often fall into a cycle of half-completed technology replacements. Our experiences have taught us a series of patterns that allow us to break this cycle, relying on: a deliberate recognition of the desired outcomes of displacing the legacy software, breaking this displacement in parts, incrementally delivering these parts, and changing the culture of the organization to recognize that change is the unvarying reality...."</i></p><p><a href="https://martinfowler.com/articles/patterns-legacy-displacement/">https://martinfowler.com/articles/patterns-legacy-displacement/</a></p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-82177015088327464002020-02-20T08:56:00.002-08:002021-06-24T03:41:16.396-07:00HTTP/2 - HTTP/1HTTP/1.1 assumes that a TCP connection should be kept open unless directly told to close.<br />
HTTP2 reduces latency by using multiplexing, compression and prioritization.<br />
An application level API would still create messages in the conventional HTTP formats, but the underlying layer converts the payload into binary (binary framing).<br />
HTTP/2 establishes a single connection object between the two machines. Within this connection there are multiple streams of data. Each stream consists of multiple messages in the familiar request/response format. Finally, each of these messages split into smaller units called frames.<br />
Multiplexing: Several requests and responses can run in parallel using a single TCP connection without blocking each other. This reduces processor and memory resources and the SSL handshakes.<br />
Stream prioritization feature allows developers to prioritize the requests by assigning a weight between 1 and 256 to each stream. The higher number indicates higher priority.<br />
server can send a resource to a client along with the requested HTML page, providing the resource before the client asks for it. This process is called server push. <br />
Additionally, server can send a resource to a client along with the requested HTML page, providing the resource before the client asks for it. This process is called server push.<br />
<br />
Read more: <a href="https://www.digitalocean.com/community/tutorials/http-1-1-vs-http-2-what-s-the-difference" target="_blank">https://www.digitalocean.com/community/tutorials/http-1-1-vs-http-2-what-s-the-difference</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2716584870787871812.post-44674020115988526202020-02-18T11:29:00.002-08:002020-02-18T11:29:43.850-08:00Some thoughts on Conway's law<br />
<ul>
<li><span style="background-color: white; color: rgba(0, 0, 0, 0.84); font-family: "Courier New", Courier, monospace; letter-spacing: -0.084px;">Human beings are complex social animals.</span></li>
<li><span style="background-color: white; color: rgba(0, 0, 0, 0.84); font-family: "Courier New", Courier, monospace; letter-spacing: -0.084px;">Rome was not built in a day. Address the issues that can be addressed first.</span></li>
<li><span style="background-color: white; color: rgba(0, 0, 0, 0.84); font-family: "Courier New", Courier, monospace; letter-spacing: -0.084px;">Create independent subsystems to reduce the communication cost.</span></li>
</ul>
<br />
<br />
Read more: <a href="https://medium.com/@Alibaba_Cloud/conways-law-a-theoretical-basis-for-the-microservice-architecture-c666f7fcc66a" target="_blank">https://medium.com/@Alibaba_Cloud/conways-law-a-theoretical-basis-for-the-microservice-architecture-c666f7fcc66a</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2716584870787871812.post-11473941319865131242019-12-17T03:15:00.000-08:002019-12-17T03:15:13.674-08:00Java 9 Jigsaw - How to create modules<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/k0Hu-VZnE3s/0.jpg" frameborder="0" height="315" src="https://www.youtube.com/embed/k0Hu-VZnE3s?feature=player_embedded" width="560"></iframe></div>
<div style="text-align: center;">
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-81789284322494445182019-12-17T01:54:00.001-08:002019-12-17T01:54:28.081-08:00Java 10 - type inference with var<br />
Go to:<br />
<a href="https://blog.codefx.org/java/java-10-var-type-inference/" target="_blank">https://blog.codefx.org/java/java-10-var-type-inference/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-91451734764426749872019-12-16T10:36:00.001-08:002019-12-16T10:36:30.345-08:00Java - Replace traditional for loops with IntStreams<br />
Go to:<br />
<a href="https://www.deadcoderising.com/2015-05-19-java-8-replace-traditional-for-loops-with-intstreams/" target="_blank">https://www.deadcoderising.com/2015-05-19-java-8-replace-traditional-for-loops-with-intstreams/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-41508117978009294862019-12-13T03:59:00.000-08:002019-12-13T03:59:30.506-08:00Finagle<br />
<br />
Build request:<br />
<br />
RequestBuilder requestBuilder = new RequestBuilder() // custom class<br />
.withMethod(method)<br />
.withHeader(xxx, "xxx")<br />
.withPath(endpoint)<br />
.withParams(request.getPathParams())<br />
.withQueryParams(request.getQueryParams());<br />
<br />
Service<Request, Response> restService = restServiceProvider.getService(serviceLabel);<br />
<br />
<br />
Finagle Call:<br />
<br />
final Future<O> responseFuture = filter.apply(request, restService);<br />
final O result<br />
try {<br />
result = Await.result(responseFuture, Duration.fromMilliseconds(config.getTotalRequestTimeout()));<br />
} catch (Exception e) { ... }<br />
return result;Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2716584870787871812.post-73037834019707259922019-11-28T01:47:00.000-08:002019-11-28T01:47:07.456-08:00Java Optional - How to use correctlyHow to use Java Optional correctly, what to avoid and good practices:<br />
<a href="https://dzone.com/articles/using-optional-correctly-is-not-optional" target="_blank">https://dzone.com/articles/using-optional-correctly-is-not-optional</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-66286098452600544892019-11-11T03:12:00.000-08:002019-11-11T03:12:29.204-08:00Spring boot - Conditional Bean Creation<span style="font-family: Courier New, Courier, monospace;">@ConditionalOnBean(name = "otherNeededBean")</span><br />
The bean is only created, if the bean "otherNeededBean" already exist.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">@ConditionalOnMissingBean</span><br />
The bean is only created, if no other bean with the same name already exist.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">@ConditionalOnMissingBean(type = "alternativeBean")</span><br />
The bean is only created, if bean "alternativeBean" doesn't exist.<br />
<br />
Conditional based on Environment property<br />
<br />
Add proprty file to the Configuration class.<br />
<span style="font-family: Courier New, Courier, monospace;">@PropertySource("classpath:myspecific.properties")</span><br />
<span style="font-family: Courier New, Courier, monospace;">public class MySpecificConfiguration {}</span><br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">@ConditionalOnProperty(name = "email.notification", havingValue = "true")</span><br />
<span style="font-family: Courier New, Courier, monospace;">@Bean</span><br />
<span style="font-family: Courier New, Courier, monospace;">public MailService ...</span><br />
<br />
myspecific.properties:<br />
<i>email.notification = true | false</i>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-159189962516050202019-10-24T05:18:00.001-07:002019-10-24T05:18:10.895-07:00Command Query Responsibility Segregation (CQRS)<br />
"every method should either be a Command that performs an action or a Query that returns data. A Command cannot return data and a Query cannot change the data...<br />
it might be desirable to use two different data stores...<br />
this allows you to store the data in the read database as denormalised data...<br />
it allows you to scale the two different sides of your application separately..."<br />
<br />
More info: <a href="https://culttt.com/2015/01/14/command-query-responsibility-segregation-cqrs/" target="_blank">https://culttt.com/2015/01/14/command-query-responsibility-segregation-cqrs/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-86453887992770898632019-10-21T02:22:00.000-07:002019-10-21T02:25:27.769-07:00Dzone Java Developer Roadmap 2019<br />
<a href="https://dzone.com/articles/the-2019-java-developer-roadmap" target="_blank">https://dzone.com/articles/the-2019-java-developer-roadmap</a><br />
<br />
<a href="https://dzone.com/articles/the-2019-java-developer-roadmap" target="_blank"><br />
<img alt="https://dzone.com/articles/the-2019-java-developer-roadmap" border="0" data-original-height="1593" data-original-width="1036" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh76RczmyxUaDRvPO9XyngNb9DyPf9WlceWtoBeKuI4YLaZshVbcOBttQyPUD_quB8g3Q2cIaSj50FXrvAAfjZbGD1CnPTN8LDUeY6Pl0qZvnuOtNuzS64erOULwayHJYBWYfk_5ran908/s1600/The+2019+Java+Developer+RoadMap.jpg" title="https://dzone.com/articles/the-2019-java-developer-roadmap" /></a><br />
<br />
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-14833209548874086202019-10-14T02:42:00.004-07:002019-10-14T02:42:49.424-07:00Git Merge vs. Rebase<i><span style="font-size: large;">"Merge</span> creates a new “merge commit” in the target branch that ties together the histories of both branches. </i><i>Merging is nice because it’s a non-destructive operation. The existing branches are not changed in any way.</i><br />
<i>On the other hand, the target branch will have an extraneous merge commit every time you merge. </i><br />
<i><span style="font-size: large;">Rebase</span> moves the entire source branch to begin on the tip of the target branch, effectively incorporating all of the new commits in target. </i><br />
<i>But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.</i><br />
<i>You get a much cleaner project history and it eliminates the unnecessary merge commits.</i><br />
<i>But, there are two trade-offs for this pristine commit history: safety and traceability.</i><br />
<i><u>The Golden Rule of Rebasing:</u></i><br />
<span style="color: red;"><i>The golden rule of git rebase is to never use it on public branches.</i></span><br />
<i>Rebase moves all of the commits in source onto the tip of target. The problem is that this only happened in your repository. </i><br />
<i>All of the other developers are still working with the original source.</i><br />
<i>Since rebasing results in brand new commits, Git will think that your source branch’s history has diverged from everybody else’s. </i><br />
<i>So, before you run git rebase, always ask yourself, “Is anyone else looking at this branch?”</i><br />
From : <a href="https://www.atlassian.com/git/tutorials/merging-vs-rebasing" target="_blank">https://www.atlassian.com/git/tutorials/merging-vs-rebasing</a><br />
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-4452312744567453062019-10-11T06:47:00.002-07:002019-10-11T06:47:54.998-07:00Java Keytool, Keys and Certificatesapp-1 will provide a copy of his public key to app-2 and signs the communication with its private key.<br />
<br />
Step 1: app-1 creates private/public key pair in its keystore:<br />
<span style="font-family: Courier New, Courier, monospace;">$ keytool -genkey -alias "app-1-key" -keystore app-1.jks</span><br />
Verify:<br />
<span style="font-family: Courier New, Courier, monospace;">$ keytool -v -list -keystore app-1.jks</span><br />
<br />
Step 2: app-1 generates a certificate file from its private keystore:<br />
<span style="font-family: Courier New, Courier, monospace;">$ keytool -export -alias "app-1-key" -file app-1.cer -keystore app-1.jks</span><br />
<br />
Step 3: app-2 imports the public key of app-1 into its keystore:<br />
<span style="font-family: Courier New, Courier, monospace;">$ keytool -import -alias "app-1-publickey" -file app-1.cer -keystore app-2-publickey.store</span><br />
<div>
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-40084929335391938242019-10-11T06:45:00.002-07:002019-11-06T03:55:45.661-08:00PI Mutation Tests<blockquote class="tr_bq">
Faults (or mutations) are automatically seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived.</blockquote>
<a href="https://pitest.org/" target="_blank">https://pitest.org/</a><br />
<br />
<br />
<u><b><i>Example</i></b></u><br />
Method: isPositive<br />
Actual implementation:<br />
<span style="font-family: Courier New, Courier, monospace;"> if (number >= 0) return true;</span><br />
Following test will pass:<br />
<span style="font-family: Courier New, Courier, monospace;"> assertEquals(true, xxx.isPositive(10));</span><br />
But fail for following code mutation:<br />
<span style="font-family: Courier New, Courier, monospace;"> if (number > 0) return true;</span><br />
To kill the mutation, the unit test should test boundaries:<br />
<span style="font-family: Courier New, Courier, monospace;"> assertEquals(true, xxx.isPositive(10));</span><br />
<span style="font-family: Courier New, Courier, monospace;"> assertEquals(true, xxx.isPositive(0));</span><br />
<br />
See: <a href="https://www.mkyong.com/maven/maven-pitest-mutation-testing-example/" target="_blank">https://www.mkyong.com/maven/maven-pitest-mutation-testing-example/</a><br />
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-43737698861805381412019-10-09T05:47:00.001-07:002020-01-27T00:21:08.095-08:00Mutual TLS - Easy explained<br />
<ol>
<li>A puts an envelope in a box, locks the box with his key and sends it to B. The box can't be opened on the way, since it is locked.</li>
<li>B receives the box, and accepts to view it. But can't open the box neither, since it is locked.</li>
<li>B lockes the box again, this time with his own lock and sends it back to A.</li>
<li>The box is now locked with 2 locks, one from A, and one from B.</li>
<li>A receives the box and realizes, that B has accepted the communication by locking the box with his lock. </li>
<li>A can now remove his lock and send the box back to B. </li>
<li>The box still can't be opened by anyone other than B.</li>
<li>B receives the box with his lock and can now open the box with his own key and open the envelope sent by A originally.</li>
<li>For A and B to trust each others locks (certificates), a Certificate Authority (CA) must approve both certificates.</li>
</ol>
<div>
See also: <a href="https://www.codeproject.com/Articles/326574/An-Introduction-to-Mutual-SSL-Authentication" target="_blank">https://www.codeproject.com/Articles/326574/An-Introduction-to-Mutual-SSL-Authentication</a></div>
<div>
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-33321476117118156572019-10-02T07:10:00.003-07:002019-10-02T07:10:46.031-07:00Log-based Change-Data-Capture (CDC) and Kafka Connect"Kafka Connect provides scalable and resilient integration between Kafka and other systems. The Confluent JDBC Connector for Kafka Connect enables you to stream data to and from Kafka and any RDBMS that supports JDBC.<div>
...<br /><div>
CDC basically enables you to stream every single event from a database into Kafka. Broadly put, relational databases use a transaction log ( redo log depending on DB flavour), to which every event in the database is written. Update a row, insert a row, delete a row – it all goes to the database’s transaction log..."</div>
</div>
<div>
<br /></div>
<div>
Read more: <a href="https://www.confluent.io/blog/no-more-silos-how-to-integrate-your-databases-with-apache-kafka-and-cdc" target="_blank">https://www.confluent.io/blog/no-more-silos-how-to-integrate-your-databases-with-apache-kafka-and-cdc</a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
See also <a href="https://www.oracle.com/middleware/data-integration/goldengate/big-data/" target="_blank">https://www.oracle.com/middleware/data-integration/goldengate/big-data/</a></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-18493726910731904292019-10-02T02:38:00.000-07:002019-10-02T02:43:07.256-07:00Forward Proxy -> Reverse Proxy"The difference between a forward and reverse proxy is subtle but important. A simplified way to sum it up would be to say that a forward proxy sits in front of a client and ensures that no origin server ever communicates directly with that specific client. On the other hand, a reverse proxy sits in front of an origin server and ensures that no client ever communicates directly with that origin server..."<br />
<br />
Read more here: <a href="https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/" target="_blank">https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-56293116436577005612019-09-17T01:19:00.000-07:002019-09-17T01:28:27.931-07:00OWASP Web Top 10 2017<br />
OWASP Web Top 10 2017 and what has changed compare to 2010?<br />
Go to link: <a href="https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf" target="_blank">https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf</a><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHQ0I-qYLtaoe30RpgsfTtUM7CdCix5qI6a2nng48fmJK1MyQMqUHSpfHLfzAvOKgLVhQu8_kutjEPK5tgEQKIVSIRvo-VGYCFmphpGJ5PvXeBRPGxsQ8smQ0VU-Wjkh-EEE0joIeNCEA/s1600/owasp2017.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="364" data-original-width="675" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHQ0I-qYLtaoe30RpgsfTtUM7CdCix5qI6a2nng48fmJK1MyQMqUHSpfHLfzAvOKgLVhQu8_kutjEPK5tgEQKIVSIRvo-VGYCFmphpGJ5PvXeBRPGxsQ8smQ0VU-Wjkh-EEE0joIeNCEA/s640/owasp2017.PNG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Source: www.owasp.org</td></tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-15451781236786960712019-09-11T10:37:00.000-07:002019-09-11T10:37:23.485-07:00REST Endpoint: Consume / Produce JSON/XML<br />
<br />
Import Jackson Data format:<br />
<br />
<div style="text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-b1dTiE-UkX01OstqVw_FBJmZ-_hB9JOiU6UImxXfqQu99blFNsk79hzjwP2qfzr5pqauthNPbPTVh7FRZpSqw5wLF7iWrLkz-ObnRlj2rOlSjjzU-ceRQ9jJynFa1ck5qIjzch_RWYo/s1600/1.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em;"><img border="0" data-original-height="128" data-original-width="1004" height="80" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-b1dTiE-UkX01OstqVw_FBJmZ-_hB9JOiU6UImxXfqQu99blFNsk79hzjwP2qfzr5pqauthNPbPTVh7FRZpSqw5wLF7iWrLkz-ObnRlj2rOlSjjzU-ceRQ9jJynFa1ck5qIjzch_RWYo/s640/1.jpg" width="640" /></a></div>
<br />
<br />
Annotate the REST method to consume and produce the desired format(s):<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif638TIpfPE9qkrKopRqENJBEch-hyD-hdGT0fZLyzMYkM1NChNCHj6HQ-gezfikOoGq7vIk23dZajy0Ts00mWzqpn7UCGG-O5ZNhSy4ShKScZL6E6OjL61jGKiDo_QjQ_3H5BJe8BdkA/s1600/2.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="96" data-original-width="900" height="67" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif638TIpfPE9qkrKopRqENJBEch-hyD-hdGT0fZLyzMYkM1NChNCHj6HQ-gezfikOoGq7vIk23dZajy0Ts00mWzqpn7UCGG-O5ZNhSy4ShKScZL6E6OjL61jGKiDo_QjQ_3H5BJe8BdkA/s640/2.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
In HTTP Request header, set attribute:</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">Content-Type</span> to application/json|xml to indicate the body format</li>
<li><span style="font-family: Courier New, Courier, monospace;">Accept</span> to application/json|xml to indicate the desired response format</li>
</ul>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKhM_hy5RAO5gdBmhyphenhyphenhwClKxKq73Yt_KRp-8IiwrC6eUmUF02fsjM6Em2NZTG0hOIQPfTU7QdRg7x4ZtqPz2aWSqBmxZ6Dz6lCBIGrtF9LjkV0pYTr23Im2nQjijPiPAcESKJxwW5Zyhc/s1600/3.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="156" data-original-width="799" height="124" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKhM_hy5RAO5gdBmhyphenhyphenhwClKxKq73Yt_KRp-8IiwrC6eUmUF02fsjM6Em2NZTG0hOIQPfTU7QdRg7x4ZtqPz2aWSqBmxZ6Dz6lCBIGrtF9LjkV0pYTr23Im2nQjijPiPAcESKJxwW5Zyhc/s640/3.jpg" width="640" /></a></div>
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-91347662844770808482019-09-11T03:27:00.000-07:002019-09-11T03:27:10.954-07:00Java 8<a href="https://howtodoinjava.com/java-8-tutorial/" target="_blank">https://howtodoinjava.com/java-8-tutorial/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-72832030502346101352019-09-11T03:25:00.001-07:002019-09-11T03:25:28.453-07:00Java Collections<a href="https://howtodoinjava.com/java-collections/" target="_blank">https://howtodoinjava.com/java-collections/</a><br />
<a href="https://howtodoinjava.com/interview-questions/useful-java-collection-interview-questions/" target="_blank">https://howtodoinjava.com/interview-questions/useful-java-collection-interview-questions/</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-70294125583460709372019-09-11T01:57:00.000-07:002019-09-11T01:57:03.383-07:00extends Thread vs implements Runnable<b><u>Thread</u></b><br />
<span style="font-family: Courier New, Courier, monospace;"> Class T1 extends Thread {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public void run(){...}</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
Run with:<br />
<span style="font-family: Courier New, Courier, monospace;"> new T1().start();</span><br />
<br />
<b><u>Runnable</u></b><br />
<span style="font-family: Courier New, Courier, monospace;"> Class R2 implements Runnable{</span><br />
<span style="font-family: Courier New, Courier, monospace;"> public void run(){...}</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
Run with:<br />
<span style="font-family: Courier New, Courier, monospace;"> Thread t2 = new Thread(R2);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> t2.start();</span><br />
<br />
R1 still allows you to extend a class (and thus, the behaviour), which is not possible with T1.<br />
Further, multiple threads of T2 shares the same runnable instance, where multiple T1 creating unique instances.<br />
If you don't need extention behaviour, use rather Runnable implementation.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-55367987069982121602019-09-10T13:39:00.000-07:002019-09-10T13:39:51.068-07:00Object mapping performance comparisonA performance comparison between:<br />
<br />
<br />
<ul>
<li>Dozer: recursively copies data from one object to another</li>
<li>Orika: recursively copies (byte) data from one object to another</li>
<li>MapStruct: Conde generator</li>
<li>ModelMapper: simple, based on conventions</li>
<li>JMapper: The framework allows for different ways of configuration: annotation-based, XML or API-based.</li>
</ul>
<br />
See complete results here: <a href="https://www.baeldung.com/java-performance-mapping-frameworks" target="_blank">https://www.baeldung.com/java-performance-mapping-frameworks</a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-90170377756786738702019-09-10T06:47:00.002-07:002019-09-10T06:48:49.548-07:00CountDownLatch<br />
The main thread initializes a CountDownLatch, e.g.:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">CountDownLatch countDownLatch = new CountDownLatch(3);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
It passes countDownLatch to n (in this example 3) sub-threads, for instance via constructor.<br />
Finally, the main thread waits for the execution of the sub threads:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">countDownLatch.await();</span><br />
<br />
Once ready, every thread finally calls<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">countDownLatch.countDown();</span><br />
<br />
Every countDown() call decrements the initial number, and the main thread finally will resume with the operations defined after the wait() statement.<br />
<br />
See more here: <a href="https://howtodoinjava.com/java/multi-threading/when-to-use-countdownlatch-java-concurrency-example-tutorial/" target="_blank">https://howtodoinjava.com/java/multi-threading/when-to-use-countdownlatch-java-concurrency-example-tutorial/</a><br />
<br />
<br />Unknownnoreply@blogger.comtag:blogger.com,1999:blog-2716584870787871812.post-78687860260508900962019-09-07T05:17:00.004-07:002019-09-10T06:49:10.604-07:00Spring 5 WebFlux: WebClient and WebTestClientWebClient is part of Spring 5’s reactive web framework called Spring WebFlux...<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">webClient</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .post() </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .uri("/uri")</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .header(...)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .retrieve().bodyToFlux(Clazz.class);</span><br />
<span style="font-family: inherit;"> Or </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> .retrieve().bodyToMono(Clazz.class);</span><br />
<br />
Go to: <a href="https://www.callicoder.com/spring-5-reactive-webclient-webtestclient-examples/" target="_blank">https://www.callicoder.com/spring-5-reactive-webclient-webtestclient-examples/</a>Unknownnoreply@blogger.com