View RSS Feed

Spring Framework

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

  1. 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
    Security , Spring EL
  2. Advanced Uses of SpEL

    by , 11-16-2011 at 04:50 PM
    There are a number of operations that you can apply on values as well as class scoped methods and constants using SpEL. Consider for example doing basic math operations on values. SpEL supports all the basic arithmetic operations that are supported in Javaís libraries. Consider that if you want to use constants or class-scoped methods you will need to use the T() operator. Below is an example of how it is to be used:

    T(java.lang.Math)

    The creates a Class object that ...
  3. More Simple SpEL Expressions

    by , 11-16-2011 at 04:48 PM
    Another basic thing that a SpEL expression can do is to reference another bean by its ID. With this functionality it is possible to use SpEL to wire one bean into another beanís property by using the bean ID as the SpEL expression:

    Java Code:
    <property name="engine" value="#{hybrid}"/>
    As you can see, weíre using SpEL to wire the bean whose ID is "hybrid" into an engine property. Now it is possible to do this without SpEL, and you would get ...
  4. The Basics of SpEL

    by , 11-16-2011 at 04:44 PM
    The goal of a SpEL expression is to arrive at some value after evaluation. In the course of calculating that value, other values are considered and operated upon. The simplest kinds of values that SpEL can evaluate may be literal values, references to a beanís properties, or perhaps a constant on some class.

    The most basic type of SpEL expression is one that contains only a literal value. A literal value would be a perfectly valid SpEL expression:

    Java Code:
    <property name="message"
    ...
  5. Introduction to Spring Expression Language

    by , 11-16-2011 at 04:42 PM
    Up until now, in the tips Iíve shown, all the constructor arguments and bean properties have been statically wired in the Spring configuration XML. What this means is that any definition you make has to be provided during development. This also applies to other beans which need to be defined statically in the Spring configuration.

    In Spring 3, the Spring Expression Language (SpEL) was introduced as a powerful and concise means of dynamically wiring values in constructor arguments ...