View RSS Feed

Spring Framework

SpringSource Spring Framework tutorials and examples. Focusing on Spring 3 and above.

  1. 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
  2. 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, ...
  3. 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 ...
  4. 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. ...
  5. 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
  6. 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 ...
  7. 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
    JPA , Spring 3 , EntityManager , EntityManagerFactory
  8. Finding the Appropriate View in Spring

    by , 11-28-2011 at 01:19 AM
    In my previous tips we have gone through calling the appropriate RESTful methods, returning the results, and the initial parts of the determining the view involving determining the appropriate media type and looked at factors that could influence that decision. In the last tip on RESTful services I will show how the appropriate view is selected.

    Given that our previous post focused on the ContentNegotiatingViewResolver, one would expect that this view resolver directly resolves the ...

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

    Categories
    MVC , REST , Resource , View Helper
  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. Resource Representation in Spring

    by , 11-28-2011 at 01:05 AM
    In my previous tips, I looked out how to make the key RESTful method calls. In all of them the controllerís handler method finishes, and a logical view name is usually returned. In the case that the method doesnít return a logical view name (a method returning void) then the logical view name is derived from the requestís URL. The DispatcherServlet passes the view name to a view resolver in order to facilitate the determination of which view should render the results of the request.

    ...

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

    Categories
    Resource , Configuration , View , XML , REST
  12. RESTful POST Method in Spring

    by , 11-28-2011 at 01:02 AM
    In my previous tips, I have shown you how to write RESTful methods for GET, PUT and DELETE. In this tip, I will tackle the method which is probably the most used (and abused), the POST method.

    The POST method is the one method that you need to be most mindful of. First it is not safe and second it is not idempotent. Therefore you must take extra care in how you design your URL as well as your method . In this case, I will add another method to the CarController that creates a new ...

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

    Categories
    REST , HTTP
  13. RESTful DELETE Method in Spring

    by , 11-28-2011 at 12:59 AM
    Continuing on my previous tip, of showing how to write RESTful methods, in this tip, I will show you how to write RESTful methods using the verb HTTP Verb, PUT.

    There are times when we might want to get rid of a resource in its entirety. In the case we would use the HTTP DELETE method in order to accomplish this. In this case, I will add another method to the CarController that handles the DELETE requests to remove a Car resource:

    Java Code:
    @RequestMapping(value="/{id}",
    ...

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

    Categories
    REST , HTTP
  14. RESTful PUT Method in Spring

    by , 11-28-2011 at 12:56 AM
    In my previous tip, I looked at the verbs available for RESTful services. In this tip, I will show you how to write RESTful methods using the verb HTTP Verb, PUT.

    The purpose of the PUT methodís is exactly as it states. Is serves to transfer the resourceís state from the client to the server. For an example of this, please see the following method that Iíve created for putCar() that is annotated to receive a Car object from a PUT request:

    Java Code:
    @RequestMapping(value="/{id}",
    ...

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

    Categories
    REST , HTTP
  15. Key REST Verbs

    by , 11-28-2011 at 12:54 AM
    In my previous tip, I looked at setting up RESTful Controllers. Now in the post we will look at the verbs available for RESTful services. . Although this is nice for writing RESTless controllers, it is not ideal for writing RESTful controllers. The reason is that controllers made in this way are action oriented and not resource oriented. This can be easily surmised by the names used for the different requests which are focused on the particular use cases but not on the resources.

    ...

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

    Tags: rest, spring, verbs Add / Edit Tags
    Categories
    HTTP , REST
  16. 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
  17. RESTful URLs in Spring

    by , 11-28-2011 at 12:31 AM
    In my previous tip, I presented to you an overview of Spring support of REST. In this tip, I will followup with a tip for look at RESTful URLs.

    If you want to create a RESTful controller, you will need to handle URLs in a RESTful way. Thatís because everything thatís done in REST is done through a URL. The URLís RESTful nature is even implied by itís name, uniform resource locator. Given that name, it seems that a URL is intended to locate a resource. Above and beyond this, URLs ...

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

    Categories
    Web , Web Service , REST
  18. 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
    REST , Spring 3 , Web Service
  19. Proxying JAX-WS Services in Spring

    by , 11-28-2011 at 12:25 AM
    I have been exploring JAX-WS services in Spring. In this tip, I will look into proxying JAX-WS services on the client side. Consuming web services with Spring involves client-side proxies in a way similar to how Spring based clients consume other remoting technologies.

    Using JaxWsPortProxyFactoryBean is used to wire the Car web service in Spring similar to any other Spring bean. The JaxWsPortProxyFactoryBean is a factory bean that produces a proxy that knows how to talk to a SOAP ...

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

    Categories
    Web , Web Service
  20. 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
  21. 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
    Web , Web Service , Spring 3
  22. Using SpEL for Spring Security

    by , 11-27-2011 at 10:58 PM
    Sometimes you might need to have a more sophisticated method of defining security constraints. Fortunately as of version 3.0, Spring Security also supports SpEL as a means for declaring access requirements. I will give you show you how to use it in this tip.

    First thing you will need to do is to enable it. To do this, you must set the use-expressions attribute of <http> to true:

    Java Code:
    <http auto-config="true" use-expressions="true">
    ...

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

    Categories
    Spring EL , Security
  23. 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 ...
  24. 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
  25. 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
  26. 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"
    ...
  27. 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 ...
  28. 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 ...
  29. 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
  30. Defining the Page View with Tiles View Resolvers in Spring MVC

    by , 11-27-2011 at 10:41 PM
    Following on from my previous tip, I will now define the page view from our previous tip. Using Tiles properly, the home page is composed of several distinct pieces. The main_template.jsp file describes the common layout for all pages in the Springexample application, while home.jsp displays the main content for the home page. Plus, carForm.jsp and login.jsp provide additional common elements.
    The home.jsp is where the home page request finishes its journey. It picks up the list of Cars ...
Page 2 of 4 FirstFirst 1234 LastLast