Spring Security 3.2 M1 Highlights, Servlet 3 API Support

Engineering | Rob Winch | December 17, 2012 | ...

Last week I announced the release of Spring Security 3.2 M1 that contains improved Servlet 3 support. In this post, I will introduce some of the more exciting features found in the 3.2 M1 release. Specifically, we will take a look at the following new Spring Security features:

Concurrency Support

You might ask "What is concurrency support doing in a release that has a Servlet 3 focused theme?" The reason is that the concurrency support provides a foundation for all the other features found in this release. While the concurrency support is used by the Servlet 3 integration, it can also serve as building blocks to support concurrency and Spring Security in any application. Let's take a look at Spring Security's concurrency support now.

DelegatingSecurityContextRunnable

One of the most fundamental building blocks within Spring Security's concurrency support is the DelegatingSecurityContextRunnable. It wraps a delegate Runnable in order to initialize the SecurityContextHolder with a specified SecurityContext for the delegate. It then invokes the delegate Runnable ensuring to clear the SecurityContextHolder afterwards. The DelegatingSecurityContextRunnable looks something like this:

public void run() {
  try {
    SecurityContextHolder.setContext(securityContext);
    delegate.run();
  } finally {
    SecurityContextHolder.clearContext();
  }
}

While very simple, it makes it seamless to transfer the SecurityContext from one Thread to another. This is important since, in most cases, the SecurityContextHolder acts on a per Thread basis. For example, you might have used Spring Security's <global-method-security> support to secure one of your services. You can now easily transfer the SecurityContext of the current Thread to the Thread that invokes the secured service. An example of how you might do this can be found below:


Runnable originalRunnable = new Runnable() {
  public void run() {
    // invoke secured service
  }
};

SecurityContext context = SecurityContextHolder.getContext();
DelegatingSecurityContextRunnable wrappedRunnable =
    new DelegatingSecurityContextRunnable(originalRunnable, context);

new Thread(wrappedRunnable).start();

The code above performs the following steps:

  • Creates a Runnable that will be invoking our secured service. Notice that it is not aware of Spring Security
  • Obtains the SecurityContext that we wish to use from the SecurityContextHolder and initializes the DelegatingSecurityContextRunnable
  • Use the DelegatingSecurityContextRunnable to create a Thread
  • Start the Thread we created

Since it is quite common to create a DelegatingSecurityContextRunnable with the SecurityContext from the SecurityContextHolder there is a shortcut constructor for it. The following code is the same as the code above:


