tobias karlsson springsource a division of vmware...36 spring 3.2 strategy ! early support for...
TRANSCRIPT
![Page 1: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/1.jpg)
© 2011 VMware Inc. All rights reserved
Enable your applications to unleash the power of the cloud using Spring Framework
Tobias Karlsson
SpringSource a division of VMware
![Page 2: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/2.jpg)
2
Who’s Tobias?
§ Started out as a Java consultant
§ Worked 4 years with mobile services in MENA and APAC
§ Currently living in Stockholm
§ Currently working for SpringSource as a Sales Engineer in Northern Europe
![Page 3: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/3.jpg)
3
Agenda
§ Background § Implications for your application § The evolving runtime environment § Spring Framework § Moving your application to Cloud Foundry § Architectural Principles of the cloud
Auto-Reconfiguration: Getting Started
• Deploy Spring apps to the cloud without changing a single line of code
• Cloud Foundry automatically re-configures bean definitions to bind to cloud services
• Works with spring and grails frameworks
9
Thursday, October 27, 2011
![Page 4: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/4.jpg)
4 It’s a “New” World
![Page 5: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/5.jpg)
5
Mobile first, mobile only???
![Page 6: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/6.jpg)
6
web-app & browser
users & services
User Centric
![Page 7: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/7.jpg)
7
what happened
last month?
what’s happening
now?
Real-time, contextual, social
![Page 8: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/8.jpg)
8
Solving Google style type problems
![Page 9: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/9.jpg)
9
SSD
Latency Sensitive
“memory is the new disk”
![Page 10: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/10.jpg)
10
SaaS
App
SaaS
App
SaaS
App IaaS
PaaS
PaaS
Corporate Data
Centers
On modern infrastructure
![Page 11: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/11.jpg)
11
SaaS
App
SaaS
App
SaaS
App IaaS
PaaS
PaaS
Corporate Data
Centers
On modern infrastructure
![Page 12: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/12.jpg)
12
Frequent deployments
![Page 13: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/13.jpg)
13
So, what does this all mean for your applications?
![Page 14: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/14.jpg)
14
Real life developing a web product Real life developing a web product
9
![Page 15: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/15.jpg)
15
Client
Server
View Generation
Controllers
Service Layer
Repositories Channels RDBMS CRUD
Application
Server
Browser Browser-based
HTML Rendering
(progressive
enhancement)
HTML HTTP
Anatomy of a web app
![Page 16: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/16.jpg)
16
Client
PaaS
Browser app or
embedded in native
JSON HTTP & websockets
HTML5 & JS Engine
Controllers DOM
Client-side model
events &
notifications
web stg
Service Service Service business /
domain services
Service Service Service platform services,
web APIs SQL NoSQL Other
Anatomy of a next-gen app
![Page 17: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/17.jpg)
17
Data isn’t just relational
§ Relational database stores CRUD data, seeing huge rise in CRAP data • Created, Replicated, Appended, Processed
§ Other store types: • Document [MongoDB] • Key-value [Redis]
• Column-family [Cassandra]
• Graph database [Neo4j] • Blob stores
§ Trend is to supplement RDB with non-relational stores
![Page 18: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/18.jpg)
18
New Era Requires a Shift: Elasticity from Apps to Data
Develop using modern frameworks: agile apps decoupled from middleware
Access app data through elastic data fabric and/or in-memory SQL:
maximize data scalability
Use cloud-friendly messaging protocols: enable flexible app integration
Leverage runtime container optimized for virtualization: provision in seconds
Store app state in elastic data cache: maximize app scalability
![Page 19: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/19.jpg)
19
The evolving runtime environment
![Page 20: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/20.jpg)
20
New Eras Bring New Application Platforms
Mainframe PC/Client-Server Web Cloud
App Platform COBOL UNIX Services App Server PaaS
Each new era in computing brings a new application platform: for the Cloud era it is “Platform as a Service”
vFabric
Cloud Foundry
VMware Cloud
Application Platform
![Page 21: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/21.jpg)
21
Three layers of Cloud Computing
SaaS Software as a Service
SaaSSoftware as a Service
PaaSPlatform as a Service
IaaSInfrastructure as a
Service
Three layers of Cloud Computing
3
PaaS Platform as a Service
IaaS Infrastructure as a Service
![Page 22: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/22.jpg)
22
Data Services
Other Services
Msg Services
Cloud Foundry Big Picture
.js
Private Clouds
Public Clouds
Micro
Clouds
.COM
Partners
![Page 23: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/23.jpg)
23
Cloud Foundry Open PaaS
§ Multiple languages and frameworks § Multiple deployment options § A variety of services
Cloud Foundry Open PaaS
• Multiple languages and frameworks• Multiple deployment options• A variety of services
5
Open Source
Extend it to meet your needs
![Page 24: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/24.jpg)
24
Inside Cloud Foundry Inside Cloud Foundry
6
Router
vSphere 5
Health Manager
Execution environment Services
user apps Cloud Controller user apps
vmc client STS plugin browser (user app access)
![Page 25: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/25.jpg)
25
Broad support for application frameworks
§ JVM • Spring, Grails, Roo, Lift, plain Java
§ Ruby • Rails, Sinatra
§ Node.js § Community contributions • Erlang, Python, PHP, .Net
![Page 26: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/26.jpg)
26
JVM Frameworks
§ Unit of deployment: Java WARs • Can run any standard WAR file • Servlet 2.5
• don’t assume a particular container
§ Spring, Grails, Lift framework • Auto-reconfiguration goodies
![Page 27: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/27.jpg)
27
Inside Staged Applications
§ Stager packages applications into executable droplets • provides a runtime container • can rewrite configuration files
• can add libraries
§ For Spring/Grails applications • provides a servlet container
• deploys the app into the container
• configures the container to listen on the correct port – adds auto-reconfiguration lib to the class path
• rewrites web.xml • registers auto-reconfiguration BeanFactoryPostProcessor • registers CloudApplicationContextInitializer
• adds JDBC drivers to class path • MySQL or PostgreSQL depending on bound services
![Page 28: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/28.jpg)
28
“Leave my app alone!”
§ No Problem § Plain Java framework • bare minimum staging • no manipulation of configuration files – no additions to the class path
• just your application
![Page 29: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/29.jpg)
29
Elasticity on demand
§ Scale up in seconds
• vmc instances myapp +2
§ Scale down in seconds
• vmc instances myapp -2
§ Monitor your application instances
• per instance: memory, CPU, disk, uptime
• vmc stats myapp
![Page 30: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/30.jpg)
30
Surviving Disaster
§ Applications crash • impossible to avoid • it will happen, sooner or later
§ Optimize for mean time to recovery
• mean time between failures is not as important
![Page 31: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/31.jpg)
31
Services: Developer’s perspective
§ Use services that meet applicationʼs needs
§ Trivial provisioning of services
• vmc create-service mongodb documents-db
• vmc bind-service inventory-app documents-db
§ Build service-focused polyglot apps
• Change languages and framework as needed
§ Not worry about operating services!
![Page 32: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/32.jpg)
32
Exposing services
§ VCAP_* environment variables provide configuration to applications
§ VCAP_SERVICES with service connection info {
"name": "inventory-‐db", "label": "mysql-‐5.1", "plan": "free", "credentials": { "node_id": "mysql_node_4", "hostname": "192.168.2.35", "port": 45678, "password": "dfdsf89414", "name": "kjkrewqr90", "user": "hwerkjewk” }
}
![Page 33: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/33.jpg)
33
How will Spring help you to move your apps to the cloud?
![Page 34: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/34.jpg)
34
Key Elements of Spring: Ready for 2012 & Beyond
4CONFIDENTIAL 4CONFIDENTIAL
Key Elements of Spring: Ready for 2011 & Beyond
Simple
Object
Simple
ObjectsDep
ende
ncy
Inje
ctio
n
AOP
Portable Service Abstractions
More important than ever!
![Page 35: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/35.jpg)
35
Spring Focus Areas
35
Integration
Core
Tools
Data
Web & Mobile
Spring Framework
Spring MVC
Spring Web Flow
Spring Web Services
Spring Integration
Spring AMQP
Spring Batch
STS
Spring Roo
WaveMaker
Spring Mobile
Spring Android
Spring Social
Spring Data
Spring GemFire
Spring Hadoop
![Page 36: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/36.jpg)
36
Spring 3.2 Strategy
§ Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for selected specifications in individual form
• With Java 8’s language and API enhancements in mind already
§ Preserving compatibility with Java 5+ • Java SE 5+ as well as Java EE 5+
• For the entire Spring 3.x branch • However, stronger focus on a Java SE 7 and Servlet 3.0+ world
§ Best possible experience on modern deployment environments • From Tomcat 7 and WebSphere 8 to Google App Engine and Cloud Foundry
![Page 37: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/37.jpg)
37
Auto-Reconfiguration: Getting Started
§ Deploy Spring apps to the cloud without changing a single line of code
§ Cloud Foundry automatically re-configures bean definitions to bind to cloud services
§ Works with spring and grails frameworks
Auto-Reconfiguration: Getting Started
• Deploy Spring apps to the cloud without changing a single line of code
• Cloud Foundry automatically re-configures bean definitions to bind to cloud services
• Works with spring and grails frameworks
9
Thursday, October 27, 2011
![Page 38: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/38.jpg)
38
Auto-Reconfiguration: Relational DB Auto-Reconfiguration: Relational DB
• Detects beans of type javax.sql.DataSource• Connects to MySQL or PostgreSQL services
– Specifies driver, url, username, password, validation query• Creates Commons DBCP or Tomcat DataSource
10
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.h2.Driver" />" <property name="url" value="jdbc:h2:mem:" />" <property name="username" value="sa" />" <property name="password" value="" /></bean>
Thursday, October 27, 2011
§ Detects beans of type javax.sql.DataSource § Connects to MySQL or PostgreSQL services • Specifies driver, url, username, password, validation query
§ Creates Commons DBCP or Tomcat DataSource
![Page 39: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/39.jpg)
39
Auto-Reconfiguration: ORM
§ Adjusts Hibernate Dialect § Changes hibernate.dialect property to MySQLDialect (MyISAM) or
PostgreSQLDialect • org.springframework.orm.jpa.AbstractEntityManagerFactoryBean • org.springframework.orm.hibernate3.AbstractSessionFactoryBean(Spring 2.5
and 3.0) • org.springframework.orm.hibernate3.SessionFactoryBuilderSupport (Spring
3.1)
Auto-Reconfiguration: ORM
• Adjusts Hibernate Dialect• Changes hibernate.dialect property to MySQLDialect
(MyISAM) or PostgreSQLDialect– org.springframework.orm.jpa.AbstractEntityManagerFactoryBean– org.springframework.orm.hibernate3.AbstractSessionFactoryBean (Spring
2.5 and 3.0)– org.springframework.orm.hibernate3.SessionFactoryBuilderSupport
(Spring 3.1)
11
<bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean"id="entityManagerFactory">
<property name="dataSource" ref="dataSource"/></bean>
Thursday, October 27, 2011
![Page 40: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/40.jpg)
40
Auto-Reconfiguration: NoSQL
§ Works with Spring Data • Connects to MongoDB service (Document Store) • Connects to Redis service (Key-Value Store)
Auto-Reconfiguration: NoSQL
• Works with Spring Data• Connects to MongoDB service (Document Store)• Connects to Redis service (Key-Value Store)
12
Thursday, October 27, 2011
![Page 41: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/41.jpg)
41
What is Spring Data?
§ Umbrella of projects embracing the various new data access technologies • Non-relational DBs • Map-Reduce frameworks – Cloud-based data services
§ Enhances developer productivity • Removes API noise, boiler-plate code and resource management • Offers a consistent programming model
§ Builds on top of existing Spring features and projects • e.g. Inversion of control, life-cycle management, type conversion, portable data
access exceptions, caching • Easy to add to your application
![Page 42: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/42.jpg)
42
Auto-Reconfiguration: RabbitMQ
§ Works with Spring AMQP 1.0 • Provides publishing, multithreaded consumer generation, and message
converters
• Facilitates management of AMQP resources while promoting DI and declarative configuration
§ Detects beans of type org.springframework.amqp.rabbit.connection.ConnectionFactory
§ Connects to Rabbit Service • Specifies host, virtual host, port, username, password
§ Creates CachingConnectionFactory
Auto-Reconfiguration: RabbitMQ
• Works with Spring AMQP 1.0– Provides publishing, multithreaded consumer generation,
and message converters– Facilitates management of AMQP resources while promoting
DI and declarative configuration• Detects beans of type
org.springframework.amqp.rabbit.connection.ConnectionFactory
• Connects to Rabbit Service– Specifies host, virtual host, port, username, password
• Creates CachingConnectionFactory
16
<rabbit:connection-factory id="rabbitConnectionFactory" host="localhost" password="testpwd" port="1238" username="testuser" virtual-host="virthost" />
Thursday, October 27, 2011
![Page 43: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/43.jpg)
43
Auto-Reconfiguration: How it works
§ Cloud Foundry installs a BeanFactoryPostProcessor in your application context during staging
• Adds jar to your application
• Modifies web.xml to load BFPP
§ Adds context file to contextConfigLocation – web-app context-param
• Spring MVC DispatcherServlet init-param
§ Adds PostgreSQL and MySQL driver jars as needed for DataSource reconfiguration
![Page 44: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/44.jpg)
44
Auto-Reconfiguration: Limitations
§ Exactly one service of a given type bound to application
• e.g. Only one relational DB service (MySQL or PostgreSQL)
§ Exactly one bean of matching type in application
• e.g. Only one bean of type javax.sql.DataSource
§ Auto-Reconfiguration is skipped if limitations not met
§ Custom configuration is not preserved
• e.g. Pool sizes, caching or connection properties
§ Use cloud namespace instead
![Page 45: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/45.jpg)
45
Auto-Reconfiguration: Opting Out
§ Two ways to explicitly disable auto-reconfiguration:
• Choose framework “JavaWeb” when deploying application
• Application remains unchanged during staging
• Unable to take advantage of profile feature
• Use any <cloud> element that creates a bean representing a service
• Explicit control of service bindings implies that auto- reconfiguration is unnecessary
![Page 46: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/46.jpg)
46
Introducing… the Cloud Namespace
§ <cloud:> namespace for use in Spring app contexts § Provides application-level control of bean service bindings § Recommended for development of new cloud apps § Use when: • You have multiple services of the same type • You have multiple connecting beans of the same type
• e.g. DataSource, MongoDBFactory
• You have custom bean configuration • e.g. DataSource pool size, connection properties
![Page 47: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/47.jpg)
47
Including Cloud Namespace in Your App
§ Declare Maven Dependency and Repository § Add namespace declaration to app context files
Including Cloud Namespace in Your App
• Declare Maven Dependency and Repository• Add namespace declaration to app context files
24
<dependencies><dependency>
<groupId>org.cloudfoundry</groupId><artifactId>cloudfoundry-runtime</artifactId><version>0.8.1</version>
" </dependency>......<repositories>
<repository>" <id>org.springframework.milestone</id>
" " <name>Spring Framework Milestone Repository</name>" " <url>http://maven.springframework.org/milestone</url>
</repository>......
Thursday, October 27, 2011
![Page 48: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/48.jpg)
48
<cloud:service-scan>
§ Scans all services bound to the application and creates a bean of an appropriate type for each • Same bean types as auto-reconfiguration
§ Useful during early development phases
<cloud:service-scan>
• Scans all services bound to the application and creates a bean of an appropriate type for each– Same bean types as auto-reconfiguration
• Useful during early development phases
25
<beans" ... xmlns:cloud="http://schema.cloudfoundry.org/spring"" xsi:schemaLocation="http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd" ...">
<cloud:service-scan/>
</beans>
Thursday, October 27, 2011
![Page 49: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/49.jpg)
49
<cloud:service-scan> Autowire Dependencies
§ Created beans can be autowired as dependencies § Use @Qualifier with service name if multiple services of same type
bound to app
<cloud:service-scan> Autowire Dependencies
• Created beans can be autowired as dependencies• Use @Qualifier with service name if multiple services of
same type bound to app
26
@Autowired(required=false)private ConnectionFactory rabbitConnectionFactory;
@Autowiredprivate RedisConnectionFactory redisConnectionFactory;
@Autowired@Qualifier("test_mysql_database")private DataSource mysqlDataSource;
@Autowired(required=false)@Qualifier("test_postgres_database")private DataSource postgresDataSource;
Thursday, October 27, 2011
![Page 50: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/50.jpg)
50
<cloud:service-scan> Declare Dependencies
§ Created beans ids will match service names § Use service name in dependency declarations
<cloud:service-scan> Declare Dependencies
• Created beans ids will match service names• Use service name in dependency declarations
27
<!-- Connects to cloud service named "contacts-db" --><bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="entityManagerFactory"> <property name="dataSource" ref="contacts-db"/></bean>
<!-- Connects to cloud service named "tweet-cache" --><bean id= "redisTemplate" class= "org.sf.data.redis.core.RedisTemplate" > " <property name="connectionFactory" ref="tweet-cache"/>
....</bean>
Thursday, October 27, 2011
![Page 51: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/51.jpg)
51
<cloud:data-source>
§ Configures a DataSource bean • Commons DBCP or Tomcat DataSource
§ Basic attributes: • id: defaults to service name
• service-name: only needed if you have multiple relational database services bound to the app
<cloud:data-source>
• Configures a DataSource bean– Commons DBCP or Tomcat DataSource
• Basic attributes:– id: defaults to service name– service-name: only needed if you have multiple relational
database services bound to the app
•
29
<cloud:data-source id="dataSource"/>
<bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean"id="entityManagerFactory">
<property name="dataSource" ref="dataSource"/></bean>
Thursday, October 27, 2011
![Page 52: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/52.jpg)
52
Spring 3.1 Environment Abstraction
§ Bean definitions for a specific environment (Profiles) • e.g. development, testing, production • Possibly different deployment environments
• Activate profiles by name • spring.profiles.active system property • Other means outside deployment unit • “default” profile activates if no other profiles specified
§ Custom resolution of placeholders • Dependent on the actual environment
• Ordered property sources
§ Requires Spring 3.1 (or later)
![Page 53: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/53.jpg)
53
Isolating Cloud Foundry Configuration
§ Switch between local, testing and Cloud Foundry deployments with Profiles
§ “cloud” profile automatically activates on Cloud Foundry • usage of the cloud namespace should occur within the cloud profile block
![Page 54: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/54.jpg)
54
Isolating Cloud Foundry Configuration Isolating Cloud Foundry Configuration
47
<bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean"id="entityManagerFactory">
<property name="dataSource" ref="dataSource"/></bean>
<beans profile="cloud">" <cloud:data-source id="dataSource" /></beans>"<beans profile="default">" <bean class="org.a.commons.dbcp.BasicDataSource" id="dataSource">
" <property name="url" value="jdbc:mysql://localhost/stalker" />" </bean></beans>
Thursday, October 27, 2011
![Page 55: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/55.jpg)
55
Using Profiles to Enable Features
§ Use profiles to add features when deploying to Cloud Foundry • e.g. Using Send Grid to send email
Using Profiles to Enable Features
• Use profiles to add features when deploying to Cloud Foundry– e.g. Using Send Grid to send email
49
<beans profile="cloud"><bean name="mailSender" class="example.SendGridMailSender">" <property name="apiUser" value="[email protected]" />
" " <property name="apiKey" value="secureSecret" />" </bean></beans>
Thursday, October 27, 2011
![Page 56: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/56.jpg)
56
Cloud Properties
§ Cloud Foundry uses Environment abstraction to automatically expose properties to Spring 3.1 apps • Basic information about the application, such as its name and the cloud
provider
• Detailed connection information for bound services • cloud.services.{service-name}.connection.{property} • aliases for service name created based on the service type
• e.g. “cloud.services.mysql.connection.{property}” • only if there is a single service for that type bound
![Page 57: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/57.jpg)
57
Profile Support: How it works
§ Cloud Foundry installs a custom ApplicationContextInitializer in your app during staging
• Modifies web.xml
• Adds to contextInitializerClasses context-param
§ Adds “cloud” as an active profile
§ Adds a PropertySource to the Environment
![Page 58: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/58.jpg)
58
Summary
§ Comprehensive set of services
§ Spring developers served well
• Dependency injection proves the right approach, again!
§ Many simplifications to use services
• Auto-reconfig
• Cloud namespace
• Cloud profile
§ Focus on your app; let us worry about services!
![Page 59: Tobias Karlsson SpringSource a division of VMware...36 Spring 3.2 Strategy ! Early support for latest Java specifications • Java EE 7 as the central theme • As usual, support for](https://reader034.vdocuments.net/reader034/viewer/2022042200/5e9f6b4aaaa64651467a6006/html5/thumbnails/59.jpg)
59
Architectural Principles for the cloud
§ Decoupled § Elastic § Early instrumentation
§ Continuous optimization
§ Fast provisioning
§ Lightweight § Framework based • Spring Data
§ Container independent § Enhanced with new NoSQL