PropertyEditor is an interface that provides a support for the conversion of the value of a property (usually of type String) in an object that can be Date, URL, etc. Continue reading “PropertyEditors in Spring 3”
The equals() method is inherited from the superclass Object and determines if two instances are equal or equivalent.
Usually this method should be overridden because the equals() method of the Object class is equivalent to the operator ==, which returns true if and only if the two references refer to the same object. Continue reading “Overriding the equals() and hashCode() methods”
There are 3 ways to execute code to create a bean in Spring:
- with the annotation @PostConstruct
- implementing the interface InitializingBean
- configuring the property init-method
The reason why you run code when you create a bean is often to check the dependencies, and assign a default value, or automated actions such as starting a scheduled task.
The constructor of the bean may not be suitable for this purpose because the bean is not fully initialized until the constructor has not completed. Continue reading “Executing code on the creation or destruction of a bean in Spring”
In the previous post about the Comparable interface I explained how you can extend a class of objects that implement the Comparable interface and then order them in a list according to the logic defined in the overridden method compareTo.
If you want to be able to sort the list according to a number of different criteria you must use the Comparator interface, for example, in the case of a list of countries, it is possible that you want to order them not only alphabetically but also in order of area or population. Continue reading “The Comparator interface”
In this post I explain how to implement Spring Security in a web application, as I did in a previous post but the authenticated user’s username and password are not saved to a file .xml but in a MySQL database.
As in the previous post, I configure one user only trying to access index.html and he is redirected to the standard login page for authentication.
In this project I configure log4j and maven too. Continue reading “Basic configuration of Spring Security 3 and MySQL”
In this post I write about a basic configuration of Spring Security 3, the Spring framework for authentication and authorization of the users.
In this example there is only one user trying to access to index.html and he is redirected to the standard login page for authentication.
In this project I use and configure maven and log4j too. Continue reading “Basic configuration of Spring Security 3”
You can’t access to the members of an outer class from an inner class using the keyword “this”.
In fact, the keyword “this” in an inner class is a reference to the inner class itself.
To have a reference to the outer class, you must use the syntax:
where [OuterClassName] is the name of the outer class. Continue reading “How to access to the members of outer class from inner class”
In this article I explain how to set the visibility of methods and instance variables, ie those variables declared outside of any method (the variables declared within a method are called local variables and they are visible in the method only). Continue reading “The access modifiers of methods and variables of a java class”
The modifiers of a Java class are: