Posts

Showing posts with the label Spring

Spring 3 Part 9: Spring Security LDAP integration

The expectation of this blog is to enable developer to start LDAP integration quickly and easily with Spring Security. I have used ApacheDS which is embedded in the Apache Studio. Here the steps: The DN dc=example,dc=com is a example domain controller you can easily follow the documentation. Here the ldif document #[1] create domain (distinguished name) dn: dc=example,dc=com objectclass: top objectclass: domain dc: example #[ 2 ] create people organizational unit dn: ou=people,dc=example,dc=com objectClass: organizationalUnit objectClass: top ou: people #[ 3 ] create a user dn: uid=ojitha,ou=people,dc=example,dc=com objectClass: organizationalPerson objectClass: person objectClass: inetOrgPerson objectClass: top cn: Ojitha Hewa sn: Hewa uid: ojitha #[ 4 ] create group dn: ou=groups,dc=example,dc=com ...

Spring 3 Part 10: Java Web development with AngularJS

Angular Basics AngularJS is MVC based fronted framework. To make the things easier, I’ve use Atom editor with the the atom-html-preview plugin (Ctrl+Shift+H). Anytime you can invoke developer tools pressing by Alt+Command+i. Using MVC Here the most basic Angular+Bootstrap mvc example. In this example, there are three users listed in the ex1 and controller is FriendController which is used as friendList in the HTML. < html > < head > < script src = "https://code.jquery.com/jquery-1.12.0.min.js" > </ script > < script src = "https://code.jquery.com/jquery-migrate-1.2.1.min.js" > </ script > < link rel = "stylesheet" href = "bootstrap-3.3.6-dist/css/bootstrap.css" /> < script type = "text/javascript" src = "angular-1.5.3/angular.js" > </ script > < script type = "text/javascript" src = "bootstrap-3.3.6-dist/js/bootstrap.js...

RAD 2– Spring for Vaadin without Spring Boot

Image
In my previous blog RAD 1 – Spring for Vaadin , I have introduced the recommended way of integrating Spring and Vaadin. In this blog, I am going to use the alternative way which is without Spring Boot explained in the article“ Getting started with Vaadin Spring without Spring Boot ”.  This is the hardest way. I’ve configured this in the Intellij Idea 14. Create a maven archetype as explained in the Creating a Project with Intellij Idea :2.8.3 Create Maven Project. Create a new folder WEB-INF under the webapp folder. Create a applicationContext.xml under the WEB-INF folder. Now you have to add the Spring Facet to the project. You have to add the Spring Context created in the step 3. However, I first add the Spring module. My applicationContext.xml is as follows <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...

JPA Part 4: Attribute Overrides

Image
This is a continuation of Part 1 . Fore eample This is a very quick blog on @AttributeOverrides. I refactored the Part 1 of this series to add the Address to Department and moved the Contact embeddable attribute to the Person which is a @MappedSuperclass. Now the class relationships are changed as follows. Fig 1: HR Domain Model As shown in the above figure 1, It is a challenge to sharing the same Address class among the Asset and Employee (extended from Person) entities because Asset use the TOWN field instead of the SUBURB. It is possible for example, package au . com . ojitha . blogspot . jpaex1 . domain ; import javax . persistence . AttributeOverride ; import javax . persistence . AttributeOverrides ; import javax . persistence . Column ; import javax . persistence . Embedded ; import javax . persistence . Entity ; import javax . persistence . GeneratedValue ; import javax . persistence . Id ; import javax . persistence . OneToOne ; imp...

Spring 3 Part 8: Spring Hibernate open session in view

Image
This is the 8th part of the Spring 3 Series . In this blog I am going to use Hibernate 3.5.2 to explain the use of Spring Transaction which fulfil the requirements of open session in view pattern. First understand some important concepts in Hibernate. First of all, it is very important to understand the object states in the Hibernate. Transient object will become a persistent object in the context of active session. This persistent object represent one row of the data table. There can be two transient object references which are not refer to the same object but can hold same data. These objects are identical only in the persistence context (persistent objects are identical) because persistence objects are identified based on the database primary key. Therefore, persistence object identifier is the same as data table identifier.  For the transient and detached object, equal() and hashcode() are the methods to be implemented to define the identifier. Figur...