Upload
lukas-vlcek
View
3.528
Download
3
Tags:
Embed Size (px)
DESCRIPTION
Lightning talk about JBoss Snowdrop project
Citation preview
CZJUG JAN-2010 | LUKAS VLCEK1
TITLE SLIDE: HEADLINE
Presenter
nameTitle, Red HatDate
JBOSS SNOWDROP
Lukáš Vlček
Senior QA Engineer, JBossJanuary 25th, 2010
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
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
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:
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="UTF8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/springbeans.xsd">
<description>BeanFactory=(SpringDao)</description>
<import resource="classpath*:daocontext.xml"/> <import resource="classpath*:infrastructure.xml"/>
</beans>
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:componentscanbasepackage="org.jboss.snowdrop.sample.springmvc"/>
<import resource=”classpath*:METAINF/*.xml”/>
CZJUG JAN-2010 | LUKAS VLCEK7
JBoss VFS Support Solution
● JBoss added two implementations of ApplicationContext
Spring class JBoss class
ClassPathXmlApplicationContext VFSClassPathXmlApplicationContext
XmlWebApplicationContext VFSXmlWebApplicationContext
<servlet> <servletname>springmvcservlet</servletname> <servletclass>org.springframework.web.servlet.DispatcherServlet</servletclass> <initparam> <paramname>contextClass</paramname> <paramvalue> org.jboss.spring.vfs.context.VFSXmlWebApplicationContext </paramvalue> </initparam> <initparam> <paramname>contextConfigLocation</paramname> <paramvalue>/WEBINF/springservletcontext.xml</paramvalue> </initparam></servlet>
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; ...}
CZJUG JAN-2010 | LUKAS VLCEK9
JSF and Spring
● Spring provides implementation of ELResolver
facesconfig.xml<application> <viewhandler>com.sun.facelets.FaceletViewHandler</viewhandler> <elresolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver </elresolver></application>
web.xml<contextparam> <paramname>contextConfigLocation</paramname> <paramvalue>/WEBINF/springbeans.xml</paramvalue></contextparam><listener> <listenerclass> org.springframework.web.context.ContextLoaderListener </listenerclass></listener>
facesconfig.xml<application> <viewhandler>com.sun.facelets.FaceletViewHandler</viewhandler> <elresolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver </elresolver></application>
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
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
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
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
CZJUG JAN-2010 | LUKAS VLCEK14
Questions?