<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sergio Leal</title>
    <description>Mostly java and angular stuff.
</description>
    <link>http://sergiolealdev.com/blog/</link>
    <atom:link href="http://sergiolealdev.com/blog/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 27 May 2019 22:37:49 +0000</pubDate>
    <lastBuildDate>Mon, 27 May 2019 22:37:49 +0000</lastBuildDate>
    <generator>Jekyll v3.8.5</generator>
    
      <item>
        <title>Update in Weather Widget Project</title>
        <description>&lt;p&gt;I just updated my angularJS Weather Widget component that you can install from bower as a standalone component in your AngularJS app.&lt;/p&gt;

&lt;p&gt;Feel free to fork it and also you can use a full &lt;a href=&quot;http://sergiolealdev.com/WeatherWidget/app.html&quot; target=&quot;_blank&quot;&gt;demo&lt;/a&gt; with the main features.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png&quot; alt=&quot;github_24px&quot; width=&quot;24&quot; height=&quot;24&quot; /&gt;&lt;a href=&quot;https://github.com/sergiolealdev/WeatherWidgetAngularJS&quot; target=&quot;_blank&quot;&gt;Watch / Download project on Github&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 02 Feb 2016 00:00:00 +0000</pubDate>
        <link>http://sergiolealdev.com/blog/2016/02/02/update-weather-widget.html</link>
        <guid isPermaLink="true">http://sergiolealdev.com/blog/2016/02/02/update-weather-widget.html</guid>
        
        
      </item>
    
      <item>
        <title>Mixins in SASS</title>
        <description>&lt;p&gt;Sass is a great technology that allows us to handle our style files by adding features like variables, nesting, mixins, inheritance…… Basically is like “programming” your css.&lt;/p&gt;

&lt;p&gt;The purpose of this post is not to explain how to use and install Sass; If you don’t have any previous experience with Sass, you may want to have a look at the &lt;a href=&quot;http://sass-lang.com/&quot;&gt;official webpage&lt;/a&gt;.&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;To help me with the preprocessing, I have used a brilliant tool called &lt;a href=&quot;http://mhs.github.io/scout-app/&quot;&gt;Scout&lt;/a&gt;, very simple to use, to install and to configure.&lt;/p&gt;

&lt;p&gt;Mixins is basically a way to refactor and to re-use parts of the code that we will called from different places; it has basically the look of a function. We can even pass arguments.&lt;/p&gt;

&lt;p&gt;Let’s imagine we have declared a couple of buttons and we have used some Sass to define their look.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;o&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Style&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;button&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.main-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main-button-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;            &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;          &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;padding-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Style&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;regular&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;button&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;.regular-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;regular-button-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;            &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;          &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;padding-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;I won’t add all the code here, you can download it on my Github account using the link at the bottom of the post.&lt;/p&gt;

&lt;p&gt;Here we have just defined  the width, padding and background color of our two buttons. Note that both width and padding are exactly the same in this example, the buttons only differentiate in the background color.&lt;/p&gt;

&lt;p&gt;So, let’s use mixins to declare our ‘function’ and also pass it an argument to pass for the background color (which is the only element that is different in each case).&lt;/p&gt;