Runnable originalRunnable = new Runnable() {
  public void run() {
    // invoke secured…

Spring Framework 3.2 goes GA

Engineering | Juergen Hoeller | December 13, 2012 | ...

Dear Spring community,

Exactly one year after the Spring Framework 3.1 release, I'm pleased to announce that Spring Framework 3.2 is generally available now!

We recommend an upgrade from all previous Spring releases, in particular from Spring Framework 3.1.x which this is a direct successor for.

As previously discussed, key features in Spring Framework 3.2 include:

  • Refined Java SE 7 support within the framework as well as through upgrades to CGLIB 3.0, ASM 4.0 (both of which we're inlining now) and AspectJ 1.7
  • Concurrency refinements across the framework, avoiding the use of synchronization wherever possible - in particular for scoped/prototype beans
  • Allowing for @Autowired and @Value to be used as meta-annotations, e.g. to build custom injection annotations in combination with specific qualifiers
  • Support for custom @Bean definition annotations in @Configuration classes, e.g. in combination with specific qualifiers, @Lazy, @Primary, etc
  • Asynchronous MVC processing on Servlet 3.0

This Week in Spring - 11 December, 2012

Engineering | Josh Long | December 11, 2012 | ...

Welcome to another installment of This Week in Spring! We finished SpringOne China over the weekend and are today at the first of two events for SpringOne India in Bangalore and SpringOne in Hyderabad. The shows have been really amazing! In particular, we've enjoyed the food, the sites and the amazing community that have turned up in droves!

An attendee took a shot of me as I was giving a talk on Spring on Cloud Foundry Dr. Mark Pollack, myself, Gary Russell and Chris Richardson at a restaurant in Beijing
I gave a talk in Bangalore and people deluged the stage with questions and greetings. I asked the last wave of people to take a photo with me. LtoR: Gary Russel, Josh Long, Jennifer Hickey, Jeremy Grelle, Oliver Gierke, Chris Richardson -- the whole SpringOne India lineup

 

    <LI> Roy Clarkson has announced <a href = "http://www.springsource.org/spring-android/news/1.0.1-released">Spring for Android 1.0</a>, which     adds support for Jackson 2.x in <code>RestTemplate</code> through the new <code>MappingJackson2HttpMessageConverter</code>. It also addresses several bugs and compatibility issues with <code>RestTemplate</code> and Android Jelly Bean.</LI>
    <LI>The <a href="http://www.tomcatexpert.com">TomcatExpert.com portal</a> has a nice post on Spring Insight Developer to analyze code, <a href="http://www.springsource.org/node/3761">install it with Tomcat, and…

    Introducing Spring Scala

    Engineering | Arjen Poutsma | December 10, 2012 | ...

    Last October, at SpringOne2GX, I introduced the Spring Scala project to the world. Since then, I've also presented this project at Devoxx. In this blog post, I would like to give further details about this project and how you can use it in your Scala projects.

    Why Spring Scala?

    The goal of the Spring Scala project is simply to make it easier to use the Spring framework in Scala. We believe that there are many Spring users out there who want to try Scala out, but do not want to leave their experience with Spring behind. This project is meant for those people.

    Obviously, you can use the (Java) Spring Framework in Scala today, without Spring Scala. But doing so will be awkward in certain places. Just like any programming language, Scala has its own, different way of doing things, and using a pure Java framework like Spring in Scala will just feel "too Java-esque". Spring Scala tries to fix…

    IOC + Javascript at SpringOne 2GX

    Engineering | John Hann | December 06, 2012 | ...

    by Brian CavalierJohn Hann

    We gave a talk on IOC + Javascript at SpringOne 2GX. Front-end web application architecture seemed to be quite a hot topic at the conference, in general, and our talk seemed to be very well received. Here are the video and slides from the talk.

    We'll also be starting a blog series about architectural patterns for modern Javascript web apps, featuring posts from members of SpringSource's new front-end architecture team, S2JS. The posts will expand on the concepts presented in our talk, as well as those presented by Scott Andrews and Jeremy Grelle in their talks.

    The first post in the series is coming next week. Until then, we hope you enjoy the video and the slides.  If you'd like to get a head start, you can browse the demo app's source code

    This Week in Spring - December 4th, 2012

    Engineering | Josh Long | December 05, 2012 | ...

    Wow guys! December 4th already! Time sure flies when you're having fun!

    Welcome back to another installment of <EM>This Week in Spring</EM>. This week, I'm in Beijing for <a href="http://springonechina.cloudfoundry.com">SpringOne China</a> and, next week, I'm off to India for <A href="http://springoneindia.cloudfoundry.com/">SpringOne India</a>. If you're in Beijing, Bangalore or Hyderabad, I'd love to see you at these events!
    

    Alright, let's get on with this week's roundup!

    1. Mark Fisher gets the ball rolling this week with a very nice present: Spring Integration 2.2.0.GA has been released! The new release is well described in the blogs on the various new features referenced in the release announcement, so be sure to check it out!
      	</LI>
      <LI>Martin Lippert's announced that the <a href="http://www.springsource.org/node/3757">Spring Tool Suite and Groovy Tool Suite 3.2.0.M1 have been released!</a> </li>
      
       <LI> Tobias…

    This Week in Spring - 27 November, 2012

    Engineering | Josh Long | November 28, 2012 | ...

    Welcome back to another installment of This Week in Spring! If you're in the states, then I hope you're well rested from a hopefully very pleasant holiday weekend, because we've got a lot to cover this week!

    I hope you find this roundup useful. If you should ever want to peruse previous weeks' roundups, we've recently created a This Week in Spring hash tag for the blog archives.

    Anyway, we've got a lot to cover this week, so let's get on with it!

    1. Chris Beams has announced that the Spring Framework 3.2 RC2 has been released, consisting largely of bugfixes and refactoring as the project nears GA.
    2. Andy Wilkinson has announced the release and availability of the Spring Migration Analyzer, a command-line utility that analyzes enterprise Java applications and produces a report describing the application and how it can be migrated to Spring. Input an EAR file, get a migration effort report. It supports WebLogic, WebSphere, Java EE and JBoss in the milestone release, but we are looking for community support to make it better for GA!
    3. Catch the latest in the Spring Data webinar series on Dec 13th -- Data Access and Processing with Spring Data, Hadoop, Batch, Integration. We are also have a webinar on Spring Data Gemfire on Dec 6th: The Data Renaissance: Going in-Memory with VMWare vFabric GemFire 7.0 and Spring.
    4. If you have missed the other webinars in the Spring Data Webinar series, check out the SpringSource Dev Youtube channel for recently published replays on: Data Access with Spring -- Getting the most out of JPA, JDBC and REST and Introducing Spring for Apache Hadoop.
    5. Gary Russell has announced that Spring Integration 2.2.0.RC3 has been released.
    6. Spring Social 1.1.0 has been released. The new release includes easier XML and Java configuration, tighter adherence to the latest OAuth 2 specification drafts, including HTTP Basic client authentication and support for Resource Owner Credentials Grant and Client Credentials Grant, and updates to the Facebook and Twitter API bindings.
    7. Jens Schauder has a nice post on creating new Spring beans on demand using the singleton scope.
    8. The Java How to Program blog has a nice roundup on
        <a href="http://www.hubberspot.com/2012/10/how-to-use-component-annotation-for.html">How to use <CODE>@Component</CODE> 
        annotation to automatically configure Spring beans</a>.
      
    9. This is a nice post on how to implement the chain-of-responsibility pattern using Spring and @Autowired (or alternatively @Inject).
    10. Viral Patel's back at it again, this time with a post on Spring 3 MVC interceptors.
    11. The Mkyong blog has another nice post up on Spring and Java threading example using the Spring thread scope.
    12. DZone has a nice post up on easy integration testing with Spring and the JUnit 4 support.
    13. I recently wrote up a version of a tutorial on getting started with SpringSource Tool Suite and Spring for beginners.

    Introducing Spring Migration Analyzer

    Engineering | Andy Wilkinson | November 27, 2012 | ...

    It's my pleasure to announce that we've released the first milestone of Spring Migration Analyzer (SMA), a command-line utility that analyzes enterprise Java applications and produces a report describing the application and how it can be migrated to Spring.

    Why migrate an application to Spring?

    We see two main reasons when people choose to use Spring. Firstly, Spring offers the greatest range of deployment options including cloud and PaaS, allowing you to deploy your application to lighter-weight runtimes with lower operating costs. Secondly, as Adrian recently explained Spring provides access to a host of technologies that are at the forefront of enterprise Java.

    When it comes to considering the migration of an existing application to Spring, it's typically the deployment flexibility that motivates the move as it can significantly reduce the application's operating costs.

    Using SMA to analyze an application

    To get started with SMA, download the distribution. Once it's downloaded, unzip it:
    unzip spring-migration-analyzer-1.0.0.M1-dist.zip
    

    With JAVA_HOME set, you can then run the migration-analysis script to…

    This Week in Spring - 20 November, 2012

    Engineering | Josh Long | November 20, 2012 | ...

    Wow! Guys, can you believe we are again staring down the end of the year? Time sure flies! In the US, this is the week of Thanksgiving, a holiday where we're supposed to take a moment and reflect upon the things for which we're grateful. I am (and I'm sure I speak for the team in saying that we are..) eternally grateful for you guys, the wonderful, vibrant and engaging community surrounding Spring, RabbitMQ and Cloud Foundry that makes putting together this roundup such a pleasure every week.

    With that, let's get on with the news:

    1. Thomas Risberg has announced that the Cloud Foundry Maven plugin 1.0.0.M4 is now available.
      </Li>
       <LI>Did you miss out at <A href="http://springone2gx.com/conference/washington/2012/10/home">SpringOneOne2GX 2012  in Washington D.C.</a>?  Don't fret. We'll release 2 sessions every week on <a href="http://www.springsource.org/SpringOne2012Recordings">springsource.org</a>. We've already released Day 1 and 2 Keynotes. Available now:  a talk from Rossen Stoyanchev on "What's New in Spring Mvc 3.2" and a talk from Roy Clarkson and Craig Walls on "Extending Spring Mvc With Spring Mobile and Javascript."
      	Awesome. 
      	
      	</li>
      <LI> Our friend Tobias Trelle is at it again! This week, he's   <A…

    Dependency analysis in Scripted

    Engineering | Kris De Volder | November 20, 2012 | ...

    Scripted, a JavaScript editor from VMWare was announced on this blog last month. In this article we'll take a look under the hood at Scripted's Dependency Analysis Engine. But before diving into the details, lets motivate why we need it.

    Main Motivation: Cross-file Content Assist

    To provide a great JavaScript editing experience, Scripted needs to provide accurate suggestions about the functions, methods or identifiers you can use in your current editor context.

    [caption id="attachment_12178" align="aligncenter" width="533" caption="Cross-file Content Assist"][/caption]

    Two components work together to achieve this goal:

    • a fine-grained type inference analysis engine
    • a coarse-grained dependency analysis engine
    The inference engine parses your code and walks every declaration, statement and expression. This allows it to determine what identifiers are valid in a given context, and make good guesses about the kinds of things that may be stored in these variables. This information is then used to make content assist suggestions.

    If you wanted to simply put all your code into one big file, then a good quality inferencer alone would be sufficient to provide some pretty good content assist. In reality, projects will be divided…

    Get the Spring newsletter

    Stay connected with the Spring newsletter

    Subscribe

    Get ahead

    VMware offers training and certification to turbo-charge your progress.

    Learn more

    Get support

    Tanzu Spring offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

    Learn more

    Upcoming events

    Check out all the upcoming events in the Spring community.

    View all