The new Brave web browser is trying to do something radically different with your boring old browser. Brave burst onto the scene at the start of 2016, positioning itself as the latest battleground in the war between ad producers and ad blockers. Brave is built on the promise of faster load times and better privacy protection by blocking web trackers and targeted ads. If Brave users agree to replace those ads with anonymous ads from the Brave network, the user will be paid in bitcoin. Being paid to surf has been the dream of many web aficionados and Brave promises to make it real.The Philosophy Behind Brave
In the first part of notes on Akka FSM, we saw the basics of Akka FSM and the outline of the Coffee vending machine that we planned to build - the structure of the Actor and a list of messages we pass to the Actor. In this second and final part, we will go ahead and implement each of these States.Recap
As a quick recap, let's look at the structure of the FSM and the messages that can be sent to it.
Every so often I’ll crawl out of my Java cave and run into a seasoned dev who has embraced Scala. And I have noticed that not one of them seems to want to go back to Java programming.
Having moved to Java 8 and embraced Optional and streams, I can see the appeal of thinking functionally. Whenever I see a nested for loop iterating over a collection or a bunch of null checks on a class hierarchy, I shudder little. Not only because the code is so ugly, but because for the longest time I didn’t know any better myself.
Suppose we have a project where we use Lombok annotations. To use it we must change the compiler configuration for our project and enable annotation processing. We can find this in the Preferences or Settings window under Build, Execution, Deployment | Compiler | Annotation Processors. Here we have a checkbox Enable annotation processing that we must check to use the annotations from IntelliJ IDEA. We can automate this setting with some configuration in our Gradle build file.
In the next example build file we alter the generated IntelliJ IDEA project file using the withXml hook. We can access the generated XML as a groovy.util.Node and change the XML.
Polymorphism is one of the pillars of OOP in Java.
An object showing different behaviors at different stages of its life cycle is known as polymorphism. There are two types of polymorphism:
You obviously need cache. There are options to do that with EhCache, Hazelcast, Infinispan, memcached, Redis, AWS’s ElastiCache and some others. However, EhCache supports only replicated and not distributed cache, and Hazelcast does not yet work with the latest version of Hibernate. Infinispan and Hazelcast support consistent hashing, so the entries live only on specific instance(s), rather than having a full copy of all the cache on the heap of each instance. ElastiCache is AWS-specific, so Infinispan seems the most balanced option with the Spring / Hibernate setup.
So, let’s first setup the Hibernate 2nd-level cache. The official documentation for Infinispan is not the top Google result—it is usually either very old documentation, or just 2 versions old documentation. You’d better open the latest one from the homepage.
A fresh EAP build for IntelliJ IDEA 2016.2 is out and, being a good EAP build that it is, has something new for you to try:General
The result is that the code writes "1" to the standard outputThis Week's Quiz: Exception Handling in Java
This quiz is aimed at advanced Java programmers.
Java Code Challenge is a new weekly segment taking the best challenge from Reddit's dailyprogrammer. Things are a little different here as we're focused on Java. A working solution is not enough; we're looking for the cleanest Java code with tests. 3rd party libraries are welcome but if you can do it without it will be easier for others to comprehend.
If you can fit your solution in the comments then go for it, but preferably put your answer in GitHub and link in the comments. Next week we'll be sharing the best solutions and sharing the best code practices we see!
It's not uncommon for computers to need to communicate with each other. In the early days this was done with simple string messages. Which was problematic. There was no standard language. XML evolved to address this. XML provides a very structured way of sharing data between systems. XML is so structured, many find it too restrictive. JSON is a popular alternative to XML. JSON offers a lighter and more forgiving syntax than XML.
JSON is a text-based data interchange format that is lightweight, language-independent, and easy for humans to read and write. In the current enterprise, JSON is used for enterprise messaging, communicating with RESTful web services, and AJAX-based communications. JSON is also extensively used by NoSQL database such as, MongoDB, Oracle NoSQL Database, and Oracle Berkeley DB to store records as JSON documents. Traditional relational databases, such as PostgreSQL is also constantly gaining more JSON capabilities. Oracle Database also supports JSON data natively with features, such as transactions, indexing, declarative querying, and views.
Testing multithreaded code is a tough challenge. The first advice that you get when trying to test concurrency is to isolate your concurrent concerns in the code as much as possible. This a general design advice but in this case it's even more important. Make sure to first properly unit test the logic that is wrapped by the concurrent construct. Otherwise you might spend a long time trying to figure out a concurrency problem that turns out to be flawed business logic in the end.
OK, let’s have a look at our first pattern.
The singleton pattern is one of the most well-known design patterns and is used extensively by frameworks such as Spring, pool managers, and loggers.
Modular design has a lot of benefits, including:
But, it is much much much harder than people think. For a start, the abstractions have to be at the right level. Too high and they can become meaningless and too low and they cease to be abstractions, as they will end up having way too many dependencies ( efferent and afferent).
AndroMDA is a framework for code generation based on UML modeling.
In this article I use AndroMDA to build a complete stack of (JPA, Spring, CXF Apache web service) as a basic traditional J2EE application.
Export to Word Plugin for dotCMS allow users to export online content into Word Processing document using Aspose.Words for Java. It dynamically exports the content of the Web page to a Word Processing document and then automatically downloads the file to the disk location selected by the user in just a couple of seconds. The generated Word processing document can then be opened using any Word Processing Application such as Microsoft Word, Apache OpenOffice, etc.Supported Platforms
In order to deploy Export to Word OSGI/Dynamic Plugin you need to have the following requirements met:
A Constructor Function implementation in Java.Implementation: Java
The Constructor Function is not a pattern commonly used in Java, since most of the time the desire when holding state is to hold it as accessible member variables of an object, which Java supports directly via fields. Additionally, thanks to Java’s “C-family” heritage, it directly supports encapsulatory access control (meaning we can annotate the field with “private” to prevent access to the field from outside the class). However, in some cases, this standard mode of access control is not enough, and/or we want to provide a slightly different means of construction for clients. This is when a Constructor Function can be of use, usually modeled as a static method (or methods) on the class itself.
Given that Scala is a functional language (object/functional, really), building a Constructor Function in Scala is actually pretty straightforward.Object Method Constructor
Scala allows us to create per-class methods on the class object, providing a convenient place on which to store methods designed to construct instances of the class. Scala traits are used to define the Interface, so as to better take advantage of the statically-typed nature of the compiler and provide compilation guarantees. In addition, because Scala supports nested classes (meaning, in this particular case, classes whose definition appears entirely inside a function definition), we can “hide” the implementation in much the same way that Java uses inner-class implementations, though we still do need to provide a name to the type.
I recently had the opportunity to play with Akka FSM at work for some really interesting use-case. The API (in fact, the DSL) is pretty awesome and the entire experience was amazing. Here's my attempt to log my notes on building a Finite State Machine using Akka FSM. As an example, we'll walk through the steps of building a (limited) Coffee vending machine.Why not become and unbecome?
We know that the plain vanilla Akka Actors can switch its behavior by using become/unbecome. Then, why do we need Akka FSM? Can't a plain Actor just switch between the States and behave differently? Yes, it could. But while Akka's become and unbecome is most often enough to switch the behavior of Actors with a couple of states involved, building a State Machine with more than a few states quickly makes the code hard to reason with (and even harder to debug).
Who’s on top and who’s left behind? We analyzed 47,251 dependencies on GitHub and pulled out the top 100 Java libraries
Our favorite pastime for long weekends is to go through GitHub and search for popular Java libraries. We decided to share the fun and the information with you.
I’ve been really pleased with the responses to the node challenge. Great work everybody!
This is a relatively simple challenge but one that demonstrates why programming is more of an art than a science. Every single response was different in design and style. There is no one “correct” answer, which is one of the wonderful things about programming.