&lt;p&gt;To create a mixin, we just need to add the special element @mixin, name the mixin and add (optionally) some arguments. Inside of the mixin we will define what this ‘function’ will do:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;k&quot;&gt;@mixin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;button-background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;button-background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;            &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;width-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;          &lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;padding-all-buttons&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s it, we only need to call this mixin from each button with the @include element, and also pass the parameter to define the color of each background:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nc&quot;&gt;.main-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@include&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;all-buttons($main-button-color);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;.regular-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@include&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;all-buttons($regular-button-color);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As we can see, the refactor leaves our scss file cleaner and easier to use and understand. Also, in the final css file we can check that both before and after treatment gives exactly the same result.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-css&quot; data-lang=&quot;css&quot;&gt;&lt;span class=&quot;nc&quot;&gt;.main-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;#81c3e5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;250px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;.regular-button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;#47c333&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;250px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;nl&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;5px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Feel free to fork the sample and play with it to understand how it works and also to try many other capabilities that are not included in this post.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png&quot; alt=&quot;github_24px&quot; width=&quot;24&quot; height=&quot;24&quot; /&gt;&lt;a href=&quot;https://github.com/sergiolealdev/SampleMixinsSass&quot; target=&quot;_blank&quot;&gt;Watch / Download example on Github&lt;/a&gt;
&lt;br /&gt;
&lt;img src=&quot;http://icons.iconarchive.com/icons/dakirby309/windows-8-metro/256/Web-YouTube-Metro-icon.png&quot; alt=&quot;github_24px&quot; width=&quot;24&quot; height=&quot;24&quot; /&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Roe93U8X9LE&quot; target=&quot;_blank&quot;&gt;Watch how to setup Scout&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 09 Sep 2015 00:00:00 +0000</pubDate>
        <link>http://sergiolealdev.com/blog/2015/09/09/mixins-in-sass.html</link>
        <guid isPermaLink="true">http://sergiolealdev.com/blog/2015/09/09/mixins-in-sass.html</guid>
        
        
      </item>
    
      <item>
        <title>Computing Industrialization?</title>
        <description>&lt;p&gt;Last week I was discussing with a friend about the technologies to use in our next project. We were arguing about the features, performances, pros and cons of&lt;a href=&quot;http://www.thymeleaf.org/features.html&quot;&gt; Thymeleaf&lt;/a&gt;, JSP’s or&lt;a href=&quot;http://en.wikipedia.org/wiki/JavaServer_Faces&quot;&gt; JSF&lt;/a&gt;, among others.&lt;/p&gt;

&lt;p&gt;At some point of the discussion, an idea came up, it was about time computing industry actually get industrialized for good, letting a few companies to decide the destiny and future of the technology, cutting the freedom of developing new ways of doing things but allowing standards to settle and grow.&lt;/p&gt;

&lt;p&gt;Java’s universe has been expanding since a long time now, and now it seems like that universe is converging again.&lt;/p&gt;

&lt;p&gt;Today for example, JSF is a technology used by thousands of companies around the world, is relatively mature, and has many other projects attached to it that also evolves really fast, such as&lt;a href=&quot;http://primefaces.org/&quot;&gt; PrimeFaces&lt;/a&gt; or&lt;a href=&quot;http://richfaces.jboss.org/&quot;&gt; RichFaces&lt;/a&gt;. But who can guarantee the future of JSF in the future?&lt;/p&gt;

&lt;p&gt;And when I say future, I only talk about 3-5 years. Java has already released a&lt;a href=&quot;https://jcp.org/en/jsr/detail?id=371&quot;&gt; spec&lt;/a&gt; to eventually adopt MVC as a standard pattern. Someone may think this move would make JSF to eventually die in the mid-future.
In Java, there are several companies that vote each spec of the language, companies like Hewlett-Packard, IBM, RedHat or Oracle. In this case, my friend was convinced that the way to go should be to ‘shutdown’ technologies like Spring or Hibernate, and let those companies to decide the future of java. In this case, it would assure the ‘industrialization’ of the technology since we will always know at any given time what the present and future of the technology is.&lt;/p&gt;

&lt;p&gt;In the other hand, at least in the java world, is a fact that technologies like Hibernate or Spring have been moving faster and better than java itself, creating better projects and products, that later java has been taking into account and adopted.&lt;/p&gt;

&lt;p&gt;Also .Net core has been released as open source last November ‘14, so even in Redmond’s company values the opportunity given by the fact that a whole community can operate and expand .Net universe and allow others to develop new ideas.&lt;/p&gt;

