• Like

Next stop: Spring 4

  • 9,388 views
Uploaded on

In this presentation I will go through latest features being added in Spring 3.1/3.2 one more time and also will try to look behind the scene on what new features are comming in Spring 4 which should …

In this presentation I will go through latest features being added in Spring 3.1/3.2 one more time and also will try to look behind the scene on what new features are comming in Spring 4 which should be released at the end of this year.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
9,388
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
159
Comments
0
Likes
11

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Speaker: Oleg Tsal-Tsalko (@tsaltsol)Next stop: Spring 4
  • 2. About meOleg Tsal-Tsalko• Senior Java Developer in EPAM Systems.• Mostly working with enterprise businessapplications.• Member of LJC and JUG KPI communities.
  • 3. What version of Spring are you using?Bankapplications
  • 4. Spring 3.1(Previous stop)• Environment abstraction and profiles• Java-based application configuration• Overhaul of the test context framework• Cache abstraction & declarative caching• Servlet 3.0 based web applications• @MVC processing & flash attributes• Support for Java SE 7And much more…
  • 5. Exposing entities via REST
  • 6. XML based configuration<beans …><cache:annotation-driven /><bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">…</bean><context:property-placeholder location="classpath:/app-common.properties"/><bean id="bookStoreService" class="spring.samples.service.BookStoreService" c:bookStoreDao-ref="bookStoreDao"/><bean id="bookStoreDao" class="spring.samples.dao.BookStoreDao"><property name="dataSource" ref="dataSource"/></bean>…</beans>ApplicationContext context = new ClassPathXmlApplicationContext("bookstore-app-context.xml");
  • 7. Java based configurationApplicationContext context = new AnnotationConfigApplicationContext(BookStoreAppConfig.class);
  • 8. Test context java basedconfiguration
  • 9. Profiles in XML based configuration<beans>...<beans profile="dev"><jdbc:embedded-database id="dataSource"><jdbc:script location="classpath:db/schema.sql"/><jdbc:script location="classpath:db/test-data.sql"/></jdbc:embedded-database></beans><beans profile="production"><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="oracle.jdbc.OracleDriver"/><property name="url" value="jdbc:oracle:thin:@localhost:1521:booklibrary"/><property name="username" value="admin"/><property name="password" value="admin"/></bean></beans>...</beans>
  • 10. Profiles in Java based configuration@Configuration@Profile("dev")public class DevProfileConfig {@Bean(name="dataSource”)public DataSource dataSource() {…}}@Configuration@Profile("production")public class ProductionProfileConfig {@Bean(name="dataSource”)public DataSource dataSource() {…}}@Configuration@Import( { DevProfileConfig.class, ProductionProfileConfig.class } )public class BookStoreAppConfig {@Injectprivate DataSource dataSource;}
  • 11. How to enable active profile?1) Using JVM property, which is preferred way:2) Programmatically in standalone app:-Dspring.profiles.active=dev3) In web.xml file:
  • 12. Cache abstraction• CacheManager and Cache abstraction inorg.springframework.cache• Out of the box support for ConcurrentMapand EhCache• Ability to plug any Cache implementation (seeSpring GemFire project for GemFile adapter)
  • 13. Declarative Cache support
  • 14. Enable caching annotations@Configuration@EnableCachingpublic class AppConfig {@Beanpublic CacheManager cacheManager() {…}…}<beans …><cache:annotation-driven /><bean id="cacheManager"class="org.springframework.cache.support.SimpleCacheManager">…</bean>…</beans>
  • 15. Servlet 3.0 support• such as Tomcat 7 and GlassFish 3Explicit supportfor Servlet 3.0containers• Servlet 3.0s ServletContainerInitializer mechanism• Spring 3.1sAnnotationConfigWebApplicationContext• Spring 3.1s environment abstractionSupport for XML-free webapplication setup• such as standard Servlet 3.0 file upload behindSprings MultipartResolver abstractionExposure of nativeServlet 3.0functionality inSpring MVC
  • 16. Spring MVC without web.xml
  • 17. Spring 3.2(Current stop)• Gradle-based build• Sources moved to GitHub• Sources built against Java 7• Async MVC processing on Servlet 3.0• Spring MVC test support• MVC configuration and SpEL refinementsAnd much more…
  • 18. Async MVC processing: Callable- thread managed by Spring MVC- good for long running database jobs, 3rd party REST API calls, etc
  • 19. Async MVC Processing: DeferredResult- thread managed outside of Spring MVC- JMS or AMQP message listener, another HTTP request, etc.
  • 20. Async MVC Processing: WebAsyncTask- same as Callable, with extra features- override timeout value for async processing- lets you specify a specific AsyncTaskExecutor
  • 21. MVC Test Framework Server
  • 22. MVC Test Framework Client
  • 23. Spring 4Engineering works will be held till the end of the year…
  • 24. Spring 4(Next stop)We are expecting to see:• Comprehensive Java 8 support• Support for Java EE 7 APIs• Focus on message-oriented architectures• Annotation-driven JMS endpoint model• Revised application event mechanism• WebSocket support in Spring MVC• Next-generation Groovy supportAnd more…
  • 25. Java 8 & Java EE 7 supportComprehensive Java 8support• Lambdas• Date and Time API (JSR-310)• Parameter name discovery• Repeatable annotations• Concurrency enhancementSupport for Java EE 7 APIs• Asynchronous API for RestTemplate• Bean Validation 1.1 (JSR-349)• Expression Language 3.0 (JSR-341)• JMS 2.0 (JSR-343)• Concurrency Utilities for Java EE (JSR-236)• JPA 2.1 (JSR-338)• Servlet 3.1 (JSR-340)• JSF 2.2 (JSR-344)
  • 26. Annotation driven messageendpoints<jms:annotation-driven>@JmsListener(destination="myQueue")public void handleMessage(TextMessage payload);@JmsListener(destination="myQueue", selector="...")public void handleMessage(String payload);@JmsListener(destination="myQueue")public String handleMessage(String payload);However this is not implemented yet -https://jira.springsource.org/browse/SPR-9882
  • 27. Bean Validation 1.1 supportMethodValidationInterceptor autodetects Bean Validation 1.1s ExecutableValidator API nowand uses it in favor of Hibernate Validator 4.2s native variant.
  • 28. JMS 2.0 supportWhat was done already:• Added "deliveryDelay" property on JmsTemplate• Added support for "deliveryDelay" and CompletionListener toCachedMessageProducer• Added support for the new "create(Shared)DurableConsumer" variants inSpring’s CachingConnectionFactory• Added support for the new "createSession" variants with fewerparameters in Spring’s SingleConnectionFactoryKnown constraints:• There is no special support for the simplified JMSContext API, and likelynever will be, because of different Spring mechanism of managingconnection pools and sessions• JmsTemplate has no out-of-the-box support for send calls with an asynccompletion listener.
  • 29. JEE7 concurrency utilities in Spring 4This is built into ConcurrentTaskExecutor and ConcurrentTaskScheduler now,automatically detecting the JSR-236 ExecutorService variants and adaptingto them.Example of ManagedExecutorService usage introduced in JEE7:
  • 30. JPA 2.1 supportEntityManagerFactory.createEntityManager(SynchronizationType.SYNCHRONIZED/UNSYNCHRONIZED, Map)@PersistenceContext(synchronizationType=SYNCHRONIZED/UNSYNCHRONIZED)Support for both transactional and extended EntityManagersand for both Spring-managed resource transactions and JTAtransactions
  • 31. WebSockets server side support
  • 32. WebSockets server side support
  • 33. WebSockets server side support
  • 34. WebSockets Client side supportProgramatic approach:Configuration based approach:
  • 35. JDK8 support in depth• Implicit use of LinkedHashMap/Set instead of simpleHashMap/Set to preserve ordering diffs in JDK7 and JDK8• Embed ASM4.1 into Spring codebase to support JDK8bytecode changes and to keep compatibility with CGLib3.0• Support for JDK 8 Data & Time (JSR-310) encorporated withSpring’s Joda Time lib• Add awaitTerminationSeconds/commonPool properties toForkJoinPoolFactoryBean to support JDK8 changes in it.• Encorporate JDK8 changes in reflection API (such asjava.lang.reflect.Parameter)
  • 36. Other changes…• Replace Burlap with Hessian (lightweight binary WS protocol)• Introduced @Conditional annotation (@Profile annotationhas been refactored)• Updated to Gradle 1.6
  • 37. How to track progress?• Track JIRA -https://jira.springsource.org/issues/?jql=project%20%3D%20SPR%20AND%20labels%20%3D%20%22major-theme-4.0%22• Check commits to codebase -https://github.com/SpringSource/spring-framework/commits/master
  • 38. Thank you!Oleg Tsal-TsalkoEmail: oleg.tsalko@gmail.comTwitter: @tsaltsolSpecial thanks to Josh Long (@starbuxman) forsharing quite useful info…