Powerful Google developer tools for immediate impact! (2023-24 C)
JBoss Snowdrop
1. JBOSS SNOWDROP
TITLE SLIDE: HEADLINE
Presenter
Lukáš Vlček
name
Senior QAHat
Title, Red Engineer, JBoss
January 25th, 2010
Date
1 CZJUG JAN-2010 | LUKAS VLCEK
2. 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
2 CZJUG JAN-2010 | LUKAS VLCEK
3. Why Using Spring on JBoss AS?
● Spring provides popular development model
● JBoss AS provides runtime services
● More details: Spring on JBoss, JBoss World 2009
by Marius Bogoevici (Snowdrop lead developer)
“JBoss is a great place for
running Spring applications!”
● http://www.redhat.com/f/pdf/jbw/mbogoevici_1050_spring_on_jboss.pdf
3 CZJUG JAN-2010 | LUKAS VLCEK
4. Spring Deployer
● Recognizes and deploy Spring applications
● /META-INF/*-spring.xml (archives: JAR, WAR, EAR...)
How it works:
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.
4 CZJUG JAN-2010 | LUKAS VLCEK
5. 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>
5 CZJUG JAN-2010 | LUKAS VLCEK
6. 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 [:]
<import resource=”classpath*:METAINF/*.xml”/>
● if classes need to be scanned for annotations
<context:componentscan
basepackage="org.jboss.snowdrop.sample.springmvc"/>
6 CZJUG JAN-2010 | LUKAS VLCEK
7. 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>
7 CZJUG JAN-2010 | LUKAS VLCEK
8. 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;
...
}
8 CZJUG JAN-2010 | LUKAS VLCEK
9. 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>
9 CZJUG JAN-2010 | LUKAS VLCEK
10. Not Covered in this Lightning Talk
● JTA
● JAX-WS
● JPA
● JMX
● Tooling (JBoss Eclipse extensions)
... see Snowdrop examples and Marius' presentation
10 CZJUG JAN-2010 | LUKAS VLCEK
11. 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
11 CZJUG JAN-2010 | LUKAS VLCEK
12. Snowdrop Roadmap
● Spring AOP integration with JBoss AOP
● Spring integration with JBoss MC
● Clustering support for Spring through Infinispan
● Spring 3
● JBoss AS 6
12 CZJUG JAN-2010 | LUKAS VLCEK
13. Related Articles
● Spring and EJB 3.0 in Harmony, Aleš Justin (2006 ~ little dated)
http://java.sys-con.com/node/180386
Spring 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
13 CZJUG JAN-2010 | LUKAS VLCEK