Posts

Showing posts from October, 2013

Building Webservices using Spring

In this post, I'm going to explain how to write a contract first webservice using Spring. We are going to create a service for creating a person record. We are going to call the service as 'CreatePersonService'. It will accept first name, middle name and last name as parameters and return a id parameter back as a response. We need to first define the XSD representing the person record. Also, we need an XSD to represent the request to create the Person record.  Let us first start with the maven dependencies required: pom.xml: We will be using jaxb for generating classes from xsd. <dependency> <groupId>org.springframework.ws</groupId> <artifactId>spring-ws-core</artifactId> <version>2.1.3.RELEASE</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.dom4j</groupId> <artifactId>dom4j</artif

Popups using Javascript and CSS

Image
In this post, I'm writing about an interesting way of displaying popups using javascript and css. These popups do not show up in a new window, but rather in the same page as a different box. You might have seen these kind of popups while logging in or during display of your profile details in various social networking sites or email websites like gmail. The idea here is to use css and div to display a box which embeds a separate html form of its own. Lets first create a the form elements for login: <div id="popupbox"> <form name="login" action="" method="post"> <div id="centertag">Username:</div> <div id="centertag"><input name="username" size="14" /></div> <div id="centertag">Password:</div> <div id="centertag"><input name="password" type="password" size="14" /></div> <

Site Map

All Posts by Category: 1. Patterns: Proxy Pattern 2. Spring Framework: Spring AOP:                 Spring AOP Part-I                 Spring AOP Part-II                 Spring AOP Part-III Spring Autowiring Spring MVC               Spring MVC Part-I               Spring MVC part-II Spring Webflow:               Spring Webflow Part-I               Spring Webflow Part-II               Spring Webflow Part-III               Spring Webflow Part-IV Spring Restful Services Spring Webservices:               Building Webservices Using Spring 3. Architecture Restful Services           Restful Architecture         4. Hibernate   Hibernate tutorial Series:                      Hibernate tutorial Part I                     Hibernate tutorial Part II

Spring Beans Autowiring

In this post I'm going to write about Autowiring feature in Spring. Overview: Generally, in Spring, you will define the beans and inject other beans into their properties by configuring them in xml. For eg, if we have a DAO, UserDAO and a service class UserService, which has a property reference for the DAO, then, the bean configuration would look like this: <bean id="userDAO" class="com.myorg.service.dao.UserDAO"> </bean> <bean id="userSvc" class="com.myorg.service.UserService"> <propertyname="userDAO" ref="userDAO"/> </bean> Spring provides a feature called Autowiring, wherein the decision to wire the bean properties could be left to the Spring framework and this saves us a lot of configuration hassle. There are four types of autowiring: byName byType constructor autodetect 1. Autowiring - byName: In this type of wiring, Spring attempts to find the beans which ha

Spring AOP - Part III

For part I, refer to: Spring AOP - Part I For part II, refer to: Spring AOP - Part II Continuing further on AOP examples, in this post, we will see how can we pass arguments to the Aspect classes. Passing parameters to Aspect classes: In this example, we will write a very basic auditing service, which will store audit details of who accessed a particular service. The audit details could be stored in database. But that part is not shown here to keep the details simple. Let us say we have an Account service, which offers CRUD on the account. The username parameter which is the first parameter for all the methods, indicates the user who will perform a CRUD on the account. public interface AccountService { public long createAccount(String username, Account account); public void updateAccount(String username, Account account); public void deleteAccount(String username, Account account); } Define a corresponding AccountServiceImpl which will actually perform t