SlideShare una empresa de Scribd logo
1 de 32
Spring and Java EE Side by
Side
Reza Rahman
Java EE/GlassFish Evangelist
Reza.Rahman@Oracle.com
@reza_rahman
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public2
Program Agenda
 Spring and Java EE
 Side-by-Side
 Ecosystems
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public3
A Bird’s Eye View
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public4
Main Features/APIs
• Spring also integrates with EJB 3, but not CDI
• Similar patterns for validation, WebSocket, JSON, XML, SOAP, remoting, scheduling, caching, etc
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public5
Java EE and Spring Component
@Stateless
public class BidService {
@PersistenceContext
private EntityManager entityManager;
public void addBid(Bid bid) {
entityManager.persist(bid);
}
}
@Component
public class BidService {
@PersistenceContext
private EntityManager entityManager;
@Transactional
public void addBid(Bid bid) {
entityManager.persist(bid);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public6
Spring Bootstrap (XML)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:component-scan base-package="com.actionbazaar"/>
<tx:annotation-driven/>
...
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
</bean>
</beans>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public7
Defining the Data Source
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver"/>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:actionbazaar"/>
<property name="user" value="scott"/>
<property name="password" value="tiger"/>
</bean>
<data-source>
<name>java:global/jdbc/myDataSource</name>
<class-name>oracle.jdbc.driver.OracleDriver</class-name>
<port-number>1521</port-number>
<server-name>localhost</server-name>
<database-name>actionbazaar</database-name>
<user>scott</user>
<password>tiger</password>
<property>
<name>createDatabase</name>
<value>create</value>
</property>
</data-source>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public8
Spring Bootstrap (Java)
@Configuration
@ComponentScan(basePackages="com.actionbazaar")
@EnableTransactionManagement
public class DataConfiguration {
@Bean(destroyMethod="close")
public DataSource dataSource(){
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@localhost:1521:actionbazaar");
ds.setUser("scott");
ds.setPassword("tiger");
return ds;
}
@Bean
public PlatformTransactionManager transactionManager(){
return new DataSourceTransactionManager(dataSource());
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(){
LocalContainerEntityManagerFactoryBean factory = LocalContainerEntityManagerFactoryBean();
factory.setDataSource(dataSource());
factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
return factory;
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public9
Servlet Bootstrap
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:**/applicationContext*.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
...
</web-app>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public10
Simple JSF Page
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/WEB-INF/template.xhtml">
<ui:define name="title">Add Bid</ui:define>
<ui:define name="content">
<h3>Add Bid</h3>
<h:form>
<p>Item: <h:outputText value="#{item.name}"/></p>
<p>Current bid:
<h:outputText value="#{item.highestBid.amount}"/></p>
<p>Amount: <h:inputText id="amount" value="#{bid.amount}"/></p>
<p><h:commandButton value="Add bid"
action="#{addBid.onClick}"/></p>
</h:form>
</ui:define>
</ui:composition>
</html>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public11
CDI/JPA Components
CDI Backing Bean JPA Entity
@Named @ViewScoped
public class AddBid {
@Inject private BidService bidService;
@Inject @LoggedIn private User user;
@Inject @SelectedItem private Item item;
@Produces @Named
private Bid bid = new Bid();
public String onClick() {
bid.setBidder(user);
bid.setItem(item);
bidService.addBid(bid);
return “bid_confirm.xhtml”;
}
}
@Entity @Table(name="BIDS")
public class Bid {
@Id @GeneratedValue
private long id;
@ManyToOne(optional=false)
private User bidder;
@ManyToOne(optional=false)
private Item item;
DecimalMin("0.0")
private double amount;
...
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public12
Servlet Bootstrap
<web-app>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public13
Spring MVC JSP Page
<%@ taglib prefix="tiles“
uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="form"
uri="http://www.springframework.org/tags/form" %>
<tiles:insertDefinition name="defaultTemplate">
<tiles:putAttribute name=“title">Add Bid</tiles:putAttribute>
<tiles:putAttribute name=“content">
<h3>Add Bid</h3>
<form:form modelAttribute="bid" method="post">
<p>Item: <form:errors path="item" cssClass="error"/>
${item.name}</p>
<p>Current bid: ${item.highestBid.amount}</p>
<p>Amount: <form:errors path="amount" cssClass="error"/>
<form:input path="amount"/></p>
<p><input type="submit" value="Add Bid">
</form:form>
</tiles:putAttribute>
</tiles:insertDefinition>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public14
Spring MVC Controller
@RequestMapping("/add_bid.do") @SessionAttributes({"item", "bid"})
public class BidController {
@Autowired private ItemService itemService;
@Autowired private BidService bidService;
@RequestMapping(method=RequestMethod.GET)
public String setupForm(@RequestParam("itemId") int itemId, ModelMap model) {
Item item = itemService.getItem(itemId);
model.addAttribute("item", item);
Bid bid = new Bid();
model.addAttribute("bid", bid);
return "add_bid";
}
@RequestMapping(method=RequestMethod.POST)
public String addBid(@ModelAttribute("item") Item item, @Valid @ModelAttribute("bid") Bid bid,
HttpSession session, BindingResult result, SessionStatus status) {
bid.setBidder((User)session.getAttribute("user"));
bid.setItem(item);
if (result.hasErrors()) {
return "add_bid";
} else {
bidService.addBid(bid);
status.setComplete();
return "redirect:confirm_bid.do?itemId=" + item.getItemId();
}
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public15
Spring MVC Bootstrap
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.actionbazaar"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/tiles-definitions.xml</value>
</list>
</property>
</bean>
</beans>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public16
Servlet Bootstrap
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:**/applicationContext*.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>actionbazaar</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>actionbazaar</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public17
CDI Interceptor
@Stateless
public class BidService {
@Inject private BidRepository bidRepository;
...
@Audited
public void addBid(Bid bid) {
...
bidRepository.saveBid(bid);
}
}
@Interceptor @Audited
public class AuditInterceptor {
@AroundInvoke
public Object audit(InvocationContext context) {
logger.log(Level.INFO, "Executing: {0}",
context.getMethod().getName());
return context.proceed();
}
}
@InterceptorBindingType
@Target({TYPE, METHOD}) @Retention(RUNTIME)
public @interface Audited {}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public18
Spring/AspectJ
@Component
public class BidService {
@Autowired private BidRepository bidRepository;
...
@Audited @Transactional
public void addBid(Bid bid) {
...
bidRepository.saveBid(bid);
}
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Audited {}
@Component @Aspect
public class AuditAspect {
@Before("execution(public * *(..)) && @annotation(Audited)")
public void audit(JoinPoint joinPoint) {
logger.log(Level.INFO, "Entering: {0}", joinPoint);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public19
Spring/AspectJ Bootstrap
<beans xmlns="http://www.springframework.org/schema/beans"
...
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
...
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
...
<aop:aspectj-autoproxy/>
...
</beans>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public20
JMS MDB
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destinationLookup",
propertyValue = "java:global/jms/OrderQueue")})
public class OrderProcessor implements MessageListener {
@Inject private OrderService orderService;
public void onMessage(Message message) {
try {
ObjectMessage objectMessage = (ObjectMessage) message;
Order order = (Order) objectMessage.getObject();
orderService.addOrder(order);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
<jms-destination>
<name>java:global/jms/OrderQueue</name>
<interface-name>javax.jms.Queue</interface-name>
<resource-adapter>jmsra</resource-adapter>
<destination-name>OrderQueue</destination-name>
</jms-destination>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public21
Spring JMS Listener
@Component
public class OrderProcessor implements MessageListener {
@Autowired private OrderService orderService;
@Transactional
public void onMessage(Message message) {
try {
ObjectMessage objectMessage = (ObjectMessage) message;
Order order = (Order) objectMessage.getObject();
orderService.addOrder(order);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public22
Spring Message Listener Bootstrap
<beans xmlns="http://www.springframework.org/schema/beans"
...
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
...
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">
...
<amq:broker useJmx="false" persistent="false">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://localhost:0" />
</amq:transportConnectors>
</amq:broker>
<amq:queue id="jms/OrderQueue" physicalName="queue.OrderQueue"/>
<amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost"/>
<jms:listener-container transaction-manager="transactionManager"
concurrency="3-5">
<jms:listener destination="jms/OrderQueue" ref="orderProcessor"/>
</jms:listener-container>
</beans>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public23
JMS 2 Message Sender
@Stateless
public class OrderService {
@Inject private JMSContext jmsContext;
@Resource(lookup = "java:global/jms/OrderQueue")
private Destination orderQueue;
...
public void sendOrder(Order order) {
jmsContext.createProducer()
.setPriority(HIGH_PRIORITY)
.setDisableMessageID(true)
.setDisableMessageTimestamp(true)
.send(orderQueue, order);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public24
Spring JMS Message Sender
@Component
public class OrderService {
private JmsTemplate jmsTemplate;
@Resource(name="jms/OrderQueue")
private Queue queue;
...
@Autowired
public void setConnectionFactory(
ConnectionFactory connectionFactory) {
jmsTemplate = new JmsTemplate(connectionFactory);
}
@Transactional
public void sendOrder(Order order) {
jmsTemplate.setExplicitQosEnabled(true);
jmsTemplate.setPriority(HIGH_PRIORITY);
jmsTemplate.setMessageIdEnabled(false);
jmsTemplate.setMessageTimestampEnabled(false);
jmsTemplate.convertAndsend(queue, order);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public25
EJB3 and Spring Scheduling
@Stateless
public class NewsLetterGenerator {
...
@Schedule(dayOfMonth="Last Tues",
month="Jan-May, Sep-Nov",
timezone="America/New_York")
public void generateMonthlyNewsLetter() {
...
}
}
@Component
public class NewsLetterGenerator {
...
@Scheduled(
cron="0 0 0 ? JAN-MAY,SEP-NOV 3L")
public void generateMonthlyNewsLetter() {
...
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public26
Spring Scheduling Bootstrap
<beans xmlns="http://www.springframework.org/schema/beans"
...
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
...
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
...
<task:annotation-driven scheduler="myScheduler"/>
<task:scheduler id="myScheduler" pool-size="10"/>
</beans>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public27
Spring Projects
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public28
Java EE Ecosystem
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public29
CDI Ecosystem
Implementations
Weld CanDI
RuntimesPortable
Extensions
Tools
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public30
CDI Extensions
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public31
Decisions, decisions…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public32
A Bird’s Eye View

Más contenido relacionado

La actualidad más candente

Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootJosué Neis
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
Spring framework Introduction
Spring framework IntroductionSpring framework Introduction
Spring framework IntroductionAnuj Singh Rajput
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
Spring vs java ee
Spring vs java eeSpring vs java ee
Spring vs java eeWalid Yaich
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsJames Bayer
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewShahed Chowdhuri
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action Alex Movila
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCFunnelll
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootOmri Spector
 

La actualidad más candente (20)

Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Spring framework Introduction
Spring framework IntroductionSpring framework Introduction
Spring framework Introduction
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring vs java ee
Spring vs java eeSpring vs java ee
Spring vs java ee
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic Concepts
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Introduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoCIntroduction to Spring Framework and Spring IoC
Introduction to Spring Framework and Spring IoC
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 

Destacado

Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Springspringbyexample
 
Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Eduardo Pelegri-Llopart
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginiSchogini Systems Pvt Ltd
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBArun Gupta
 
Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)springbyexample
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafkamarius_bogoevici
 

Destacado (8)

Lightweight J2EE development using Spring
Lightweight J2EE development using SpringLightweight J2EE development using Spring
Lightweight J2EE development using Spring
 
Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208Ejb3 1 Overview Glassfish Webinar 100208
Ejb3 1 Overview Glassfish Webinar 100208
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
jVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by SchoginijVoiD - the enterprise ecommerce Java by Schogini
jVoiD - the enterprise ecommerce Java by Schogini
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJB
 
Tu1 1 5l
Tu1 1 5lTu1 1 5l
Tu1 1 5l
 
Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)Lightweight J2EE development with Spring (special for UADEV)
Lightweight J2EE development with Spring (special for UADEV)
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 

Similar a Java EE and Spring Side-by-Side

Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdfShaiAlmog1
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_daviddTakashi Ito
 
Prairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API ResponsesPrairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API Responsesdarrelmiller71
 
Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloudAndy Bosch
 
Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentAccenture Hungary
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2Paras Mendiratta
 
Hi5 Hackathon Presentation
Hi5 Hackathon PresentationHi5 Hackathon Presentation
Hi5 Hackathon PresentationLou Moore
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Darwin Biler
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Arun Gupta
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...jaxLondonConference
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015Pushkar Chivate
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsRapidValue
 
A resource oriented framework using the DI/AOP/REST triangle
A resource oriented framework using the DI/AOP/REST triangleA resource oriented framework using the DI/AOP/REST triangle
A resource oriented framework using the DI/AOP/REST triangleAkihito Koriyama
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX London
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSUFYAN SATTAR
 

Similar a Java EE and Spring Side-by-Side (20)

Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Prairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API ResponsesPrairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API Responses
 
Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloud
 
Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web Component
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Hi5 Hackathon Presentation
Hi5 Hackathon PresentationHi5 Hackathon Presentation
Hi5 Hackathon Presentation
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API Requests
 
A resource oriented framework using the DI/AOP/REST triangle
A resource oriented framework using the DI/AOP/REST triangleA resource oriented framework using the DI/AOP/REST triangle
A resource oriented framework using the DI/AOP/REST triangle
 
Sightly_techInsight
Sightly_techInsightSightly_techInsight
Sightly_techInsight
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 

Más de Reza Rahman

IBM WebSphere Family on Azure
IBM WebSphere Family on AzureIBM WebSphere Family on Azure
IBM WebSphere Family on AzureReza Rahman
 
Why Java/Jakarta EE Developers are First-Class Citizens on Azure
Why Java/Jakarta EE Developers are First-Class Citizens on AzureWhy Java/Jakarta EE Developers are First-Class Citizens on Azure
Why Java/Jakarta EE Developers are First-Class Citizens on AzureReza Rahman
 
Running WebLogic on Azure Kubernetes and Virtual Machines
Running WebLogic on Azure Kubernetes and Virtual MachinesRunning WebLogic on Azure Kubernetes and Virtual Machines
Running WebLogic on Azure Kubernetes and Virtual MachinesReza Rahman
 
Powering Java on Azure with JBoss EAP
Powering Java on Azure with JBoss EAPPowering Java on Azure with JBoss EAP
Powering Java on Azure with JBoss EAPReza Rahman
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEReza Rahman
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reza Rahman
 
Testing Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianTesting Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianReza Rahman
 
JavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchJavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchReza Rahman
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 

Más de Reza Rahman (9)

IBM WebSphere Family on Azure
IBM WebSphere Family on AzureIBM WebSphere Family on Azure
IBM WebSphere Family on Azure
 
Why Java/Jakarta EE Developers are First-Class Citizens on Azure
Why Java/Jakarta EE Developers are First-Class Citizens on AzureWhy Java/Jakarta EE Developers are First-Class Citizens on Azure
Why Java/Jakarta EE Developers are First-Class Citizens on Azure
 
Running WebLogic on Azure Kubernetes and Virtual Machines
Running WebLogic on Azure Kubernetes and Virtual MachinesRunning WebLogic on Azure Kubernetes and Virtual Machines
Running WebLogic on Azure Kubernetes and Virtual Machines
 
Powering Java on Azure with JBoss EAP
Powering Java on Azure with JBoss EAPPowering Java on Azure with JBoss EAP
Powering Java on Azure with JBoss EAP
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EE
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!
 
Testing Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianTesting Java EE Applications Using Arquillian
Testing Java EE Applications Using Arquillian
 
JavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great MatchJavaScript Frameworks and Java EE – A Great Match
JavaScript Frameworks and Java EE – A Great Match
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 

Último

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Último (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Java EE and Spring Side-by-Side

  • 1. Spring and Java EE Side by Side Reza Rahman Java EE/GlassFish Evangelist Reza.Rahman@Oracle.com @reza_rahman
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public2 Program Agenda  Spring and Java EE  Side-by-Side  Ecosystems
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public3 A Bird’s Eye View
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public4 Main Features/APIs • Spring also integrates with EJB 3, but not CDI • Similar patterns for validation, WebSocket, JSON, XML, SOAP, remoting, scheduling, caching, etc
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public5 Java EE and Spring Component @Stateless public class BidService { @PersistenceContext private EntityManager entityManager; public void addBid(Bid bid) { entityManager.persist(bid); } } @Component public class BidService { @PersistenceContext private EntityManager entityManager; @Transactional public void addBid(Bid bid) { entityManager.persist(bid); } }
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public6 Spring Bootstrap (XML) <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <context:component-scan base-package="com.actionbazaar"/> <tx:annotation-driven/> ... <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> </property> </bean> </beans>
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public7 Defining the Data Source <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@localhost:1521:actionbazaar"/> <property name="user" value="scott"/> <property name="password" value="tiger"/> </bean> <data-source> <name>java:global/jdbc/myDataSource</name> <class-name>oracle.jdbc.driver.OracleDriver</class-name> <port-number>1521</port-number> <server-name>localhost</server-name> <database-name>actionbazaar</database-name> <user>scott</user> <password>tiger</password> <property> <name>createDatabase</name> <value>create</value> </property> </data-source>
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public8 Spring Bootstrap (Java) @Configuration @ComponentScan(basePackages="com.actionbazaar") @EnableTransactionManagement public class DataConfiguration { @Bean(destroyMethod="close") public DataSource dataSource(){ BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("oracle.jdbc.driver.OracleDriver"); ds.setUrl("jdbc:oracle:thin:@localhost:1521:actionbazaar"); ds.setUser("scott"); ds.setPassword("tiger"); return ds; } @Bean public PlatformTransactionManager transactionManager(){ return new DataSourceTransactionManager(dataSource()); } @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(){ LocalContainerEntityManagerFactoryBean factory = LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource()); factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factory; } }
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public9 Servlet Bootstrap <web-app> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:**/applicationContext*.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> ... </web-app>
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public10 Simple JSF Page <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <ui:composition template="/WEB-INF/template.xhtml"> <ui:define name="title">Add Bid</ui:define> <ui:define name="content"> <h3>Add Bid</h3> <h:form> <p>Item: <h:outputText value="#{item.name}"/></p> <p>Current bid: <h:outputText value="#{item.highestBid.amount}"/></p> <p>Amount: <h:inputText id="amount" value="#{bid.amount}"/></p> <p><h:commandButton value="Add bid" action="#{addBid.onClick}"/></p> </h:form> </ui:define> </ui:composition> </html>
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public11 CDI/JPA Components CDI Backing Bean JPA Entity @Named @ViewScoped public class AddBid { @Inject private BidService bidService; @Inject @LoggedIn private User user; @Inject @SelectedItem private Item item; @Produces @Named private Bid bid = new Bid(); public String onClick() { bid.setBidder(user); bid.setItem(item); bidService.addBid(bid); return “bid_confirm.xhtml”; } } @Entity @Table(name="BIDS") public class Bid { @Id @GeneratedValue private long id; @ManyToOne(optional=false) private User bidder; @ManyToOne(optional=false) private Item item; DecimalMin("0.0") private double amount; ... }
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public12 Servlet Bootstrap <web-app> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> </web-app>
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public13 Spring MVC JSP Page <%@ taglib prefix="tiles“ uri="http://tiles.apache.org/tags-tiles" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <tiles:insertDefinition name="defaultTemplate"> <tiles:putAttribute name=“title">Add Bid</tiles:putAttribute> <tiles:putAttribute name=“content"> <h3>Add Bid</h3> <form:form modelAttribute="bid" method="post"> <p>Item: <form:errors path="item" cssClass="error"/> ${item.name}</p> <p>Current bid: ${item.highestBid.amount}</p> <p>Amount: <form:errors path="amount" cssClass="error"/> <form:input path="amount"/></p> <p><input type="submit" value="Add Bid"> </form:form> </tiles:putAttribute> </tiles:insertDefinition>
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public14 Spring MVC Controller @RequestMapping("/add_bid.do") @SessionAttributes({"item", "bid"}) public class BidController { @Autowired private ItemService itemService; @Autowired private BidService bidService; @RequestMapping(method=RequestMethod.GET) public String setupForm(@RequestParam("itemId") int itemId, ModelMap model) { Item item = itemService.getItem(itemId); model.addAttribute("item", item); Bid bid = new Bid(); model.addAttribute("bid", bid); return "add_bid"; } @RequestMapping(method=RequestMethod.POST) public String addBid(@ModelAttribute("item") Item item, @Valid @ModelAttribute("bid") Bid bid, HttpSession session, BindingResult result, SessionStatus status) { bid.setBidder((User)session.getAttribute("user")); bid.setItem(item); if (result.hasErrors()) { return "add_bid"; } else { bidService.addBid(bid); status.setComplete(); return "redirect:confirm_bid.do?itemId=" + item.getItemId(); } } }
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public15 Spring MVC Bootstrap <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <mvc:annotation-driven/> <context:component-scan base-package="com.actionbazaar"/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/tiles/tiles-definitions.xml</value> </list> </property> </bean> </beans>
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public16 Servlet Bootstrap <web-app> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:**/applicationContext*.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>actionbazaar</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>actionbazaar</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>jsp/index.jsp</welcome-file> </welcome-file-list> </web-app>
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public17 CDI Interceptor @Stateless public class BidService { @Inject private BidRepository bidRepository; ... @Audited public void addBid(Bid bid) { ... bidRepository.saveBid(bid); } } @Interceptor @Audited public class AuditInterceptor { @AroundInvoke public Object audit(InvocationContext context) { logger.log(Level.INFO, "Executing: {0}", context.getMethod().getName()); return context.proceed(); } } @InterceptorBindingType @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface Audited {}
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public18 Spring/AspectJ @Component public class BidService { @Autowired private BidRepository bidRepository; ... @Audited @Transactional public void addBid(Bid bid) { ... bidRepository.saveBid(bid); } } @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Audited {} @Component @Aspect public class AuditAspect { @Before("execution(public * *(..)) && @annotation(Audited)") public void audit(JoinPoint joinPoint) { logger.log(Level.INFO, "Entering: {0}", joinPoint); } }
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public19 Spring/AspectJ Bootstrap <beans xmlns="http://www.springframework.org/schema/beans" ... xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans ... http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> ... <aop:aspectj-autoproxy/> ... </beans>
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public20 JMS MDB @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/jms/OrderQueue")}) public class OrderProcessor implements MessageListener { @Inject private OrderService orderService; public void onMessage(Message message) { try { ObjectMessage objectMessage = (ObjectMessage) message; Order order = (Order) objectMessage.getObject(); orderService.addOrder(order); } catch (JMSException e) { e.printStackTrace(); } } } <jms-destination> <name>java:global/jms/OrderQueue</name> <interface-name>javax.jms.Queue</interface-name> <resource-adapter>jmsra</resource-adapter> <destination-name>OrderQueue</destination-name> </jms-destination>
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public21 Spring JMS Listener @Component public class OrderProcessor implements MessageListener { @Autowired private OrderService orderService; @Transactional public void onMessage(Message message) { try { ObjectMessage objectMessage = (ObjectMessage) message; Order order = (Order) objectMessage.getObject(); orderService.addOrder(order); } catch (JMSException e) { e.printStackTrace(); } } }
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public22 Spring Message Listener Bootstrap <beans xmlns="http://www.springframework.org/schema/beans" ... xmlns:jms="http://www.springframework.org/schema/jms" xmlns:amq="http://activemq.apache.org/schema/core" xsi:schemaLocation="http://www.springframework.org/schema/beans ... http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> ... <amq:broker useJmx="false" persistent="false"> <amq:transportConnectors> <amq:transportConnector uri="tcp://localhost:0" /> </amq:transportConnectors> </amq:broker> <amq:queue id="jms/OrderQueue" physicalName="queue.OrderQueue"/> <amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost"/> <jms:listener-container transaction-manager="transactionManager" concurrency="3-5"> <jms:listener destination="jms/OrderQueue" ref="orderProcessor"/> </jms:listener-container> </beans>
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public23 JMS 2 Message Sender @Stateless public class OrderService { @Inject private JMSContext jmsContext; @Resource(lookup = "java:global/jms/OrderQueue") private Destination orderQueue; ... public void sendOrder(Order order) { jmsContext.createProducer() .setPriority(HIGH_PRIORITY) .setDisableMessageID(true) .setDisableMessageTimestamp(true) .send(orderQueue, order); } }
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public24 Spring JMS Message Sender @Component public class OrderService { private JmsTemplate jmsTemplate; @Resource(name="jms/OrderQueue") private Queue queue; ... @Autowired public void setConnectionFactory( ConnectionFactory connectionFactory) { jmsTemplate = new JmsTemplate(connectionFactory); } @Transactional public void sendOrder(Order order) { jmsTemplate.setExplicitQosEnabled(true); jmsTemplate.setPriority(HIGH_PRIORITY); jmsTemplate.setMessageIdEnabled(false); jmsTemplate.setMessageTimestampEnabled(false); jmsTemplate.convertAndsend(queue, order); } }
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public25 EJB3 and Spring Scheduling @Stateless public class NewsLetterGenerator { ... @Schedule(dayOfMonth="Last Tues", month="Jan-May, Sep-Nov", timezone="America/New_York") public void generateMonthlyNewsLetter() { ... } } @Component public class NewsLetterGenerator { ... @Scheduled( cron="0 0 0 ? JAN-MAY,SEP-NOV 3L") public void generateMonthlyNewsLetter() { ... } }
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public26 Spring Scheduling Bootstrap <beans xmlns="http://www.springframework.org/schema/beans" ... xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans ... http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> ... <task:annotation-driven scheduler="myScheduler"/> <task:scheduler id="myScheduler" pool-size="10"/> </beans>
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public27 Spring Projects
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public28 Java EE Ecosystem
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public29 CDI Ecosystem Implementations Weld CanDI RuntimesPortable Extensions Tools
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public30 CDI Extensions
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public31 Decisions, decisions…
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public32 A Bird’s Eye View