It was about “time”…

Java SE 8 Date and Time

by Ben Evans and Richard Warburton

<head>
<title>Hoisting example</title>
</head>
<body>
    <h1>Hoisting in action</h1>
    <script type="application/javascript">
        var hoisting = "global variable";
        alert("global 'hoisting' var => " + hoisting);
        (function(){
            alert("local 'hoisting' var (BEFORE declaration WILL NOT PICK its global 'shadow' -> undefined !) => " + hoisting);
            var hoisting = "local variable";
            alert("local 'hoisting' var (AFTER declaration WILL HIDE its global 'shadow' -> assigned value !) => " + hoisting);
            // block
            {
                var hoisting = "block variable";
                alert("block 'hoisting' var (AFTER declaration WILL OVERRIDE its local 'shadow' -> assigned value !) => " + hoisting);
            }
            // after block
            alert("local 'hoisting' var REPLACED AFTER BLOCK with its block 'shadow' => " + hoisting);
            // THE moral
            alert("The Hoisting MORAL: ALL local variables (even from blocks) are pre-defined/hoisted by JavaScript Runtime in front of the method body !\nDYI to make it clear !");
        })(); //self-executing function 
    </script>
</body>

Thank you Dev{eloper} Stonez (@devstonez) for the tip.

1. References of used class/method in code

This is a very quick and useful way to find out where a class or method is used throughout the workspace/project. How to do it – select class/method > right click > References > Workspace (Ctrl+Shift+G) || Project

Once you’ve done that, the results will be displayed in the Search view:

Show-References

Show references

Another alternative for that is by selecting the class/method > start Java Search (Ctrl+H) > select your search criteria (in this case Type) and limit to References:

show references - java search

Show References via Java Search

Continue Reading ...

This is sort of a follow up post for a previous post of mine – RESTful Web Services Example in Java with Jersey, Spring and MyBatis. It is based on the same example application, which, via a REST API, can execute CRUD operations against a single Podcasts table. If in the first post the focus was on how to build the REST API with Jersey, this time it is on the data persistence layer. I will present how to implement a container-agnostic persistence layer with JPA2/Hibernate, being glued in the application via Spring.

Continue Reading ...

Note: At the time of writing this post I was just starting with REST and Jersey so I  suggest you have a look at  Tutorial – REST API design and implementation in Java with Jersey and Spring instead. My gained REST knowledge will be from now on reflected in this post, which is already an “(r)evolution” regarding REST API design, REST best practices used and backend architecture/implementation supporting the REST API presented in the tutorial.

Looking to REST? In Java? There’s never time for that :), but if you are looking to use an “architectural style consisting of a coordinated set of constraints applied to components, connectors, and data elements, within a distributed hypermedia system” in Java, then you have come to the right place, because in this post I will present a simple RESTful API that maps REST calls to backend services offering CRUD functionality.

Note: I will not focus too much on Representational state transfer (REST) itself, because there are plenty of resources on the topic in the internet, some of which I listed under Resources at the end of the post.

Continue Reading ...