View RSS Feed

Spring 3

Spring 3

  1. Building your first Spring 3 MVC application using Eclipse

    by , 12-10-2011 at 06:51 AM
    Spring is one of the most popular application frameworks for Java development. The framework comes with various projects like Spring Core, Spring Data, Spring Web Services, Spring MVCÖEach project suits for a particular area, and for the area of web development, Spring MVC is very well-known.
    Spring MVC makes web development easier by separating the three components: Model, View, and Controller.

    • The model represents the principal data that is managed by the application.
    ...
    Tags: eclipse, mvc, spring 3 Add / Edit Tags
    Categories
    MVC , Spring 3 , Eclipse
  2. Using Spring Web Flow Part 2

    by , 11-30-2011 at 05:00 AM
    In the previous article, we looked at the components of Spring Web Flow. In this article, I will tie all the pieces together for the application.

    As you know, Spring Web Flow provides a powerful controller to control the user navigation in case your application requires it. Below is the definition of a simple flow to carry out a booking process is shown graphically below:

    Why Spring Web Flow
    We know that defining and understanding page flow of a complex web application ...

    Updated 12-05-2011 at 01:45 PM by Spring Framework

    Categories
    MVC , Spring 3 , Web Flow , Spring Flow , Webflow
  3. Using Spring Web Flow Part 1

    by , 11-30-2011 at 04:52 AM
    In a previous article, I gave an introduction to Spring Web Flow. In this article, I will delve into the details of how to use Spring Web Flow.

    In Spring Web Flow, a flow is defined by three primary elements: states, transitions, and flow data. States are points in a flow where something happens. Consider if you want to plan a short holiday in Florence. You need to first choose your flights, then you choose your hotel, you might also choose a car, etc. Similarly, as a flow progresses, ...
  4. Viewing Options in Spring

    by , 11-30-2011 at 04:38 AM
    In your application, once the service have handled the request and returned the results desired, you will need to render the results in a useful manner to the user. This is the purpose of viewing technology such as JavaServer Pages (JSP). Although you can use JSPs in Spring there are a number of other viewing technologies that Spring support. In this tip, I will outline some of the other view technologies that are available.

    When Spring is looking to render some content, the DispatcherServlet ...
  5. How to Handle Input with Spring MVC

    by , 11-29-2011 at 02:57 AM
    Spring MVC is structured to handle state management, workflow and validation. It is an application of the Model-View-Controller pattern. As with all things Spring, it follows the principles of loose coupling and flexibility. When a request is made, it reaches the DispatcherServlet whose role is to forward the request to the relevant Spring MVC controller, it is the controller that processes the request. In this article we will look in depth in what a Spring Controller does when it processes input. ...
  6. How to Inject AspectJ Aspects into Spring

    by , 11-29-2011 at 02:53 AM
    For those of you who have already worked with Spring AOP knows that it is sufficient for many of the applications of aspects that are generally done in a system. Still it is weak in certain areas of AOP solution in contrast to AspectJ that has added a number of powerful features over time. There are now many types of AspectJ pointcuts that arenít possible with Spring AOP.

    For example, Springís proxy-based AOP is not able to advise on object creation. This is because constructors in ...
    Categories
    AOP , Spring 3
  7. Introduction to Spring Web Flow

    by , 11-29-2011 at 02:49 AM
    When you are developing an user interaction for an application, one of the most challenging aspects is to define a proper narrative for the behavior of the application so that the user can get into a flow while using the application. Sometimes it is necessary to step a user through a process, such as ordering a plane ticket. This is called a flowed application. Now is a possible to use any web framework, such as Struts or Java Server Faces, in order to do this. Unfortunately none of them properly ...
  8. Data Access with Java Persistence API

    by , 11-29-2011 at 02:44 AM
    Spring integration with Java Persistence API (JPA) came about on the release of Spring 2.0. It is very easy to use JPA with Spring because it is all based on plain old java beans (POJOs). In this tip, we will outline the steps required for you to use JPA with Spring.

    JPA-based applications are based on the implementation of EntityManagerFactory in order to get an instance of an EntityManager. There are two kinds of entity managers from the JPA Specification that both implement the ...

    Updated 11-30-2011 at 03:23 AM by Spring Framework

    Categories
    EntityManager , EntityManagerFactory , JPA , Spring 3
  9. Factors Influencing Media Type Selection in Spring

    by , 11-28-2011 at 01:17 AM
    In my previous tips, we looked at the components Spring uses to determine the appropriate media type for the results returned. We know that the ContentNegotiatingViewResolver is used to determine what the appropriate media type is for the results. I will discuss the second part of the strategy used for making this determination. This involves factors that influence the requested media type(s).

    After the ContentNegotiatingViewResolver has determined the requested media type, there ...

    Updated 11-30-2011 at 01:51 PM by Spring Framework

    Categories
    MVC , REST , Spring 3 , Resource
  10. Determining the Requested Media Type in Spring MVC

    by , 11-28-2011 at 01:12 AM
    In my previous tips, we looked at the components Spring uses to determine the appropriate media type for the results returned. We know that the ContentNegotiatingViewResolver is used to determine what the appropriate media type is for the results. I will discuss the first part of the strategy used for making this determination. This involves determining the requested media type(s).

    When the controllerís handler method finishes, and a logical view name is usually returned. The DispatcherServlet ...

    Updated 11-30-2011 at 01:44 PM by Spring Framework

    Categories
    View Helper , MVC , REST , Spring 3 , Resource
  11. RESTful Controllers in Spring

    by , 11-28-2011 at 12:47 AM
    In my previous tip, I presented to you an overview of how to handle RESTful URLs. In this tip, I will followup will look at RESTful Controllers. From my previous posts, I believe you have surmised that Spring MVCís model is a very flexible framework for for writing controller classes. Almost any method with almost any signature can be annotated to handle a web request. Although this is nice for writing RESTless controllers, it is not ideal for writing RESTful controllers. The reason is that controllers ...
    Categories
    MVC , Controller , REST , Spring 3
  12. REST Services in Spring

    by , 11-28-2011 at 12:28 AM
    In Spring 3.0, the Spring team added support for Representational State Transfer (REST). It has emerged as a popular information-centric alternative to traditional SOAP-based web services. Spring developers have taken advantage of the REST architectural model to pack the Spring MVC with first-class support for working with REST. In this tip, we will look at the fundamentals of REST.

    In order to understand what REST is all about, it helps to break down the acronym into its constituent ...
    Categories
    Web Service , REST , Spring 3
  13. How to Export JAX-WS EndPoints in Spring

    by , 11-28-2011 at 12:22 AM
    In my previous tip, I showed you how to autowire a JAX-WS endpoint. Although this is very useful, but recognize that the objects whose properties are being injected doesnít have its lifecycle managed by Spring. There are circumstances though, where itís possible to export a Spring-managed bean as a JAX-WS endpoint. In this tip, I will show you how.

    Springís SimpleJaxWsServiceExporter works by publishing Spring-managed beans as service endpoints in a JAX-WS runtime. SimpleJaxWsServiceExporter ...

    Updated 11-30-2011 at 01:35 PM by Spring Framework

    Categories
    Web , Web Service , Spring 3
  14. Intro to Web Services with Spring

    by , 11-27-2011 at 11:02 PM
    One of the most important changes in IT in the last 10 years has been the advent of Service Oriented Architecture (SOA). At the core SOA is the idea of building system via a common set of core services rather than the traditional monolithic method. Java and web services have been intimately intwined. There are a number of options are available for working with web services in Java. Spring facilitates the integration of many of these options. In fact, Spring provides support for publishing and consuming ...

    Updated 11-30-2011 at 01:35 PM by Spring Framework

    Categories
    Spring 3 , Web , Web Service
  15. Request Interception with Spring Security

    by , 11-27-2011 at 10:54 PM
    This is the last of a series of tips on Spring Security. From my previous tips, you should be able to configure Spring Security as well as setup login and logout. In the last tip, I will show you how to intercept requests. The <intercept-url> element is the key in the request-level security. Its pattern attribute is provide with a URL pattern that will be matched against incoming requests. If any requests match the pattern, then the <intercept-url>ís security rules will be applied. So ...
  16. Logging Out with Spring Security

    by , 11-27-2011 at 10:52 PM
    In my previous tips, I showed you how to configure and setup Spring Security as well as the login form autogenerated when auto-config is set to true. In this tip, I will show you how to setup the logout for your application. Basically the <logout> element will setup a Spring Security filter that will invalidate a user session. If it is used as is, the filter set up by <logout> is mapped to /j_spring_security_ logout. In order to ensure that there is no collision with the DispatcherServlet, ...
    Categories
    Security , Web , Spring 3
  17. Login Forms with Spring Security

    by , 11-27-2011 at 10:51 PM
    In my previous tips I showed how to add in the necessary servlet filters in your Spring application file and then to configure minimal security in your Spring application. In this tip, we will look at setting up a form for logging into an application.

    As I mention in the last tip, by setting auto-config to true, the autoconfiguration give our a free login page, support for HTTP Basic authentication and logging out, and Spring Security will automatically generate a login page page. ...
    Categories
    Security , Web , Spring 3
  18. Configuring Web Security in Spring

    by , 11-27-2011 at 10:49 PM
    In a previous tip, I showed how to add in the necessary servlet filters in your Spring application file. We added both the Delegating FilterProxy along with the another filter, FilterChainProxy. In general, Spring security will automatically create these beans for you when you configure the <http> element.

    Java Code:
    <http> 
        <form-login />
        <http-basic />
        <logout /> 
        <intercept-url pattern="/**" access="ROLE_USER"
    ...
  19. Setting up Secure Web Requests in Spring

    by , 11-27-2011 at 10:48 PM
    Continuing our investigation of Spring Security, in this tip I will look at making secure web requests. All activities that starts in a java web application is initiated via an HttpServletRequests. As such, this is where the security of your application will start. This security takes the form of request-level security. This involves declaring one or more URL patterns as requiring some level of granted authority and restricting access to those without authority from accessing the content of those ...
  20. Configuring Spring Security

    by , 11-27-2011 at 10:45 PM
    In the last tip, I introduced Spring Security and outlined the modules that are available. In this tip, we will look at configuring namespaces. Using Spring, the nice thing about Spring Security is that all the security elements are configured as beans in the application context. It is not uncommon to have a Acegi configuration containing dozens of bean declarations that span multiple pages.

    Another nice feature is that Spring Security has its own security-specific namespace to simplify ...
  21. Intro to Spring Security

    by , 11-27-2011 at 10:44 PM
    Spring Security is a security framework that started out as Acegi Security and then became an official part of Spring in version 2.0. It provides declarative security for all Spring-based applications. Spring Security handles all aspects of security from authentication to authorization at both the web request level and at the method invocation level. Like many Spring Framework modules, it takes full advantage of dependency injection (DI) and aspect-oriented techniques.

    Irrespective ...
    Categories
    Security , Spring 3
  22. Using Tiles in Spring MVC

    by , 11-27-2011 at 10:39 PM
    In earlier tips, I talked about using Spring MVC and the use of different view technologies. In this tip, I will look at Tiles as a view technology for Spring MVC. Tiles was initially built to be used with the Struts Framework. But as it is a powerful view technology it has been reused by other web frameworks. To use Tiles with Spring MVC you need to register the Tilesí view resolver as a bean with the applicationís xml file, springexamples.xml.

    Java Code:
    <bean class= "org.springframework.web.servlet.view.tiles2.TilesViewResolver"/>
    ...
    Tags: spring mvc, tiles Add / Edit Tags
    Categories
    MVC , Tiles , Spring 3
  23. Configuring Transactions in XML with Spring

    by , 11-27-2011 at 10:33 PM
    Continuing from my previous post, I will demonstrate how you can declare transactions in XML using Spring. Continuing from the previous tips on transaction attributes, letís dive straight in. Spring has a tx configuration namespace to simply declaring transactions in Spring. It is recommended that you include the aop namespace as well since some of the declarative transaction configuration elements use AOP configuration elements. The following shows how <tx:advice> is used for the Car service. ...

    Updated 11-27-2011 at 10:36 PM by Spring Framework

    Categories
    Configuration , Transaction , XML , Spring 3
    Attached Thumbnails Attached Images  
  24. Transaction Propagation Strategies in Spring

    by , 11-27-2011 at 10:29 PM
    In the previous tip, we looked at the key properties that are required for handling any transaction. In Spring, when you want to have your application are using. Spring transaction concepts are taken from the JEE specification specifically the EJB 3.0 specification. Another key aspect of managing transactions is the ability to control the propagation of transactions in your application. Spring has the org.springframework.transaction.TransactionStatus interface that allows an application to check ...
  25. Define a Controller in Spring MVC

    by , 11-27-2011 at 10:17 PM
    When you work with Spring MVC, after configuring the Dispatcher Servlet in order to build an application you need to do the following:
    Define controllers that invoke business logic and create a ModelAndView object.
    Visualization component like JSP, Velocity or FreeMarker.
    Annotation configuration or XML to wire the components together

    The first thing that you will most likely do is to define a home page controller. Spring provides a number of controllers to use ...
    Categories
    MVC , Controller , Spring 3
  26. Configuring a Hibernate SessionFactory in Spring

    by , 11-27-2011 at 10:11 PM
    In an earlier post, I showed you how to integrate Hibernate with Spring using the annotation oriented persistence. For those still interested in the standard way I outline how you can accomplish that below. The key to the standard way is to use a Hibernate org.hibernate.SessionFactory for all access to the database through the domain objects. The Java configuration for the SessionFactory is shown below.

    Java Code:
    package com.acme.springexamples.car.dao.config;
    import org.springframework.beans.factory.annotation.Value;
    ...
    Tags: hibernate Add / Edit Tags
    Categories
    Hibernate , Configuration , Spring 3
  27. Spring MVC Basics

    by , 11-27-2011 at 10:03 PM
    Spring MVCís key component is the DispatcherServlet. This servlet that functions as Spring MVCís front controller. Like any servlet, DispatcherServlet must be configured in the web applicationís web.xml file. If you need to setup the Dispatcher Servlet it is relatively straightforward. Below is what needs to be added to the web.xml file.

    Java Code:
    <servlet> 
         <servlet-name>springexamples</servlet-name> 
           <servlet-class>org.springframework.web.servlet.DispatcherServlet
    ...
    Tags: spring mvc Add / Edit Tags
    Categories
    MVC , Spring 3
  28. Configuring a Spring Data Source Continued

    by , 11-27-2011 at 10:02 PM
    There are a number of DataSource connection pool implementations provided by different vendors as well as projects like C3PO and Apache Commons DBCP providing popular open-source options. It is easy to switch between different data source implementations, because of the common DataSource interface. Spring provides a convenient data source implementations as well but it is not considered as powerful as the vendor or open source implementations. The simplest one is org.springframework.jdbc.datasource.DriverManagerD ataSource, ...
  29. Writing A Namespace Handler in Spring

    by , 11-27-2011 at 09:58 PM
    Custom XML namespaces were introduced in Spring 2.0. Similar to Java packages, custom namespaces make it possible to define components without concern of colliding with other named components. Spring has already some predefined namespaces such as jee, aop, util, as well as others. Custom namespaces are handled using the NamespaceHandlerSupport class that generates metadata to be consumed by the Spring framework. This metadata is processed by parser classes that are also supplied by a component developer. ...
  30. Introducing Behaviors to Your Spring Beans

    by , 11-27-2011 at 09:55 PM
    In Spring AOP, you can use what is called an introduction (a special type of advice) that enables your objects to implement an interface dynamically, by providing the implementation class for that interface. This behavior can be multiplied to give the impression of multiple inheritance to your beans. To define an introduction, use the @DeclareParents annotation, which gives matching types a new parent.

    Java Code:
    package com.acme.springexamples.derivautos;
    import org.aspectj.lang.annotation.Aspect;
    ...
    Categories
    Bean , Spring 3
Page 1 of 2 12 LastLast