&lt;p&gt;In my opinion, I think Java won’t quit this idea anytime soon, and projects will continue growing and/or dying, and from that evolution java will improved in following releases, and so will .Net. But the task of deciding which technologies to use in projects that need a certain evolution in time is becoming more and more difficult if this expansion never ends.&lt;/p&gt;
</description>
        <pubDate>Tue, 12 May 2015 09:25:41 +0000</pubDate>
        <link>http://sergiolealdev.com/blog/computing/industrialization/2015/05/12/computing-industrialization.html</link>
        <guid isPermaLink="true">http://sergiolealdev.com/blog/computing/industrialization/2015/05/12/computing-industrialization.html</guid>
        
        
        <category>computing</category>
        
        <category>industrialization</category>
        
      </item>
    
      <item>
        <title>Static Resources Handling in Spring 4.1</title>
        <description>&lt;p&gt;Not long time ago I faced the need of handling static resources with Spring, and I came up with this &lt;a href=&quot;http://www.infoq.com/presentations/resource-spring-mvc-4-1&quot;&gt;presentation&lt;/a&gt; from Spring Framework committers &lt;a href=&quot;https://twitter.com/brianclozel&quot;&gt;Brian Clozel&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/rstoya05&quot;&gt;Rossen Stoyanchev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the video Brian and Rossen explain how they have developed a new way of handling this type of files and propose from version 4.1 of Spring a very easy and simple way of implement this idea.&lt;/p&gt;

&lt;p&gt;In the presentation they explain how they used this in a project called &lt;a href=&quot;https://github.com/spring-io/sagan&quot;&gt;Sagan&lt;/a&gt;, which it turns out to be the new Spring’s home page.&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;Also in this presentation they try to explain how to use this new feature by referring to a much more &lt;a href=&quot;https://github.com/bclozel/spring-resource-handling&quot;&gt;simple project&lt;/a&gt;, based in two parts, a client part, where they handle all the js,css and other static resources, and a server side, where they implement Spring’s part.&lt;/p&gt;

&lt;p&gt;I wanted to go one more step in terms of simplifying this demonstration and I’ve created a little &lt;a href=&quot;https://github.com/sergiolealdev/SpringStaticResourceHandling&quot;&gt;boilerplate project&lt;/a&gt; with Spring MVC, Spring Boot and a jsp that uses bootstrap and jquery, and in the Spring’s side I use this new implementation to handle my static resources.&lt;/p&gt;

