If you are using XML configuration in your Spring application, you should know about gorgeous feature, that spring has: bean inheritance. What does this mean ? This mean, that you can create an abstract bean with some predefined properties, and later, you will be able to make an inheritance from this bean.
Here is an example
Here you have DefaultDao implementation, which has three fields - persistenceManager, which is the same in every Dao class, queryBuilder for building dynamic queries, which are dynamic field, and entityClass, which is the name of Class, that will be mapped to result from database.
And here we have xml context, that we use without bean inheritance.
After some modification and refactoring we will receive
As you can see, we reduce number of lines in context and now we are instantiating persistenceManager from one place and if we will want to change it, we will do that very quickly.
Recently I experienced a problem, when I had CharacterEncodingFilter filter in my web.xml, but no encoding were done at all. I started to investigate this problem and find out, that few weeks ago I added additional filters on top of my web.xml, and , as a result, my CharacterEncodingFilter was placed on second or third position.Good news for me, I added integration test with ukrainian words, and my web service returned some incorrect characters.
After few minutes, I discovered, that If you want to have correct unicode data, then you need to place encoding filter at the top of all your filters. Thereafter, your filter will the first chain and you will be sure, that all other filters will work with correct unicode.
Nowadays, it’s very popular to have applications, that can somehow notificate people.We’re gonna use emails to send text and html mails to someone.Whar requirements do we need? Possibility to send simple text emails Posibility to send html emails. Of course, to send emails, we need to have some template engine. We will use handlebars for that. We will use Spring. Maven as build tool Java Mail package Handlebars template engine Greenmail for “mocking” email server. Structure We need to have four subpackages, exception package for having custom exceptions, model package for storing our model, sender package for main functionality and template package for storing template service. Your pom.xml should have similar structure So, let’s create Exception package Model package We created all required models and resources for further developing, so let’s start adding core functionality Template package Have ever you ever think about sending emails with html content ? Imagine, your application sends email with some pretty organized html page. Sound great. To do such things, of course, you need to have template engine. I prefer Handlebards template engine. [gist id=”60fd72b167cb6243c74f”] if you have template in your resources/templates folder with name template1.html, then you should call handlebars.compile(“template1”); in your code....
Hi all! Today I started to use ghost blogging platform.One I can say for sure - It’s much more faster than wordpress or other cms. In this article I will try to explain how to setup your application with some custom theme. What Will we need for that ? Digital Ocean instance. I use Linux for all maintenance, so, if u are windows - related -> Sorry :) Ghost Blogging platform Custom theme, that you want to setup. I was lucky to buy this theme - Pepe - Multipurpose Responsive Theme Let’s start Firstly, create instance on Digital Ocean - I noticed, that ghost is much more faster, than Wordpress, so it should be enough to buy 5$ instance for first time. Type your instance name, desired size. I recommend access by ssh, which is very powerful way for serving all your instances. If you don’t have any ssh key yet - follow this instruction on how to create one. Once you are ready, attach your public key to digitalocean profile and select it when you will create instance. You can read this article for better understanding. It should take some time to create instance. Once it ended, go to...