14
CZJUG JAN-2010 | LUKAS VLCEK 1 TITLE SLIDE: HEADLINE Presenter name Title, Red Hat Date JBOSS SNOWDROP Lukáš Vlček Senior QA Engineer, JBoss January 25 th , 2010

JBoss Snowdrop

Embed Size (px)

DESCRIPTION

Lightning talk about JBoss Snowdrop project

Citation preview

Page 1: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK1

TITLE SLIDE: HEADLINE

Presenter

nameTitle, Red HatDate

JBOSS SNOWDROP

Lukáš Vlček

Senior QA Engineer, JBossJanuary 25th, 2010

Page 2: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK2

What is JBoss Snowdrop?

● Informal:“... you can easily develop, deploy and run Spring based applications on JBoss AS utilizing its JEE services”

● More formal:Snowdrop is a utility package that contains JBoss specific extensions to the Spring Framework.

● License: LGPL v2.1

● Hosted: http://jboss.org/snowdrop

Page 3: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK3

Why Using Spring on JBoss AS?

● Spring provides popular development model

● JBoss AS provides runtime services

● More details: Spring on JBoss, JBoss World 2009by Marius Bogoevici (Snowdrop lead developer)

“JBoss is a great place forrunning Spring applications!”

● http://www.redhat.com/f/pdf/jbw/mbogoevici_1050_spring_on_jboss.pdf

Page 4: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK4

Spring Deployer

● Recognizes and deploy Spring applications

● /META-INF/*-spring.xml (archives: JAR, WAR, EAR...)

Spring deployer parses the deployment descriptor to create a Spring bean factory, and registers that Spring bean factory under some JNDI name so that it can be looked up and used by other applications. And if deployed archive is removed, JBoss destroy the bean factory and unregister it from JNDI.

How it works:

Page 5: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK5

Example of /META-INF/jboss-spring.xml

● Spring BeanFactory is registered in JNDI with name SpringDao.

<?xml version="1.0" encoding="UTF­8"?><beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema­instance"       xsi:schemaLocation="http://www.springframework.org/schema/beans       http://www.springframework.org/schema/beans/spring­beans.xsd">

    <description>BeanFactory=(SpringDao)</description>

    <import resource="classpath*:dao­context.xml"/>    <import resource="classpath*:infrastructure.xml"/>

</beans>

Page 6: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK6

JBoss Virtual File System

● JDK URL resource handling is not easy● Windows file locking, code duplicity

● Virtual File System was created to solve these issues but resource and classpath scanning in Spring's 2.5.x did not work properly:

● if resource path has [*] after [:]

● if classes need to be scanned for annotations

<context:component­scanbase­package="org.jboss.snowdrop.sample.springmvc"/>

<import resource=”classpath*:META­INF/*.xml”/>

Page 7: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK7

JBoss VFS Support Solution

● JBoss added two implementations of ApplicationContext

Spring class JBoss class

ClassPathXmlApplicationContext VFSClassPathXmlApplicationContext

XmlWebApplicationContext VFSXmlWebApplicationContext

<servlet>   <servlet­name>spring­mvc­servlet</servlet­name>   <servlet­class>org.springframework.web.servlet.DispatcherServlet</servlet­class>   <init­param>      <param­name>contextClass</param­name>      <param­value>         org.jboss.spring.vfs.context.VFSXmlWebApplicationContext      </param­value>   </init­param>   <init­param>      <param­name>contextConfigLocation</param­name>      <param­value>/WEB­INF/spring­servlet­context.xml</param­value>  </init­param></servlet>

Page 8: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK8

Injecting Spring Beans in EJB3

● Spring deployer introduced new annotation: @Spring

● Using Spring @Autowired annotation

@Stateless@Interceptors(SpringLifecycleInterceptor.class)@LocalBinding(jndiBinding = "sportsclub/SubscriptionService")public class SubscriptionServiceImpl implements SubscriptionService{

   @Spring(bean = "accountRepository", jndiName = "SpringDao")   private AccountRepository accountRepository;

   @Spring(bean = "personRepository", jndiName = "SpringDao")   private PersonRepository personRepository; ...}

Page 9: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK9

JSF and Spring

● Spring provides implementation of ELResolver

faces­config.xml<application>    <view­handler>com.sun.facelets.FaceletViewHandler</view­handler>    <el­resolver>        org.springframework.web.jsf.el.SpringBeanFacesELResolver    </el­resolver></application>

web.xml<context­param>    <param­name>contextConfigLocation</param­name>    <param­value>/WEB­INF/spring­beans.xml</param­value></context­param><listener>    <listener­class>        org.springframework.web.context.ContextLoaderListener    </listener­class></listener>

faces­config.xml<application>    <view­handler>com.sun.facelets.FaceletViewHandler</view­handler>    <el­resolver>        org.springframework.web.jsf.el.SpringBeanFacesELResolver    </el­resolver></application>

Page 10: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK10

Not Covered in this Lightning Talk

● JTA

● JAX-WS

● JPA

● JMX

● Tooling (JBoss Eclipse extensions)

... see Snowdrop examples and Marius' presentation

Page 11: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK11

Snowdrop Status

● 1.0.0GA released in October 2009● Supports

● JBoss AS 5.x (preferably 5.1.0 GA)● Spring 2.5.x (preferably 2.5.6 SEC01)

● 1.1.0GA to be released soon

Page 12: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK12

Snowdrop Roadmap

● Spring AOP integration with JBoss AOP

● Spring integration with JBoss MC

● Clustering support for Spring through Infinispan

● Spring 3

● JBoss AS 6

Page 13: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK13

Related Articles

● Spring and EJB 3.0 in Harmony, Aleš Justin (2006 ~ little dated)http://java.sys-con.com/node/180386Spring deployer, Injecting Spring into EJB

● DZone JBoss Microcontainer Series, Aleš Justin (2008-2009)Component Model, Advanced Dependency Injection and IoC, Virtual File System, ClassLoading Layer

Page 14: JBoss Snowdrop

CZJUG JAN-2010 | LUKAS VLCEK14

Questions?