&lt;p&gt;There are basically two main parts that we have to take into account in the project.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;In the jsp presentation, I handle my resources by using a jstl core tag, for Spring to notice and be aware of them.&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;lt;c:url value=&quot;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;resources&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;bootstrap&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&quot; rel=&quot;stylesheet&quot;&amp;gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;script &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;src=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;lt;c:url value=&quot;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;resources&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;jquery-2&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;In the server side, when we configure our files, we extend the &lt;a href=&quot;http://docs.spring.io/autorepo/docs/spring/3.2.3.RELEASE/javadoc-api/org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.html&quot;&gt;WebMvcConfigurerAdapter&lt;/a&gt; and we override the addResourceHandlers method to basically tell Spring where to find our resources, how much time we want the resources to be cached in the client and which type of resolvers and transformers we may want to use.&lt;/li&gt;
&lt;/ol&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;addResourceHandlers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ResourceHandlerRegistry&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;registry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;registry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addResourceHandler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/resources/**&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addResourceLocations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/resources/&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setCachePeriod&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;resourceChain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addResolver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;VersionResourceResolver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As of version 4.1.6 of Spring, several things have changed and I have noticed that even classes that I have used in version 4.1.1 don’t exist anymore in the current version, so I have the feeling maybe more things will change in the future about this, but there are many great features in this new part of Spring, having even the possibility of versioning our resources (maybe in another post) and control when and how we want our clients to refresh their versions of our resources.&lt;/p&gt;

&lt;p&gt;Again, I encourage you to watch Brian &amp;amp; Rossen’s presentation, where they explain this concept much better than I do.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png&quot; alt=&quot;github_24px&quot; width=&quot;24&quot; height=&quot;24&quot; /&gt;&lt;a href=&quot;https://github.com/sergiolealdev/SpringStaticResourceHandling&quot; target=&quot;_blank&quot;&gt;Watch / Download this demo in Github&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 25 Apr 2015 00:00:00 +0000</pubDate>
        <link>http://sergiolealdev.com/blog/2015/04/25/spring-handling-static-resources.html</link>
        <guid isPermaLink="true">http://sergiolealdev.com/blog/2015/04/25/spring-handling-static-resources.html</guid>
        
        
      </item>
    
      <item>
        <title>What do we have in Java 8 (Part 1)</title>
        <description>&lt;p dir=&quot;ltr&quot;&gt;&lt;strong&gt;Stream API&lt;/strong&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;A Stream in the new Java 8 is a typed interface, where we can use a Stream of T elements, being T an integer, a String, an Employer object, etc.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;With Stream we can handle data the same way we would work in a &lt;a href=&quot;http://en.wikipedia.org/wiki/Big_data&quot;&gt;Big Data&lt;/a&gt; environment, applying map-filter-reduce operations, for example.&lt;!--more--&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;But aware you must! a Stream may look like a &lt;a href=&quot;http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html&quot;&gt;Collection&lt;/a&gt; at first sight, but it is NOT a collection. I repeat. It is &lt;b&gt;not &lt;/b&gt;a collection. Collections and Streams work in a total different way. In fact, a Stream object does not store any info, unlike a Collection.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;employees&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Arrays&lt;/span&gt;
                &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;asList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;John \&quot;Hannibal\&quot; Smith &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
                         &lt;span class=&quot;s&quot;&gt;&quot;Templeton Peck&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
                         &lt;span class=&quot;s&quot;&gt;&quot; H.M. \&quot;Howling Mad\&quot; Murdock&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
                         &lt;span class=&quot;s&quot;&gt;&quot;\&quot;Bad Attitude\&quot;, Baracus &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;);&lt;/span&gt; 

&lt;span class=&quot;c1&quot;&gt;//We want all items that start with T &lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;employees&lt;/span&gt; 
   &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; 
   &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;T&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; 
   &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt; 

&lt;span class=&quot;c1&quot;&gt;//But at the end, the employees list remains intact &lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;employees&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt; 
If we execute this code, we would get the following console output.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;Templeton&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Peck&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p dir=&quot;ltr&quot;&gt;One of the most interesting features of this Stream interface is the fact that it will work in parallel, meaning, will use all processors we may have in our machine, avoiding the programmer to handle this work for him, in a total transparent way.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;&lt;b&gt;Filtering&lt;/b&gt;&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;What we have done in the last piece of code was a nice filter. Filtering data with Streams is fairly simple. In the following example, we want to get all the employees that contains the word 'Attitude'&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;Stream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;streamEmployees&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;listEmployees&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Stream&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;employeesFiltered&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;streamEmployees&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Attitude&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;employeesFiltered&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p dir=&quot;ltr&quot;&gt;In this case we would get what we were searching for:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;s&quot;&gt;&quot;Bad Attitude&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Baracus&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p dir=&quot;ltr&quot;&gt;There is something &lt;b&gt;very important to remember&lt;/b&gt; when we work with Streams. Once we have used a Stream, it cannot be reused, or we will have a nice exception in our console. Hence, if we try to apply the forEach method again:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;employeesFiltered&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p dir=&quot;ltr&quot;&gt;We will get this message in our console:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;thread&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;main&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;IllegalStateException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;has&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;already&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;been&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;operated&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upon&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closed&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;util&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;AbstractPipeline&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AbstractPipeline&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;229&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;util&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ReferencePipeline&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ReferencePipeline&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;418&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sergiolealdev&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java8&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;streams&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p dir=&quot;ltr&quot;&gt;This is it for the first part of the new features in Java8. New posts arriving soon!!&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;&lt;img src=&quot;http://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png&quot; alt=&quot;github_24px&quot; width=&quot;24&quot; height=&quot;24&quot; /&gt;&amp;lt;/a&amp;gt; &lt;a href=&quot;https://github.com/sergiolealdev/SampleStreamAPIJava8&quot; target=&quot;_blank&quot;&gt;Watch/Download this code in Github&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 01 Feb 2015 09:25:41 +0000</pubDate>
        <link>http://sergiolealdev.com/blog/java/java8/2015/02/01/what-is-new-java8.html</link>
        <guid isPermaLink="true">http://sergiolealdev.com/blog/java/java8/2015/02/01/what-is-new-java8.html</guid>
        
        
        <category>java</category>
        
        <category>java8</category>
        
      </item>
    
  </channel>
</rss>
