a comprehensive spring showcase: personal cloud storage application
TRANSCRIPT
1 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
A Comprehensive Spring Showcase:
Personal Cloud Storage Application
Erdem Günay, Expert Software Developer, Turkcell
@gunayus
2 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
About me
3 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
About professional me
B. Sc. Degree from Computer Engineering, Middle East Technical
University, Ankara, 1999
15 years experience with Java
10 years experience with Spring
Started and contirbuted project http://www.gwt-openlayers.org/
Enterprise application architecture
Working @Turkcell for 10 years
In organization Advanced Spring Framework trainer
In the project, software architect and developer
4 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Agenda
Spring Boot
Spring Data
Spring Amqp
Elastic Search
Openstack
App Demo
5 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Mobile Cloud Middleware
6 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Personal Cloud Solution Architecture
Clients
AP
I LA
YER
Frontend Storage
Elastic Search
file metadata indextoken cache
Oracle DB
accountsubscription
file system structurefile metadata
sharing metadata
Openstack
keystoneswift
file binary dataupload / downoad
Social / Cloud
Backend
BackendServices
Legacy
Enterprise Backend Systems
Rabbit MQ
7 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
spring.io
8 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
SPRING IO EXECUTION:
Spring Boot
9 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Before Spring Boot – hard work on dependency management
….
….
many others
10 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
After Spring Boot – less work on dependency management
11 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
After Spring Boot – still have all the jars
….
….
many others
12 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
So easy to start & debug a web app
13 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
& Expose a Rest service
14 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
& Expose a SOAP Web service
15 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Deploy on a web app container
16 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Auto configuring properties
application.properties
# Spring Profiles
# ===============
spring.profiles.active=test, apiservice, backend
# Global properties
...
application-apiservice.properties
# apiservice related properties
# ===============
api.service.url=http://...
# other properties
...
application-backend.properties
# backend related properties
# ===============
backend.service.url=http://...
# other properties
...
17 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Configuring environmental differences – DEV
18 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Configuring environmental differences – TEST & PROD
19 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
@Scheduled, @Async
20 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
@Scheduled, @Async
21 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
SPRING IO FOUNDATION:
Spring Data
22 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
In the beginning – all work done by developers
23 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring killed the pain a bit – obtained & released resources
24 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Got better with JPA & Hibernate, but still coded by developers
25 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Finally, «no code no bug»
26 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
All you need is javax.persistence @Entity
/**
* @author Oliver Gierke
*/
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstname;
private String lastname;
@JsonIgnore
@OneToMany(mappedBy="customer")
private Set<Account> accounts = new HashSet<Account>();
27 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Still plain old Sql, but not coded, auto generated, time saving
select customer0_.id as id1_1_,
customer0_.firstname as firstnam2_1_,
customer0_.lastname as lastname3_1_
from customer customer0_
where (customer0_.firstname like ?)
and upper(customer0_.lastname)=upper(?)
public List<Customer> findByFirstnameLikeAndLastnameIgnoreCase(
String firstname, String lastname);
28 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Custom, native, modifying queries
29 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring AMQP
30 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring AMQP – RabbitMQ Configuration
31 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring AMQP – Consumer Configuration
32 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring AMQP – Message listener
33 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring AMQP – Message producer
34 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Spring summary
Spring Boot : the parent of everything, auto configuration
Spring Web : Restful APIs, @RestTemplate
Spring Data JPA : Repositories, custom, native, modifying queries
Spring Security
Spring Social : sharing on Twitter, Facebook
Spring Web Services : client & server
Spring AMQP
@Async, @Scheduled, @Transactional
@Bean Java config
No XML config or web.xml at all
35 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search
36 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search
37 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search
38 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – index a document
index type id
source
39 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – get a document
40 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – Integrate with Spring App Context
41 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – Index a document
42 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – Search documents
43 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Elastic Search – Delete user documents
44 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/Unless otherwise indicated, these sl ides are © 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
openstack
45 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack
46 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack - Modules
47 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – Keystone authentication API
48 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – Authentication from Spring
49 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – Account creation from Spring
50 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – User creation from Spring
51 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – File upload from Spring
https://{swift_url}/v1/AUTH_049037f79ea24214b2778830c96fd243/CONTAINER_MAIN/
3b841cd9-547b-432a-98d9-3ce6211bab4f
project_id container_name
file_path
52 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Openstack – File download from Spring
53 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Demo
Unless otherwise indicated, these sl ides are
© 2014-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense:
http://creativecommons.org/l icenses/by -nc/3.0/
APPLICATION
54 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
The Team
Volkan Esgel – Security master
Hüseyin Özcan – The UI man
Erdem Günay – it’s me
Kemal Yılmaz – the manager of the team
55 Unless otherwise indicated, these sl ides are © 201 4-2015 Pivotal Software, Inc. and l icensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/l icenses/by -nc/3.0/
Learn More. Stay Connected.
Twitter: twitter.com/gunayus
LinkedIn: linkedin.com/in/gunayus
Github: github.com/egunay
Twitter: twitter.com/springcentral
YouTube: spring.io/video
LinkedIn: spring.io/linkedin
Google Plus: spring.io/gplus